Skip to main content
Version: 0.6.1

MCP Server

Expose agents using the Model Context Protocol (MCP).

What is MCP?​

MCP (Model Context Protocol) is a standardized protocol for AI systems to interact with external tools and data sources.

Enabling MCP​

export AK_MCP__ENABLED=true

or

mcp:
enabled: true

Endpoint: The MCP server is always mounted at /mcp on the main API server. The full endpoint is http://{api.host}:{api.port}/mcp. Use api.port (or AK_API__PORT) to change the port.

Starting MCP Server​

from agentkernel.api import RESTAPI

if __name__ == "__main__":
RESTAPI.run()

Agent as MCP Tool​

Agents are automatically exposed as MCP tools if you set mcp.expose_agents to true. You can selectively expose agents as well.

Custom Tools​

Expose custom tools via MCP:

from agentkernel.mcp import MCP
from agentkernel.api import RESTAPI

mcp = MCP.get()

@mcp.tool
def custom_tool(param: str) -> str:
return f"Processed: {param}"

RESTAPI.run()

Configuration​

mcp:
enabled: true
expose_agents: true
agents: ['*']
stateless_http: false # Set to true for stateless mode (no Mcp-Session-Id)

Integration​

Use agents from other AI systems:

result = mcp_client.call_tool(
"custom_tool",
{"message": "Hello!"}
)

Ready to Ship Your
First Agent?

Free, open-source, Apache 2.0. No licensing costs, no vendor lock-in. Join hundreds of developers building production AI agents with Agent Kernel.

Agent Kernel
Ask Agent Kernel