# eduardocruz/mcp-php-sdk architecture

> Architecture diagram of the GitHub repository eduardocruz/mcp-php-sdk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eduardocruz/mcp-php-sdk
- Repository: https://github.com/eduardocruz/mcp-php-sdk

## Overview

This repository is an MCP server SDK: an application registers resources, tools, and prompts, connects the server to a transport, and serves JSON-RPC requests from an MCP client. The facade coordinates domain managers and protocol handling; stdio is the documented transport. The graph also captures protocol errors, notifications, cancellation, and logging. Some implementation excerpts are incomplete, so links for documented but unsampled domain behavior rely on the README or SOURCE INDEX references rather than implying inspection of omitted code.

Main entry points: [`src/Server/Server.php`](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Server/Server.php) (Request dispatcher), [`src/Server/McpServer.php`](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Server/McpServer.php) (MCP server facade), [`src/Protocol/Notifications/NotificationManager.php`](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Protocol/Notifications/NotificationManager.php) (Notification delivery), [`src/Transport/StdioTransport.php`](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Transport/StdioTransport.php) (stdio transport)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["Server and capabilities"]
  node_facade["MCP server facade<br/>[McpServer.php]"]
  node_core["Request dispatcher<br/>[Server.php]"]
end

subgraph group_domains["MCP domains"]
  node_resources["Resource management"]
  node_resource_types["Resource types<br/>[Resource.php]"]
  node_uri_templates["URI templates<br/>[UriTemplate.php]"]
  node_tools["Tool management<br/>[ToolManager.php]"]
  node_tool_schema["Tool validation<br/>[Validator.php]"]
  node_prompts["Prompt management<br/>[PromptManager.php]"]
  node_prompt["Prompt execution<br/>[Prompt.php]"]
  node_prompt_schema["Prompt schema<br/>[PromptSchema.php]"]
end

subgraph group_protocol["Protocol handling"]
  node_request["JSON-RPC requests<br/>[Request.php]"]
  node_notification["JSON-RPC notifications<br/>[Notification.php]"]
  node_errors["Error responses"]
  node_recovery["Error recovery<br/>[ErrorRecovery.php]"]
  node_notify["Notification delivery"]
end

subgraph group_runtime["Transport and operations"]
  node_transport["Transport contract"]
  node_stdio["stdio transport<br/>[StdioTransport.php]"]
  node_buffer["Message framing<br/>[MessageBuffer.php]"]
  node_cancel["Request cancellation"]
  node_token["Cancellation token"]
  node_health["Health monitoring<br/>[HealthMonitor.php]"]
  node_logger["Console logging<br/>[ConsoleLogger.php]"]
end

node_client(("MCP client"))
node_app(("Host application"))

node_app -->|"registers capabilities"| node_facade
node_app -->|"connects transport"| node_stdio
node_client -->|"exchanges messages"| node_stdio
node_stdio -->|"frames messages"| node_buffer
node_stdio -->|"dispatches messages"| node_core
node_facade -->|"configures server"| node_core
node_facade -->|"registers resources"| node_resources
node_facade -->|"registers tools"| node_tools
node_facade -->|"registers prompts"| node_prompts
node_core -->|"handles requests"| node_request
node_core -->|"builds errors"| node_errors
node_core -->|"tracks cancellation"| node_cancel
node_core -->|"sends notifications"| node_notify
node_resources -->|"manages resources"| node_resource_types
node_resource_types -->|"matches templates"| node_uri_templates
node_tools -->|"validates arguments"| node_tool_schema
node_prompts -->|"executes prompts"| node_prompt
node_prompts -->|"validates prompt schema"| node_prompt_schema
node_prompts -->|"announces changes"| node_notify
node_notify -->|"queues notifications"| node_notification
node_notify -->|"delivers notifications"| node_transport
node_cancel -->|"manages tokens"| node_token
node_core -->|"monitors requests"| node_health
node_recovery -->|"builds error responses"| node_errors
node_stdio -->|"logs transport events"| node_logger
node_notify -->|"logs delivery"| node_logger
node_cancel -->|"logs cancellation"| node_logger

click node_facade "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Server/McpServer.php"
click node_core "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Server/Server.php"
click node_resources "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Protocol/Resources/ResourceManager.php"
click node_resource_types "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Protocol/Resources/Resource.php"
click node_uri_templates "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Protocol/Resources/UriTemplate.php"
click node_tools "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Server/Tools/ToolManager.php"
click node_tool_schema "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Server/Tools/Schema/Validator.php"
click node_prompts "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Server/Prompts/PromptManager.php"
click node_prompt "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Server/Prompts/Prompt.php"
click node_prompt_schema "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Server/Prompts/Schema/PromptSchema.php"
click node_transport "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Transport/TransportInterface.php"
click node_stdio "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Transport/StdioTransport.php"
click node_buffer "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Transport/MessageBuffer.php"
click node_request "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Protocol/Messages/Request.php"
click node_notification "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Protocol/Messages/Notification.php"
click node_errors "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Protocol/Errors/ErrorResponseBuilder.php"
click node_recovery "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Protocol/Errors/ErrorRecovery.php"
click node_notify "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Protocol/Notifications/NotificationManager.php"
click node_cancel "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Utilities/Cancellation/CancellationManager.php"
click node_token "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Utilities/Cancellation/CancellationToken.php"
click node_health "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Utilities/HealthMonitor.php"
click node_logger "https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Utilities/Logging/ConsoleLogger.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_facade,node_core,node_client toneBlue
class node_resources,node_resource_types,node_uri_templates,node_tools,node_tool_schema,node_prompts,node_prompt,node_prompt_schema toneAmber
class node_request,node_notification,node_errors,node_recovery,node_notify toneMint
class node_transport,node_stdio,node_buffer,node_cancel,node_token,node_health,node_logger toneRose
class node_app toneIndigo
```

## Components

### Server and capabilities

- [MCP server facade](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Server/McpServer.php): `src/Server/McpServer.php`
- [Request dispatcher](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Server/Server.php): `src/Server/Server.php`

### MCP domains

- [Resource management](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Protocol/Resources/ResourceManager.php): `src/Protocol/Resources/ResourceManager.php`
- [Resource types](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Protocol/Resources/Resource.php): `src/Protocol/Resources/Resource.php`
- [URI templates](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Protocol/Resources/UriTemplate.php): `src/Protocol/Resources/UriTemplate.php`
- [Tool management](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Server/Tools/ToolManager.php): `src/Server/Tools/ToolManager.php`
- [Tool validation](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Server/Tools/Schema/Validator.php): `src/Server/Tools/Schema/Validator.php`
- [Prompt management](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Server/Prompts/PromptManager.php): `src/Server/Prompts/PromptManager.php`
- [Prompt execution](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Server/Prompts/Prompt.php): `src/Server/Prompts/Prompt.php`
- [Prompt schema](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Server/Prompts/Schema/PromptSchema.php): `src/Server/Prompts/Schema/PromptSchema.php`

### Protocol handling

- [JSON-RPC requests](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Protocol/Messages/Request.php): `src/Protocol/Messages/Request.php`
- [JSON-RPC notifications](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Protocol/Messages/Notification.php): `src/Protocol/Messages/Notification.php`
- [Error responses](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Protocol/Errors/ErrorResponseBuilder.php): `src/Protocol/Errors/ErrorResponseBuilder.php`
- [Error recovery](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Protocol/Errors/ErrorRecovery.php): `src/Protocol/Errors/ErrorRecovery.php`
- [Notification delivery](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Protocol/Notifications/NotificationManager.php): `src/Protocol/Notifications/NotificationManager.php`

### Transport and operations

- [Transport contract](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Transport/TransportInterface.php): `src/Transport/TransportInterface.php`
- [stdio transport](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Transport/StdioTransport.php): `src/Transport/StdioTransport.php`
- [Message framing](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Transport/MessageBuffer.php): `src/Transport/MessageBuffer.php`
- [Request cancellation](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Utilities/Cancellation/CancellationManager.php): `src/Utilities/Cancellation/CancellationManager.php`
- [Cancellation token](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Utilities/Cancellation/CancellationToken.php): `src/Utilities/Cancellation/CancellationToken.php`
- [Health monitoring](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Utilities/HealthMonitor.php): `src/Utilities/HealthMonitor.php`
- [Console logging](https://github.com/eduardocruz/mcp-php-sdk/blob/main/src/Utilities/Logging/ConsoleLogger.php): `src/Utilities/Logging/ConsoleLogger.php`

### Other components

- **MCP client**
- **Host application**

## Connections

- Host application → MCP server facade: registers capabilities (evidence: `README.md`)
- Host application → stdio transport: connects transport (evidence: `README.md`)
- MCP client → stdio transport: exchanges messages (evidence: `README.md`)
- stdio transport → Message framing: frames messages (evidence: `src/Transport/StdioTransport.php`)
- stdio transport → Request dispatcher: dispatches messages (evidence: `src/Transport/StdioTransport.php`)
- MCP server facade → Request dispatcher: configures server (evidence: `src/Server/McpServer.php`)
- MCP server facade → Resource management: registers resources (evidence: `src/Server/McpServer.php`)
- MCP server facade → Tool management: registers tools (evidence: `src/Server/McpServer.php`)
- MCP server facade → Prompt management: registers prompts (evidence: `src/Server/McpServer.php`)
- Request dispatcher → JSON-RPC requests: handles requests (evidence: `src/Server/Server.php`)
- Request dispatcher → Error responses: builds errors (evidence: `src/Server/Server.php`)
- Request dispatcher → Request cancellation: tracks cancellation (evidence: `src/Server/Server.php`)
- Request dispatcher → Notification delivery: sends notifications (evidence: `src/Server/Server.php`)
- Resource management → Resource types: manages resources (evidence: `src/Protocol/Resources/ResourceManager.php`)
- Resource types → URI templates: matches templates (evidence: `src/Protocol/Resources/Resource.php`)
- Tool management → Tool validation: validates arguments (evidence: `src/Server/Tools/ToolManager.php`)
- Prompt management → Prompt execution: executes prompts (evidence: `src/Server/Prompts/PromptManager.php`)
- Prompt management → Prompt schema: validates prompt schema (evidence: `src/Server/Prompts/PromptManager.php`)
- Prompt management → Notification delivery: announces changes (evidence: `src/Server/Prompts/PromptManager.php`)
- Notification delivery → JSON-RPC notifications: queues notifications (evidence: `src/Protocol/Notifications/NotificationManager.php`)
- Notification delivery → Transport contract: delivers notifications (evidence: `src/Protocol/Notifications/NotificationManager.php`)
- Request cancellation → Cancellation token: manages tokens (evidence: `src/Utilities/Cancellation/CancellationManager.php`)
- Request dispatcher → Health monitoring: monitors requests (evidence: `src/Server/Server.php`)
- Error recovery → Error responses: builds error responses (evidence: `src/Protocol/Errors/ErrorRecovery.php`)
- stdio transport → Console logging: logs transport events (evidence: `src/Transport/StdioTransport.php`)
- Notification delivery → Console logging: logs delivery (evidence: `src/Protocol/Notifications/NotificationManager.php`)
- Request cancellation → Console logging: logs cancellation (evidence: `src/Utilities/Cancellation/CancellationManager.php`)
