Get the FREE Ultimate OpenClaw Setup Guide →

mcp -example-v2

A simple example of a Model Context Protocol Server implementation

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio dabouelhassan-mcp-server-example-v2 uvx src.main:app --reload

How to use

This MCP server is a lightweight FastAPI-based implementation of the Model Context Protocol (MCP). It exposes two endpoints: a health check at GET / and a context processor at POST /context. The server accepts a JSON payload containing a prompt_id and optional parameters, and returns a generated context based on the provided template. It is designed to demonstrate basic MCP concepts such as template-driven prompts and parameter substitution. To run locally, start the server and then call the /context endpoint with a JSON payload specifying the prompt_id and any required parameters. The example shows a greeting prompt with a time parameter, illustrating how parameterized prompts can be supplied to customize responses.

How to install

Prerequisites:

  • Python 3.9 or newer
  • pip (comes with Python)
  • Network access to install dependencies

Step-by-step installation:

  1. Create and activate a virtual environment (recommended): """ python -m venv venv

On Windows:

venv\Scripts\activate

On macOS/Linux:

source venv/bin/activate """ 2) Install dependencies from requirements.txt: """ pip install -r requirements.txt """ 3) Run the server (as in the README): """ uvx src.main:app --reload """ 4) Open http://localhost:8000 to verify the health check and use the /context endpoint.

Additional notes

Notes and tips:

  • The server runs by default on http://localhost:8000. If you need to change the port, configure the uvicorn/uvx command accordingly.
  • The /context endpoint expects a POST with a JSON body containing at least a prompt_id, and optionally a parameters object for templated prompts, e.g., {"prompt_id": "greeting", "parameters": {"time": "12:00 PM"}}.
  • Ensure requirements.txt is present and contains all necessary dependencies for FastAPI and your context logic.
  • If you encounter CORS or network issues, ensure the server is reachable from the client and that any firewalls allow port 8000.
  • For development, use the --reload flag as shown to auto-reload on code changes (works with uvx as wrapper).

Related MCP Servers

Sponsor this space

Reach thousands of developers