You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Registry Architecture Refactoring - Enhanced Separation of Concerns (modelcontextprotocol#46)
* refactor: Separate Registry concerns following SOLID principles [WIP]
- Extract ReferenceProvider and ReferenceRegistryInterface interfaces
- Create DefaultToolExecutor with ReferenceHandlerInterface
- Remove execution responsibility from Registry class
- Enable custom handler and executor implementations
* refactor: implement SOLID principles with separated execution concerns
* Create DefaultResourceReader, DefaultPromptGetter
* Refactor JsonRpc Handler and RequestHandlers to use dedicated executors
* Update ServerBuilder to support custom executors via dependency injection
* chore: remove extra comments
* feat: introduce DispatchableRegistry for enhanced tool and resource management
* refactor: use proper interfaces
* refactor: implement HandlerInterface for improved abstraction and flexibility
* test: add unit tests for DispatchableRegistry and Registry classes
* refactor: cover with unit tests Resource reader, Prompt getter and Tool executor
* cs fix
* phpstan fix
* test: add unit tests for CallToolHandler, GetPromptHandler, PingHandler, and ReadResourceHandler
* refactor: revert Handler
* chore: remove style guide for tests
* refactor: remove "Default" prefix from classes
* refactor: remove DispatchableRegistry
* refactor: use package specific exception classes
* refactor: remove DispatchableRegistry
* refactor: add logger support to PromptGetter and ResourceReader classes
* Update src/Capability/Prompt/PromptGetter.php
Co-authored-by: Christopher Hertel <[email protected]>
* refactor: Use FQN for Resource class to avoid cs-fixer misinterpreting it as `resource`
* refactor: rename ToolExecutor to ToolCaller and related classes for clarity and consistency
* refactor: add missed docblock
* refactor: rename ToolExecutor references to ToolCaller
* refactor: rename ToolCallerTest property and variable references
* cs fix
* ignore some phpstan errors
---------
Co-authored-by: Christopher Hertel <[email protected]>
message:'#^Parameter \#1 \$registry of class Mcp\\Server\\RequestHandler\\CallToolHandler constructor expects Mcp\\Capability\\Registry, Mcp\\Capability\\ToolChain given\.$#'
370
+
message:'#^Parameter \#1 \$registry of class Mcp\\Server\\RequestHandler\\ListPromptsHandler constructor expects Mcp\\Capability\\Registry\\ReferenceProviderInterface, Mcp\\Capability\\PromptChain given\.$#'
371
371
identifier:argument.type
372
372
count:1
373
373
path:examples/09-standalone-cli/src/Builder.php
374
374
375
375
-
376
-
message:'#^Parameter \#1 \$registry of class Mcp\\Server\\RequestHandler\\GetPromptHandler constructor expects Mcp\\Capability\\Registry, Mcp\\Capability\\PromptChain given\.$#'
376
+
message:'#^Parameter \#1 \$registry of class Mcp\\Server\\RequestHandler\\ListResourcesHandler constructor expects Mcp\\Capability\\Registry\\ReferenceProviderInterface, Mcp\\Capability\\ResourceChain given\.$#'
377
377
identifier:argument.type
378
378
count:1
379
379
path:examples/09-standalone-cli/src/Builder.php
380
380
381
381
-
382
-
message:'#^Parameter \#1 \$registry of class Mcp\\Server\\RequestHandler\\ListPromptsHandler constructor expects Mcp\\Capability\\Registry, Mcp\\Capability\\PromptChain given\.$#'
382
+
message:'#^Parameter \#1 \$registry of class Mcp\\Server\\RequestHandler\\ListToolsHandler constructor expects Mcp\\Capability\\Registry\\ReferenceProviderInterface, Mcp\\Capability\\ToolChain given\.$#'
383
383
identifier:argument.type
384
384
count:1
385
385
path:examples/09-standalone-cli/src/Builder.php
386
386
387
387
-
388
-
message:'#^Parameter \#1 \$registry of class Mcp\\Server\\RequestHandler\\ListResourcesHandler constructor expects Mcp\\Capability\\Registry, Mcp\\Capability\\ResourceChain given\.$#'
389
-
identifier:argument.type
390
-
count:1
391
-
path:examples/09-standalone-cli/src/Builder.php
392
-
393
-
-
394
-
message:'#^Parameter \#1 \$registry of class Mcp\\Server\\RequestHandler\\ListToolsHandler constructor expects Mcp\\Capability\\Registry, Mcp\\Capability\\ToolChain given\.$#'
395
-
identifier:argument.type
396
-
count:1
397
-
path:examples/09-standalone-cli/src/Builder.php
398
-
399
-
-
400
-
message:'#^Parameter \#1 \$registry of class Mcp\\Server\\RequestHandler\\ReadResourceHandler constructor expects Mcp\\Capability\\Registry, Mcp\\Capability\\ResourceChain given\.$#'
401
-
identifier:argument.type
402
-
count:1
403
-
path:examples/09-standalone-cli/src/Builder.php
404
-
405
-
-
406
-
message:'#^Call to protected method formatResult\(\) of class Mcp\\Capability\\Registry\\ResourceReference\.$#'
407
-
identifier:method.protected
408
-
count:1
409
-
path:src/Capability/Registry.php
410
-
411
-
-
412
-
message:'#^Cannot import type alias CallableArray\: type alias does not exist in Mcp\\Capability\\Registry\\ElementReference\.$#'
413
-
identifier:typeAlias.notFound
414
-
count:1
415
-
path:src/Capability/Registry.php
416
-
417
-
-
418
-
message:'#^Method Mcp\\Capability\\Registry\:\:handleCallTool\(\) has parameter \$arguments with no value type specified in iterable type array\.$#'
419
-
identifier:missingType.iterableValue
420
-
count:1
421
-
path:src/Capability/Registry.php
422
-
423
-
-
424
-
message:'#^Method Mcp\\Capability\\Registry\:\:handleCallTool\(\) return type has no value type specified in iterable type array\.$#'
425
-
identifier:missingType.iterableValue
426
-
count:1
427
-
path:src/Capability/Registry.php
428
-
429
-
-
430
-
message:'#^Method Mcp\\Capability\\Registry\:\:handleGetPrompt\(\) has parameter \$arguments with no value type specified in iterable type array\.$#'
431
-
identifier:missingType.iterableValue
432
-
count:1
433
-
path:src/Capability/Registry.php
434
-
435
-
-
436
-
message:'#^Method Mcp\\Capability\\Registry\:\:registerPrompt\(\) has parameter \$handler with no value type specified in iterable type array\.$#'
437
-
identifier:missingType.iterableValue
438
-
count:1
439
-
path:src/Capability/Registry.php
440
-
441
-
-
442
-
message:'#^Method Mcp\\Capability\\Registry\:\:registerResource\(\) has parameter \$handler with no value type specified in iterable type array\.$#'
443
-
identifier:missingType.iterableValue
444
-
count:1
445
-
path:src/Capability/Registry.php
446
-
447
-
-
448
-
message:'#^Method Mcp\\Capability\\Registry\:\:registerResourceTemplate\(\) has parameter \$handler with no value type specified in iterable type array\.$#'
449
-
identifier:missingType.iterableValue
450
-
count:1
451
-
path:src/Capability/Registry.php
452
-
453
-
-
454
-
message:'#^Method Mcp\\Capability\\Registry\:\:registerTool\(\) has parameter \$handler with no value type specified in iterable type array\.$#'
455
-
identifier:missingType.iterableValue
456
-
count:1
457
-
path:src/Capability/Registry.php
458
-
459
-
-
460
-
message:'#^PHPDoc tag @param for parameter \$handler with type \(callable\)\|Mcp\\Capability\\CallableArray\|string is not subtype of native type array\|\(callable\)\|string\.$#'
461
-
identifier:parameter.phpDocType
462
-
count:4
463
-
path:src/Capability/Registry.php
464
-
465
-
-
466
-
message:'#^Parameter \$handler of method Mcp\\Capability\\Registry\:\:registerPrompt\(\) has invalid type Mcp\\Capability\\CallableArray\.$#'
467
-
identifier:class.notFound
388
+
message:'#^PHPDoc tag @return with type array is incompatible with native type object\.$#'
389
+
identifier:return.phpDocType
468
390
count:1
469
-
path:src/Capability/Registry.php
391
+
path:src/Schema/Result/EmptyResult.php
470
392
471
393
-
472
-
message:'#^Parameter \$handler of method Mcp\\Capability\\Registry\:\:registerResource\(\) has invalid type Mcp\\Capability\\CallableArray\.$#'
473
-
identifier:class.notFound
394
+
message:'#^Method Mcp\\Schema\\Result\\ReadResourceResult\:\:jsonSerialize\(\) should return array\{contents\: array\<Mcp\\Schema\\Content\\BlobResourceContents\|Mcp\\Schema\\Content\\TextResourceContents\>\} but returns array\{contents\: array\<Mcp\\Schema\\Content\\ResourceContents\>\}\.$#'
395
+
identifier:return.type
474
396
count:1
475
-
path:src/Capability/Registry.php
397
+
path:src/Schema/Result/ReadResourceResult.php
476
398
477
399
-
478
-
message:'#^Parameter \$handler of method Mcp\\Capability\\Registry\:\:registerResourceTemplate\(\) has invalid type Mcp\\Capability\\CallableArray\.$#'
message:'#^PHPDoc tag @return with type array is incompatible with native type object\.$#'
497
-
identifier:return.phpDocType
498
-
count:1
499
-
path:src/Schema/Result/EmptyResult.php
500
-
501
-
-
502
-
message:'#^Method Mcp\\Schema\\Result\\ReadResourceResult\:\:jsonSerialize\(\) should return array\{contents\: array\<Mcp\\Schema\\Content\\BlobResourceContents\|Mcp\\Schema\\Content\\TextResourceContents\>\} but returns array\{contents\: array\<Mcp\\Schema\\Content\\ResourceContents\>\}\.$#'
503
-
identifier:return.type
504
-
count:1
505
-
path:src/Schema/Result/ReadResourceResult.php
506
-
507
-
-
508
-
message:'#^Method Mcp\\Capability\\Registry\:\:getPrompts\(\) invoked with 2 parameters, 0 required\.$#'
0 commit comments