Symfony AI Mate with DDEV
While experimenting with the new Symfony AI component, I realized that you cannot only build MCP servers for your application but also have an MCP server integrated that exposes insights in your Symfony app for your coding agent. This component is called the AI Mate.
While looking through the source code, I realized that AI Mate depends on the StdioTransport to communicate with the agent. While we run all our PHP projects with DDEV (and Docker), I opened an issue on GitHub to see if it would be possible to support the HttpTransport as well.
The consensus of the discussion was that StdioTransport is more performant and will also work in a Docker environment. And, as it turns out, it is also easy to set up with DDEV.
To set up AI Mate with DDEV, you will need to install the Mate bundle and the Symfony bridge. This can be done using the following command:
ddev composer require --dev symfony/ai-mate symfony/ai-symfony-mate-extension
Next, you will need to initialize the AI Mate configuration:
ddev php vendor/bin/mate init
You can then discover available extensions using the following command:
ddev php vendor/bin/mate discover
To get AI Mate working with DDEV, create a new file mate in the .ddev/commands/web directory of your project:
#!/bin/bash
## Description: Run Symfony Mate
## Usage: mate
vendor/bin/mate serve --force-keep-alive
This allows you to start AI Mate with the command ddev mate.
Next, we configure our AI coding agent to use the ddev mate MCP server. In my example, I use OpenCode; other AI coding agents should be configured similarly.
I created a new file opencode.json in the project root directory with the following content:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"symfony-mate": {
"enabled": true,
"type": "local",
"command": ["ddev", "mate"]
}
}
}
What does it do? Thanks to the symfony/ai-symfony-mate-extension package we have installed earlier, we can let our AI coding agent inspect the Symfony service container or access available profiler profiles.
In this blog post, we have covered how to set up AI Mate with DDEV and configure your AI coding agent to use the ddev mate MCP server. With these steps, you can take advantage of the features provided by AI Mate and improve your development workflow.
