Attach a server

Note: Run this on your machine. Try it Yourself cannot start a server or open a path on the host.

Local tool first

MCP attaches a server process. Practise a plain function tool in Try it Yourself, then use MCP(…) on your machine.

Example

from praisonai import Agent

def echo(text: str) -> str:
    """Return the same text."""
    return text

agent = Agent(instructions="Use echo when asked.", tools=[echo])
print(agent.start("Echo: ready for MCP."))

Try it Yourself

Example explained

  • from praisonai import Agent — Imports Agent needed for local tool first.
  • def echo — Defines `echo` used directly in the local tool first workflow.
  • Agent(…) — Instantiates the Agent configured for local tool first.
  • .start(…) — Executes the configured run for local tool first and returns the result.

One server

tools=MCP(…) points at a server command. Replace the path with a server you actually have.

The string is the command that starts the server. The agent receives whatever tools that server offers.

Example

from praisonai import Agent, MCP

agent = Agent(
    instructions="You are a helpful assistant",
    tools=MCP("python /path/to/mcp_server.py"),
)
print(agent.start("Which tools do you have?"))

Example explained

  • MCP — The wrapper that launches a tool server.
  • tools — Where the server is attached, in place of a plain function.

Reference: documentation