From 2d50e2572a3efb6d1251af7f67e71c0e1f85287f Mon Sep 17 00:00:00 2001 From: Kyrian Obikwelu Date: Sun, 28 Sep 2025 04:20:51 +0100 Subject: [PATCH] refactor: rename ServerBuilder to Builder Remove redundant "Server" prefix since class is already in Server namespace. --- phpstan-baseline.neon | 52 +++++++++---------- src/Server.php | 6 +-- src/Server/{ServerBuilder.php => Builder.php} | 8 ++- src/Server/Configuration.php | 2 +- 4 files changed, 36 insertions(+), 32 deletions(-) rename src/Server/{ServerBuilder.php => Builder.php} (99%) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 7a4071ba..c1e53ebe 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -31,79 +31,79 @@ parameters: path: src/Schema/Result/ReadResourceResult.php - - message: '#^Method Mcp\\Server\\ServerBuilder\:\:addPrompt\(\) has parameter \$handler with no value type specified in iterable type array\.$#' + message: '#^Method Mcp\\Server\\Builder\:\:addPrompt\(\) has parameter \$handler with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: src/Server/ServerBuilder.php + path: src/Server/Builder.php - - message: '#^Method Mcp\\Server\\ServerBuilder\:\:addResource\(\) has parameter \$handler with no value type specified in iterable type array\.$#' + message: '#^Method Mcp\\Server\\Builder\:\:addResource\(\) has parameter \$handler with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: src/Server/ServerBuilder.php + path: src/Server/Builder.php - - message: '#^Method Mcp\\Server\\ServerBuilder\:\:addResourceTemplate\(\) has parameter \$handler with no value type specified in iterable type array\.$#' + message: '#^Method Mcp\\Server\\Builder\:\:addResourceTemplate\(\) has parameter \$handler with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: src/Server/ServerBuilder.php + path: src/Server/Builder.php - - message: '#^Method Mcp\\Server\\ServerBuilder\:\:addTool\(\) has parameter \$handler with no value type specified in iterable type array\.$#' + message: '#^Method Mcp\\Server\\Builder\:\:addTool\(\) has parameter \$handler with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: src/Server/ServerBuilder.php + path: src/Server/Builder.php - - message: '#^Method Mcp\\Server\\ServerBuilder\:\:addTool\(\) has parameter \$inputSchema with no value type specified in iterable type array\.$#' + message: '#^Method Mcp\\Server\\Builder\:\:addTool\(\) has parameter \$inputSchema with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: src/Server/ServerBuilder.php + path: src/Server/Builder.php - - message: '#^Method Mcp\\Server\\ServerBuilder\:\:getCompletionProviders\(\) return type has no value type specified in iterable type array\.$#' + message: '#^Method Mcp\\Server\\Builder\:\:getCompletionProviders\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: src/Server/ServerBuilder.php + path: src/Server/Builder.php - - message: '#^Method Mcp\\Server\\ServerBuilder\:\:setDiscovery\(\) has parameter \$excludeDirs with no value type specified in iterable type array\.$#' + message: '#^Method Mcp\\Server\\Builder\:\:setDiscovery\(\) has parameter \$excludeDirs with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: src/Server/ServerBuilder.php + path: src/Server/Builder.php - - message: '#^Method Mcp\\Server\\ServerBuilder\:\:setDiscovery\(\) has parameter \$scanDirs with no value type specified in iterable type array\.$#' + message: '#^Method Mcp\\Server\\Builder\:\:setDiscovery\(\) has parameter \$scanDirs with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: src/Server/ServerBuilder.php + path: src/Server/Builder.php - - message: '#^Property Mcp\\Server\\ServerBuilder\:\:\$instructions is never read, only written\.$#' + message: '#^Property Mcp\\Server\\Builder\:\:\$instructions is never read, only written\.$#' identifier: property.onlyWritten count: 1 - path: src/Server/ServerBuilder.php + path: src/Server/Builder.php - - message: '#^Property Mcp\\Server\\ServerBuilder\:\:\$prompts type has no value type specified in iterable type array\.$#' + message: '#^Property Mcp\\Server\\Builder\:\:\$prompts type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: src/Server/ServerBuilder.php + path: src/Server/Builder.php - - message: '#^Property Mcp\\Server\\ServerBuilder\:\:\$resourceTemplates type has no value type specified in iterable type array\.$#' + message: '#^Property Mcp\\Server\\Builder\:\:\$resourceTemplates type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: src/Server/ServerBuilder.php + path: src/Server/Builder.php - - message: '#^Property Mcp\\Server\\ServerBuilder\:\:\$resources type has no value type specified in iterable type array\.$#' + message: '#^Property Mcp\\Server\\Builder\:\:\$resources type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: src/Server/ServerBuilder.php + path: src/Server/Builder.php - - message: '#^Property Mcp\\Server\\ServerBuilder\:\:\$tools type has no value type specified in iterable type array\.$#' + message: '#^Property Mcp\\Server\\Builder\:\:\$tools type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: src/Server/ServerBuilder.php + path: src/Server/Builder.php diff --git a/src/Server.php b/src/Server.php index 7f1468ab..a529134e 100644 --- a/src/Server.php +++ b/src/Server.php @@ -12,7 +12,7 @@ namespace Mcp; use Mcp\JsonRpc\Handler; -use Mcp\Server\ServerBuilder; +use Mcp\Server\Builder; use Mcp\Server\TransportInterface; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; @@ -30,9 +30,9 @@ public function __construct( ) { } - public static function builder(): ServerBuilder + public static function builder(): Builder { - return new ServerBuilder(); + return new Builder(); } public function connect(TransportInterface $transport): void diff --git a/src/Server/ServerBuilder.php b/src/Server/Builder.php similarity index 99% rename from src/Server/ServerBuilder.php rename to src/Server/Builder.php index f22cd9bc..b3d36ca4 100644 --- a/src/Server/ServerBuilder.php +++ b/src/Server/Builder.php @@ -52,7 +52,7 @@ /** * @author Kyrian Obikwelu */ -final class ServerBuilder +final class Builder { private ?Implementation $serverInfo = null; @@ -108,17 +108,21 @@ final class ServerBuilder * annotations: Annotations|null} * > */ private array $resourceTemplates = []; + /** @var array< * array{handler: array|string|\Closure, * name: string|null, * description: string|null} * > */ private array $prompts = []; + private ?string $discoveryBasePath = null; + /** - * @var array|string[] + * @var string[] */ private array $discoveryScanDirs = []; + /** * @var array|string[] */ diff --git a/src/Server/Configuration.php b/src/Server/Configuration.php index f5c4fabb..ab629b58 100644 --- a/src/Server/Configuration.php +++ b/src/Server/Configuration.php @@ -17,7 +17,7 @@ /** * Value Object holding core configuration and shared dependencies for the MCP Server instance. * - * This object is typically assembled by the ServerBuilder and passed to the Server constructor. + * This object is typically assembled by the Builder and passed to the Server constructor. * * @author Kyrian Obikwelu */