docs/ai-chat/mcp.mdx
The Trigger.dev MCP server includes tools for having conversations with your chat agents directly from AI coding tools like Claude Code, Cursor, Windsurf, and others. This lets your AI assistant interact with your agents without writing any code.
| Tool | Description |
|---|---|
list_agents | List all agents in the current worker |
start_agent_chat | Start a conversation with an agent |
send_agent_message | Send a message and get the response |
close_agent_chat | Close a conversation |
See the MCP Tools Reference for full details on each tool.
If the agent uses `withClientData`, pass the required fields via `clientData`.
Here's what a typical MCP conversation with an agent looks like:
You: List my agents
AI: Found 3 agents in worker 20250402.12 (dev):
- support-agent (src/trigger/support.ts)
- pr-review (src/trigger/pr-review.ts)
- research (src/trigger/research.ts)
You: Start a chat with the support agent
AI: Agent chat started and preloaded.
- Chat ID: abc-123
- Agent: support-agent
- Run ID: run_xyz
You: Ask it to look up order #4821
AI: I found order #4821. It was placed on March 15 and shipped via
FedEx (tracking: 7891234). Current status: In Transit, estimated
delivery March 19.
Tools used: lookupOrder, getShippingStatus
You: Close the chat
AI: Chat abc-123 closed.
If you haven't set up the MCP server yet, see the MCP Server introduction for installation and client configuration.
Agent chat tools require:
trigger dev) or a deployed workerchat.agent() or chat.customAgent()Under the hood, the MCP tools use the same protocol as the frontend transport and AgentChat SDK:
start_agent_chat triggers a task run with the preload trigger and stores the session (run ID, chat ID) in memory.send_agent_message sends the message via the run's input stream and subscribes to the output SSE stream to collect the agent's full response.close_agent_chat sends a close signal via the input stream and removes the session.Sessions are held in-memory within the MCP server process. If the MCP server restarts, active sessions are lost — but the underlying agent runs continue until their idle timeout.
<Note> The `get_current_worker` tool also labels agents with `[agent]` in its output, making it easy to identify which tasks are agents even when listing all tasks. </Note>