Expose Extra as an MCP server
Extra can currently connect to MCP servers and use their tools.
I want to support the opposite flow as well: run an Extra system as an MCP server, so another agent or MCP client can use the full Extra graph as one tool.
The MCP server should be started from the CLI:
agentctl mcp serve --config ./agents.yml
It should expose one tool:
Example input:
{
"message": "Search the internal documentation",
"session_id": "optional-session-id",
"user_id": "optional-user-id"
}
Example output:
{
"session_id": "abc123",
"answer": "The relevant documentation is...",
"visited": ["root", "knowledge_agent"],
"used_tools": ["search_internal_documents"]
}
Conversation history
The MCP integration should reuse the existing ConversationService.
When no session_id is provided, Extra should create a new session and return its ID.
When the same session_id is sent again, Extra should load the previous messages and continue the conversation.
The MCP layer should not implement its own history or prompt-building logic. It should reuse the existing:
- conversation repository
- context window
- token budget
- message persistence
ConversationService.send
Expected flow
MCP Client
↓
Extra MCP Server
↓
ConversationService
↓
Extra Engine
↓
Agent Graph
The engine should be built once when the MCP server starts and reused for all requests.
The MCP layer should only handle:
- request validation
- session creation or loading
- mapping the request into the existing Extra context
- calling
ConversationService
- returning the result as MCP content
Routing, tool execution, approvals, hooks and access control should continue to be handled by the existing Extra runtime.
Initial scope
For the first version:
- support
stdio
- expose one tool for the full Extra system
- support conversation history
- create a session automatically when needed
- return the session ID to the caller
- reuse the existing database and repository
- close the engine and database correctly on shutdown
- add unit and integration tests
- add a small working example
HTTP transport, streaming and exposing individual agents as separate tools can be handled later.
Done when
agentctl mcp serve --config ./agents.yml starts an MCP server
- an MCP client can discover
extra_chat
- the client can send a message and receive an answer
- a new session is created when no session ID is provided
- the same session can continue a previous conversation
- different sessions do not share history
- the engine is built once and reused
- the existing Extra behavior is not duplicated or changed
Expose Extra as an MCP server
Extra can currently connect to MCP servers and use their tools.
I want to support the opposite flow as well: run an Extra system as an MCP server, so another agent or MCP client can use the full Extra graph as one tool.
The MCP server should be started from the CLI:
It should expose one tool:
Example input:
{ "message": "Search the internal documentation", "session_id": "optional-session-id", "user_id": "optional-user-id" }Example output:
{ "session_id": "abc123", "answer": "The relevant documentation is...", "visited": ["root", "knowledge_agent"], "used_tools": ["search_internal_documents"] }Conversation history
The MCP integration should reuse the existing
ConversationService.When no
session_idis provided, Extra should create a new session and return its ID.When the same
session_idis sent again, Extra should load the previous messages and continue the conversation.The MCP layer should not implement its own history or prompt-building logic. It should reuse the existing:
ConversationService.sendExpected flow
The engine should be built once when the MCP server starts and reused for all requests.
The MCP layer should only handle:
ConversationServiceRouting, tool execution, approvals, hooks and access control should continue to be handled by the existing Extra runtime.
Initial scope
For the first version:
stdioHTTP transport, streaming and exposing individual agents as separate tools can be handled later.
Done when
agentctl mcp serve --config ./agents.ymlstarts an MCP serverextra_chat