Stdio Transport
The stdio (standard input/output) transport is the default one in Kern's integration. It works best for local integrations.
To use it, simply initialize the MCPTools class with the command argument.
The command you want to pass is the one used to run the MCP server the agent will have access to.
For example uvx mcp-server-git, which runs a git MCP server:
1from kern.agent import Agent2from kern.models.openai import OpenAIResponses3from kern.tools.mcp import MCPTools45# Initialize and connect to the MCP server6# Can also use custom binaries: command="./my-mcp-server"7mcp_tools = MCPTools(command="uvx mcp-server-git")8await mcp_tools.connect()910try:11 agent = Agent(model=OpenAIResponses(id="gpt-5.2"), tools=[mcp_tools])12 await agent.aprint_response("What is the license for this project?", stream=True)13finally:14 # Always close the connection when done15 await mcp_tools.close()You can also use multiple MCP servers at once, with the MultiMCPTools class. For example:
1import asyncio2import os34from kern.agent import Agent5from kern.tools.mcp import MultiMCPTools678async def run_agent(message: str) -> None:9 """Run the Airbnb and Google Maps agent with the given message."""1011 env = {12 **os.environ,13 "GOOGLE_MAPS_API_KEY": os.getenv("GOOGLE_MAPS_API_KEY"),14 }1516 # Initialize and connect to multiple MCP servers17 mcp_tools = MultiMCPTools(18 commands=[19 "npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt",20 "npx -y @modelcontextprotocol/server-google-maps",21 ],22 env=env,23 )24 await mcp_tools.connect()2526 try:27 agent = Agent(28 tools=[mcp_tools],29 markdown=True,30 )3132 await agent.aprint_response(message, stream=True)33 finally:34 # Always close the connection when done35 await mcp_tools.close()363738# Example usage39if __name__ == "__main__":40 # Pull request example41 asyncio.run(42 run_agent(43 "What listings are available in Cape Town for 2 people for 3 nights from 1 to 4 August 2025?"44 )45 )