Add more inspector tests for functionality tests of STDIO examples (#115)
This commit is contained in:
parent
48a19b93a7
commit
7190bee153
27 changed files with 286 additions and 15 deletions
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": []
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"resources": [
|
||||
{
|
||||
"name": "calculator_config",
|
||||
"uri": "config://calculator/settings",
|
||||
"description": "Current settings for the calculator tool (precision, allow_negative).",
|
||||
"mimeType": "application/json"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"contents": [
|
||||
{
|
||||
"uri": "config://calculator/settings",
|
||||
"mimeType": "application/json",
|
||||
"text": "{\n \"precision\": 2,\n \"allow_negative\": true\n}"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"resourceTemplates": []
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"content": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": "19.8"
|
||||
}
|
||||
],
|
||||
"isError": false
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"tools": [
|
||||
{
|
||||
"name": "calculate",
|
||||
"description": "Performs a calculation based on the operation.",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"a": {
|
||||
"type": "number",
|
||||
"description": "the first operand"
|
||||
},
|
||||
"b": {
|
||||
"type": "number",
|
||||
"description": "the second operand"
|
||||
},
|
||||
"operation": {
|
||||
"type": "string",
|
||||
"description": "the operation ('add', 'subtract', 'multiply', 'divide')"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b",
|
||||
"operation"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "update_setting",
|
||||
"description": "Updates a specific configuration setting.",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"setting": {
|
||||
"type": "string",
|
||||
"description": "the setting key ('precision' or 'allow_negative')"
|
||||
},
|
||||
"value": {
|
||||
"description": "the new value (int for precision, bool for allow_negative)"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"setting",
|
||||
"value"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -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