PHPackages                             klapaudius/symfony-mcp-server - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [DevOps &amp; Deployment](/categories/devops)
4. /
5. klapaudius/symfony-mcp-server

ActiveSymfony-bundle[DevOps &amp; Deployment](/categories/devops)

klapaudius/symfony-mcp-server
=============================

Build your own LLM tools inside your symfony project by adding to it a Model Context Protocol Server

1.8.2(3mo ago)2716.5k↓17.8%3[1 issues](https://github.com/klapaudius/symfony-mcp-server/issues)[2 PRs](https://github.com/klapaudius/symfony-mcp-server/pulls)MITPHPPHP ^8.2CI passing

Since May 18Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/klapaudius/symfony-mcp-server)[ Packagist](https://packagist.org/packages/klapaudius/symfony-mcp-server)[ Docs](https://github.com/klapaudius/symfony-mcp-server)[ GitHub Sponsors](https://github.com/klapaudius)[ RSS](/packages/klapaudius-symfony-mcp-server/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (14)Versions (22)Used By (0)

Symfony MCP Server
==================

[](#symfony-mcp-server)

 A powerful Symfony package to build a Model Context Protocol Server seamlessly and **build Intelligent AI Agents.**
 Transform your Symfony applications into powerful AI-driven systems

[![Build Status](https://github.com/klapaudius/symfony-mcp-server/actions/workflows/tests.yml/badge.svg)](https://github.com/klapaudius/symfony-mcp-server/actions)[ ![Coverage](https://camo.githubusercontent.com/01012fc84a934938e7e530792e904436c958d329729ff28c71be0dc46966b52a/68747470733a2f2f636f6465636f762e696f2f67682f6b6c61706175646975732f73796d666f6e792d6d63702d7365727665722f67726170682f62616467652e7376673f746f6b656e3d3546584f4a5658505a31)](https://codecov.io/gh/klapaudius/symfony-mcp-server)[![License](https://camo.githubusercontent.com/e012fab54a9f734ab57b19de154d166039ce3e3ebf28e9f733c87c4bafdb9f03/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6b6c61706175646975732f73796d666f6e792d6d63702d736572766572)](https://packagist.org/packages/klapaudius/symfony-mcp-server)[![Latest Stable Version](https://camo.githubusercontent.com/165d182ca80d2064c0884b50207d147286c1318bf0a8f1eca89ebe2cfdf918f1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b6c61706175646975732f73796d666f6e792d6d63702d736572766572)](https://packagist.org/packages/klapaudius/symfony-mcp-server)[![Total Downloads](https://camo.githubusercontent.com/bd82f3c7f3708173ee373254512974cc3455fbe8c3997e7c672388fa80704d5d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b6c61706175646975732f73796d666f6e792d6d63702d736572766572)](https://packagist.org/packages/klapaudius/symfony-mcp-server)

🤖 Unleash the Power of AI Agents in Your Symfony Apps
-----------------------------------------------------

[](#-unleash-the-power-of-ai-agents-in-your-symfony-apps)

Symfony 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.

### 🎯 Why Build Agents with Symfony MCP Server?

[](#-why-build-agents-with-symfony-mcp-server)

**Transform Static Tools into Intelligent Agents:**

- 🧠 **AI-Powered Reasoning**: Tools can consult LLMs mid-execution to make smart decisions
- 🔄 **Dynamic Adaptation**: Agents adapt their behavior based on context and real-time analysis
- 💡 **Complex Problem Solving**: Break down complex tasks and solve them iteratively with AI assistance
- 🎨 **Creative Generation**: Generate content and solutions that evolve with user needs

**Enterprise-Grade Security:**

- 🔒 **Secure Transports**: StreamableHTTP and SSE instead of STDIO for production environments
- 🛡️ **Protected APIs**: Keep your internal systems safe while exposing AI capabilities
- 🎛️ **Fine-Grained Control**: Manage authentication, authorization, and access at every level

**Key Features:**

- 🛠️ **Tools**: Create powerful, executable functions that LLM can invoke to interact with your application
- 💬 **Prompts**: Define conversation starters and templates to guide AI behavior and interactions
- 📚 **Resources**: Expose structured data and documents that AI can read and reason about
- 🧠 **Sampling**: Enable tools to consult AI models mid-execution for intelligent decision-making
- 📊 **Progress Streaming**: Real-time progress notifications for long-running operations
- 🎨 **Multi-Modal Results**: Support for Text, Image, Audio, and Resource outputs from tools
- 🔌 **Flexible Architecture**: Adapter-based design with Pub/Sub messaging for scalable deployments

🚀 Agent-First Features
----------------------

[](#-agent-first-features)

### 🧪 Sampling: The Core of Agentic Behavior (v1.4.0+)

[](#-sampling-the-core-of-agentic-behavior-v140)

Transform your tools into autonomous agents that can think and reason:

```
class IntelligentAnalyzer implements SamplingAwareToolInterface
{
    private SamplingClient $samplingClient;

    public function execute(array $arguments): ToolResultInterface
    {
        // Check if sampling is available
        if ($this->samplingClient !== null && $this->samplingClient->isEnabled()) {
            try {
                // Let AI analyze and reason about complex data
                $response = $this->samplingClient->createTextRequest(
                    "Analyze this data and suggest optimizations: {$arguments['data']}",
                    new ModelPreferences(
                        [['name' => 'claude-3-sonnet']],
                        0.3, // costPriority
                        0.8, // intelligencePriority
                        0.2  // speedPriority
                    ),
                    'You are a data analysis expert.',
                    2000
                );

                // Execute actions based on AI reasoning
                return new TextToolResult($response->getContent()->getText());
            } catch (\Exception $e) {
                // Fallback to basic analysis
                return new TextToolResult('Basic analysis: Data structure appears valid.');
            }
        }

        return new TextToolResult('Advanced analysis requires AI capabilities.');
    }

    public function setSamplingClient(SamplingClient $samplingClient): void
    {
        $this->samplingClient = $samplingClient;
    }
}
```

### 🛠️ Tool System: Building Blocks for Agents

[](#️-tool-system-building-blocks-for-agents)

Create powerful tools that AI agents can orchestrate:

- **StreamableToolInterface**: Real-time progress updates for long-running operations
- **Multi-Result Support**: Return text, images, audio, or resources
- **Progress Notifications**: Keep users informed during complex agent operations
- **Dynamic Tool Discovery**: Agents can discover and use tools based on capabilities

### 🎭 Prompt Engineering for Agent Behavior

[](#-prompt-engineering-for-agent-behavior)

Define agent personalities and behaviors through sophisticated prompt systems:

- **Context-Aware Prompts**: Guide agent behavior based on application state
- **Multi-Modal Support**: Text, image, audio, and resource-based prompts
- **Dynamic Prompt Generation**: Prompts that adapt based on user interaction

### 📚 Resource Management for Agent Memory

[](#-resource-management-for-agent-memory)

Give your agents access to structured knowledge:

- **Dynamic Resource Loading**: Agents can access and reason about your data
- **Template-Based Resources**: Generate resources on-the-fly based on context
- **Multi-Provider Support**: File system, database, API, or custom providers

🎯 Real-World Agent Examples
---------------------------

[](#-real-world-agent-examples)

### 🔍 Intelligent Code Review Agent

[](#-intelligent-code-review-agent)

```
class CodeReviewAgent implements SamplingAwareToolInterface
{
    private SamplingClient $samplingClient;

    public function execute(array $arguments): ToolResultInterface
    {
        // Check if sampling is available
        if ($this->samplingClient !== null && $this->samplingClient->isEnabled()) {
            try {
                // AI analyzes code for patterns, security, and best practices
                $review = $this->samplingClient->createTextRequest(
                    "Review this code for security vulnerabilities, performance issues, and suggest improvements: {$arguments['code']}",
                    new ModelPreferences(
                        [['name' => 'claude-3-sonnet']],
                        0.2, // costPriority
                        0.8, // intelligencePriority
                        0.2  // speedPriority
                    ),
                    'You are a senior code reviewer with expertise in security and performance.',
                    2000
                );

                // Generate actionable recommendations
                return new TextToolResult($this->formatReview($review->getContent()->getText()));
            } catch (\Exception $e) {
                // Fallback to basic analysis
                return new TextToolResult('Basic code review: Structure appears valid.');
            }
        }

        return new TextToolResult('Advanced code review requires AI capabilities.');
    }

    public function setSamplingClient(SamplingClient $samplingClient): void
    {
        $this->samplingClient = $samplingClient;
    }
}
```

### 📊 Data Analysis Agent

[](#-data-analysis-agent)

```
class DataInsightAgent implements SamplingAwareToolInterface, StreamableToolInterface
{
    private SamplingClient $samplingClient;
    private ?ProgressNotifierInterface $progressNotifier = null;

    public function execute(array $arguments): ToolResultInterface
    {
        // Check if sampling is available
        if ($this->samplingClient !== null && $this->samplingClient->isEnabled()) {
            try {
                // Multi-step reasoning process
                $steps = [
                    'Identify patterns and anomalies',
                    'Generate statistical insights',
                    'Create visualizations',
                    'Recommend actions'
                ];
                $this->progressNotifier?->sendProgress(
                    progress: 0,
                    total: count($steps)+1,
                    message: "Analyzing dataset..."
                );

                $insights = [];
                foreach ($steps as $i => $step) {
                    $response = $this->samplingClient->createTextRequest(
                        "$step for this data: {$arguments['data']}",
                        new ModelPreferences(
                            [['name' => 'claude-3-sonnet']],
                            0.2, // costPriority
                            0.8, // intelligencePriority
                            0.2  // speedPriority
                        ),
                        'You are a data analysis expert.',
                        2000
                    );
                    $insights[] = $response->getContent()->getText();
                    $this->progressNotifier?->sendProgress(
                        progress: $i+1,
                        total: count($steps)+1,
                        message: $step
                    );
                }

                return new TextToolResult($this->compileReport($insights));
            } catch (\Exception $e) {
                return new TextToolResult('Basic data analysis: Dataset appears well-formed.');
            }
        }

        return new TextToolResult('Advanced data analysis requires AI capabilities.');
    }

    public function setSamplingClient(SamplingClient $samplingClient): void
    {
        $this->samplingClient = $samplingClient;
    }

    public function setProgressNotifier(ProgressNotifierInterface $progressNotifier): void
    {
        $this->progressNotifier = $progressNotifier;
    }
}
```

### 🤝 Customer Support Agent

[](#-customer-support-agent)

```
class SupportAgent implements SamplingAwareToolInterface
{
    private SamplingClient $samplingClient;

    public function execute(array $arguments): ToolResultInterface
    {
        // Check if sampling is available
        if ($this->samplingClient !== null && $this->samplingClient->isEnabled()) {
            try {
                // Load customer context
                $context = $this->loadCustomerHistory($arguments['customer_id']);

                // AI determines best response strategy
                $response = $this->samplingClient->createTextRequest(
                    "Customer issue: {$arguments['issue']}\nHistory: $context\nDetermine the best resolution approach.",
                    new ModelPreferences(
                        [['name' => 'claude-3-sonnet']],
                        0.2, // costPriority
                        0.8, // intelligencePriority
                        0.2  // speedPriority
                    ),
                    'You are an expert customer support agent.',
                    2000
                );

                // Send back the strategy for user approval
                return new TextToolResult($response->getContent()->getText());
            } catch (\Exception $e) {
                return new TextToolResult('Standard support response: We will review your issue and respond within 24 hours.');
            }
        }

        return new TextToolResult('Personalized support requires AI capabilities.');
    }

    public function setSamplingClient(SamplingClient $samplingClient): void
    {
        $this->samplingClient = $samplingClient;
    }
}
```

🚀 Quick Start: Build Your First Agent
-------------------------------------

[](#-quick-start-build-your-first-agent)

### 1. Requirements

[](#1-requirements)

- PHP &gt;=8.2
- Symfony &gt;=6.4

### 2. Install Symfony MCP Server

[](#2-install-symfony-mcp-server)

#### Create the configuration file config/packages/klp\_mcp\_server.yaml and paste into it:

[](#create-the-configuration-file-configpackagesklp_mcp_serveryaml-and-paste-into-it)

```
```yaml
klp_mcp_server:
    enabled: true
    server:
        name: 'My MCP Server'
        version: '1.0.0'
    default_path: 'mcp'
    ping:
        enabled: true  # Read the warning section in the default configuration file before disable it
        interval: 30
    server_providers: ['streamable_http','sse']
    sse_adapter: 'cache'
    adapters:
        cache:
            prefix: 'mcp_sse_'
            ttl: 100
    tools:
        - KLP\KlpMcpServer\Services\ToolService\Examples\CodeAnalyzerTool     # Agentic tool sample
        - KLP\KlpMcpServer\Services\ToolService\Examples\HelloWorldTool
        - KLP\KlpMcpServer\Services\ToolService\Examples\ProfileGeneratorTool
        - KLP\KlpMcpServer\Services\ToolService\Examples\SearchResultsTool
        - KLP\KlpMcpServer\Services\ToolService\Examples\StreamingDataTool
        - KLP\KlpMcpServer\Services\ToolService\Examples\VersionCheckTool
    prompts:
        - KLP\KlpMcpServer\Services\PromptService\Examples\CodeReviewPrompt   # Agentic prompt sample
        - KLP\KlpMcpServer\Services\PromptService\Examples\HelloWorldPrompt
    resources:
        - KLP\KlpMcpServer\Services\ResourceService\Examples\HelloWorldResource
        - KLP\KlpMcpServer\Services\ResourceService\Examples\ProjectSummaryResource # Agentic resource sample
    resources_templates:
        - KLP\KlpMcpServer\Services\ResourceService\Examples\DynamicAnalysisResource # Agentic resource template sample
        - KLP\KlpMcpServer\Services\ResourceService\Examples\McpDocumentationResource
```

```

For more detailed explanations, you can open the default configuration file [from that link.](src/Resources/config/packages/klp_mcp_server.yaml)

#### Install the package via Composer:

[](#install-the-package-via-composer)

```
composer require klapaudius/symfony-mcp-server
```

#### Add routes in your `config/routes.yaml`

[](#add-routes-in-your-configroutesyaml)

```
klp_mcp_server:
    resource: '@KlpMcpServerBundle/Resources/config/routes.php'
    type: php
```

**You're all done!** Upon completing this setup, your project will include 3 new API endpoints:

- **Streaming Endpoint for MCP Clients**: `GET /{default_path}/sse`
- **Request Submission Endpoint**: `POST /{default_path}/messages`
- **Streamable HTTP Endpoint**: `GET|POST /{default_path}`

### Docker Setup (Optional)

[](#docker-setup-optional)

The project includes a Docker setup that can be used for development. The Docker setup includes Nginx, PHP-FPM with Redis extension, and Redis server.

For detailed instructions on how to set up and use the Docker containers, please refer to the [Development Guidelines](CONTRIBUTING.md#docker-setup).

### 3. Create Your First Tool

[](#3-create-your-first-tool)

```
# Generate a new tool
php bin/console make:mcp-tool MyCustomTool

# Test your tool locally
php bin/console mcp:test-tool MyCustomTool --input='{"task":"analyze this code"}'
```

### 4. Visualizing with Inspector

[](#4-visualizing-with-inspector)

You can use the Model Context Protocol Inspector to visualize and test your MCP tools:

```
# Run the MCP Inspector without installation
npx @modelcontextprotocol/inspector node build/index.js
```

This will typically open a web interface at `localhost:6274`. To test your MCP server:

### 5. Connect AI Clients

[](#5-connect-ai-clients)

Your agents are now accessible to:

- 🤖 Claude Desktop / Claude.ai
- 🧠 Custom AI applications
- 🔗 Any MCP-compatible client

🏗️ Architecture for Agent Builders
----------------------------------

[](#️-architecture-for-agent-builders)

### Secure Agent Communication

[](#secure-agent-communication)

- **StreamableHTTP**: Direct, secure agent-to-client communication
- **SSE (Server-Sent Events)**: Real-time updates for long-running agent tasks
- **No STDIO**: Enterprise-safe, no system exposure

### Scalable Agent Infrastructure

[](#scalable-agent-infrastructure)

- **Pub/Sub Messaging**: Handle multiple agent sessions concurrently
- **Redis/Cache Adapters**: Scale your agent platform horizontally
- **Progress Streaming**: Real-time feedback for complex agent operations

### Agent Development Tools

[](#agent-development-tools)

- **MCP Inspector**: Visualize and debug agent behavior
- **Test Commands**: Rapid agent development and testing

### Current Available MCP Features

[](#current-available-mcp-features)

RessourcesPromptsToolsDiscoverySamplingRootsElicitation✅✅✅❌✅❌❌🎓 Agent Development Resources
-----------------------------

[](#-agent-development-resources)

- 📖 **[Building Intelligent Tools](https://github.com/klapaudius/symfony-mcp-server/blob/master/docs/building_tools.md)**: Complete guide to creating AI-powered tools
- 🧠 **[Sampling Documentation](https://github.com/klapaudius/symfony-mcp-server/blob/master/docs/sampling.md)**: Master agent reasoning capabilities
- 🎭 **[Prompt Engineering](https://github.com/klapaudius/symfony-mcp-server/blob/master/docs/building_prompts.md)**: Design agent behaviors and personalities
- 📚 **[Resource Management](https://github.com/klapaudius/symfony-mcp-server/blob/master/docs/building_resources.md)**: Give agents access to knowledge

🌟 Join the Agent Revolution
---------------------------

[](#-join-the-agent-revolution)

Build 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.

### Community

[](#community)

- 💬 [GitHub Discussions](https://github.com/klapaudius/symfony-mcp-server/discussions): Share your agent creations
- 🐛 [Issue Tracker](https://github.com/klapaudius/symfony-mcp-server/issues): Report bugs and request features
- 🌟 [Examples](https://github.com/klapaudius/symfony-mcp-server/tree/master/src/Services/ToolService/Examples): Learn from working agents

📜 License
---------

[](#-license)

MIT License - Build freely!

📰 MCP Registries referencing
----------------------------

[](#-mcp-registries-referencing)

-
-

---

*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)*

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance84

Actively maintained with recent releases

Popularity38

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~12 days

Total

21

Last Release

116d ago

Major Versions

0.9.0 → 1.0.02025-05-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/64e21dad1586abffda80d609d01d811b2a384911803d32141fad9d00fd1088c7?d=identicon)[klapaudius](/maintainers/klapaudius)

---

Top Contributors

[![klapaudius](https://avatars.githubusercontent.com/u/610451?v=4)](https://github.com/klapaudius "klapaudius (63 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![trandbert37](https://avatars.githubusercontent.com/u/16879382?v=4)](https://github.com/trandbert37 "trandbert37 (9 commits)")[![Wolfgang-check24](https://avatars.githubusercontent.com/u/184122006?v=4)](https://github.com/Wolfgang-check24 "Wolfgang-check24 (7 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

agentic-aiagentsaimcpmcp-promptsmcp-servermcp-toolsmodel-context-protocolpromptsresourcesstreamable-httpsymfonytoolsmcpaiservertoolsllmModel Context Protocol

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/klapaudius-symfony-mcp-server/health.svg)

```
[![Health](https://phpackages.com/badges/klapaudius-symfony-mcp-server/health.svg)](https://phpackages.com/packages/klapaudius-symfony-mcp-server)
```

###  Alternatives

[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.4M193](/packages/simplesamlphp-simplesamlphp)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
