Books API MCP Server

Books API MCP Server

A demo MCP server that proxies a Flask REST API for books, providing tools to list books, get book details, list genres, and check API health via HTTP transport.

Category
访问服务器

README

my-mcp-server — 3-layer HTTP + MCP demo

A small, all-Python demo of three layers wired together over HTTP:

VS Code (native MCP client)
        │  HTTP  →  http://127.0.0.1:9100/mcp
        ▼
MCP server  (mcp_server/server.py, Streamable HTTP transport)
        │  HTTP  →  http://127.0.0.1:8000
        ▼
HTTP API server  (http_server/app.py, Flask, GET endpoints)
        │
        ▼
   in-memory "books" data
  • Layer 1 — HTTP API (http_server/app.py): a plain Flask REST-ish API with GET endpoints. Knows nothing about MCP.
  • Layer 2 — MCP server (mcp_server/server.py): exposes MCP tools over the Streamable HTTP transport. Each tool calls a layer-1 endpoint with httpx.
  • Layer 3 — VS Code: uses its built-in MCP client via .vscode/mcp.json to connect to layer 2 over HTTP. No custom extension or Node.js needed.

Setup

Note: a Windows .venv/ is committed to this repo for convenience. It contains hardcoded paths to C:\Users\400861\... and Windows-only binaries, so it will not work on macOS/Linux or other machines. On any other setup, delete .venv/ and rebuild it with the steps below.

Create a project-local virtual environment and install the pinned deps. Each machine should build its own venv from requirements.txt.

Windows (PowerShell):

python -m venv .venv
.\.venv\Scripts\python.exe -m pip install --upgrade pip
.\.venv\Scripts\python.exe -m pip install -r requirements.txt

macOS / Linux (bash/zsh):

python3 -m venv .venv
./.venv/bin/python -m pip install --upgrade pip
./.venv/bin/python -m pip install -r requirements.txt

The direct-path form above works without "activating" the venv. If you prefer to activate it: .\.venv\Scripts\Activate.ps1 (Windows) or source .venv/bin/activate (macOS/Linux), after which plain python uses the venv.

Run (two terminals)

Use the venv's Python. Windows examples use .\.venv\Scripts\python.exe; on macOS/Linux swap in ./.venv/bin/python.

Terminal 1 — the HTTP API (port 8000):

.\.venv\Scripts\python.exe http_server/app.py

Terminal 2 — the MCP server (port 9100):

.\.venv\Scripts\python.exe mcp_server/server.py

Port 9100 is used because 9000 is occupied by Zscaler (ZSATunnel) on this machine. Override any port with env vars: HTTP_SERVER_PORT, MCP_SERVER_PORT, HTTP_API_BASE_URL.

Verify the chain

With both servers running:

.\.venv\Scripts\python.exe mcp_server/test_client.py

Expected: it lists the tools (list_books, get_book, list_genres, api_health) and prints results proxied from the Flask API.

Use from VS Code

  1. Open this folder in VS Code (MCP support requires a recent VS Code build).
  2. With both servers running, VS Code reads .vscode/mcp.json and connects to http://127.0.0.1:9100/mcp.
  3. Start the server from the mcp.json gutter "Start" action (or the MCP: List Servers command), then use the tools from Copilot Chat's Agent mode.

HTTP API endpoints (layer 1)

Method Path Description
GET /health Liveness probe
GET /books List books; filters: ?genre=, ?author=
GET /books/<id> Single book by id
GET /genres Distinct genres

MCP tools (layer 2)

Tool Calls
list_books GET /books
get_book GET /books/<id>
list_genres GET /genres
api_health GET /health

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选