MCP server
On this page:
Mailcoach can expose an MCP server that lets AI assistants work with the Mailcoach data the authenticated user is allowed to access.
The server is disabled by default. It is available in Mailcoach 10.4 or higher.
Installing Laravel MCP
First, install Laravel MCP in your application:
composer require laravel/mcp
Enabling the MCP server
Enable the Mailcoach MCP server in your environment:
MAILCOACH_MCP_ENABLED=true
By default, the MCP server is mounted at /mcp, so your server URL will look like this:
https://your-domain.test/mcp
You can customize the path in the mailcoach.mcp.path config value.
Authentication
The default self-hosted endpoint uses Sanctum authentication and the configured mailcoach.mcp.middleware stack.
Read access requires a token with the mailcoach:mcp:read ability.
Write tools are disabled by default. To enable them, set:
MAILCOACH_MCP_WRITE_TOOLS_ENABLED=true
Write access also requires a token with the mailcoach:mcp:write ability.
Tools
With read access, assistants can:
- get the current Mailcoach context
- list email lists
- list and look up subscribers
- list and inspect campaigns
- get campaign statistics
- list and inspect campaign templates
- list recent transactional mail log items
With write access, assistants can also:
- create and update draft campaigns
- create and update campaign templates
- send campaign test emails
The MCP server does not expose a tool that sends a campaign to your full audience.
All tool results are filtered through the existing Mailcoach authorization policies. If a user cannot view or change something in Mailcoach, the assistant cannot access it through MCP either.
Customizing behavior
You can customize the MCP path, middleware, token abilities, context resolver, and authorizer in the mailcoach.mcp config.
The default config values include:
'mcp' => [
'enabled' => env('MAILCOACH_MCP_ENABLED', false),
'path' => 'mcp',
'middleware' => [
'auth:sanctum',
'throttle:60,1',
],
'write_tools_enabled' => env('MAILCOACH_MCP_WRITE_TOOLS_ENABLED', false),
'read_token_ability' => 'mailcoach:mcp:read',
'write_token_ability' => 'mailcoach:mcp:write',
],