{"id":28159610,"url":"https://github.com/klapaudius/symfony-mcp-server","last_synced_at":"2026-01-17T20:41:07.264Z","repository":{"id":293303352,"uuid":"976054541","full_name":"klapaudius/symfony-mcp-server","owner":"klapaudius","description":"A Symfony package designed for building secure servers based on the Model Context Protocol, utilizing Server-Sent Events (SSE) and/or StreamableHTTP for real-time communication. It offers a scalable tool system tailored for enterprise-grade applications.","archived":false,"fork":false,"pushed_at":"2026-01-12T00:58:59.000Z","size":776,"stargazers_count":25,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-01-12T04:55:43.780Z","etag":null,"topics":["agentic-ai","agents","ai","mcp","mcp-prompts","mcp-server","mcp-tools","model-context-protocol","prompts","resources","streamable-http","symfony","tools"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/klapaudius.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["klapaudius"]}},"created_at":"2025-05-01T12:04:51.000Z","updated_at":"2026-01-12T00:58:57.000Z","dependencies_parsed_at":"2025-05-30T23:50:37.041Z","dependency_job_id":"6940fe66-135a-475d-a05b-7e457003ab19","html_url":"https://github.com/klapaudius/symfony-mcp-server","commit_stats":null,"previous_names":["klapaudius/symfony-mcp-server"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/klapaudius/symfony-mcp-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klapaudius%2Fsymfony-mcp-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klapaudius%2Fsymfony-mcp-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klapaudius%2Fsymfony-mcp-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klapaudius%2Fsymfony-mcp-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/klapaudius","download_url":"https://codeload.github.com/klapaudius/symfony-mcp-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klapaudius%2Fsymfony-mcp-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28517923,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T18:55:29.170Z","status":"ssl_error","status_checked_at":"2026-01-17T18:55:03.375Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agentic-ai","agents","ai","mcp","mcp-prompts","mcp-server","mcp-tools","model-context-protocol","prompts","resources","streamable-http","symfony","tools"],"created_at":"2025-05-15T10:11:12.800Z","updated_at":"2026-01-17T20:41:07.252Z","avatar_url":"https://github.com/klapaudius.png","language":"PHP","funding_links":["https://github.com/sponsors/klapaudius"],"categories":["📚 Projects (1974 total)","🤖 AI/ML"],"sub_categories":["MCP Servers"],"readme":"\u003ch1 align=\"center\"\u003eSymfony MCP Server\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  A powerful Symfony package to build a Model Context Protocol Server seamlessly and\n  \u003cstrong\u003ebuild Intelligent AI Agents.\u003c/strong\u003e\u003cbr\u003e\n  Transform your Symfony applications into powerful AI-driven systems\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/klapaudius/symfony-mcp-server/actions\"\u003e\u003cimg src=\"https://github.com/klapaudius/symfony-mcp-server/actions/workflows/tests.yml/badge.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://codecov.io/gh/klapaudius/symfony-mcp-server\" \u003e  \u003cimg src=\"https://codecov.io/gh/klapaudius/symfony-mcp-server/graph/badge.svg?token=5FXOJVXPZ1\" alt=\"Coverage\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/klapaudius/symfony-mcp-server\"\u003e\u003cimg src=\"https://img.shields.io/packagist/l/klapaudius/symfony-mcp-server\" alt=\"License\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/klapaudius/symfony-mcp-server\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/klapaudius/symfony-mcp-server\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/klapaudius/symfony-mcp-server\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/klapaudius/symfony-mcp-server\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## 🤖 Unleash the Power of AI Agents in Your Symfony Apps\n\nSymfony MCP Server enables you to build **intelligent, context-aware AI agents** that can reason, make decisions, and interact with your application's business logic. By implementing the Model Context Protocol (MCP), your Symfony application becomes a platform for sophisticated AI-driven automation and intelligence.\n\n### 🎯 Why Build Agents with Symfony MCP Server?\n\n**Transform Static Tools into Intelligent Agents:**\n- 🧠 **AI-Powered Reasoning**: Tools can consult LLMs mid-execution to make smart decisions\n- 🔄 **Dynamic Adaptation**: Agents adapt their behavior based on context and real-time analysis\n- 💡 **Complex Problem Solving**: Break down complex tasks and solve them iteratively with AI assistance\n- 🎨 **Creative Generation**: Generate content and solutions that evolve with user needs\n\n**Enterprise-Grade Security:**\n- 🔒 **Secure Transports**: StreamableHTTP and SSE instead of STDIO for production environments\n- 🛡️ **Protected APIs**: Keep your internal systems safe while exposing AI capabilities\n- 🎛️ **Fine-Grained Control**: Manage authentication, authorization, and access at every level\n\n**Key Features:**\n- 🛠️ **Tools**: Create powerful, executable functions that LLM can invoke to interact with your application\n- 💬 **Prompts**: Define conversation starters and templates to guide AI behavior and interactions\n- 📚 **Resources**: Expose structured data and documents that AI can read and reason about\n- 🧠 **Sampling**: Enable tools to consult AI models mid-execution for intelligent decision-making\n- 📊 **Progress Streaming**: Real-time progress notifications for long-running operations\n- 🎨 **Multi-Modal Results**: Support for Text, Image, Audio, and Resource outputs from tools\n- 🔌 **Flexible Architecture**: Adapter-based design with Pub/Sub messaging for scalable deployments\n\n## 🚀 Agent-First Features\n\n### 🧪 Sampling: The Core of Agentic Behavior (v1.4.0+)\n\nTransform your tools into autonomous agents that can think and reason:\n\n```php\nclass IntelligentAnalyzer implements SamplingAwareToolInterface\n{\n    private SamplingClient $samplingClient;\n\n    public function execute(array $arguments): ToolResultInterface\n    {\n        // Check if sampling is available\n        if ($this-\u003esamplingClient !== null \u0026\u0026 $this-\u003esamplingClient-\u003eisEnabled()) {\n            try {\n                // Let AI analyze and reason about complex data\n                $response = $this-\u003esamplingClient-\u003ecreateTextRequest(\n                    \"Analyze this data and suggest optimizations: {$arguments['data']}\",\n                    new ModelPreferences(\n                        [['name' =\u003e 'claude-3-sonnet']],\n                        0.3, // costPriority\n                        0.8, // intelligencePriority\n                        0.2  // speedPriority\n                    ),\n                    'You are a data analysis expert.',\n                    2000\n                );\n                \n                // Execute actions based on AI reasoning\n                return new TextToolResult($response-\u003egetContent()-\u003egetText());\n            } catch (\\Exception $e) {\n                // Fallback to basic analysis\n                return new TextToolResult('Basic analysis: Data structure appears valid.');\n            }\n        }\n        \n        return new TextToolResult('Advanced analysis requires AI capabilities.');\n    }\n    \n    public function setSamplingClient(SamplingClient $samplingClient): void\n    {\n        $this-\u003esamplingClient = $samplingClient;\n    }\n}\n```\n\n### 🛠️ Tool System: Building Blocks for Agents\n\nCreate powerful tools that AI agents can orchestrate:\n- **StreamableToolInterface**: Real-time progress updates for long-running operations\n- **Multi-Result Support**: Return text, images, audio, or resources\n- **Progress Notifications**: Keep users informed during complex agent operations\n- **Dynamic Tool Discovery**: Agents can discover and use tools based on capabilities\n\n### 🎭 Prompt Engineering for Agent Behavior\n\nDefine agent personalities and behaviors through sophisticated prompt systems:\n- **Context-Aware Prompts**: Guide agent behavior based on application state\n- **Multi-Modal Support**: Text, image, audio, and resource-based prompts\n- **Dynamic Prompt Generation**: Prompts that adapt based on user interaction\n\n### 📚 Resource Management for Agent Memory\n\nGive your agents access to structured knowledge:\n- **Dynamic Resource Loading**: Agents can access and reason about your data\n- **Template-Based Resources**: Generate resources on-the-fly based on context\n- **Multi-Provider Support**: File system, database, API, or custom providers\n\n## 🎯 Real-World Agent Examples\n\n### 🔍 Intelligent Code Review Agent\n```php\nclass CodeReviewAgent implements SamplingAwareToolInterface\n{\n    private SamplingClient $samplingClient;\n\n    public function execute(array $arguments): ToolResultInterface\n    {\n        // Check if sampling is available\n        if ($this-\u003esamplingClient !== null \u0026\u0026 $this-\u003esamplingClient-\u003eisEnabled()) {\n            try {\n                // AI analyzes code for patterns, security, and best practices\n                $review = $this-\u003esamplingClient-\u003ecreateTextRequest(\n                    \"Review this code for security vulnerabilities, performance issues, and suggest improvements: {$arguments['code']}\",\n                    new ModelPreferences(\n                        [['name' =\u003e 'claude-3-sonnet']],\n                        0.2, // costPriority\n                        0.8, // intelligencePriority\n                        0.2  // speedPriority\n                    ),\n                    'You are a senior code reviewer with expertise in security and performance.',\n                    2000\n                );\n                \n                // Generate actionable recommendations\n                return new TextToolResult($this-\u003eformatReview($review-\u003egetContent()-\u003egetText()));\n            } catch (\\Exception $e) {\n                // Fallback to basic analysis\n                return new TextToolResult('Basic code review: Structure appears valid.');\n            }\n        }\n        \n        return new TextToolResult('Advanced code review requires AI capabilities.');\n    }\n    \n    public function setSamplingClient(SamplingClient $samplingClient): void\n    {\n        $this-\u003esamplingClient = $samplingClient;\n    }\n}\n```\n\n### 📊 Data Analysis Agent\n```php\nclass DataInsightAgent implements SamplingAwareToolInterface, StreamableToolInterface\n{\n    private SamplingClient $samplingClient;\n    private ?ProgressNotifierInterface $progressNotifier = null;\n\n    public function execute(array $arguments): ToolResultInterface\n    {\n        // Check if sampling is available\n        if ($this-\u003esamplingClient !== null \u0026\u0026 $this-\u003esamplingClient-\u003eisEnabled()) {\n            try {\n                // Multi-step reasoning process\n                $steps = [\n                    'Identify patterns and anomalies',\n                    'Generate statistical insights',\n                    'Create visualizations',\n                    'Recommend actions'\n                ];\n                $this-\u003eprogressNotifier?-\u003esendProgress(\n                    progress: 0,\n                    total: count($steps)+1,\n                    message: \"Analyzing dataset...\"\n                );\n                \n                $insights = [];\n                foreach ($steps as $i =\u003e $step) {\n                    $response = $this-\u003esamplingClient-\u003ecreateTextRequest(\n                        \"$step for this data: {$arguments['data']}\",\n                        new ModelPreferences(\n                            [['name' =\u003e 'claude-3-sonnet']],\n                            0.2, // costPriority\n                            0.8, // intelligencePriority\n                            0.2  // speedPriority\n                        ),\n                        'You are a data analysis expert.',\n                        2000\n                    );\n                    $insights[] = $response-\u003egetContent()-\u003egetText();\n                    $this-\u003eprogressNotifier?-\u003esendProgress(\n                        progress: $i+1,\n                        total: count($steps)+1,\n                        message: $step\n                    );\n                }\n                \n                return new TextToolResult($this-\u003ecompileReport($insights));\n            } catch (\\Exception $e) {\n                return new TextToolResult('Basic data analysis: Dataset appears well-formed.');\n            }\n        }\n        \n        return new TextToolResult('Advanced data analysis requires AI capabilities.');\n    }\n    \n    public function setSamplingClient(SamplingClient $samplingClient): void\n    {\n        $this-\u003esamplingClient = $samplingClient;\n    }\n    \n    public function setProgressNotifier(ProgressNotifierInterface $progressNotifier): void\n    {\n        $this-\u003eprogressNotifier = $progressNotifier;\n    }\n}\n```\n\n### 🤝 Customer Support Agent\n```php\nclass SupportAgent implements SamplingAwareToolInterface\n{\n    private SamplingClient $samplingClient;\n\n    public function execute(array $arguments): ToolResultInterface\n    {\n        // Check if sampling is available\n        if ($this-\u003esamplingClient !== null \u0026\u0026 $this-\u003esamplingClient-\u003eisEnabled()) {\n            try {\n                // Load customer context\n                $context = $this-\u003eloadCustomerHistory($arguments['customer_id']);\n                \n                // AI determines best response strategy\n                $response = $this-\u003esamplingClient-\u003ecreateTextRequest(\n                    \"Customer issue: {$arguments['issue']}\\nHistory: $context\\nDetermine the best resolution approach.\",\n                    new ModelPreferences(\n                        [['name' =\u003e 'claude-3-sonnet']],\n                        0.2, // costPriority\n                        0.8, // intelligencePriority\n                        0.2  // speedPriority\n                    ),\n                    'You are an expert customer support agent.',\n                    2000\n                );\n                \n                // Send back the strategy for user approval\n                return new TextToolResult($response-\u003egetContent()-\u003egetText());\n            } catch (\\Exception $e) {\n                return new TextToolResult('Standard support response: We will review your issue and respond within 24 hours.');\n            }\n        }\n        \n        return new TextToolResult('Personalized support requires AI capabilities.');\n    }\n    \n    public function setSamplingClient(SamplingClient $samplingClient): void\n    {\n        $this-\u003esamplingClient = $samplingClient;\n    }\n}\n```\n\n## 🚀 Quick Start: Build Your First Agent\n\n### 1. Requirements\n\n- PHP \u003e=8.2\n- Symfony \u003e=6.4\n\n### 2. Install Symfony MCP Server\n\n#### Create the configuration file config/packages/klp_mcp_server.yaml and paste into it:\n\n    ```yaml\n    klp_mcp_server:\n        enabled: true\n        server:\n            name: 'My MCP Server'\n            version: '1.0.0'\n        default_path: 'mcp'\n        ping:\n            enabled: true  # Read the warning section in the default configuration file before disable it\n            interval: 30\n        server_providers: ['streamable_http','sse']\n        sse_adapter: 'cache'\n        adapters:\n            cache:\n                prefix: 'mcp_sse_'\n                ttl: 100\n        tools:\n            - KLP\\KlpMcpServer\\Services\\ToolService\\Examples\\CodeAnalyzerTool     # Agentic tool sample\n            - KLP\\KlpMcpServer\\Services\\ToolService\\Examples\\HelloWorldTool\n            - KLP\\KlpMcpServer\\Services\\ToolService\\Examples\\ProfileGeneratorTool\n            - KLP\\KlpMcpServer\\Services\\ToolService\\Examples\\SearchResultsTool\n            - KLP\\KlpMcpServer\\Services\\ToolService\\Examples\\StreamingDataTool\n            - KLP\\KlpMcpServer\\Services\\ToolService\\Examples\\VersionCheckTool\n        prompts:\n            - KLP\\KlpMcpServer\\Services\\PromptService\\Examples\\CodeReviewPrompt   # Agentic prompt sample\n            - KLP\\KlpMcpServer\\Services\\PromptService\\Examples\\HelloWorldPrompt\n        resources:\n            - KLP\\KlpMcpServer\\Services\\ResourceService\\Examples\\HelloWorldResource\n            - KLP\\KlpMcpServer\\Services\\ResourceService\\Examples\\ProjectSummaryResource # Agentic resource sample\n        resources_templates:\n            - KLP\\KlpMcpServer\\Services\\ResourceService\\Examples\\DynamicAnalysisResource # Agentic resource template sample\n            - KLP\\KlpMcpServer\\Services\\ResourceService\\Examples\\McpDocumentationResource\n    ```\nFor more detailed explanations, you can open the default configuration file\n[from that link.](src/Resources/config/packages/klp_mcp_server.yaml)\n\n#### Install the package via Composer:\n\n   ```bash\n   composer require klapaudius/symfony-mcp-server\n   ```\n\n#### Add routes in your `config/routes.yaml`\n\n```yaml\nklp_mcp_server:\n    resource: '@KlpMcpServerBundle/Resources/config/routes.php'\n    type: php\n```\n\n**You're all done!** Upon completing this setup, your project will include 3 new API endpoints:\n\n- **Streaming Endpoint for MCP Clients**: `GET /{default_path}/sse`\n- **Request Submission Endpoint**: `POST /{default_path}/messages`\n- **Streamable HTTP Endpoint**: `GET|POST /{default_path}`\n\n### Docker Setup (Optional)\n\nThe project includes a Docker setup that can be used for development. The Docker setup includes Nginx, PHP-FPM with Redis extension, and Redis server.\n\nFor detailed instructions on how to set up and use the Docker containers, please refer to the [Development Guidelines](CONTRIBUTING.md#docker-setup).\n\n\n### 3. Create Your First Tool\n\n```bash\n# Generate a new tool\nphp bin/console make:mcp-tool MyCustomTool\n\n# Test your tool locally\nphp bin/console mcp:test-tool MyCustomTool --input='{\"task\":\"analyze this code\"}'\n```\n\n### 4. Visualizing with Inspector\n\nYou can use the Model Context Protocol Inspector to visualize and test your MCP tools:\n\n```bash\n# Run the MCP Inspector without installation\nnpx @modelcontextprotocol/inspector node build/index.js\n```\nThis will typically open a web interface at `localhost:6274`. To test your MCP server:\n\n### 5. Connect AI Clients\n\nYour agents are now accessible to:\n- 🤖 Claude Desktop / Claude.ai\n- 🧠 Custom AI applications\n- 🔗 Any MCP-compatible client\n\n## 🏗️ Architecture for Agent Builders\n\n### Secure Agent Communication\n- **StreamableHTTP**: Direct, secure agent-to-client communication\n- **SSE (Server-Sent Events)**: Real-time updates for long-running agent tasks\n- **No STDIO**: Enterprise-safe, no system exposure\n\n### Scalable Agent Infrastructure\n- **Pub/Sub Messaging**: Handle multiple agent sessions concurrently\n- **Redis/Cache Adapters**: Scale your agent platform horizontally\n- **Progress Streaming**: Real-time feedback for complex agent operations\n\n### Agent Development Tools\n- **MCP Inspector**: Visualize and debug agent behavior\n- **Test Commands**: Rapid agent development and testing\n\n### Current Available MCP Features\n\n| Ressources | Prompts | Tools | Discovery | Sampling | Roots | Elicitation |\n|:----------:|:-------:|:-----:|:---------:|:--------:|:-----:|:-----------:|\n|     ✅      |    ✅    |   ✅   |   ❌   |    ✅     |   ❌   |   ❌   |\n\n## 🎓 Agent Development Resources\n\n- 📖 **[Building Intelligent Tools](https://github.com/klapaudius/symfony-mcp-server/blob/master/docs/building_tools.md)**: Complete guide to creating AI-powered tools\n- 🧠 **[Sampling Documentation](https://github.com/klapaudius/symfony-mcp-server/blob/master/docs/sampling.md)**: Master agent reasoning capabilities\n- 🎭 **[Prompt Engineering](https://github.com/klapaudius/symfony-mcp-server/blob/master/docs/building_prompts.md)**: Design agent behaviors and personalities\n- 📚 **[Resource Management](https://github.com/klapaudius/symfony-mcp-server/blob/master/docs/building_resources.md)**: Give agents access to knowledge\n\n## 🌟 Join the Agent Revolution\n\nBuild the next generation of AI-powered applications with Symfony MCP Server. Your tools aren't just functions anymore – they're intelligent agents capable of reasoning, learning, and evolving.\n\n### Community\n\n- 💬 [GitHub Discussions](https://github.com/klapaudius/symfony-mcp-server/discussions): Share your agent creations\n- 🐛 [Issue Tracker](https://github.com/klapaudius/symfony-mcp-server/issues): Report bugs and request features\n- 🌟 [Examples](https://github.com/klapaudius/symfony-mcp-server/tree/master/src/Services/ToolService/Examples): Learn from working agents\n\n## 📜 License\n\nMIT License - Build freely!\n\n## 📰 MCP Registries referencing\n\n- https://mcpreview.com/mcp-servers/klapaudius/symfony-mcp-server\n- https://mcp.so/server/symfony-mcp-server/klapaudius\n\n---\n\n*Built with ❤️ by [Boris AUBE](https://github.com/klapaudius) and the [contributors](https://github.com/klapaudius/symfony-mcp-server/contributors) - Inspired by [OP.GG/laravel-mcp-server](https://github.com/opgginc/laravel-mcp-server)*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklapaudius%2Fsymfony-mcp-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fklapaudius%2Fsymfony-mcp-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklapaudius%2Fsymfony-mcp-server/lists"}