Demo-MCP

Demo-MCP

A minimal Model Context Protocol server exposing arithmetic, time, and note-taking tools over streamable HTTP, with in-memory state and Docker support.

Category
访问服务器

README

Demo-MCP

A minimal Model Context Protocol server in Python, served over streamable HTTP from a Docker container.

What it exposes

Kind Name Purpose
tool add(a, b) adds two numbers
tool server_time() UTC time from inside the container
tool save_note(title, body) writes to an in-memory store
tool list_notes() lists saved note titles
resource note://{title} reads a saved note
prompt summarize_note(title) prompt template over a note

State lives in process memory, so it resets whenever the container restarts.

Setup

The server requires a shared bearer token. Generate one and put it in .env:

make token          # prints a random token
cp .env.example .env
# paste the token as MCP_AUTH_TOKEN in .env

docker compose reads .env automatically, so make up picks it up with no extra flags.

Run it

docker compose up --build

The endpoint is http://localhost:8000/mcp.

While iterating on server.py, this reloads the container on save:

docker compose watch

Connect from another Claude Code session

claude mcp add --transport http demo-mcp http://localhost:8000/mcp \
  --header "Authorization: Bearer $MCP_AUTH_TOKEN"

Then in that session, /mcp lists the connection and the tools show up as mcp__demo-mcp__add, etc.

To remove it later:

claude mcp remove demo-mcp

Adding a tool

Add a decorated function in server.py — the type hints become the input schema and the docstring becomes the tool description, so both matter to the calling model:

@mcp.tool()
def word_count(text: str) -> int:
    """Count whitespace-separated words in the given text."""
    return len(text.split())

Async functions work too, and adding a ctx: Context parameter gives you await ctx.info(...) for logging back to the client and await ctx.report_progress(...) for long operations. The parameter is injected by the SDK and is not part of the tool's schema.

Makefile

Wraps the commands above. Run make (or make help) to list targets.

Target Does
help List targets (default)
build docker compose build
up Build and start the container in the background
down Stop and remove the container
restart down then up
logs Follow container logs
ps Show container status
watch docker compose watch — live reload on server.py edits
shell Shell into the running container
health Smoke-check /mcp responds, with the bearer token attached
health-unauth Same, without a token — expect 401
token Generate a random value for MCP_AUTH_TOKEN
env Create .env with a generated MCP_AUTH_TOKEN if one doesn't exist yet (used by CI)
register claude mcp add --transport http demo-mcp http://localhost:8000/mcp --header "Authorization: Bearer $MCP_AUTH_TOKEN"
unregister claude mcp remove demo-mcp
clean docker compose down -v --rmi local

Releasing

Commits follow Conventional Commits: feat: bumps the minor version, fix:/perf: bumps patch, and a ! or BREAKING CHANGE: footer bumps major (minor, while the project is still 0.x). Merging to main runs python-semantic-release automatically — it computes the next version from commit history, updates pyproject.toml and __version__ in server.py, tags the commit, generates CHANGELOG.md, and publishes a GitHub Release. PRs are squash-merged, so the PR title is what gets parsed — it must itself be a valid Conventional Commit, and CI lints it.

Notes

  • The server binds 0.0.0.0 inside the container so Docker can publish the port; only 8000 on the host is exposed.
  • Auth is a single shared static bearer token (MCP_AUTH_TOKEN), not OAuth. There's no rotation and no per-client identity — everyone holding the token is demo-client. The issuer_url set in server.py is a placeholder; no authorization server actually runs. This is appropriate for a localhost demo only — keep the published port off any untrusted network, and note there's no TLS, so the token is exposed to anything on the network path.
  • server.py imports MCPServer with a fallback to FastMCP, the SDK's older name for the same class, so it builds against either release line.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选