agentix.mcp¶
mcp ¶
MCP (Model Context Protocol) client support.
Connect to an MCP server, discover its tools, and expose them as agentix
:class:~agentix.tools.Tool objects that route calls back over the live
connection. The discovered tools plug straight into Agent(tools=...)::
async with MCPServer(command="my-mcp-server", args=["--flag"]) as server:
agent = Agent(model=..., system_prompt="...", tools=await server.list_tools())
await agent.run("...") # run INSIDE the block
The tools are only valid while the connection is open, so keep the agent run
inside the async with. Requires the mcp package (lazy-imported):
pip install "agentix[mcp]".
MCP tools already carry a JSON Schema (inputSchema), which is exactly
agentix's parameters convention — so they flow through to any provider
adapter (e.g. Anthropic's input_schema) unchanged.
MCPServer ¶
MCPServer(
*,
command: str | None = None,
args: Sequence[str] | None = None,
env: dict[str, str] | None = None,
url: str | None = None,
transport: str | None = None,
name: str | None = None,
session: Any = None,
)
A connection to a single MCP server.
Construct with a transport (command= for stdio, url= for HTTP/SSE),
or pass a pre-built session (anything exposing async initialize() /
list_tools() / call_tool(name, args)) for testing or to reuse an
existing client. Use as an async context manager.
list_tools
async
¶
Discover the server's tools as agentix :class:Tool objects.