Skip to content

Commit 9932bac

Browse files
author
klapaudius
committed
Add CLAUDE.md with project guidance and usage instructions
- Introduced `CLAUDE.md` to provide comprehensive project overview and developer guidance. - Documented testing commands, development tools, architecture details, and key components. - Included notes on protocol implementation, configuration, and code standards for better clarity.
1 parent 7cb92e8 commit 9932bac

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

CLAUDE.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is a Symfony bundle that enables developers to seamlessly add a Model Context Protocol (MCP) server to their Symfony applications. The main goal is to provide a production-ready implementation following the official MCP specifications at https://modelcontextprotocol.io/specification/2025-03-26.
8+
9+
The bundle allows Symfony applications to expose tools and resources that can be consumed by Large Language Models (LLMs) through secure transport protocols (SSE and StreamableHTTP), avoiding the security risks of STDIO transport in enterprise environments.
10+
11+
## Commands
12+
13+
### Testing
14+
```bash
15+
# Run all tests
16+
vendor/bin/phpunit
17+
18+
# Run a specific test file
19+
vendor/bin/phpunit tests/path/to/TestFile.php
20+
21+
# Generate code coverage
22+
vendor/bin/phpunit --coverage-html build/coverage
23+
24+
# Run PHPStan static analysis
25+
vendor/bin/phpstan analyse
26+
```
27+
28+
### Development Tools
29+
```bash
30+
# Create a new MCP tool
31+
php bin/console make:mcp-tool MyCustomTool
32+
33+
# Test a specific MCP tool
34+
php bin/console mcp:test-tool MyCustomTool
35+
36+
# Test tool with specific input
37+
php bin/console mcp:test-tool MyCustomTool --input='{"param":"value"}'
38+
39+
# List all available tools
40+
php bin/console mcp:test-tool --list
41+
```
42+
43+
### MCP Inspector
44+
```bash
45+
# Run the MCP Inspector for visual testing
46+
npx @modelcontextprotocol/inspector node build/index.js
47+
```
48+
49+
## Architecture Overview
50+
51+
### Package Structure
52+
This is a Symfony bundle that implements the Model Context Protocol (MCP) server. It provides:
53+
54+
- **Dual Transport Support**: Both SSE (Server-Sent Events) and StreamableHTTP protocols
55+
- **Tool System**: Extensible framework for creating MCP tools that LLMs can invoke
56+
- **Resource System**: Management of resources that can be exposed to LLM clients
57+
- **Progress Notifications**: Real-time progress updates for long-running operations
58+
59+
### Key Components
60+
61+
#### Transport Layer
62+
- **SSE Transport**: Uses Server-Sent Events with a pub/sub pattern via adapters (Cache or Redis)
63+
- **StreamableHTTP Transport**: Direct HTTP-based communication supporting both streaming and non-streaming responses
64+
- **Adapter System**: Abstraction layer allowing different message brokers (Cache, Redis)
65+
66+
#### Tool System
67+
- **BaseToolInterface**: Core interface for all tools (deprecated in favor of StreamableToolInterface)
68+
- **StreamableToolInterface**: Modern interface supporting progress notifications
69+
- **ToolResultInterface**: Abstraction for different result types (Text, Image, Audio, Resource)
70+
- **ProgressNotifier**: System for sending real-time progress updates during tool execution
71+
72+
#### Request Handlers
73+
- Located in `src/Server/Request/`: Handle different MCP protocol methods
74+
- Each handler implements specific MCP operations (initialize, tools/list, tools/call, etc.)
75+
76+
#### Protocol Implementation
77+
- **MCPProtocol**: Core protocol implementation handling request/response flow
78+
- **RequestHandler/NotificationHandler**: Process different message types
79+
- **MCPServer**: Main server orchestrating all components
80+
81+
### Configuration
82+
- Main config: `config/packages/klp_mcp_server.yaml`
83+
- Tools and resources are registered in configuration
84+
- Supports multiple adapters for SSE transport
85+
86+
## Important Notes
87+
88+
- **Cannot use** `symfony server:start` - requires proper web server (Nginx/Apache + PHP-FPM) for concurrent connections
89+
- Tools should implement `StreamableToolInterface` for modern features
90+
- Progress notifications only work with streaming tools (`isStreaming()` returns true)
91+
- All types should use `string|null` syntax instead of `?string` (null at the end)
92+
- Follow PSR-12 coding standards and include PHPDoc for all public methods

0 commit comments

Comments
 (0)