Skip to main content

MCP

Defined in the mcp module.
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

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?")