Skip to content

Commit 8362241

Browse files
committed
refactor: reorganize examples and fix PHPStan baseline
- Move cached discovery example from examples/10 to examples/09 - Update composer.json autoload-dev namespace mapping - Fix PHPStan baseline by removing invalid entries for non-existent files - Update server.php to follow proper example pattern with logging and lifecycle
1 parent 861a74d commit 8362241

File tree

4 files changed

+17
-35
lines changed

4 files changed

+17
-35
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@
5959
"Mcp\\Example\\DependenciesStdioExample\\": "examples/06-custom-dependencies-stdio/",
6060
"Mcp\\Example\\ComplexSchemaHttpExample\\": "examples/07-complex-tool-schema-http/",
6161
"Mcp\\Example\\SchemaShowcaseExample\\": "examples/08-schema-showcase-streamable/",
62-
"Mcp\\Example\\HttpTransportExample\\": "examples/10-simple-http-transport/",
63-
"Mcp\\Example\\CachedDiscoveryExample\\": "examples/10-cached-discovery-stdio/",
62+
"Mcp\\Example\\CachedDiscoveryExample\\": "examples/09-cached-discovery-stdio/",
6463
"Mcp\\Tests\\": "tests/"
6564
}
6665
},

examples/10-cached-discovery-stdio/server.php renamed to examples/09-cached-discovery-stdio/server.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,28 @@
1212
* file that was distributed with this source code.
1313
*/
1414

15-
require_once __DIR__.'/../bootstrap.php';
15+
require_once dirname(__DIR__) . '/bootstrap.php';
16+
chdir(__DIR__);
1617

1718
use Mcp\Server;
1819
use Mcp\Server\Transport\StdioTransport;
1920
use Symfony\Component\Cache\Adapter\ArrayAdapter;
2021
use Symfony\Component\Cache\Psr16Cache;
2122

22-
Server::make()
23+
logger()->info('Starting MCP Cached Discovery Calculator Server...');
24+
25+
$server = Server::make()
2326
->setServerInfo('Cached Discovery Calculator', '1.0.0', 'Calculator with cached discovery for better performance.')
24-
->setDiscovery(__DIR__, ['.'])
27+
->setContainer(container())
2528
->setLogger(logger())
29+
->setDiscovery(__DIR__, ['.'])
2630
->setCache(new Psr16Cache(new ArrayAdapter()))
27-
->build()
28-
->connect(new StdioTransport());
31+
->build();
32+
33+
$transport = new StdioTransport(logger: logger());
34+
35+
$server->connect($transport);
36+
37+
$transport->listen();
38+
39+
logger()->info('Server listener stopped gracefully.');

phpstan-baseline.neon

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -321,35 +321,7 @@ parameters:
321321
count: 1
322322
path: examples/08-schema-showcase-streamable/SchemaShowcaseElements.php
323323

324-
-
325-
message: '#^Instantiated class Mcp\\Server\\Transports\\StreamableHttpServerTransport not found\.$#'
326-
identifier: class.notFound
327-
count: 1
328-
path: examples/08-schema-showcase-streamable/server.php
329-
330-
-
331-
message: '#^Parameter \#1 \$transport of method Mcp\\Server\:\:connect\(\) expects Mcp\\Server\\TransportInterface, Mcp\\Server\\Transports\\StreamableHttpServerTransport given\.$#'
332-
identifier: argument.type
333-
count: 1
334-
path: examples/08-schema-showcase-streamable/server.php
335-
336-
-
337-
message: '#^Parameter \#1 \$registry of class Mcp\\Server\\RequestHandler\\ListPromptsHandler constructor expects Mcp\\Capability\\Registry\\ReferenceProviderInterface, Mcp\\Capability\\PromptChain given\.$#'
338-
identifier: argument.type
339-
count: 1
340-
path: examples/09-standalone-cli/src/Builder.php
341324

342-
-
343-
message: '#^Parameter \#1 \$registry of class Mcp\\Server\\RequestHandler\\ListResourcesHandler constructor expects Mcp\\Capability\\Registry\\ReferenceProviderInterface, Mcp\\Capability\\ResourceChain given\.$#'
344-
identifier: argument.type
345-
count: 1
346-
path: examples/09-standalone-cli/src/Builder.php
347-
348-
-
349-
message: '#^Parameter \#1 \$registry of class Mcp\\Server\\RequestHandler\\ListToolsHandler constructor expects Mcp\\Capability\\Registry\\ReferenceProviderInterface, Mcp\\Capability\\ToolChain given\.$#'
350-
identifier: argument.type
351-
count: 1
352-
path: examples/09-standalone-cli/src/Builder.php
353325

354326
-
355327
message: '#^Call to an undefined method Mcp\\Capability\\Registry\\ResourceTemplateReference\:\:handle\(\)\.$#'

0 commit comments

Comments
 (0)