Skip to main content
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)

Config fields

FieldTypeRequiredDescription
namestringYesIdentifier for this server. Used in logs and error messages.
typestringYesConnection type: "http" or "stdio".
urlstringHTTP onlyFull URL of the MCP HTTP endpoint.
commandstringstdio onlyExecutable to run (e.g. npx, python).
argslist[string]stdio onlyArguments passed to the command.
envobjectNoEnvironment variables to set for the process (stdio) or pass as headers (as needed).
headersobjectHTTP onlyHTTP headers to include in every request.
timeoutnumberNoRequest 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.