-
Notifications
You must be signed in to change notification settings - Fork 81
[Server] Registry Architecture Refactoring - Enhanced Separation of Concerns #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
chr-hertel
merged 27 commits into
modelcontextprotocol:main
from
butschster:feature/tool-execution
Sep 14, 2025
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
6e4c57d
refactor: Separate Registry concerns following SOLID principles [WIP]
butschster 047004e
refactor: implement SOLID principles with separated execution concerns
butschster 9bf2a7e
chore: remove extra comments
butschster 4aafe6b
feat: introduce DispatchableRegistry for enhanced tool and resource m…
butschster bd4791a
refactor: use proper interfaces
butschster fc467d8
refactor: implement HandlerInterface for improved abstraction and fle…
butschster e6dc2af
test: add unit tests for DispatchableRegistry and Registry classes
butschster 20de24f
refactor: cover with unit tests Resource reader, Prompt getter and To…
butschster 7237665
cs fix
butschster 1f160f9
phpstan fix
butschster e7494da
test: add unit tests for CallToolHandler, GetPromptHandler, PingHandl…
butschster 3773e75
refactor: revert Handler
butschster 8a66539
chore: remove style guide for tests
butschster 156f842
refactor: remove "Default" prefix from classes
butschster 4f64998
refactor: remove DispatchableRegistry
butschster d9cd7ba
refactor: use package specific exception classes
butschster addfd23
refactor: remove DispatchableRegistry
butschster f3110eb
refactor: add logger support to PromptGetter and ResourceReader classes
butschster 79618f7
Update src/Capability/Prompt/PromptGetter.php
butschster f1edddc
Merge branch 'main' into feature/tool-execution
butschster e413594
refactor: Use FQN for Resource class to avoid cs-fixer misinterpretin…
butschster 9e798ad
refactor: rename ToolExecutor to ToolCaller and related classes for c…
butschster e11c0c1
refactor: add missed docblock
butschster 3c70c5c
refactor: rename ToolExecutor references to ToolCaller
butschster 7bd23b3
refactor: rename ToolCallerTest property and variable references
butschster 32f2de9
cs fix
butschster 0ca952b
ignore some phpstan errors
butschster File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,15 +12,15 @@ | |
| namespace App; | ||
|
|
||
| use Mcp\Capability\Tool\MetadataInterface; | ||
| use Mcp\Capability\Tool\ToolExecutorInterface; | ||
| use Mcp\Capability\Tool\ToolCallerInterface; | ||
| use Mcp\Schema\Content\TextContent; | ||
| use Mcp\Schema\Request\CallToolRequest; | ||
| use Mcp\Schema\Result\CallToolResult; | ||
|
|
||
| /** | ||
| * @author Tobias Nyholm <[email protected]> | ||
| */ | ||
| class ExampleTool implements MetadataInterface, ToolExecutorInterface | ||
| class ExampleTool implements MetadataInterface, ToolCallerInterface | ||
| { | ||
| public function call(CallToolRequest $request): CallToolResult | ||
| { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ | |
|
|
||
| use Mcp\Capability\Registry\ReferenceHandlerInterface; | ||
| use Mcp\Capability\Registry\ReferenceProviderInterface; | ||
| use Mcp\Exception\ToolExecutionException; | ||
| use Mcp\Exception\ToolCallException; | ||
| use Mcp\Exception\ToolNotFoundException; | ||
| use Mcp\Schema\Content\AudioContent; | ||
| use Mcp\Schema\Content\EmbeddedResource; | ||
|
|
@@ -30,7 +30,7 @@ | |
| * | ||
| * @author Pavel Buchnev <[email protected]> | ||
| */ | ||
| final class ToolExecutor implements ToolExecutorInterface | ||
| final class ToolCaller implements ToolCallerInterface | ||
| { | ||
| public function __construct( | ||
| private readonly ReferenceProviderInterface $referenceProvider, | ||
|
|
@@ -40,7 +40,7 @@ public function __construct( | |
| } | ||
|
|
||
| /** | ||
| * @throws ToolExecutionException if the tool execution fails | ||
| * @throws ToolCallException if the tool execution fails | ||
| * @throws ToolNotFoundException if the tool is not found | ||
| */ | ||
| public function call(CallToolRequest $request): CallToolResult | ||
|
|
@@ -75,7 +75,7 @@ public function call(CallToolRequest $request): CallToolResult | |
| 'trace' => $e->getTraceAsString(), | ||
| ]); | ||
|
|
||
| throw new ToolExecutionException($request, $e); | ||
| throw new ToolCallException($request, $e); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,18 +11,18 @@ | |
|
|
||
| namespace Mcp\Capability\Tool; | ||
|
|
||
| use Mcp\Exception\ToolExecutionException; | ||
| use Mcp\Exception\ToolCallException; | ||
| use Mcp\Exception\ToolNotFoundException; | ||
| use Mcp\Schema\Request\CallToolRequest; | ||
| use Mcp\Schema\Result\CallToolResult; | ||
|
|
||
| /** | ||
| * @author Tobias Nyholm <[email protected]> | ||
| */ | ||
| interface ToolExecutorInterface | ||
| interface ToolCallerInterface | ||
| { | ||
| /** | ||
| * @throws ToolExecutionException if the tool execution fails | ||
| * @throws ToolCallException if the tool execution fails | ||
| * @throws ToolNotFoundException if the tool is not found | ||
| */ | ||
| public function call(CallToolRequest $request): CallToolResult; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,9 +14,9 @@ | |
| use Mcp\Capability\Tool\CollectionInterface; | ||
| use Mcp\Capability\Tool\IdentifierInterface; | ||
| use Mcp\Capability\Tool\MetadataInterface; | ||
| use Mcp\Capability\Tool\ToolExecutorInterface; | ||
| use Mcp\Capability\Tool\ToolCallerInterface; | ||
| use Mcp\Exception\InvalidCursorException; | ||
| use Mcp\Exception\ToolExecutionException; | ||
| use Mcp\Exception\ToolCallException; | ||
| use Mcp\Exception\ToolNotFoundException; | ||
| use Mcp\Schema\Request\CallToolRequest; | ||
| use Mcp\Schema\Result\CallToolResult; | ||
|
|
@@ -26,7 +26,7 @@ | |
| * | ||
| * @author Tobias Nyholm <[email protected]> | ||
| */ | ||
| class ToolChain implements ToolExecutorInterface, CollectionInterface | ||
| class ToolChain implements ToolCallerInterface, CollectionInterface | ||
| { | ||
| public function __construct( | ||
| /** | ||
|
|
@@ -63,11 +63,11 @@ public function getMetadata(int $count, ?string $lastIdentifier = null): iterabl | |
| public function call(CallToolRequest $request): CallToolResult | ||
| { | ||
| foreach ($this->items as $item) { | ||
| if ($item instanceof ToolExecutorInterface && $request->name === $item->getName()) { | ||
| if ($item instanceof ToolCallerInterface && $request->name === $item->getName()) { | ||
| try { | ||
| return $item->call($request); | ||
| } catch (\Throwable $e) { | ||
| throw new ToolExecutionException($request, $e); | ||
| throw new ToolCallException($request, $e); | ||
| } | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,12 +16,12 @@ | |
| /** | ||
| * @author Tobias Nyholm <[email protected]> | ||
| */ | ||
| final class ToolExecutionException extends \RuntimeException implements ExceptionInterface | ||
| final class ToolCallException extends \RuntimeException implements ExceptionInterface | ||
| { | ||
| public function __construct( | ||
| public readonly CallToolRequest $request, | ||
| ?\Throwable $previous = null, | ||
| ) { | ||
| parent::__construct(\sprintf('Execution of tool "%s" failed with error: "%s".', $request->name, $previous?->getMessage() ?? ''), previous: $previous); | ||
| parent::__construct(\sprintf('Tool call "%s" failed with error: "%s".', $request->name, $previous?->getMessage() ?? ''), previous: $previous); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.