Skip to main content
Protocol Revision: 2025-11-25

Expose Tools as MCP Server

PraisonAI allows you to expose your Python functions as MCP (Model Context Protocol) tools that can be consumed by any MCP client, including Claude Desktop, Cursor, and other AI assistants.

Quick Start

1

Install Dependencies

2

Create Your Tools

Define Python functions with type hints and docstrings:
3

Create and Run MCP Server

Basic Usage

Simple MCP Server

Using the Convenience Function

Transport Options

stdio Transport (Default)

Best for local integrations like Claude Desktop:

SSE Transport

For web-based clients and remote access:
Access at: http://localhost:8080/sse

Tool Schema Generation

PraisonAI automatically generates MCP-compatible schemas from your Python functions:
Output:

Supported Type Mappings

Custom Tool Metadata

Override default name and description using special attributes:

Async Tools

Async functions are fully supported:

Claude Desktop Integration

1

Create Your Server Script

Save as my_mcp_server.py:
2

Configure Claude Desktop

Add to Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
3

Restart Claude Desktop

Restart Claude Desktop to load your new MCP server. Your tools will be available in conversations.

Cursor Integration

1

Create Server Script

Same as Claude Desktop setup above.
2

Configure Cursor

Add to Cursor’s MCP configuration:

Exposing Built-in PraisonAI Tools

You can expose PraisonAI’s built-in tools as an MCP server:

Complete Example

API Reference

ToolsMCPServer

launch_tools_mcp_server

Best Practices

Type Hints

Always use type hints for proper schema generation

Docstrings

Write clear docstrings - they become tool descriptions

Error Handling

Return error information in response dict, don’t raise exceptions

Security

Validate inputs, especially for file/system operations

Next Steps

Connect to MCP servers as client

Create agent-based MCP servers