-
-
Notifications
You must be signed in to change notification settings - Fork 29
MCP Demo #132
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
MCP Demo #132
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mcp: | ||
app: demo-app | ||
version: 0.0.1 | ||
client_transports: | ||
stdio: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,11 @@ services: | |
- '../src/DependencyInjection/' | ||
- '../src/Entity/' | ||
- '../src/Kernel.php' | ||
|
||
Symfony\AI\McpSdk\Capability\Tool\ToolExecutorInterface: | ||
class: Symfony\AI\McpSdk\Capability\ToolChain | ||
arguments: | ||
- ['@App\MCP\Tools\CurrentTimeTool'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Off topic, but it would be nice if this is configurable via the bundle config cc @Nyholm There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you pass a service reference in bundle config? E.g. mcp:
tools:
- '@App\MCP\Tools\CurrentTimeTool' Would a tag + compiler pass perhaps be a cleaner way of doing this? App\MCP\Tools\CurrentTimeTool:
tags:
- { name: mcp_tool_executor }
- { name: mcp_tool_metadata } or just |
||
|
||
Symfony\AI\McpSdk\Capability\Tool\CollectionInterface: | ||
alias: Symfony\AI\McpSdk\Capability\Tool\ToolExecutorInterface |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace App\MCP\Tools; | ||
|
||
use Symfony\AI\McpSdk\Capability\Tool\MetadataInterface; | ||
use Symfony\AI\McpSdk\Capability\Tool\ToolCall; | ||
use Symfony\AI\McpSdk\Capability\Tool\ToolCallResult; | ||
use Symfony\AI\McpSdk\Capability\Tool\ToolExecutorInterface; | ||
|
||
/** | ||
* @author Tom Hart <[email protected]> | ||
*/ | ||
class CurrentTimeTool implements MetadataInterface, ToolExecutorInterface | ||
TomHart marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
public function call(ToolCall $input): ToolCallResult | ||
{ | ||
$format = $input->arguments['format'] ?? 'Y-m-d H:i:s'; | ||
|
||
return new ToolCallResult( | ||
(new \DateTime('now', new \DateTimeZone('UTC')))->format($format) | ||
); | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return 'current-time'; | ||
} | ||
|
||
public function getDescription(): string | ||
{ | ||
return 'Returns the current time in UTC'; | ||
} | ||
|
||
public function getInputSchema(): array | ||
{ | ||
return [ | ||
'type' => 'object', | ||
'properties' => [ | ||
'format' => [ | ||
'type' => 'string', | ||
'description' => 'The format of the time, e.g. "Y-m-d H:i:s"', | ||
'default' => 'Y-m-d H:i:s', | ||
], | ||
], | ||
'required' => ['format'], | ||
]; | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.