Skip to main content

A3M Router MCP Server (Python)

MCP (Model Context Protocol) server for A3M Router — parallel multi-LLM execution for AI agents.

Allows any MCP-compatible AI agent (Claude Desktop, Cursor, Windsurf, Codex, n8n, etc.) to use A3M's intelligent routing and ensemble execution directly from Python.

Tools

Tool Description
a3m_route Route a query to the optimal LLM provider — returns model, tier, cost, reasoning
a3m_ensemble Execute a query across multiple providers in parallel and merge results
a3m_classify Classify query type (fast/creative/deep/code) and get provider recommendations
a3m_providers List all configured providers with cost and availability

Installation

# From source
cd python/mcp-server
pip install -e .

# Or install the package directly (when published)
pip install a3m-mcp-server

Configuration

Set environment variables:

# Required: A3M Router URL (must be running)
export A3M_BASE_URL=http://localhost:8787

# Optional
export A3M_API_KEY=not-needed  # default
export A3M_TIMEOUT=30.0

Start A3M Router

# Node.js way
npx a3m-router serve

# Python way
pip install a3m-router
a3m-router serve

Usage

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "a3m-router": {
      "command": "python",
      "args": ["-m", "a3m_mcp"],
      "env": {
        "A3M_BASE_URL": "http://localhost:8787"
      }
    }
  }
}

Cursor

Settings → Features → MCP Servers → Add:

Name: A3M Router
Command: python
Arguments: -m a3m_mcp

n8n MCP Trigger

Add MCP Trigger node with:

{
  "server": "a3m-router",
  "command": "python",
  "args": ["-m", "a3m_mcp"]
}

Direct stdio (pipe JSON-RPC)

# List tools
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | python -m a3m_mcp

# Call a3m_route
echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"a3m_route","arguments":{"query":"Write a Python quicksort"}}}' | python -m a3m_mcp

Examples

Route a query

# a3m_route tool
Input:  {"query": "Write a Python function to sort a list"}
Output:
{
  "model": "groq/llama-3.3-70b-versatile",
  "tier": "cheap",
  "cost": 0.000012,
  "reasoning": "Code query detected, routing to fast coding provider",
  "classification": "code"
}

Ensemble execution

# a3m_ensemble tool
Input:  {"query": "Explain quantum computing in 3 sentences", "providers": ["groq", "google", "cerebras"]}
Output:
{
  "query": "Explain quantum computing in 3 sentences",
  "parallel_responses": [
    {"provider": "groq", "content": "Quantum computing is..."},
    {"provider": "google", "content": "At its core, quantum..."},
    {"provider": "cerebras", "content": "Quantum computing leverages..."}
  ],
  "best_answer": "Quantum computing is...",
  "stats": {"total_providers": 3, "successful": 3, "failed": 0}
}

Architecture

┌──────────────────────────────────────────────────────┐
│           MCP Client (Claude, Cursor, Codex, n8n)      │
└──────────────────────┬───────────────────────────────┘
                       │ MCP Protocol (stdio)
┌──────────────────────▼───────────────────────────────┐
│           A3M Router MCP Server (Python)              │
│                                                        │
│  a3m_route   a3m_ensemble   a3m_classify  a3m_providers │
└──────────────────────┬───────────────────────────────┘
                       │ HTTP API
┌──────────────────────▼───────────────────────────────┐
│              A3M Router (a3m-router serve)             │
│                                                        │
│  routeQuery()  parallelEnsemble()  providers           │
└───────┬────────────┬────────────┬─────────────────────┘
        │            │            │
   ┌────▼───┐  ┌────▼───┐  ┌────▼───┐
   │  Groq  │  │ Google │  │Cerebras│  ...
   └────────┘  └────────┘  └────────┘

Testing

cd python/mcp-server
pip install -e ".[dev]"
pytest

License

MIT

Metadata

Release files for a3m-mcp-server 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for a3m-mcp-server 1.0.0
File Size Uploaded
a3m_mcp_server-1.0.0.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for a3m-mcp-server 1.0.0
File Interpreter ABI Platform
a3m_mcp_server-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.7 kB

Release files / a3m_mcp_server-1.0.0.tar.gz

Download URL a3m_mcp_server-1.0.0.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e47f60650782e21e1f8dc6eb367e46677a171092dc936f7819ba7db6cb4416b4
BLAKE2b-256 checksum
How to use checksums
44b0d359477fc1bc0dbc94672a19e7cfbc0d0c6a03e7e5e2cd8e169ab02507fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release files / a3m_mcp_server-1.0.0-py3-none-any.whl

Download URL a3m_mcp_server-1.0.0-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7d237781b8830c314bc43f894a7a2954c7c3e4713ff4c32adf1358c98171cdb
BLAKE2b-256 checksum
How to use checksums
844e723854e9be20388703799b4491386551bb67653bba3ff14b0a89411c0888
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page