Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ use Mcp\Server;
use Mcp\Server\Transport\StdioTransport;

Server::make()
->withServerInfo('Stdio Calculator', '1.1.0', 'Basic Calculator over STDIO transport.')
->withDiscovery(__DIR__, ['.'])
->setServerInfo('Stdio Calculator', '1.1.0', 'Basic Calculator over STDIO transport.')
->setDiscovery(__DIR__, ['.'])
->build()
->connect(new StdioTransport());
```
Expand Down
8 changes: 4 additions & 4 deletions examples/01-discovery-stdio-calculator/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
logger()->info('Starting MCP Stdio Calculator Server...');

Server::make()
->withServerInfo('Stdio Calculator', '1.1.0', 'Basic Calculator over STDIO transport.')
->withContainer(container())
->withLogger(logger())
->withDiscovery(__DIR__, ['.'])
->setServerInfo('Stdio Calculator', '1.1.0', 'Basic Calculator over STDIO transport.')
->setContainer(container())
->setLogger(logger())
->setDiscovery(__DIR__, ['.'])
->build()
->connect(new StdioTransport(logger: logger()));

Expand Down
12 changes: 6 additions & 6 deletions examples/02-discovery-http-userprofile/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
$container->set(LoggerInterface::class, logger());

Server::make()
->withServerInfo('HTTP User Profiles', '1.0.0')
->withLogger(logger())
->withContainer($container)
->withDiscovery(__DIR__, ['.'])
->withTool(
->setServerInfo('HTTP User Profiles', '1.0.0')
->setLogger(logger())
->setContainer($container)
->setDiscovery(__DIR__, ['.'])
->addTool(
function (float $a, float $b, string $operation = 'add'): array {
$result = match ($operation) {
'add' => $a + $b,
Expand All @@ -47,7 +47,7 @@ function (float $a, float $b, string $operation = 'add'): array {
name: 'calculator',
description: 'Perform basic math operations (add, subtract, multiply, divide)'
)
->withResource(
->addResource(
function (): array {
$memoryUsage = memory_get_usage(true);
$memoryPeak = memory_get_peak_usage(true);
Expand Down
14 changes: 7 additions & 7 deletions examples/03-manual-registration-stdio/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
logger()->info('Starting MCP Manual Registration (Stdio) Server...');

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

Expand Down
12 changes: 6 additions & 6 deletions examples/04-combined-registration-http/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
logger()->info('Starting MCP Combined Registration (HTTP) Server...');

Server::make()
->withServerInfo('Combined HTTP Server', '1.0.0')
->withLogger(logger())
->withContainer(container())
->withDiscovery(__DIR__, ['.'])
->withTool([ManualHandlers::class, 'manualGreeter'])
->withResource(
->setServerInfo('Combined HTTP Server', '1.0.0')
->setLogger(logger())
->setContainer(container())
->setDiscovery(__DIR__, ['.'])
->addTool([ManualHandlers::class, 'manualGreeter'])
->addResource(
[ManualHandlers::class, 'getPriorityConfigManual'],
'config://priority',
'priority_config_manual',
Expand Down
6 changes: 3 additions & 3 deletions examples/05-stdio-env-variables/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
logger()->info('Starting MCP Stdio Environment Variable Example Server...');

Server::make()
->withServerInfo('Env Var Server', '1.0.0')
->withLogger(logger())
->withDiscovery(__DIR__, ['.'])
->setServerInfo('Env Var Server', '1.0.0')
->setLogger(logger())
->setDiscovery(__DIR__, ['.'])
->build()
->connect(new StdioTransport(logger: logger()));

Expand Down
8 changes: 4 additions & 4 deletions examples/06-custom-dependencies-stdio/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
$container->set(Services\StatsServiceInterface::class, $statsService);

Server::make()
->withServerInfo('Task Manager Server', '1.0.0')
->withLogger(logger())
->withContainer($container)
->withDiscovery(__DIR__, ['.'])
->setServerInfo('Task Manager Server', '1.0.0')
->setLogger(logger())
->setContainer($container)
->setDiscovery(__DIR__, ['.'])
->build()
->connect(new StdioTransport(logger: logger()));

Expand Down
8 changes: 4 additions & 4 deletions examples/07-complex-tool-schema-http/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
logger()->info('Starting MCP Complex Schema HTTP Server...');

Server::make()
->withServerInfo('Event Scheduler Server', '1.0.0')
->withLogger(logger())
->withContainer(container())
->withDiscovery(__DIR__, ['.'])
->setServerInfo('Event Scheduler Server', '1.0.0')
->setLogger(logger())
->setContainer(container())
->setDiscovery(__DIR__, ['.'])
->build()
->connect(new HttpServerTransport('127.0.0.1', 8082, 'mcp_scheduler'));

Expand Down
6 changes: 3 additions & 3 deletions examples/08-schema-showcase-streamable/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
logger()->info('Starting MCP Schema Showcase Server...');

Server::make()
->withServerInfo('Schema Showcase', '1.0.0')
->withLogger(logger())
->withDiscovery(__DIR__, ['.'])
->setServerInfo('Schema Showcase', '1.0.0')
->setLogger(logger())
->setDiscovery(__DIR__, ['.'])
->build()
->connect(new StreamableHttpServerTransport('127.0.0.1', 8080, 'mcp'));

Expand Down
46 changes: 11 additions & 35 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -463,43 +463,43 @@ parameters:
path: src/Server/ServerBuilder.php

-
message: '#^Method Mcp\\Server\\ServerBuilder\:\:withDiscovery\(\) has parameter \$excludeDirs with no value type specified in iterable type array\.$#'
message: '#^Method Mcp\\Server\\ServerBuilder\:\:setDiscovery\(\) has parameter \$excludeDirs with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Server/ServerBuilder.php

-
message: '#^Method Mcp\\Server\\ServerBuilder\:\:withDiscovery\(\) has parameter \$scanDirs with no value type specified in iterable type array\.$#'
message: '#^Method Mcp\\Server\\ServerBuilder\:\:setDiscovery\(\) has parameter \$scanDirs with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Server/ServerBuilder.php

-
message: '#^Method Mcp\\Server\\ServerBuilder\:\:withPrompt\(\) has parameter \$handler with no value type specified in iterable type array\.$#'
message: '#^Method Mcp\\Server\\ServerBuilder\:\:addPrompt\(\) has parameter \$handler with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Server/ServerBuilder.php

-
message: '#^Method Mcp\\Server\\ServerBuilder\:\:withResource\(\) has parameter \$handler with no value type specified in iterable type array\.$#'
message: '#^Method Mcp\\Server\\ServerBuilder\:\:addResource\(\) has parameter \$handler with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Server/ServerBuilder.php

-
message: '#^Method Mcp\\Server\\ServerBuilder\:\:withResourceTemplate\(\) has parameter \$handler with no value type specified in iterable type array\.$#'
message: '#^Method Mcp\\Server\\ServerBuilder\:\:addResourceTemplate\(\) has parameter \$handler with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Server/ServerBuilder.php

-
message: '#^Method Mcp\\Server\\ServerBuilder\:\:withTool\(\) has parameter \$handler with no value type specified in iterable type array\.$#'
message: '#^Method Mcp\\Server\\ServerBuilder\:\:addTool\(\) has parameter \$handler with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Server/ServerBuilder.php

-
message: '#^Method Mcp\\Server\\ServerBuilder\:\:withTool\(\) has parameter \$inputSchema with no value type specified in iterable type array\.$#'
message: '#^Method Mcp\\Server\\ServerBuilder\:\:addTool\(\) has parameter \$inputSchema with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Server/ServerBuilder.php
Expand Down Expand Up @@ -535,49 +535,25 @@ parameters:
path: src/Server/ServerBuilder.php

-
message: '#^Property Mcp\\Server\\ServerBuilder\:\:\$manualPrompts has unknown class Mcp\\Server\\Closure as its type\.$#'
identifier: class.notFound
count: 1
path: src/Server/ServerBuilder.php

-
message: '#^Property Mcp\\Server\\ServerBuilder\:\:\$manualPrompts type has no value type specified in iterable type array\.$#'
message: '#^Property Mcp\\Server\\ServerBuilder\:\:\$prompts type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Server/ServerBuilder.php

-
message: '#^Property Mcp\\Server\\ServerBuilder\:\:\$manualResourceTemplates has unknown class Mcp\\Server\\Closure as its type\.$#'
identifier: class.notFound
count: 1
path: src/Server/ServerBuilder.php

-
message: '#^Property Mcp\\Server\\ServerBuilder\:\:\$manualResourceTemplates type has no value type specified in iterable type array\.$#'
message: '#^Property Mcp\\Server\\ServerBuilder\:\:\$resourceTemplates type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Server/ServerBuilder.php

-
message: '#^Property Mcp\\Server\\ServerBuilder\:\:\$manualResources has unknown class Mcp\\Server\\Closure as its type\.$#'
identifier: class.notFound
count: 1
path: src/Server/ServerBuilder.php

-
message: '#^Property Mcp\\Server\\ServerBuilder\:\:\$manualResources type has no value type specified in iterable type array\.$#'
message: '#^Property Mcp\\Server\\ServerBuilder\:\:\$resources type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Server/ServerBuilder.php

-
message: '#^Property Mcp\\Server\\ServerBuilder\:\:\$manualTools has unknown class Mcp\\Server\\Closure as its type\.$#'
identifier: class.notFound
count: 1
path: src/Server/ServerBuilder.php

-
message: '#^Property Mcp\\Server\\ServerBuilder\:\:\$manualTools type has no value type specified in iterable type array\.$#'
message: '#^Property Mcp\\Server\\ServerBuilder\:\:\$tools type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Server/ServerBuilder.php
Expand Down
Loading