How klapaudius/symfony-mcp-server works
Symfony MCP Server accepts MCP clients over HTTP/SSE or Streamable HTTP, forwards messages into the server and protocol layer, dispatches JSON-RPC methods, and returns tool, prompt, resource, or initialization results. Tools can make sampling requests and stream progress; prompts and resources provide additional agent context. Tool/resource repositories register application-provided capabilities. The README documents capabilities beyond the sampled handlers; those branches are included, but their internal call paths are not asserted. Relationships for unsampled transport and capability wiring are omitted where evidence is insufficient.
Main entry points: MCPServer.php MCP server · ToolsCallHandler.php Tool execution · SamplingClient.php Sampling client · TransportInterface.php Transport abstraction
Components 24
Client ingress
- Message endpoint
src/Controllers/MessageController.php - SSE endpoint
src/Controllers/SseController.php - Streamable HTTP endpoint
src/Controllers/StreamableHttpController.php
Protocol server
- MCP server
src/Server/MCPServer.php - Protocol dispatch
src/Protocol/MCPProtocolInterface.php - Request handlers
src/Server/Request - Notification handlers
src/Server/Notification
Agent capabilities
- Tool execution
src/Server/Request/ToolsCallHandler.php - Tool registry
src/Services/ToolService/ToolRepository.php - Tool schemas
src/Services/ToolService/Schema/StructuredSchema.php - Multimodal results
src/Services/ToolService/Result - Prompt operations
src/Server/Request - Prompt registry
src/Services/PromptService/PromptRepository.php - Resource operations
src/Server/Request - Resource registry
src/Services/ResourceService/ResourceRepository.php
Agent support
- Sampling client
src/Services/SamplingService/SamplingClient.php - Sampling response
src/Services/SamplingService/SamplingResponseHandler.php - Progress notifications
src/Services/ProgressService/ProgressNotifierRepository.php
Transports
- Transport factory
src/Transports/Factory/TransportFactoryInterface.php - Transport abstraction
src/Transports/TransportInterface.php - SSE transport
src/Transports/SseTransport.php - Streamable HTTP transport
src/Transports/StreamableHttpTransport.php - SSE adapters
src/Transports/SseAdapters/SseAdapterInterface.php
Other components
- MCP client
Connections 24
- MCP client → Message endpoint: sends message
src/Controllers/MessageController.php - MCP client → SSE endpoint: opens stream
src/Controllers/SseController.php - MCP client → Streamable HTTP endpoint: posts request
src/Controllers/StreamableHttpController.php - Message endpoint → MCP server: forwards message
src/Controllers/MessageController.php - SSE endpoint → MCP server: connects
src/Controllers/SseController.php - Streamable HTTP endpoint → MCP server: forwards message
src/Controllers/StreamableHttpController.php - MCP server → Protocol dispatch: routes messages
- Protocol dispatch → Request handlers: dispatches requests
src/Protocol/MCPProtocolInterface.php - Protocol dispatch → Notification handlers: dispatches notifications
src/Protocol/MCPProtocolInterface.php - MCP server → Tool registry: registers tools
- MCP server → Prompt registry: registers prompts
- MCP server → Resource registry: registers resources
- Tool execution → Tool registry: looks up tool
src/Server/Request/ToolsCallHandler.php - Tool execution → Sampling client: injects sampling
src/Server/Request/ToolsCallHandler.php - Tool execution → Progress notifications: registers token
src/Server/Request/ToolsCallHandler.php - Tool execution → Multimodal results: serializes result
src/Server/Request/ToolsCallHandler.php - Tool registry → Tool schemas: builds schemas
src/Services/ToolService/ToolRepository.php - Sampling client → Transport factory: gets transport
src/Services/SamplingService/SamplingClient.php - Sampling client → Transport abstraction: pushes request
src/Services/SamplingService/SamplingClient.php - Sampling response → Sampling client: handles response
src/Services/SamplingService/SamplingResponseHandler.php - Progress notifications → Transport factory: gets transport
src/Services/ProgressService/ProgressNotifierRepository.php - Progress notifications → Transport abstraction: pushes notification
src/Services/ProgressService/ProgressNotifierRepository.php - Transport factory → Transport abstraction: returns transport
src/Transports/Factory/TransportFactoryInterface.php - Transport abstraction → SSE adapters: uses adapter
src/Transports/TransportInterface.php