Skip to main content

Custom Python MCP Server

Quick Start

1

Create MCP Server

Create a new file app.py with your custom MCP server implementation:
2

Install Dependencies

Install the required dependencies in a conda environment:
3

Create Agent Integration

Create a new file stock_agent.py with the following code:
4

Run the Agent

Execute your script:
Requirements
  • Python 3.10 or higher
  • Conda for environment management
  • yfinance package for stock data
  • mcp-python-sdk for MCP server implementation
  • OpenAI API key (for the agent’s LLM)

Features

Custom Tools

Create your own custom tools with Python.

MCP Integration

Seamless integration with Model Context Protocol.

Type Hints

Strong typing for better code reliability.

Async Support

Built-in support for asynchronous functions.

Implementation Details

FastMCP Class

The FastMCP class from the mcp-python-sdk package provides a simple way to create MCP servers in Python:

Agent Integration

To use your custom MCP server with PraisonAI agents, use the MCP class to specify the command to run your Python script: