Add more inspector tests for functionality tests of STDIO examples (#115)
This commit is contained in:
parent
48a19b93a7
commit
7190bee153
33 changed files with 286 additions and 15 deletions
|
|
@ -13,8 +13,8 @@ namespace Mcp\Example\StdioCustomDependencies;
|
|||
|
||||
use Mcp\Capability\Attribute\McpResource;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Mcp\Example\DependenciesStdioExample\Service\StatsServiceInterface;
|
||||
use Mcp\Example\DependenciesStdioExample\Service\TaskRepositoryInterface;
|
||||
use Mcp\Example\StdioCustomDependencies\Service\StatsServiceInterface;
|
||||
use Mcp\Example\StdioCustomDependencies\Service\TaskRepositoryInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mcp\Example\DependenciesStdioExample\Service;
|
||||
namespace Mcp\Example\StdioCustomDependencies\Service;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mcp\Example\DependenciesStdioExample\Service;
|
||||
namespace Mcp\Example\StdioCustomDependencies\Service;
|
||||
|
||||
interface StatsServiceInterface
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mcp\Example\DependenciesStdioExample\Service;
|
||||
namespace Mcp\Example\StdioCustomDependencies\Service;
|
||||
|
||||
final class SystemStatsService implements StatsServiceInterface
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mcp\Example\DependenciesStdioExample\Service;
|
||||
namespace Mcp\Example\StdioCustomDependencies\Service;
|
||||
|
||||
/**
|
||||
* @phpstan-type Task array{id: int, userId: string, description: string, completed: bool, createdAt: string}
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@
|
|||
require_once dirname(__DIR__).'/bootstrap.php';
|
||||
chdir(__DIR__);
|
||||
|
||||
use Mcp\Example\DependenciesStdioExample\Service\InMemoryTaskRepository;
|
||||
use Mcp\Example\DependenciesStdioExample\Service\StatsServiceInterface;
|
||||
use Mcp\Example\DependenciesStdioExample\Service\SystemStatsService;
|
||||
use Mcp\Example\DependenciesStdioExample\Service\TaskRepositoryInterface;
|
||||
use Mcp\Example\StdioCustomDependencies\Service\InMemoryTaskRepository;
|
||||
use Mcp\Example\StdioCustomDependencies\Service\StatsServiceInterface;
|
||||
use Mcp\Example\StdioCustomDependencies\Service\SystemStatsService;
|
||||
use Mcp\Example\StdioCustomDependencies\Service\TaskRepositoryInterface;
|
||||
use Mcp\Server;
|
||||
use Mcp\Server\Transport\StdioTransport;
|
||||
|
||||
|
|
|
|||
29
tests/Inspector/StdioCachedDiscoveryTest.php
Normal file
29
tests/Inspector/StdioCachedDiscoveryTest.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the official PHP MCP SDK.
|
||||
*
|
||||
* A collaboration between Symfony and the PHP Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Inspector;
|
||||
|
||||
use Mcp\Tests\Inspector\InspectorSnapshotTestCase;
|
||||
|
||||
final class StdioCachedDiscoveryTest extends InspectorSnapshotTestCase
|
||||
{
|
||||
public static function provideMethods(): array
|
||||
{
|
||||
return [
|
||||
...parent::provideListMethods(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getServerScript(): string
|
||||
{
|
||||
return \dirname(__DIR__, 2).'/examples/stdio-cached-discovery/server.php';
|
||||
}
|
||||
}
|
||||
29
tests/Inspector/StdioCustomDependenciesTest.php
Normal file
29
tests/Inspector/StdioCustomDependenciesTest.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the official PHP MCP SDK.
|
||||
*
|
||||
* A collaboration between Symfony and the PHP Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Inspector;
|
||||
|
||||
use Mcp\Tests\Inspector\InspectorSnapshotTestCase;
|
||||
|
||||
final class StdioCustomDependenciesTest extends InspectorSnapshotTestCase
|
||||
{
|
||||
public static function provideMethods(): array
|
||||
{
|
||||
return [
|
||||
...parent::provideListMethods(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getServerScript(): string
|
||||
{
|
||||
return \dirname(__DIR__, 2).'/examples/stdio-custom-dependencies/server.php';
|
||||
}
|
||||
}
|
||||
38
tests/Inspector/StdioDiscoveryCalculatorTest.php
Normal file
38
tests/Inspector/StdioDiscoveryCalculatorTest.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the official PHP MCP SDK.
|
||||
*
|
||||
* A collaboration between Symfony and the PHP Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mcp\Tests\Inspector;
|
||||
|
||||
final class StdioDiscoveryCalculatorTest extends InspectorSnapshotTestCase
|
||||
{
|
||||
public static function provideMethods(): array
|
||||
{
|
||||
return [
|
||||
...parent::provideListMethods(),
|
||||
'Calculate Sum' => [
|
||||
'method' => 'tools/call',
|
||||
'toolName' => 'calculate',
|
||||
'toolArgs' => ['a' => 12.5, 'b' => 7.3, 'operation' => 'add'],
|
||||
],
|
||||
'Read Config' => [
|
||||
'method' => 'resources/read',
|
||||
'toolName' => null, // can be removed with newer PHPUnit versions
|
||||
'toolArgs' => [], // can be removed with newer PHPUnit versions
|
||||
'uri' => 'config://calculator/settings',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
protected function getServerScript(): string
|
||||
{
|
||||
return \dirname(__DIR__, 2).'/examples/stdio-discovery-calculator/server.php';
|
||||
}
|
||||
}
|
||||
29
tests/Inspector/StdioEnvVariablesTest.php
Normal file
29
tests/Inspector/StdioEnvVariablesTest.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the official PHP MCP SDK.
|
||||
*
|
||||
* A collaboration between Symfony and the PHP Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Inspector;
|
||||
|
||||
use Mcp\Tests\Inspector\InspectorSnapshotTestCase;
|
||||
|
||||
final class StdioEnvVariablesTest extends InspectorSnapshotTestCase
|
||||
{
|
||||
public static function provideMethods(): array
|
||||
{
|
||||
return [
|
||||
...parent::provideListMethods(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getServerScript(): string
|
||||
{
|
||||
return \dirname(__DIR__, 2).'/examples/stdio-env-variables/server.php';
|
||||
}
|
||||
}
|
||||
29
tests/Inspector/StdioExplicitRegistrationTest.php
Normal file
29
tests/Inspector/StdioExplicitRegistrationTest.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the official PHP MCP SDK.
|
||||
*
|
||||
* A collaboration between Symfony and the PHP Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Inspector;
|
||||
|
||||
use Mcp\Tests\Inspector\InspectorSnapshotTestCase;
|
||||
|
||||
final class StdioExplicitRegistrationTest extends InspectorSnapshotTestCase
|
||||
{
|
||||
public static function provideMethods(): array
|
||||
{
|
||||
return [
|
||||
...parent::provideListMethods(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getServerScript(): string
|
||||
{
|
||||
return \dirname(__DIR__, 2).'/examples/stdio-explicit-registration/server.php';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"prompts": []
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"resources": []
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"resourceTemplates": []
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
{
|
||||
"tools": [
|
||||
{
|
||||
"name": "add_numbers",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"a": {
|
||||
"type": "integer"
|
||||
},
|
||||
"b": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "multiply_numbers",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"a": {
|
||||
"type": "integer"
|
||||
},
|
||||
"b": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "divide_numbers",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"a": {
|
||||
"type": "integer"
|
||||
},
|
||||
"b": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "power",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"base": {
|
||||
"type": "integer"
|
||||
},
|
||||
"exponent": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"base",
|
||||
"exponent"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"prompts": []
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"resources": [
|
||||
{
|
||||
"name": "system_stats",
|
||||
"uri": "stats://system/overview",
|
||||
"description": "Provides current system statistics.",
|
||||
"mimeType": "application/json"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"resourceTemplates": []
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
"tools": [
|
||||
{
|
||||
"name": "add_task",
|
||||
"description": "Adds a new task for a given user.",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"userId": {
|
||||
"type": "string",
|
||||
"description": "the ID of the user"
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"description": "the task description"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"userId",
|
||||
"description"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "list_user_tasks",
|
||||
"description": "Lists pending tasks for a specific user.",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"userId": {
|
||||
"type": "string",
|
||||
"description": "the ID of the user"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"userId"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "complete_task",
|
||||
"description": "Marks a task as complete.",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"taskId": {
|
||||
"type": "integer",
|
||||
"description": "the ID of the task to complete"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"taskId"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"prompts": []
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue