📰 FastAPI MCP TOEIC文章生成器
基于FastAPI的 MCP(模型上下文协议) 为托业学习者生成结构化英语学习新闻文章的服务。\ 该服务与OpenAI兼容的语言模型集成,并提供专为web渲染设计的干净JSON输出。
______________________________________________________________________
🚀 特性
- 生成逼真的托业风格英语新闻文章
- 返回结构化JSON(元数据、文章和评论)
- 已准备好进行MCP集成或独立使用API
- 包括用于手动测试的响应式web界面
- 可通过Docker或Render部署
______________________________________________________________________
🧩 目录结构
├── main.py#核心FastAPI MCP服务器 ├── requirements.txt#Python依赖项 ├── Dockerfile#容器部署的构建说明 ├── docker-compose.yml#本地测试/容器编排 ├── config.py/#包含用于调用.env文件的API配置 └── index.html#(可选)简单web客户端(前端)
______________________________________________________________________
⚙️ 设置和安装
1.克隆并进入项目目录
git clone https://github.com/0xshivainu/EnglishArticleAgent-MCP-APP.git
cd EnglishArticleAgent-MCP-APP2.安装依赖项
pip install -r requirements.txt3.配置环境
创建文件 config/settings.py 并定义您的OpenAI兼容设置:
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
api_key: str = "YOUR_API_KEY"
base_url: str = "https://api.openai.com..."
settings = Settings()______________________________________________________________________
▶️ 在本地运行
使用Uvicorn
python main.py或者使用Docker Compose(mac)
docker compose up --build服务器将在以下位置可用:\ 👉 http://0.0.0.0:10000
______________________________________________________________________
🌐 API终点
健康检查
GET/健康
答复:
{
"status": "healthy",
"service": "simple-mcp"
}生成文章
POST/生成_文章
请求体
{
"topic": "artificial intelligence in the workplace"
}cURL命令示例
curl -X POST "https://0.0.0.0:10000/generate_article"
-H "Content-Type: application/json"
-d '{"topic": "artificial intelligence in the workplace"}'