Demo HTTP MCP Server
test-http-mcp
使用 http-mcp 包以 Python 实现的演示模型上下文协议 (MCP) 服务器。它可以通过 HTTP (Starlette/Uvicorn) 或 stdio 运行,向任何支持 MCP 的客户端公开示例工具和提示词。该项目包含一个 React 前端,提供了一个聊天界面,用于通过 NVD(国家漏洞数据库)查询漏洞。

项目结构
test-http-mcp/
├── backend/ # Python backend (FastAPI + MCP server)
│ ├── app/ # Application source code
│ │ ├── app.py # FastAPI app, routes, MCP mount
│ │ ├── main.py # Entry points (HTTP / stdio)
│ │ ├── agen_memory.py # SQLite message persistence
│ │ ├── config.py # Settings via pydantic-settings
│ │ ├── tools/ # MCP tools (CPE/CVE search via NVD)
│ │ └── prompts/ # MCP prompt templates
│ ├── pyproject.toml # Python deps & scripts
│ ├── uv.lock # Locked dependencies
│ ├── ruff.toml # Linter config
│ ├── mypy.ini # Type-checker config
│ └── .envrc # direnv auto-activation
├── frontend/ # React + TypeScript frontend (Vite)
│ ├── src/
│ │ ├── components/ # ChatApp, ChatInput, MessageList, MessageBubble
│ │ ├── api.ts # API client (fetch history, stream messages)
│ │ ├── types.ts # Shared TypeScript types
│ │ ├── App.tsx # Root component
│ │ └── App.css # Styles
│ ├── vite.config.ts # Vite config with dev proxy
│ └── package.json # Node dependencies
├── AGENTS.md
├── LICENSE
└── README.md要求
Python 3.13
Node.js 18+ 和 npm
uv(推荐) 或pip
安装
后端 (使用 uv):
cd backend
uv run python -V # creates a venv and syncs deps from pyproject后端 (使用 pip):
cd backend
python3.13 -m venv .venv
source .venv/bin/activate
pip install .前端:
cd frontend
npm install运行
开发 (前端 + 后端分别运行)
启动后端:
cd backend
uv run run-app
# → API on http://localhost:8000
# → MCP endpoint on http://localhost:8000/mcp/启动前端开发服务器 (在另一个终端中):
cd frontend
npm run dev
# → UI on http://localhost:5173 (proxies /api/* → backend)生产 (后端服务已构建的前端)
构建前端并启动后端:
cd frontend && npm run build && cd ..
cd backend && uv run run-app
# → Everything on http://localhost:8000运行 (stdio 模式)
与 Cursor 或其他 MCP 客户端配合使用
HTTP 模式的 .cursor/mcp.json 示例:
{
"mcpServers": {
"test-http-mcp": {
"type": "http",
"url": "http://localhost:8000/mcp/",
"headers": {
"Authorization": "Bearer $TEST_TOKEN"
}
}
}
}与 Gemini 配合使用:
{
"mcpServers": {
"test": {
"httpUrl": "http://localhost:8000/mcp/",
"timeout": 5000,
"headers": {
"Authorization": "Bearer TEST_TOKEN"
}
}
}
}通过 stdio 连接的 .cursor/mcp.json 条目示例:
{
"mcpServers": {
"test_studio": {
"command": "uv",
"args": ["run", "--project", "backend", "run-stdio"],
"env": { "AUTHORIZATION_TOKEN": "Bearer TEST_TOKEN" }
}
}
}此服务器公开的内容
工具 (参见
backend/app/tools/):search_cpe(product, version, vendor)— 通过 NVD 搜索通用平台枚举 (CPE)search_cve(cpe_name)— 为给定的 CPE 搜索通用漏洞披露 (CVE)
提示词 (参见
backend/app/prompts/):sync_nvd_search(dependency, version)— 简单的漏洞搜索提示词async_nvd_search(dependency, version)— 带有预取 CVE 数据的高级提示词
项目脚本
backend/pyproject.toml 中定义了两个控制台入口点:
run-app→app.main:run_httprun-stdio→app.main:run_stdiorun-app-local→app.app:main(带有自动重载)
开发
常见任务 (在 backend/ 目录下运行):
uv run ruff check . # lint
uv run mypy . # type check
uv run pytest # tests
uv run mdformat . # format markdown前端任务 (在 frontend/ 目录下运行):
npm run dev # start dev server
npm run build # production build
npm run lint # lint with ESLint
npx tsc --noEmit # type check实现说明
FastAPI 应用定义在
backend/app/app.py中,并将http_mcp.server.MCPServer挂载在/mcp下。聊天界面使用
pydantic-ai和 Gemini 代理,该代理可以调用 MCP 工具来搜索漏洞。聊天记录通过
agen_memory.py持久化到本地 SQLite 数据库中。React 前端以换行符分隔的 JSON 格式流式传输响应,并使用
marked库渲染 Markdown。在生产环境中,后端从
frontend/dist/提供已构建的前端,并带有 SPA 后备路由。在开发环境中,Vite 将
/api/*请求代理到 8000 端口的后端。
许可证
MIT — 参见 LICENSE。
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/yeison-liscano/demo_http_mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server