Simple MCP Server Example

Simple MCP Server Example

镜像

概述

这是一个基于 FastAPI 的模型上下文协议(MCP)服务器示例,用于提供简单的上下文服务。

快速开始

1. 安装依赖

pip install -r requirements.txt

2. 启动服务器

uvicorn src.main:app --reload

使用方法

服务器提供两个主要端点:

  • GET / - 健康检查
  • POST /context - 获取提示上下文

示例请求

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

主要特性

  • 健康检查端点
  • 参数化提示处理
  • 上下文服务接口

现在您可以开始使用这个简单的 MCP 服务器了!