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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file a3m_mcp_server-1.0.0.tar.gz.
File metadata
- Download URL: a3m_mcp_server-1.0.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e47f60650782e21e1f8dc6eb367e46677a171092dc936f7819ba7db6cb4416b4
|
|
| MD5 |
344f32e5ec74219dee55f2b73a1bef61
|
|
| BLAKE2b-256 |
44b0d359477fc1bc0dbc94672a19e7cfbc0d0c6a03e7e5e2cd8e169ab02507fc
|
File details
Details for the file a3m_mcp_server-1.0.0-py3-none-any.whl.
File metadata
- Download URL: a3m_mcp_server-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7d237781b8830c314bc43f894a7a2954c7c3e4713ff4c32adf1358c98171cdb
|
|
| MD5 |
d15067fc40bcb73da51eec3fd95bef70
|
|
| BLAKE2b-256 |
844e723854e9be20388703799b4491386551bb67653bba3ff14b0a89411c0888
|