This repository was archived by the owner on Jul 16, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 7 files changed +41
-10
lines changed Expand file tree Collapse file tree 7 files changed +41
-10
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace App ;
4
4
5
+ use App \Manager \PromptManager ;
6
+ use App \Manager \ResourceManager ;
7
+ use App \Manager \ToolManager ;
5
8
use PhpLlm \McpSdk \Server \NotificationHandler \InitializedHandler ;
6
9
use PhpLlm \McpSdk \Server \RequestHandler \InitializeHandler ;
7
10
use PhpLlm \McpSdk \Server \RequestHandler \PingHandler ;
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- namespace App ;
3
+ namespace App \ Manager ;
4
4
5
+ use App \ExamplePrompt ;
5
6
use PhpLlm \McpSdk \Capability \Prompt \CollectionInterface ;
6
7
use PhpLlm \McpSdk \Capability \Prompt \PromptGet ;
7
8
use PhpLlm \McpSdk \Capability \Prompt \PromptGetterInterface ;
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- namespace App ;
3
+ namespace App \ Manager ;
4
4
5
+ use App \ExampleResource ;
5
6
use PhpLlm \McpSdk \Capability \Resource \CollectionInterface ;
6
7
use PhpLlm \McpSdk \Capability \Resource \ResourceRead ;
7
8
use PhpLlm \McpSdk \Capability \Resource \ResourceReaderInterface ;
9
+ use PhpLlm \McpSdk \Capability \Resource \ResourceReadResult ;
8
10
use PhpLlm \McpSdk \Exception \ResourceNotFoundException ;
9
11
10
12
class ResourceManager implements CollectionInterface, ResourceReaderInterface
@@ -23,13 +25,17 @@ public function getMetadata(): array
23
25
return $ this ->items ;
24
26
}
25
27
26
- public function read (ResourceRead $ request ): mixed
28
+ public function read (ResourceRead $ request ): ResourceReadResult
27
29
{
28
30
foreach ($ this ->items as $ resource ) {
29
31
if ($ request ->uri === $ resource ->getUri ()) {
30
32
// In a real implementation, you would read the resource from its URI.
31
33
// Here we just return a dummy string for demonstration purposes.
32
- return 'Content of ' .$ resource ->getName ();
34
+ return new ResourceReadResult (
35
+ $ request ->id ,
36
+ 'Content of ' .$ resource ->getName (),
37
+ $ resource ->getUri (),
38
+ );
33
39
}
34
40
}
35
41
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- namespace App ;
3
+ namespace App \ Manager ;
4
4
5
+ use App \ExampleTool ;
5
6
use PhpLlm \McpSdk \Capability \Tool \CollectionInterface ;
6
7
use PhpLlm \McpSdk \Capability \Tool \ToolCall ;
7
8
use PhpLlm \McpSdk \Capability \Tool \ToolExecutorInterface ;
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace PhpLlm \McpSdk \Capability \Resource ;
6
+
7
+ final readonly class ResourceReadResult
8
+ {
9
+ public function __construct (
10
+ public string $ id ,
11
+ public string $ result ,
12
+ public string $ uri ,
13
+
14
+ /**
15
+ * @var "text"|"blob"
16
+ */
17
+ public string $ type = 'text ' ,
18
+ public string $ mimeType = 'text/plain ' ,
19
+ ) {
20
+ }
21
+ }
Original file line number Diff line number Diff line change @@ -11,5 +11,5 @@ interface ResourceReaderInterface
11
11
* @throws ResourceReadException if the resource execution fails
12
12
* @throws ResourceNotFoundException if the resource is not found
13
13
*/
14
- public function read (ResourceRead $ request ): mixed ;
14
+ public function read (ResourceRead $ request ): ResourceReadResult ;
15
15
}
Original file line number Diff line number Diff line change @@ -28,13 +28,12 @@ public function createResponse(Request $message): Response|Error
28
28
return Error::internalError ($ message ->id , 'Error while reading resource ' );
29
29
}
30
30
31
- // TODO get uri and mimeType from a result. (Change to "blob" if binary)
32
31
return new Response ($ message ->id , [
33
32
'contents ' => [
34
33
[
35
- 'uri ' => ' text ' ,
36
- 'mimeType ' => ' text ' ,
37
- ' text ' => $ result ,
34
+ 'uri ' => $ result -> uri ,
35
+ 'mimeType ' => $ result -> mimeType ,
36
+ $ result -> type => $ result -> result ,
38
37
],
39
38
],
40
39
]);
You can’t perform that action at this time.
0 commit comments