From 88403cf28d1f4dff86ed54608fbd1452a8d99ad0 Mon Sep 17 00:00:00 2001 From: Christopher Hertel Date: Thu, 23 Oct 2025 22:41:57 +0200 Subject: [PATCH] Add more inspector tests for functionality tests of STDIO examples --- .../McpTaskHandlers.php | 4 +- .../Service/InMemoryTaskRepository.php | 2 +- .../Service/StatsServiceInterface.php | 2 +- .../Service/SystemStatsService.php | 2 +- .../Service/TaskRepositoryInterface.php | 2 +- examples/stdio-custom-dependencies/server.php | 8 +- tests/Inspector/StdioCachedDiscoveryTest.php | 29 +++++++ .../Inspector/StdioCustomDependenciesTest.php | 29 +++++++ ...t.php => StdioDiscoveryCalculatorTest.php} | 2 +- tests/Inspector/StdioEnvVariablesTest.php | 29 +++++++ ....php => StdioExplicitRegistrationTest.php} | 2 +- ...tdioCachedDiscoveryTest-prompts_list.json} | 1 - ...dioCachedDiscoveryTest-resources_list.json | 3 + ...scoveryTest-resources_templates_list.json} | 0 .../StdioCachedDiscoveryTest-tools_list.json | 76 +++++++++++++++++++ ...ioCustomDependenciesTest-prompts_list.json | 3 + ...CustomDependenciesTest-resources_list.json | 10 +++ ...ndenciesTest-resources_templates_list.json | 3 + ...tdioCustomDependenciesTest-tools_list.json | 57 ++++++++++++++ ...oDiscoveryCalculatorTest-prompts_list.json | 3 + ...scoveryCalculatorTest-resources_list.json} | 1 - ...scoveryCalculatorTest-resources_read.json} | 0 ...lculatorTest-resources_templates_list.json | 3 + ...ioDiscoveryCalculatorTest-tools_call.json} | 0 ...ioDiscoveryCalculatorTest-tools_list.json} | 1 - .../StdioEnvVariablesTest-prompts_list.json | 3 + .../StdioEnvVariablesTest-resources_list.json | 3 + ...ariablesTest-resources_templates_list.json | 3 + .../StdioEnvVariablesTest-tools_list.json | 20 +++++ ...xplicitRegistrationTest-prompts_list.json} | 0 ...licitRegistrationTest-resources_list.json} | 0 ...trationTest-resources_templates_list.json} | 0 ...oExplicitRegistrationTest-tools_list.json} | 0 33 files changed, 286 insertions(+), 15 deletions(-) create mode 100644 tests/Inspector/StdioCachedDiscoveryTest.php create mode 100644 tests/Inspector/StdioCustomDependenciesTest.php rename tests/Inspector/{StdioCalculatorExampleTest.php => StdioDiscoveryCalculatorTest.php} (93%) create mode 100644 tests/Inspector/StdioEnvVariablesTest.php rename tests/Inspector/{ManualStdioExampleTest.php => StdioExplicitRegistrationTest.php} (89%) rename tests/Inspector/snapshots/{StdioCalculatorExampleTest-prompts_list.json => StdioCachedDiscoveryTest-prompts_list.json} (95%) create mode 100644 tests/Inspector/snapshots/StdioCachedDiscoveryTest-resources_list.json rename tests/Inspector/snapshots/{StdioCalculatorExampleTest-resources_templates_list.json => StdioCachedDiscoveryTest-resources_templates_list.json} (100%) create mode 100644 tests/Inspector/snapshots/StdioCachedDiscoveryTest-tools_list.json create mode 100644 tests/Inspector/snapshots/StdioCustomDependenciesTest-prompts_list.json create mode 100644 tests/Inspector/snapshots/StdioCustomDependenciesTest-resources_list.json create mode 100644 tests/Inspector/snapshots/StdioCustomDependenciesTest-resources_templates_list.json create mode 100644 tests/Inspector/snapshots/StdioCustomDependenciesTest-tools_list.json create mode 100644 tests/Inspector/snapshots/StdioDiscoveryCalculatorTest-prompts_list.json rename tests/Inspector/snapshots/{StdioCalculatorExampleTest-resources_list.json => StdioDiscoveryCalculatorTest-resources_list.json} (99%) rename tests/Inspector/snapshots/{StdioCalculatorExampleTest-resources_read.json => StdioDiscoveryCalculatorTest-resources_read.json} (100%) create mode 100644 tests/Inspector/snapshots/StdioDiscoveryCalculatorTest-resources_templates_list.json rename tests/Inspector/snapshots/{StdioCalculatorExampleTest-tools_call.json => StdioDiscoveryCalculatorTest-tools_call.json} (100%) rename tests/Inspector/snapshots/{StdioCalculatorExampleTest-tools_list.json => StdioDiscoveryCalculatorTest-tools_list.json} (99%) create mode 100644 tests/Inspector/snapshots/StdioEnvVariablesTest-prompts_list.json create mode 100644 tests/Inspector/snapshots/StdioEnvVariablesTest-resources_list.json create mode 100644 tests/Inspector/snapshots/StdioEnvVariablesTest-resources_templates_list.json create mode 100644 tests/Inspector/snapshots/StdioEnvVariablesTest-tools_list.json rename tests/Inspector/snapshots/{ManualStdioExampleTest-prompts_list.json => StdioExplicitRegistrationTest-prompts_list.json} (100%) rename tests/Inspector/snapshots/{ManualStdioExampleTest-resources_list.json => StdioExplicitRegistrationTest-resources_list.json} (100%) rename tests/Inspector/snapshots/{ManualStdioExampleTest-resources_templates_list.json => StdioExplicitRegistrationTest-resources_templates_list.json} (100%) rename tests/Inspector/snapshots/{ManualStdioExampleTest-tools_list.json => StdioExplicitRegistrationTest-tools_list.json} (100%) diff --git a/examples/stdio-custom-dependencies/McpTaskHandlers.php b/examples/stdio-custom-dependencies/McpTaskHandlers.php index 262d1a86..65d2f003 100644 --- a/examples/stdio-custom-dependencies/McpTaskHandlers.php +++ b/examples/stdio-custom-dependencies/McpTaskHandlers.php @@ -13,8 +13,8 @@ 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; /** diff --git a/examples/stdio-custom-dependencies/Service/InMemoryTaskRepository.php b/examples/stdio-custom-dependencies/Service/InMemoryTaskRepository.php index 47526c4c..63ce8611 100644 --- a/examples/stdio-custom-dependencies/Service/InMemoryTaskRepository.php +++ b/examples/stdio-custom-dependencies/Service/InMemoryTaskRepository.php @@ -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; diff --git a/examples/stdio-custom-dependencies/Service/StatsServiceInterface.php b/examples/stdio-custom-dependencies/Service/StatsServiceInterface.php index b8485d2a..a7e8b276 100644 --- a/examples/stdio-custom-dependencies/Service/StatsServiceInterface.php +++ b/examples/stdio-custom-dependencies/Service/StatsServiceInterface.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Mcp\Example\DependenciesStdioExample\Service; +namespace Mcp\Example\StdioCustomDependencies\Service; interface StatsServiceInterface { diff --git a/examples/stdio-custom-dependencies/Service/SystemStatsService.php b/examples/stdio-custom-dependencies/Service/SystemStatsService.php index 075dd8a0..5a766792 100644 --- a/examples/stdio-custom-dependencies/Service/SystemStatsService.php +++ b/examples/stdio-custom-dependencies/Service/SystemStatsService.php @@ -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 { diff --git a/examples/stdio-custom-dependencies/Service/TaskRepositoryInterface.php b/examples/stdio-custom-dependencies/Service/TaskRepositoryInterface.php index 975cc711..6c091be1 100644 --- a/examples/stdio-custom-dependencies/Service/TaskRepositoryInterface.php +++ b/examples/stdio-custom-dependencies/Service/TaskRepositoryInterface.php @@ -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} diff --git a/examples/stdio-custom-dependencies/server.php b/examples/stdio-custom-dependencies/server.php index 659f4499..4ebd4cbd 100644 --- a/examples/stdio-custom-dependencies/server.php +++ b/examples/stdio-custom-dependencies/server.php @@ -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; diff --git a/tests/Inspector/StdioCachedDiscoveryTest.php b/tests/Inspector/StdioCachedDiscoveryTest.php new file mode 100644 index 00000000..dfc8acec --- /dev/null +++ b/tests/Inspector/StdioCachedDiscoveryTest.php @@ -0,0 +1,29 @@ +