forked from modelcontextprotocol/php-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpSchemaShowcaseTest.php
More file actions
116 lines (111 loc) · 4.09 KB
/
HttpSchemaShowcaseTest.php
File metadata and controls
116 lines (111 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?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\Http;
final class HttpSchemaShowcaseTest extends HttpInspectorSnapshotTestCase
{
public static function provideMethods(): array
{
return [
...parent::provideMethods(),
'Format Text Tool' => [
'method' => 'tools/call',
'options' => [
'toolName' => 'format_text',
'toolArgs' => ['text' => 'Hello World Test', 'format' => 'uppercase'],
],
'testName' => 'format_text',
],
'Calculate Range Tool' => [
'method' => 'tools/call',
'options' => [
'toolName' => 'calculate_range',
'toolArgs' => ['first' => 10, 'second' => 5, 'operation' => 'multiply', 'precision' => 2],
],
'testName' => 'calculate_range',
],
'Validate Profile Tool' => [
'method' => 'tools/call',
'options' => [
'toolName' => 'validate_profile',
'toolArgs' => [
'profile' => ['name' => 'John Doe', 'email' => 'john@example.com', 'age' => 30, 'role' => 'user'],
],
],
'testName' => 'validate_profile',
],
'Manage List Tool' => [
'method' => 'tools/call',
'options' => [
'toolName' => 'manage_list',
'toolArgs' => [
'items' => ['apple', 'banana', 'cherry', 'date'],
'action' => 'sort',
],
],
'testName' => 'manage_list',
],
'Generate Config Tool' => [
'method' => 'tools/call',
'options' => [
'toolName' => 'generate_config',
'toolArgs' => [
'appName' => 'TestApp',
'baseUrl' => 'https://example.com',
'environment' => 'development',
'debug' => true,
'port' => 8080,
],
],
'testName' => 'generate_config',
],
'Schedule Event Tool' => [
'method' => 'tools/call',
'options' => [
'toolName' => 'schedule_event',
'toolArgs' => [
'title' => 'Team Meeting',
'startTime' => '2024-12-01T14:30:00Z',
'durationHours' => 1.5,
'priority' => 'high',
'attendees' => ['alice@example.com', 'bob@example.com'],
],
],
'testName' => 'schedule_event',
],
];
}
protected function getServerScript(): string
{
return \dirname(__DIR__, 3).'/examples/server/schema-showcase/server.php';
}
protected function normalizeTestOutput(string $output, ?string $testName = null): string
{
return match ($testName) {
'validate_profile' => preg_replace(
'/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/',
'2025-01-01 00:00:00',
$output
),
'generate_config' => preg_replace(
'/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2}/',
'2025-01-01T00:00:00+00:00',
$output
),
'schedule_event' => preg_replace([
'/event_[a-f0-9]{13,}/',
'/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2}/',
], [
'event_test123456789',
'2025-01-01T00:00:00+00:00',
], $output),
default => $output,
};
}
}