composer require --dev alya/symfony-inspector-mcp
config/bundles.php (only for dev environment):
return [
Alya\SymfonyInspectorMcp\SymfonyInspectorMcpBundle::class => ['dev' => true],
];
config/packages/mcp_inspector.yaml:
mcp_inspector:
transport: stdio
allowed_commands:
- cache:clear
- list
log_file: '%kernel.logs_dir%/%kernel.environment%.log'
log_tail_lines: 200
config/packages/mcp.yaml:
mcp:
client_transports:
stdio: true
http: false
Start the MCP server and connect an LLM agent (e.g., Claude Desktop):
php bin/console mcp:server
Then, in your LLM agent, ask questions like:
/api."logger in their name."Debugging Routes/Entities:
list_routes to inspect route definitions dynamically.inspect_entity to debug Doctrine entities without restarting the app.Log Inspection:
read_logs or access symfony://logs/latest for real-time debugging.Configuration Exploration:
show_config for bundle/extension settings (e.g., "framework" or "doctrine").symfony://config/{name} for structured config dumps.Command Execution:
cache:clear) in allowed_commands.run_console or run_tests.Integration with AI Agents:
bin/console mcp:server.symfony://resources URIs (e.g., symfony://routes) for direct data access.bin/console with Laravel’s artisan in the agent’s config (if adapting for Laravel).allowed_commands to trusted operations (e.g., avoid debug:config in production).log_tail_lines) to balance responsiveness and resource usage.run_tests to automate test execution from the agent (e.g., "Run the UserTest suite.").Dev-Only Enforcement:
LogicException if enabled outside dev. Avoid accidental production exposure.bundles.php and environment variables.Command Whitelisting:
allowed_commands return errors. Test whitelisted commands manually first.list, cache:clear) before adding risky ones.Doctrine Dependencies:
inspect_entity and symfony://entities require doctrine/orm. Install it if missing:
composer require doctrine/orm
symfony://migrations/status) needs doctrine/migrations.Log File Paths:
log_file must point to a valid path (e.g., %kernel.logs_dir%/%kernel.environment%.log). Verify paths in dev and test environments.Transport Limitations:
stdio transport requires the agent to connect via the console process. For remote agents, enable http transport (though this requires additional security setup).mcp.yaml for valid client_transports (e.g., stdio: true).log_file) is readable by the PHP process.symfony://config/{name} to verify configuration before querying tools like show_config.Custom Tools:
// src/Mcp/CustomTool.php
use Symfony\Component\Mcp\Tool\ToolInterface;
class CustomTool implements ToolInterface { ... }
services.yaml:
services:
App\Mcp\CustomTool:
tags: [mcp.tool]
Resource URIs:
symfony://custom/data) by implementing a ResourceProvider and tagging it:
services:
App\Mcp\CustomResourceProvider:
tags: [mcp.resource_provider]
Transport Customization:
stdio transport by creating a custom McpTransport service and configuring it in mcp.yaml.bin/console with php artisan in the agent’s config (e.g., "args": ["php", "artisan", "mcp:server"]).app()) instead of Symfony’s ContainerInterface in custom tools.config/mcp_inspector.php format:
return [
'transport' => 'stdio',
'allowed_commands' => ['cache:clear', 'list'],
'log_file' => storage_path('logs/laravel.log'),
];
How can I help you explore Laravel packages today?