alya / symfony-inspector-mcp
MCP Server for Symfony Introspection
Package info
github.com/alya-labs/symfony-inspector-mcp
Type:symfony-bundle
pkg:composer/alya/symfony-inspector-mcp
Requires
- php: >=8.2
- doctrine/persistence: ^4.1
- symfony/config: ^6.4|^7.0|^8.0
- symfony/console: ^6.4|^7.0|^8.0
- symfony/dependency-injection: ^6.4|^7.0|^8.0
- symfony/framework-bundle: ^6.4|^7.0|^8.0
- symfony/http-kernel: ^6.4|^7.0|^8.0
- symfony/mcp-bundle: ^0.5.0
- symfony/process: ^6.4|^7.0|^8.0
- symfony/service-contracts: ^3.6
- symfony/yaml: ^6.4|^7.0|^8.0
Requires (Dev)
- doctrine/orm: ^3.6
- phpunit/phpunit: ^13.0
- symfony/phpunit-bridge: ^8.0
README
A Symfony Bundle that exposes your application's internals as a Model Context Protocol (MCP) server. Connect LLM agents (Claude Desktop, Cursor, Windsurf) directly to your running Symfony app and ask questions like:
- "What routes handle POST requests to /api?"
- "Show me the last 50 lines of the dev log and explain the exception."
What it does
Symfony Inspector MCP registers an MCP server inside your Symfony application. Tools and resources let an AI agent introspect your app without leaving the chat:
- List and filter routes, services, and event listeners
- Inspect Doctrine entity mappings
- Read application logs
- Run whitelisted console commands and tests
- Show bundle/extension configuration
Installation
composer require --dev alya/symfony-inspector-mcp
Register the bundle only for the dev environment in config/bundles.php:
return [ // ... Alya\SymfonyInspectorMcp\SymfonyInspectorMcpBundle::class => ['dev' => true], ];
Security: the bundle throws a
LogicExceptionat container build time if it is accidentally enabled outside ofdev.
Configuration
Create config/packages/mcp_inspector.yaml:
mcp_inspector: transport: stdio allowed_commands: - cache:clear - list - doctrine:mapping:info log_file: '%kernel.logs_dir%/%kernel.environment%.log' log_tail_lines: 200
Create (or extend) config/packages/mcp.yaml:
mcp: client_transports: stdio: true http: false
Usage with Claude Desktop
Add the following to your claude_desktop_config.json:
{
"mcpServers": {
"my-symfony-app": {
"command": "/usr/bin/php",
"args": [
"/absolute/path/to/your/project/bin/console",
"mcp:server"
]
}
}
}
Replace /absolute/path/to/your/project with the real path. Restart Claude Desktop after saving.
Available Tools
| Tool | Description |
|---|---|
list_routes |
Lists all registered routes (name, path, methods, controller). |
list_services |
Lists container services. Accepts an optional filter string. |
show_config |
Shows resolved config for a bundle/extension (e.g. "framework", "doctrine"). Accepts an optional path sub-key. |
list_events |
Lists event dispatcher listeners. Accepts an optional event name filter (e.g. "kernel.request"). |
inspect_entity |
Inspects a Doctrine entity — mapping info + source code. Requires doctrine/orm. |
read_logs |
Reads the last N lines of the application log. Accepts an optional lines count. |
run_console |
Executes a whitelisted Symfony console command (see allowed_commands). |
run_tests |
Runs PHPUnit tests and returns output. |
Available Resources
| URI | Description |
|---|---|
symfony://routes |
Full route collection as JSON. |
symfony://entities |
List of Doctrine entity classes. |
symfony://logs/latest |
Latest N lines from the application log file. |
symfony://config/{name} |
Resolved configuration for a bundle or extension (e.g. symfony://config/framework). |
symfony://migrations/status |
Doctrine Migrations status output. Requires doctrine/migrations. |
Requirements
- PHP 8.2+
- Symfony 6.4, 7.x, or 8.x
doctrine/orm^3.0 (optional — required only forinspect_entityandsymfony://entities)doctrine/migrations(optional — required only forsymfony://migrations/status)
Security
- Dev-only enforcement: the bundle's DI extension throws at container compilation time if
kernel.environmentis notdev. There is no silent fallback. - Command whitelist:
run_consoleonly executes commands explicitly listed inmcp_inspector.allowed_commands. Any unlisted command returns an error message. - No network exposure: the default transport is
stdio, meaning the MCP server communicates only through standard input/output of your console process — no port is opened.
Contributing
Pull requests are welcome. Please open an issue first to discuss significant changes.
cd symfony-inspector-mcp
composer install
vendor/bin/phpunit
License
MIT — see LICENSE.