MCP • AI Agent SDK
MCP: Model Context Protocol (MCP) integration for PraisonAI Agents.
MCP
Defined in the MCP module.
AI Agent
Model Context Protocol (MCP) integration for PraisonAI Agents.
This class provides a simple way to connect to MCP servers and use their tools within PraisonAI agents.
Constructor
AnyNo description available.
AnyNo description available.
Methods
Return the set of MCP server names currently registered this run.
apply_tool_filters()Public API to (re)apply allow/deny tool filters to this instance.
with_tool_prefix()Namespace this server’s tool names with `prefix_` to avoid
Get the list of tool functions from this MCP instance.
get_resources()List resources/resource-templates advertised by the MCP server.
get_prompts()List prompt templates advertised by the MCP server.
to_openai_tool()Convert the MCP tool to an OpenAI-compatible tool definition.
shutdown()Explicitly shut down MCP resources.
Usage
from praisonaiagents import Agent
from praisonaiagents.mcp import MCP
# Method 1: Using command and args separately
agent = Agent(
instructions="You are a helpful assistant...",
llm="gpt-4o-mini",
tools=MCP(
command="/path/to/python",
args=["/path/to/app.py"]
)
)
# Method 2: Using a single command string
agent = Agent(
instructions="You are a helpful assistant...",
llm="gpt-4o-mini",
tools=MCP("/path/to/python /path/to/app.py")
)
# Method 3: Using an SSE endpoint
agent = Agent(
instructions="You are a helpful assistant...",
llm="gpt-4o-mini",
tools=MCP("http://localhost:8080/sse")
)
agent.start("What is the stock price of Tesla?")Source
View on GitHubpraisonaiagents/mcp/mcp.py at line 448