Skip to main content

MCP API

Server config types

McpStdioServerConfig (dict)

{
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
"env": {}, # optional extra env for subprocess
"cwd": "/path", # optional working directory
}

McpSseServerConfig (dict)

{
"type": "sse",
"url": "https://server.example.com/sse",
"headers": {"Authorization": "Bearer token"},
}

McpHttpServerConfig (dict)

{
"type": "http",
"url": "https://server.example.com/mcp",
"headers": {},
}

McpJsonRpcServerConfig

Available as a typed dataclass for IDE/type-checker support:

from agentix import McpJsonRpcServerConfig

config = McpJsonRpcServerConfig(
url="https://server.example.com/jsonrpc",
headers={"Authorization": "Bearer token"},
)

options = AgentixAgentOptions(
mcp_servers={"myserver": config}
)

McpSdkServerConfig

Created via create_sdk_mcp_server. Available as a typed class:

from agentix import McpSdkServerConfig, create_sdk_mcp_server
from agentix.mcp import mcp_tool

@mcp_tool(name="my_tool", description="A tool.")
async def my_tool(args: dict) -> dict:
return {"content": [{"type": "text", "text": "result"}]}

options = AgentixAgentOptions(
mcp_servers={
"myserver": create_sdk_mcp_server("myserver", "1.0", [my_tool])
}
)

McpServerStatus

Returned by client.get_mcp_status():

McpServerStatus(
name: str, # server name (key from mcp_servers dict)
status: str, # "connected" | "disconnected" | "error"
serverInfo: dict | None, # server metadata from MCP handshake
error: str | None, # error message if status == "error"
config: dict | None, # resolved config dict for this server
tools: list[str] | None, # tool names registered by this server
)

@mcp_tool decorator

from agentix import mcp_tool   # exported from top-level agentix
# also available as: from agentix.mcp import tool

@mcp_tool(
name="tool_name",
description="What this tool does.",
input_schema={ # optional JSON schema for args
"type": "object",
"properties": {
"query": {"type": "string"},
},
"required": ["query"],
},
)
async def my_tool(args: dict) -> dict:
# args contains the parsed tool input
return {
"content": [
{"type": "text", "text": "result text"}
]
}

create_sdk_mcp_server

from agentix import create_sdk_mcp_server

server_config = create_sdk_mcp_server(
name="my-server",
version="1.0.0",
tools=[my_tool_1, my_tool_2],
)