Get the FREE Ultimate OpenClaw Setup Guide →

mcp -demo

Demo of MCP Server in Python using FastMCP

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio alejandro-ao-mcp-server-demo python mcp_server.py

How to use

This repository provides a Python-based example MCP server built with FastMCP. It demonstrates exposing tools, resources, and prompts to AI clients so they can leverage external capabilities while reasoning. The server is intended for educational purposes to show how to structure an MCP server in Python and how clients (such as IDE helpers or chatbots) can connect and invoke defined tools.

To use the server, install the required dependency and run the script. Start by installing FastMCP, then run the Python script that starts the MCP server. Clients can connect via stdio or HTTP transports depending on the server configuration and the FastMCP setup. Once running, the server will present its exposed tools, resources, and prompts to any MCP-compliant client, allowing the client to discover available functions and invoke them with the appropriate inputs. You can extend the example by adding more tools or resources and by configuring prompts for structured interactions.

How to install

Prerequisites:

  • Python 3.8+ installed
  • Internet access to install dependencies

Step-by-step installation:

  1. Create and activate a virtual environment (optional but recommended): python -m venv venv source venv/bin/activate # on macOS/Linux .\venv\Scripts\activate # on Windows

  2. Install the FastMCP library used by the example: pip install fastmcp

  3. Ensure you have the example server code (mcp_server.py) in your project directory. If you cloned this repository, navigate to its root.

  4. Run the MCP server: python mcp_server.py

  5. Connect a compatible MCP client to the running server. Refer to the MCP client documentation for how to initiate a connection and call available tools.

Additional notes

Tips and common considerations:

  • The example focuses on illustrating the MCP structure (tools, resources, prompts) using FastMCP in Python. You can customize the tools by editing mcp_server.py or related modules to add functions, data sources, or templates.
  • If you expose the server over HTTP, ensure proper security measures (authentication, authorization, and rate limiting) in production deployments.
  • When debugging, check for common pitfalls such as missing dependencies, port conflicts, or transport configuration mismatches between client and server.
  • Environment variables are optional for this demo. If you enable networking features or port configuration, document and populate relevant env vars (e.g., PORT, HOST) as needed.
  • Review the MCP specification and FastMCP documentation for details on input/output schemas, transport options, and best practices for defining tools and prompts.

Related MCP Servers

Sponsor this space

Reach thousands of developers