Skip to main content

MCP API Reference

Context Managers

mcp

Connect to a local MCP server using stdio transport.
Parameters:
  • command (str): Command to run (e.g., “python”, “node”, “npx”)
  • *args (str): Arguments for the command
  • env (dict[str, str] | None): Environment variables
Returns: MCPServer

mcp_sse

Connect to a remote MCP server using SSE transport.
Parameters:
  • url (str): SSE endpoint URL
  • headers (dict[str, str] | None): HTTP headers
Returns: MCPServer

mcp_http

Connect to a remote MCP server using Streamable HTTP transport.
Parameters:
  • url (str): HTTP endpoint URL
  • headers (dict[str, str] | None): HTTP headers
Returns: MCPServer

Non-Context Manager Functions

connect_mcp


connect_mcp_sse


connect_mcp_http


Utility Functions

merge_tools

Combine multiple tool sources into a single ToolSet.
Parameters:
  • *tool_sources (ToolSet | MCPServer): Tool sources to merge
Returns: ToolSet (dict[str, Tool])

Types

MCPServer

Represents a connected MCP server.

MCPClient

Low-level client for connecting to MCP servers.

TransportType


Example