Skip to content

Commit 271befb

Browse files
authored
Merge branch 'main' into support-server-notifications
2 parents 4c2415b + b1e54f1 commit 271befb

File tree

64 files changed

+4832
-485
lines changed

Some content is hidden

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

64 files changed

+4832
-485
lines changed

.gitattributes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
/examples export-ignore
33
/tests export-ignore
44
/.php-cs-fixer.dist.php export-ignore
5-
/phpstan.dist.neon export-ignore
5+
/phpstan* export-ignore
66
/phpunit.xml.dist export-ignore
7+
/Makefile export-ignore

.github/workflows/pipeline.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ jobs:
3030
with:
3131
dependency-versions: "${{ matrix.dependencies }}"
3232

33-
- name: Install PHP Dependencies
34-
run: composer install --no-scripts
35-
3633
- name: Tests
3734
run: vendor/bin/phpunit --exclude-group inspector
3835

@@ -54,9 +51,6 @@ jobs:
5451
- name: Install Composer
5552
uses: "ramsey/composer-install@v3"
5653

57-
- name: Install PHP Dependencies
58-
run: composer install --no-scripts
59-
6054
- name: Code Style PHP
6155
run: vendor/bin/php-cs-fixer fix --dry-run
6256

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ The official PHP SDK for Model Context Protocol (MCP). It provides a framework-a
44

55
> [!IMPORTANT]
66
> Currently, we are still in the process of merging [Symfony's MCP SDK](https://github.com/symfony/mcp-sdk) and
7-
> [PHP-MCP](https://github.com/php-mcp) components. Not all code paths are fully tested, complete, or this package
8-
> may contain duplicate functionality or dead code.
7+
> [PHP-MCP](https://github.com/php-mcp) components. Not all code paths are fully tested or complete, and this package
8+
> may still contain duplicate functionality or dead code.
99
>
1010
> If you want to help us stabilize the SDK, please see the
1111
> [issue tracker](https://github.com/modelcontextprotocol/php-sdk/issues).
@@ -98,8 +98,8 @@ use Mcp\Server;
9898
use Mcp\Server\Transport\StdioTransport;
9999

100100
Server::make()
101-
->withServerInfo('Stdio Calculator', '1.1.0', 'Basic Calculator over STDIO transport.')
102-
->withDiscovery(__DIR__, ['.'])
101+
->setServerInfo('Stdio Calculator', '1.1.0', 'Basic Calculator over STDIO transport.')
102+
->setDiscovery(__DIR__, ['.'])
103103
->build()
104104
->connect(new StdioTransport());
105105
```

examples/01-discovery-stdio-calculator/server.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
logger()->info('Starting MCP Stdio Calculator Server...');
2020

2121
Server::make()
22-
->withServerInfo('Stdio Calculator', '1.1.0', 'Basic Calculator over STDIO transport.')
23-
->withContainer(container())
24-
->withLogger(logger())
25-
->withDiscovery(__DIR__, ['.'])
22+
->setServerInfo('Stdio Calculator', '1.1.0', 'Basic Calculator over STDIO transport.')
23+
->setContainer(container())
24+
->setLogger(logger())
25+
->setDiscovery(__DIR__, ['.'])
2626
->build()
2727
->connect(new StdioTransport(logger: logger()));
2828

examples/02-discovery-http-userprofile/server.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
$container->set(LoggerInterface::class, logger());
2525

2626
Server::make()
27-
->withServerInfo('HTTP User Profiles', '1.0.0')
28-
->withLogger(logger())
29-
->withContainer($container)
30-
->withDiscovery(__DIR__, ['.'])
31-
->withTool(
27+
->setServerInfo('HTTP User Profiles', '1.0.0')
28+
->setLogger(logger())
29+
->setContainer($container)
30+
->setDiscovery(__DIR__, ['.'])
31+
->addTool(
3232
function (float $a, float $b, string $operation = 'add'): array {
3333
$result = match ($operation) {
3434
'add' => $a + $b,
@@ -47,7 +47,7 @@ function (float $a, float $b, string $operation = 'add'): array {
4747
name: 'calculator',
4848
description: 'Perform basic math operations (add, subtract, multiply, divide)'
4949
)
50-
->withResource(
50+
->addResource(
5151
function (): array {
5252
$memoryUsage = memory_get_usage(true);
5353
$memoryPeak = memory_get_peak_usage(true);

examples/03-manual-registration-stdio/server.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
logger()->info('Starting MCP Manual Registration (Stdio) Server...');
2121

2222
Server::make()
23-
->withServerInfo('Manual Reg Server', '1.0.0')
24-
->withLogger(logger())
25-
->withContainer(container())
26-
->withTool([SimpleHandlers::class, 'echoText'], 'echo_text')
27-
->withResource([SimpleHandlers::class, 'getAppVersion'], 'app://version', 'application_version', mimeType: 'text/plain')
28-
->withPrompt([SimpleHandlers::class, 'greetingPrompt'], 'personalized_greeting')
29-
->withResourceTemplate([SimpleHandlers::class, 'getItemDetails'], 'item://{itemId}/details', 'get_item_details', mimeType: 'application/json')
23+
->setServerInfo('Manual Reg Server', '1.0.0')
24+
->setLogger(logger())
25+
->setContainer(container())
26+
->addTool([SimpleHandlers::class, 'echoText'], 'echo_text')
27+
->addResource([SimpleHandlers::class, 'getAppVersion'], 'app://version', 'application_version', mimeType: 'text/plain')
28+
->addPrompt([SimpleHandlers::class, 'greetingPrompt'], 'personalized_greeting')
29+
->addResourceTemplate([SimpleHandlers::class, 'getItemDetails'], 'item://{itemId}/details', 'get_item_details', mimeType: 'application/json')
3030
->build()
3131
->connect(new StdioTransport(logger: logger()));
3232

examples/04-combined-registration-http/server.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
logger()->info('Starting MCP Combined Registration (HTTP) Server...');
2121

2222
Server::make()
23-
->withServerInfo('Combined HTTP Server', '1.0.0')
24-
->withLogger(logger())
25-
->withContainer(container())
26-
->withDiscovery(__DIR__, ['.'])
27-
->withTool([ManualHandlers::class, 'manualGreeter'])
28-
->withResource(
23+
->setServerInfo('Combined HTTP Server', '1.0.0')
24+
->setLogger(logger())
25+
->setContainer(container())
26+
->setDiscovery(__DIR__, ['.'])
27+
->addTool([ManualHandlers::class, 'manualGreeter'])
28+
->addResource(
2929
[ManualHandlers::class, 'getPriorityConfigManual'],
3030
'config://priority',
3131
'priority_config_manual',

examples/05-stdio-env-variables/server.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
logger()->info('Starting MCP Stdio Environment Variable Example Server...');
5151

5252
Server::make()
53-
->withServerInfo('Env Var Server', '1.0.0')
54-
->withLogger(logger())
55-
->withDiscovery(__DIR__, ['.'])
53+
->setServerInfo('Env Var Server', '1.0.0')
54+
->setLogger(logger())
55+
->setDiscovery(__DIR__, ['.'])
5656
->build()
5757
->connect(new StdioTransport(logger: logger()));
5858

examples/06-custom-dependencies-stdio/server.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
$container->set(Services\StatsServiceInterface::class, $statsService);
2929

3030
Server::make()
31-
->withServerInfo('Task Manager Server', '1.0.0')
32-
->withLogger(logger())
33-
->withContainer($container)
34-
->withDiscovery(__DIR__, ['.'])
31+
->setServerInfo('Task Manager Server', '1.0.0')
32+
->setLogger(logger())
33+
->setContainer($container)
34+
->setDiscovery(__DIR__, ['.'])
3535
->build()
3636
->connect(new StdioTransport(logger: logger()));
3737

examples/07-complex-tool-schema-http/server.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
logger()->info('Starting MCP Complex Schema HTTP Server...');
2020

2121
Server::make()
22-
->withServerInfo('Event Scheduler Server', '1.0.0')
23-
->withLogger(logger())
24-
->withContainer(container())
25-
->withDiscovery(__DIR__, ['.'])
22+
->setServerInfo('Event Scheduler Server', '1.0.0')
23+
->setLogger(logger())
24+
->setContainer(container())
25+
->setDiscovery(__DIR__, ['.'])
2626
->build()
2727
->connect(new HttpServerTransport('127.0.0.1', 8082, 'mcp_scheduler'));
2828

0 commit comments

Comments
 (0)