MCP (Model Context Protocol) servers are external processes or services that expose tools your agent can call. Instead of defining every tool in your own codebase, you can point your agent at any MCP-compatible server and it will discover and use the tools it provides.
NexAU supports two connection types:
- HTTP — connects to a running HTTP/SSE endpoint
- stdio — spawns a local process and communicates over stdin/stdout
Configuration
Add mcp_servers to your agent config. Each entry describes one server.
from nexau import Agent, AgentConfig, LLMConfig
import os
llm_config = LLMConfig(
model=os.getenv("LLM_MODEL"),
base_url=os.getenv("LLM_BASE_URL"),
api_key=os.getenv("LLM_API_KEY"),
)
mcp_servers = [
{
"name": "amap-maps-streamableHTTP",
"type": "http",
"url": "https://mcp.amap.com/mcp?key=your_amap_key_here",
"headers": {
"Content-Type": "application/json",
"Accept": "application/json, text/event-stream"
},
"timeout": 10
}
]
agent_config = AgentConfig(
name="maps_agent",
system_prompt="You are an agent with access to map services.",
mcp_servers=mcp_servers,
llm_config=llm_config,
)
agent = Agent(config=agent_config)
response = agent.run("How long does it take to drive from downtown to the airport?")
print(response)
name: maps_agent
llm_config:
model: gpt-4o-mini
mcp_servers:
- name: github
type: stdio
command: npx
args: ['-y', '@modelcontextprotocol/server-github']
env:
GITHUB_PERSONAL_ACCESS_TOKEN: "your_token_here"
timeout: 30
- name: amap-maps
type: http
url: "https://mcp.amap.com/mcp?key=your_amap_key_here"
headers:
Content-Type: "application/json"
Accept: "application/json, text/event-stream"
timeout: 30
Config fields
| Field | Type | Required | Description |
|---|
name | string | Yes | Identifier for this server. Used in logs and error messages. |
type | string | Yes | Connection type: "http" or "stdio". |
url | string | HTTP only | Full URL of the MCP HTTP endpoint. |
command | string | stdio only | Executable to run (e.g. npx, python). |
args | list[string] | stdio only | Arguments passed to the command. |
env | object | No | Environment variables to set for the process (stdio) or pass as headers (as needed). |
headers | object | HTTP only | HTTP headers to include in every request. |
timeout | number | No | Request or connection timeout in seconds. |
For stdio servers, command and args are used to spawn the process. For HTTP servers, url points to the running endpoint. You cannot mix fields between the two types.