symfony-runtime-mcp

symfony-runtime-mcp

MCP server that exposes Symfony profiler runtime data (requests, queries, logs) to AI agents like Claude Code for debugging and optimization.

Category
访问服务器

README

skrepr/ai-performance-mate-extension

An AI Mate extension that exposes runtime data from the Symfony profiler to AI agents (Claude Code, Cursor, …). Where code intelligence looks at what sits on disk, this looks at what actually happens: request timing, Doctrine queries, N+1 patterns and query plans.

This is the successor to the standalone Node MCP server symfony-runtime-mcp: the same analysis tools, but now in-process as a Mate extension. That eliminates docker exec, a copied extractor script and host↔container path mapping — the tools run where the code and the database live.

For local dev environments only. Never point this at production.

Tools

Tool What it does
slow_queries Slowest query shapes over the last N requests, with total time, execution count and origin (file:line + source code)
detect_n_plus_one Repeated identical queries within a single request, with the likely parent query (1+N)
request_breakdown Wall clock of a single request broken down per category (DB / external HTTP / rendering / listeners …)
profile_diff Before/after comparison of the same endpoint: duration, memory, query count and disappeared/appeared query shapes
explain_query Runs EXPLAIN and tells you why a query is slow (full scan, unused index, filesort). analyze=true for SELECT/WITH only

Complementary to the official symfony/ai-symfony-mate-extension (which exposes raw profiler and container data): install both side by side.

Installation

composer require --dev skrepr/ai-performance-mate-extension

Already running AI Mate in your project (a mate/ directory exists)? Then you are done: the Mate composer plugin runs mate discover automatically after every composer require/update.

No AI Mate yet? The package pulls in symfony/ai-mate automatically; initialize it once:

vendor/bin/mate init          # creates mate/ + mcp.json (Claude Code and friends pick those up automatically)
vendor/bin/mate discover      # registers the extension; happens automatically from then on

The four profiler tools work right away: they read var/cache/dev/profiler. Make a few requests to your app and call request_breakdown, for example. Check with vendor/bin/mate mcp:tools:list that the tools are registered.

Configuration

All configuration is optional and goes through mate/config.php in your project.

explain_query — database connection

The extension does not know your app connection (Mate does not boot the kernel), so explain_query builds its own connection from a DSN. By default it falls back to DATABASE_URL from the environment; load that by setting mate.env_file:

// mate/config.php
return static function (ContainerConfigurator $container): void {
    $container->parameters()
        ->set('mate.env_file', '.env')   // loads .env and .env.local
    ;
};

mate.env_file expects a string (not an array) and requires symfony/dotenv in your project — already present in a standard Symfony app.

Using a different env var or multiple connections? Point at the DSN explicitly:

$container->parameters()
    ->set('mate.env_file', '.env')
    ->set('skrepr_mate.database_url', '%env(resolve:POSTCODE_DB_URL)%')
;

Query origins (strongly recommended)

Without backtraces, slow_queries/detect_n_plus_one know that a query is slow, but not where it comes from. Set in config/packages/dev/doctrine.yaml:

doctrine:
    dbal:
        profiling_collect_backtrace: true

With that, origin points to the exact file:line in your project code, including the surrounding source.

Custom profiler location

$container->parameters()
    ->set('skrepr_mate.profiler_dir', '%mate.root_dir%/var/cache/dev/profiler')
;

Known limitation: the Symfony bridge on PHP < 8.4

If you also use symfony/ai-symfony-mate-extension, its symfony-profiler-* tools fail on PHP < 8.4 with "Cannot generate lazy proxy": the collector formatters are final and ->lazy(), and before PHP 8.4 Symfony creates a lazy proxy through subclassing. On PHP 8.4+ this does not apply. Workaround without patching the vendor — redefine the formatters non-lazy in mate/config.php:

foreach (['Request','Exception','Mailer','Translation','Doctrine','Time','Logger','Memory'] as $name) {
    $fqcn = "Symfony\\AI\\Mate\\Bridge\\Symfony\\Profiler\\Service\\Formatter\\{$name}CollectorFormatter";
    $container->services()->set($fqcn)->tag('ai_mate.profiler_collector_formatter');
}

Requirements

  • PHP ≥ 8.2
  • Symfony 6.4 / 7.x / 8.x with the profiler enabled in dev (symfony/web-profiler-bundle)
  • Doctrine DBAL 3.6+ / 4.x

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选