MCP Protocol

The Model Context Protocol (MCP) is the foundation of AA Kit's universal interoperability. Every agent is an MCP server, and every tool speaks MCP.

What is MCP?

MCP is an open protocol that standardizes how AI assistants communicate with tools and data sources. It's like HTTP for AI agents - a universal language that ensures any MCP client can work with any MCP server.

Why MCP Matters

Universal Compatibility

Your AA Kit agents work seamlessly with:

  • Claude Desktop
  • Other MCP-compatible AI assistants
  • Third-party MCP tools and services
  • Your own MCP implementations

No Lock-in

With MCP, you're never locked into a single ecosystem:

  • Switch between AI providers freely
  • Mix and match tools from different sources
  • Build once, use everywhere
  • Future-proof your investments

How AA Kit Uses MCP

MCP Flow in AA Kit

Your Code

AA Kit

MCP Server

Every function becomes an MCP tool • Every agent becomes an MCP server • Everything is interoperable

Implementation Examples

Agent as MCP Server

python
from aakit import Agent

# Create your agent
agent = Agent(
    name="knowledge_assistant",
    instruction="You provide helpful information on various topics",
    model="gpt-4",
    tools=[search_web, calculate, translate_text]
)

# Serve as MCP server - instantly compatible with Claude Desktop!
agent.serve_mcp(
    port=8080,
    name="Knowledge Assistant",
    description="AI assistant with web search and calculation abilities",
    config={
        "allowed_origins": ["*"],
        "max_connections": 100,
        "enable_cors": True
    }
)

# Your agent is now accessible at http://localhost:8080
# Add to Claude Desktop: Settings > MCP Servers > Add > http://localhost:8080

Connect to MCP Tools

python
from aakit import Agent

# Use any MCP server as a tool
agent = Agent(
    name="integrated_agent",
    instruction="You coordinate various services",
    model="gpt-4",
    tools=[
        # Local functions
        my_local_function,
        
        # Other MCP servers
        "http://localhost:8081",  # Another agent
        "http://api.example.com/mcp",  # External MCP service
        "mcp://file-system-tools",  # Named MCP service
    ]
)

# Agent automatically discovers and uses available tools
response = await agent.chat(
    "Search for Python tutorials and save them to a file"
)

MCP Tool Discovery

python
from aakit import Agent

# Agents can discover tools from MCP servers
agent = Agent(
    name="discovery_agent",
    instruction="You discover and use available tools",
    model="gpt-4"
)

# Add MCP server dynamically
await agent.add_mcp_server("http://tools.example.com/mcp")

# List discovered tools
tools = agent.list_tools()
for tool in tools:
    print(f"Tool: {tool.name}")
    print(f"Description: {tool.description}")
    print(f"Parameters: {tool.parameters}")
    print("---")

MCP Protocol Details

python
# AA Kit automatically generates MCP-compliant tool definitions
def search_products(query: str, category: str = None) -> list:
    """Search for products in our catalog."""
    # Your implementation
    return results

# Becomes this MCP tool definition:
{
    "name": "search_products",
    "description": "Search for products in our catalog",
    "inputSchema": {
        "type": "object",
        "properties": {
            "query": {
                "type": "string",
                "description": "Search query"
            },
            "category": {
                "type": "string",
                "description": "Product category",
                "optional": true
            }
        },
        "required": ["query"]
    }
}

MCP Message Format

Request Format

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "search_products",
    "arguments": {
      "query": "laptop",
      "category": "electronics"
    }
  },
  "id": 1
}

Response Format

{
  "jsonrpc": "2.0",
  "result": {
    "content": [
      {
        "type": "text",
        "text": "Found 5 laptops..."
      }
    ]
  },
  "id": 1
}

MCP Endpoints

EndpointMethodDescription
/POSTMain MCP endpoint for all requests
/.well-known/mcp.jsonGETServer metadata and capabilities
/healthGETHealth check endpoint

MCP Methods

tools/list

List all available tools with their schemas.

Request: { "method": "tools/list" }

tools/call

Execute a specific tool with arguments.

Request: { "method": "tools/call", "params": { "name": "tool_name", "arguments": {} }}

completion/complete

Get completions from the AI model.

Request: { "method": "completion/complete", "params": { "messages": [...] }}

Benefits of MCP in AA Kit

For Developers

  • • Write once, use anywhere
  • • No proprietary protocols
  • • Easy integration
  • • Standard debugging tools

For Users

  • • Use any MCP client
  • • Mix tools freely
  • • No vendor lock-in
  • • Consistent experience

For Organizations

  • • Future-proof architecture
  • • Vendor independence
  • • Easy tool sharing
  • • Standard compliance

MCP Resources

Learn more about the Model Context Protocol and its ecosystem:

Next Steps

Learn about AA Kit's built-in production features for enterprise-ready deployments.

Continue to Production Features →