alya/symfony-inspector-mcp

MCP Server for Symfony Introspection

Maintainers

Package info

github.com/alya-labs/symfony-inspector-mcp

Homepage

Type:symfony-bundle

pkg:composer/alya/symfony-inspector-mcp

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-02-25 10:10 UTC

This package is auto-updated.

Last update: 2026-02-25 10:17:37 UTC


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 LogicException at container build time if it is accidentally enabled outside of dev.

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 for inspect_entity and symfony://entities)
  • doctrine/migrations (optional — required only for symfony://migrations/status)

Security

  • Dev-only enforcement: the bundle's DI extension throws at container compilation time if kernel.environment is not dev. There is no silent fallback.
  • Command whitelist: run_console only executes commands explicitly listed in mcp_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.