55use PhpMcp \Laravel \Tests \Stubs \App \Mcp \ManualTestHandler ;
66use PhpMcp \Laravel \Tests \Stubs \App \Mcp \ManualTestInvokableHandler ;
77use PhpMcp \Laravel \Tests \TestCase ;
8- use PhpMcp \Server \Definitions \ PromptDefinition ;
9- use PhpMcp \Server \Definitions \ ResourceDefinition ;
10- use PhpMcp \Server \Definitions \ ResourceTemplateDefinition ;
11- use PhpMcp \Server \Definitions \ ToolDefinition ;
8+ use PhpMcp \Server \Elements \ RegisteredTool ;
9+ use PhpMcp \Server \Elements \ RegisteredResource ;
10+ use PhpMcp \Server \Elements \ RegisteredResourceTemplate ;
11+ use PhpMcp \Server \Elements \ RegisteredPrompt ;
1212
1313class ManualRegistrationTest extends TestCase
1414{
@@ -26,15 +26,15 @@ public function test_can_manually_register_a_tool()
2626
2727 $ registry = $ this ->app ->make ('mcp.registry ' );
2828
29- $ tool = $ registry ->findTool ('manual_test_tool ' );
29+ $ tool = $ registry ->getTool ('manual_test_tool ' );
3030
31- $ this ->assertInstanceOf (ToolDefinition ::class, $ tool );
32- $ this ->assertEquals ('manual_test_tool ' , $ tool ->getName () );
33- $ this ->assertEquals ('A manually registered test tool. ' , $ tool ->getDescription () );
34- $ this ->assertEquals (ManualTestHandler::class, $ tool ->getClassName () );
35- $ this ->assertEquals ('handleTool ' , $ tool ->getMethodName () );
36- $ this ->assertArrayHasKey ('input ' , $ tool ->getInputSchema () ['properties ' ]);
37- $ this ->assertEquals ('string ' , $ tool ->getInputSchema () ['properties ' ]['input ' ]['type ' ]);
31+ $ this ->assertInstanceOf (RegisteredTool ::class, $ tool );
32+ $ this ->assertEquals ('manual_test_tool ' , $ tool ->schema -> name );
33+ $ this ->assertEquals ('A manually registered test tool. ' , $ tool ->schema -> description );
34+ $ this ->assertEquals (ManualTestHandler::class, $ tool ->handlerClass );
35+ $ this ->assertEquals ('handleTool ' , $ tool ->handlerMethod );
36+ $ this ->assertArrayHasKey ('input ' , $ tool ->schema -> inputSchema ['properties ' ]);
37+ $ this ->assertEquals ('string ' , $ tool ->schema -> inputSchema ['properties ' ]['input ' ]['type ' ]);
3838 }
3939
4040 public function test_can_manually_register_tool_using_handler_only ()
@@ -49,12 +49,12 @@ public function test_can_manually_register_tool_using_handler_only()
4949 $ this ->setMcpDefinitions ($ definitionsContent );
5050
5151 $ registry = $ this ->app ->make ('mcp.registry ' );
52- $ tool = $ registry ->findTool ('handleTool ' );
52+ $ tool = $ registry ->getTool ('handleTool ' );
5353
5454 $ this ->assertNotNull ($ tool );
55- $ this ->assertEquals (ManualTestHandler::class, $ tool ->getClassName () );
56- $ this ->assertEquals ('handleTool ' , $ tool ->getMethodName () );
57- $ this ->assertEquals ('A sample tool handler. ' , $ tool ->getDescription () );
55+ $ this ->assertEquals (ManualTestHandler::class, $ tool ->handlerClass );
56+ $ this ->assertEquals ('handleTool ' , $ tool ->handlerMethod );
57+ $ this ->assertEquals ('A sample tool handler. ' , $ tool ->schema -> description );
5858 }
5959
6060 public function test_can_manually_register_a_resource ()
@@ -63,26 +63,27 @@ public function test_can_manually_register_a_resource()
6363 <?php
6464 use PhpMcp\Laravel\Facades\Mcp;
6565 use PhpMcp\Laravel\Tests\Stubs\App\Mcp\ManualTestHandler;
66+ use PhpMcp\Schema\Annotations;
6667
6768 Mcp::resource('manual://config/app-setting', [ManualTestHandler::class, 'handleResource'])
6869 ->name('manual_app_setting')
6970 ->mimeType('application/json')
7071 ->size(1024)
71- ->annotations(['category' => 'config'] );
72+ ->annotations(Annotations::make(priority:0.8) );
7273 PHP;
7374 $ this ->setMcpDefinitions ($ definitionsContent );
7475
7576 $ registry = $ this ->app ->make ('mcp.registry ' );
76- $ resource = $ registry ->findResourceByUri ('manual://config/app-setting ' );
77-
78- $ this ->assertInstanceOf (ResourceDefinition ::class, $ resource );
79- $ this ->assertEquals ('manual_app_setting ' , $ resource ->getName () );
80- $ this ->assertEquals ('A sample resource handler. ' , $ resource ->getDescription () );
81- $ this ->assertEquals ('application/json ' , $ resource ->getMimeType () );
82- $ this ->assertEquals (1024 , $ resource ->getSize () );
83- $ this ->assertEquals (['category ' => ' config ' ], $ resource ->getAnnotations ());
84- $ this ->assertEquals (ManualTestHandler::class, $ resource ->getClassName () );
85- $ this ->assertEquals ('handleResource ' , $ resource ->getMethodName () );
77+ $ resource = $ registry ->getResource ('manual://config/app-setting ' );
78+
79+ $ this ->assertInstanceOf (RegisteredResource ::class, $ resource );
80+ $ this ->assertEquals ('manual_app_setting ' , $ resource ->schema -> name );
81+ $ this ->assertEquals ('A sample resource handler. ' , $ resource ->schema -> description );
82+ $ this ->assertEquals ('application/json ' , $ resource ->schema -> mimeType );
83+ $ this ->assertEquals (1024 , $ resource ->schema -> size );
84+ $ this ->assertEquals (['priority ' => 0.8 ], $ resource ->schema -> annotations -> toArray ());
85+ $ this ->assertEquals (ManualTestHandler::class, $ resource ->handlerClass );
86+ $ this ->assertEquals ('handleResource ' , $ resource ->handlerMethod );
8687 }
8788
8889 public function test_can_manually_register_a_prompt_with_invokable_class_handler ()
@@ -98,13 +99,13 @@ public function test_can_manually_register_a_prompt_with_invokable_class_handler
9899 $ this ->setMcpDefinitions ($ definitionsContent );
99100
100101 $ registry = $ this ->app ->make ('mcp.registry ' );
101- $ prompt = $ registry ->findPrompt ('manual_invokable_prompt ' );
102+ $ prompt = $ registry ->getPrompt ('manual_invokable_prompt ' );
102103
103- $ this ->assertInstanceOf (PromptDefinition ::class, $ prompt );
104- $ this ->assertEquals ('manual_invokable_prompt ' , $ prompt ->getName () );
105- $ this ->assertEquals ('A prompt handled by an invokable class. ' , $ prompt ->getDescription () );
106- $ this ->assertEquals (ManualTestInvokableHandler::class, $ prompt ->getClassName () );
107- $ this ->assertEquals ('__invoke ' , $ prompt ->getMethodName () );
104+ $ this ->assertInstanceOf (RegisteredPrompt ::class, $ prompt );
105+ $ this ->assertEquals ('manual_invokable_prompt ' , $ prompt ->schema -> name );
106+ $ this ->assertEquals ('A prompt handled by an invokable class. ' , $ prompt ->schema -> description );
107+ $ this ->assertEquals (ManualTestInvokableHandler::class, $ prompt ->handlerClass );
108+ $ this ->assertEquals ('__invoke ' , $ prompt ->handlerMethod );
108109 }
109110
110111 public function test_can_manually_register_a_resource_template_via_facade ()
@@ -121,16 +122,15 @@ public function test_can_manually_register_a_resource_template_via_facade()
121122 $ this ->setMcpDefinitions ($ definitionsContent );
122123
123124 $ registry = $ this ->app ->make ('mcp.registry ' );
124- $ templateMatch = $ registry ->findResourceTemplateByUri ('manual://item/123/details ' );
125-
126- $ this ->assertNotNull ($ templateMatch );
127- $ template = $ templateMatch ['definition ' ];
128- $ this ->assertInstanceOf (ResourceTemplateDefinition::class, $ template );
129- $ this ->assertEquals ('manual://item/{itemId}/details ' , $ template ->getUriTemplate ());
130- $ this ->assertEquals ('manual_item_details_template ' , $ template ->getName ());
131- $ this ->assertEquals ('A sample resource template handler. ' , $ template ->getDescription ());
132- $ this ->assertEquals ('application/vnd.api+json ' , $ template ->getMimeType ());
133- $ this ->assertEquals (ManualTestHandler::class, $ template ->getClassName ());
134- $ this ->assertEquals ('handleTemplate ' , $ template ->getMethodName ());
125+ $ template = $ registry ->getResource ('manual://item/123/details ' );
126+
127+ $ this ->assertNotNull ($ template );
128+ $ this ->assertInstanceOf (RegisteredResourceTemplate::class, $ template );
129+ $ this ->assertEquals ('manual://item/{itemId}/details ' , $ template ->schema ->uriTemplate );
130+ $ this ->assertEquals ('manual_item_details_template ' , $ template ->schema ->name );
131+ $ this ->assertEquals ('A sample resource template handler. ' , $ template ->schema ->description );
132+ $ this ->assertEquals ('application/vnd.api+json ' , $ template ->schema ->mimeType );
133+ $ this ->assertEquals (ManualTestHandler::class, $ template ->handlerClass );
134+ $ this ->assertEquals ('handleTemplate ' , $ template ->handlerMethod );
135135 }
136136}
0 commit comments