Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.praison.ai/llms.txt

Use this file to discover all available pages before exploring further.

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

command_or_string
Any
No description available.
args
Any
No description available.

Methods

get_tools()

Get the list of tool functions from this MCP instance.

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 GitHub

praisonaiagents/mcp/mcp.py at line 150

MCP Concept

MCP Lifecycle