Simple MCP Server Example

by dabouelhassan

2 stars
178 downloads
Not rated
GitHub

About

A simple example of a Model Context Protocol Server implementation

Details

Author
dabouelhassan
GitHub stars
2
Downloads
178
Categories
Other

- Basic health check endpoint
- Context endpoint that processes prompt templates
- Support for parameterized prompts

Install dependencies with pip install -r requirements.txt, then run the server using uvicorn src.main:app --reload. The server exposes two endpoints: a GET / for health checks and a POST /context to retrieve context for a given prompt with optional parameters.

Simple MCP Server Example

This is a basic implementation of a Model Context Protocol (MCP) server using FastAPI. The server demonstrates the core concepts of MCP by providing a simple context service.

Features

- Basic health check endpoint
- Context endpoint that processes prompt templates
- Support for parameterized prompts

Setup

1. Install dependencies:

   pip install -r requirements.txt

2. Run the server:

   uvicorn src.main:app --reload

Usage

The server provides two endpoints:

1. GET / - Health check
2. POST /context - Get context for a prompt

Example request:

curl -X POST http://localhost:8000/context \
-H "Content-Type: application/json" \
-d '{"prompt_id": "greeting", "parameters": {"time": "12:00 PM"}}'

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.