Skip to content

Commit 37c2b5e

Browse files
committed
Merge branch 'main' into allow-runtime-tools
2 parents d10719c + fb2c8c2 commit 37c2b5e

85 files changed

Lines changed: 593 additions & 275 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/pipeline.yaml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ jobs:
7272
- name: Tests
7373
run: vendor/bin/phpunit --testsuite=inspector
7474

75-
conformance:
75+
conformance-server:
76+
name: conformance / server
7677
runs-on: ubuntu-latest
7778
steps:
7879
- name: Checkout
@@ -122,6 +123,47 @@ jobs:
122123
if: always()
123124
run: docker compose -f tests/Conformance/Fixtures/docker-compose.yml down
124125

126+
conformance-client:
127+
name: conformance / client
128+
runs-on: ubuntu-latest
129+
steps:
130+
- name: Checkout
131+
uses: actions/checkout@v6
132+
133+
- name: Setup PHP
134+
uses: shivammathur/setup-php@v2
135+
with:
136+
php-version: '8.4'
137+
coverage: "none"
138+
139+
- name: Setup Node
140+
uses: actions/setup-node@v6
141+
with:
142+
node-version: '22'
143+
144+
- name: Install Composer
145+
uses: "ramsey/composer-install@v4"
146+
147+
- name: Create log directory
148+
run: mkdir -p tests/Conformance/logs
149+
150+
- name: Run client conformance tests
151+
working-directory: ./tests/Conformance
152+
run: npx @modelcontextprotocol/conformance client --command "php ${{ github.workspace }}/tests/Conformance/client.php" --suite all --expected-failures conformance-baseline.yml
153+
154+
- name: Show logs on failure
155+
if: failure()
156+
run: |
157+
echo "=== Client Conformance Log ==="
158+
cat tests/Conformance/logs/client-conformance.log 2>/dev/null || echo "No client conformance log found"
159+
echo ""
160+
echo "=== Test Results ==="
161+
find tests/Conformance/results -name "checks.json" 2>/dev/null | head -3 | while read f; do
162+
echo "--- $f ---"
163+
cat "$f"
164+
echo ""
165+
done || echo "No results found"
166+
125167
qa:
126168
runs-on: ubuntu-latest
127169
steps:

.php-cs-fixer.dist.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
->setRules([
3232
'@Symfony' => true,
3333
'@Symfony:risky' => true,
34-
'protected_to_private' => false,
35-
'declare_strict_types' => false,
3634
'header_comment' => ['header' => $fileHeader],
3735
'php_unit_test_case_static_method_calls' => ['call_type' => 'this'],
3836
])

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ All notable changes to `mcp/sdk` will be documented in this file.
1414
* Add OAuth 2.0 Dynamic Client Registration middleware (RFC 7591)
1515
* Add optional `title` field to `Prompt` and `McpPrompt` for MCP spec compliance
1616
* [BC Break] `Builder::addPrompt()` signature changed — `$title` parameter added between `$name` and `$description`. Callers using positional arguments for `$description` must switch to named arguments.
17+
* Add optional `title` field to `Tool` and `McpTool` for MCP spec compliance
18+
* [BC Break] `Tool::__construct()` signature changed — `$title` parameter added between `$name` and `$inputSchema`. Callers using positional arguments must switch to named arguments or pass `null` for `$title`.
19+
* [BC Break] `McpTool` attribute signature changed — `$title` parameter added between `$name` and `$description`. Callers using positional arguments for `$description` must switch to named arguments.
20+
* [BC Break] `Builder::addTool()` signature changed — `$title` parameter added between `$name` and `$description`. Callers using positional arguments for `$description` must switch to named arguments.
1721

1822
0.4.0
1923
-----

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: deps-stable deps-low cs phpstan tests unit-tests inspector-tests coverage ci ci-stable ci-lowest conformance-tests docs
1+
.PHONY: deps-stable deps-low cs phpstan tests unit-tests inspector-tests coverage ci ci-stable ci-lowest conformance-tests conformance-server conformance-client docs
22

33
deps-stable:
44
composer update --prefer-stable
@@ -21,13 +21,18 @@ unit-tests:
2121
inspector-tests:
2222
vendor/bin/phpunit --testsuite=inspector
2323

24-
conformance-tests:
24+
conformance-tests: conformance-server conformance-client
25+
26+
conformance-server:
2527
docker compose -f tests/Conformance/Fixtures/docker-compose.yml up -d
2628
@echo "Waiting for server to start..."
2729
@sleep 5
2830
cd tests/Conformance && npx @modelcontextprotocol/conformance server --url http://localhost:8000/ || true
2931
docker compose -f tests/Conformance/Fixtures/docker-compose.yml down
3032

33+
conformance-client:
34+
cd tests/Conformance && npx @modelcontextprotocol/conformance client --command "php $(CURDIR)/tests/Conformance/client.php" --suite all --expected-failures conformance-baseline.yml || true
35+
3136
coverage:
3237
XDEBUG_MODE=coverage vendor/bin/phpunit --testsuite=unit --coverage-html=coverage
3338

docs/server-builder.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ $server = Server::builder()
278278

279279
- `handler` (callable|string): The tool handler
280280
- `name` (string|null): Optional tool name
281+
- `title` (string|null): Optional human-readable title for display in UI
281282
- `description` (string|null): Optional tool description
282283
- `annotations` (ToolAnnotations|null): Optional annotations for the tool
283284
- `inputSchema` (array|null): Optional input schema for the tool
@@ -637,7 +638,7 @@ $server = Server::builder()
637638
| `addRequestHandlers()` | handlers | Prepend multiple custom request handlers |
638639
| `addNotificationHandler()` | handler | Prepend a single custom notification handler |
639640
| `addNotificationHandlers()` | handlers | Prepend multiple custom notification handlers |
640-
| `addTool()` | handler, name?, description?, annotations?, inputSchema? | Register tool |
641+
| `addTool()` | handler, name?, title?, description?, annotations?, inputSchema?, ... | Register tool |
641642
| `addResource()` | handler, uri, name?, description?, mimeType?, size?, annotations? | Register resource |
642643
| `addResourceTemplate()` | handler, uriTemplate, name?, description?, mimeType?, annotations? | Register resource template |
643644
| `addPrompt()` | handler, name?, description? | Register prompt |

docs/server-client-communication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use Mcp\Server\RequestContext;
2424

2525
class MyService
2626
{
27-
#[McpTool('my_tool', 'My Tool Description')]
27+
#[McpTool(name: 'my_tool', description: 'My Tool Description')]
2828
public function myTool(RequestContext $context): string
2929
{
3030
$context->getClientGateway()->log(...);

examples/client/http_client_communication.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the official PHP MCP SDK.
5+
*
6+
* A collaboration between Symfony and the PHP Foundation.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
/**
413
* HTTP Client Communication Example.
514
*
@@ -20,17 +29,6 @@
2029
* Eg. symfony serve --passthru=examples/server/client-communication/server.php --no-tls
2130
*/
2231

23-
declare(strict_types=1);
24-
25-
/*
26-
* This file is part of the official PHP MCP SDK.
27-
*
28-
* A collaboration between Symfony and the PHP Foundation.
29-
*
30-
* For the full copyright and license information, please view the LICENSE
31-
* file that was distributed with this source code.
32-
*/
33-
3432
require_once __DIR__.'/../../vendor/autoload.php';
3533

3634
use Mcp\Client;

examples/client/http_discovery_calculator.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the official PHP MCP SDK.
5+
*
6+
* A collaboration between Symfony and the PHP Foundation.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
/**
413
* HTTP Client Example.
514
*
@@ -12,17 +21,6 @@
1221
* php -S localhost:8080 examples/server/http-discovery-calculator/server.php
1322
*/
1423

15-
declare(strict_types=1);
16-
17-
/*
18-
* This file is part of the official PHP MCP SDK.
19-
*
20-
* A collaboration between Symfony and the PHP Foundation.
21-
*
22-
* For the full copyright and license information, please view the LICENSE
23-
* file that was distributed with this source code.
24-
*/
25-
2624
require_once __DIR__.'/../../vendor/autoload.php';
2725

2826
use Mcp\Client;

examples/client/stdio_client_communication.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the official PHP MCP SDK.
5+
*
6+
* A collaboration between Symfony and the PHP Foundation.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
/**
413
* STDIO Client Communication Example.
514
*
@@ -11,17 +20,6 @@
1120
* Usage: php examples/client/stdio_client_communication.php
1221
*/
1322

14-
declare(strict_types=1);
15-
16-
/*
17-
* This file is part of the official PHP MCP SDK.
18-
*
19-
* A collaboration between Symfony and the PHP Foundation.
20-
*
21-
* For the full copyright and license information, please view the LICENSE
22-
* file that was distributed with this source code.
23-
*/
24-
2523
require_once __DIR__.'/../../vendor/autoload.php';
2624

2725
use Mcp\Client;

examples/client/stdio_discovery_calculator.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
<?php
22

3-
/**
4-
* Simple STDIO Client Example.
5-
*
6-
* This example demonstrates how to use the MCP client with a STDIO transport
7-
* to communicate with an MCP server running as a child process.
8-
*
9-
* Usage: php examples/client/stdio_discovery_calculator.php
10-
*/
11-
12-
declare(strict_types=1);
13-
143
/*
154
* This file is part of the official PHP MCP SDK.
165
*
@@ -20,6 +9,15 @@
209
* file that was distributed with this source code.
2110
*/
2211

12+
/**
13+
* Simple STDIO Client Example.
14+
*
15+
* This example demonstrates how to use the MCP client with a STDIO transport
16+
* to communicate with an MCP server running as a child process.
17+
*
18+
* Usage: php examples/client/stdio_discovery_calculator.php
19+
*/
20+
2321
require_once __DIR__.'/../../vendor/autoload.php';
2422

2523
use Mcp\Client;

0 commit comments

Comments
 (0)