Skip to main content
MCP (Model Context Protocol) lets agents connect to external tool servers, instantly adding file system access, database queries, API integrations, and more.
from praisonaiagents import Agent, MCP

agent = Agent(
    name="FileAgent",
    instructions="You help users manage their files.",
    tools=MCP("npx -y @modelcontextprotocol/server-filesystem /tmp"),
)

agent.start("List all files in the /tmp directory.")
The user asks to inspect the filesystem; the agent calls MCP tools on the connected server.

Quick Start

1

Connect to an MCP server

from praisonaiagents import Agent, MCP

agent = Agent(
    instructions="You can read and write files.",
    tools=MCP("npx -y @modelcontextprotocol/server-filesystem /tmp"),
)
agent.start("Create a file called notes.txt with the text 'Hello World'.")
2

SSE-based MCP server

from praisonaiagents import Agent, MCP

agent = Agent(
    instructions="You can search and retrieve web content.",
    tools=MCP("https://mcp.example.com/sse"),
)
agent.start("Search for the latest news about AI.")
3

Multiple MCP servers

from praisonaiagents import Agent, MCP

filesystem_tools = MCP("npx -y @modelcontextprotocol/server-filesystem /home/user")
database_tools = MCP("npx -y @modelcontextprotocol/server-sqlite /db/app.sqlite")

agent = Agent(
    instructions="You manage files and database records.",
    tools=[*filesystem_tools, *database_tools],
)
agent.start("Read the config file and update the database with its settings.")

How It Works

PhaseWhat happens
1. ConnectMCP client connects to the server on first use
2. DiscoverServer reports its available tools
3. ExecuteAgent calls tools via the MCP protocol
4. ReturnResults flow back through the MCP client to the agent

MCP Server Types


Common Patterns

Pattern 1 — File management agent

from praisonaiagents import Agent, MCP

agent = Agent(
    name="FileManager",
    instructions="You help users organize and manage their files efficiently.",
    tools=MCP("npx -y @modelcontextprotocol/server-filesystem /home/user/documents"),
)
response = agent.start("Find all PDF files and create a summary list.")
print(response)

Pattern 2 — Database agent

from praisonaiagents import Agent, MCP

agent = Agent(
    name="DBAgent",
    instructions="You query and analyze database records.",
    tools=MCP("npx -y @modelcontextprotocol/server-sqlite /path/to/database.sqlite"),
)
agent.start("Show me all users who signed up in the last 30 days.")

Pattern 3 — GitHub integration

from praisonaiagents import Agent, MCP
import os

agent = Agent(
    name="GitHubAgent",
    instructions="You help manage GitHub repositories and issues.",
    tools=MCP(
        "npx -y @modelcontextprotocol/server-github",
        env={"GITHUB_PERSONAL_ACCESS_TOKEN": os.environ["GITHUB_TOKEN"]},
    ),
)
agent.start("List the 5 most recent open issues in my repository.")

Best Practices

Start with the official @modelcontextprotocol npm packages for common integrations (filesystem, SQLite, GitHub, etc.). They’re well-tested and actively maintained.
When using the filesystem MCP server, pass the narrowest directory path you need. Giving access to / or /home when you only need /app/data creates unnecessary risk.
Never hardcode API keys or tokens in your code. Pass them as environment variables to the MCP server via the env parameter, and source them from your environment or secrets manager.
Agents can use tools from multiple MCP servers simultaneously. Unpack each server’s tools with *MCP(...) and combine them into a single tools list for maximum capability. Loading via load_mcp_tools auto-namespaces each server’s tools (e.g. filesystem_search, github_search) so overlapping names never collide.

Tools — built-in tools and custom tool functions

MCP Tool Filtering — filter which tools to expose per agent