alya/symfony-inspector-mcp 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alya/symfony-inspector-mcp

最新稳定版本:v1.0.0

Composer 安装命令:

composer require alya/symfony-inspector-mcp

包简介

MCP Server for Symfony Introspection

README 文档

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.

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固