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
│ │ ├── auth0/ # Auth0 integration
│ │ │ ├── __init__.py # JWT token validator
│ │ │ └── client_store.py # Dynamic client registration (RFC 7591)
│ │ ├── 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身份验证 (Auth0)
MCP 端点 (/mcp/) 受 Auth0 OAuth2 身份验证保护。工具需要访问令牌中包含作用域 (tool:search_cpe, tool:search_cve)。
所需环境变量
变量 | 描述 |
| Auth0 租户域 (例如 |
| 用于令牌验证的 API 标识符 |
| 用于 MCP 应用的 Auth0 应用程序客户端 ID |
| 管理 API 客户端 ID(用于动态注册) |
| 管理 API 客户端密钥 |
| 设置为 |
将这些变量放入 backend/.env(已在 git 中忽略)。
应用挂载结构
路径 | 应用 | 身份验证 |
| 受保护的 MCP 服务器 | 需要 Auth0 Bearer 令牌 |
| 动态客户端注册 (RFC 7591) | 未经身份验证 |
| OAuth/资源元数据 | 未经身份验证 |
| 聊天界面端点 | 未经身份验证(见说明) |
| 前端静态文件 | 未经身份验证 |
注意: 聊天端点在本地开发时特意未进行身份验证。在暴露到 localhost 之外之前,请添加身份验证。
要求
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 客户端一起使用
启用 Auth0 后,客户端必须获取 OAuth2 访问令牌。服务器支持 /register 处的 RFC 7591 动态客户端注册,因此实现 auth 规范的 MCP 客户端将自动注册。
HTTP 模式的 .cursor/mcp.json 示例:
{
"mcpServers": {
"test-http-mcp": {
"type": "http",
"url": "http://localhost:8000/mcp/"
}
}
}与 Gemini 一起使用:
{
"mcpServers": {
"test": {
"httpUrl": "http://localhost:8000/mcp/",
"timeout": 5000
}
}
}通过 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实现说明
根 ASGI 应用是由
auth_mcp创建的受 Auth0 保护的 MCP 应用,它将 FastAPI 子应用挂载在/api下。/mcp/处的 MCP 端点需要一个具有适当工具作用域的有效 Auth0 Bearer 令牌。/register处的动态客户端注册代理到一个预先创建的 Auth0 应用程序,更新其允许的回调 URL。重定向 URI 经过验证(需要 HTTPS;仅允许 localhost 使用 HTTP)。聊天界面使用带有 Ollama 代理的
pydantic-ai,该代理可以调用 MCP 工具来搜索漏洞。聊天记录通过
agen_memory.py持久化在本地 SQLite 数据库中。React 前端以换行符分隔的 JSON 流式传输响应,并使用
marked库渲染 Markdown。在生产环境中,后端从
frontend/dist/提供构建好的前端,并具有 SPA 后备路由(受路径遍历保护)。在开发环境中,Vite 将
/api/*请求代理到端口 8000 上的后端。
许可证
MIT — 见 LICENSE。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA minimal Model Context Protocol server demo that exposes tools through HTTP API, including greeting, weather lookup, and HTTP request capabilities. Demonstrates MCP server implementation with stdio communication and HTTP gateway functionality.8ISC
- FlicenseBqualityDmaintenanceA demonstration server showcasing MCP capabilities with basic tools including addition calculations and weather API integration for fetching city weather data.22
- FlicenseNot gradedqualityCmaintenanceA basic MCP server for testing with echo, datetime, and calculator tools.88
- AlicenseAqualityCmaintenanceA minimal MCP server example demonstrating Tools, Resources, and Prompts. It enables calculations, time queries, note management, and code review prompts via stdio transport.310MIT
Related MCP Connectors
MCP server exposing the Backtest360 engine API as tools for AI agents.
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
MCP server for generating rough-draft project plans from natural-language prompts.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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