MCP Guidelines Server
A remote MCP server that serves versioned Enterprise & Architecture guidelines (security, architecture, compliance) to LLM clients via Streamable HTTP with Bearer-token authentication.
README
MCP Guidelines Server
A remote MCP server that serves versioned Enterprise & Architecture
guidelines (security / architecture / compliance policies) to LLM clients
(Claude Desktop, IDE integrations, …) over Streamable HTTP behind
static Bearer-token auth. Guidelines are plain Markdown files with YAML
frontmatter, indexed in-memory with SQLite FTS5 for ranked full-text search and
hot-reloaded on change. Built on the official mcp SDK (FastMCP) and packaged
for Docker (e.g. a Synology NAS behind a reverse proxy / Tailscale).
Features
- Five core MCP tools +
find_applicableand two prompts (see Tools). - Ranked full-text + tag search (SQLite FTS5,
bm25) with highlighted snippets. - Hot-reload: edits in the guidelines directory are picked up without a restart
(watchdog), with a
POST /reloadfallback for filesystems where inotify/FSEvents doesn't fire (NAS shares). - Schema validation: malformed frontmatter is logged and skipped — never crashes.
- Static Bearer-token auth; unauthenticated MCP calls get
401. Scopes are modelled (data-model ready) but not enforced in Phase 1. - Structured JSON audit logging per tool call; optional Prometheus
/metrics. - Per-token rate limiting and a
/healthendpoint for Docker/reverse-proxy. - Read-only by design: the server never writes guidelines.
Project layout
src/mcp_guidelines/
server.py # composition root: FastMCP, watcher lifecycle, ops routes, entrypoint
loader.py # read dir, parse frontmatter, validate, skip-on-error
models.py # Pydantic models (frontmatter contract + I/O shapes)
index.py # GuidelineIndex: in-memory cache + SQLite FTS5 search
auth.py # static bearer tokens, scope model, rate limiter
tools.py # MCP tool + prompt registrations
config.py # 12-factor env config
metrics.py # dependency-free Prometheus counters
logging_setup.py # JSON logging to stdout
guidelines/ # seed guidelines (security / architecture / compliance)
tests/ # loader, index/search, auth, tools (MCP protocol), HTTP (401)
Dockerfile docker-compose.yml .env.example pyproject.toml
Installation
Requires Python ≥ 3.11.
# editable install with dev/test extras
pip install -e ".[dev]"
# or, with uv
uv sync
Running locally
AUTH_TOKENS=dev=secret GUIDELINES_PATH=guidelines mcp-guidelines
# equivalently: python -m mcp_guidelines
The MCP endpoint is served at http://<host>:<port>/mcp (Streamable HTTP).
Clients MUST send Authorization: Bearer <token>.
curl -s localhost:8000/health # {"status":"ok","documents":4,"revision":"…"}
# unauthenticated MCP call is rejected:
curl -s -o /dev/null -w '%{http_code}\n' -X POST localhost:8000/mcp \
-H 'content-type: application/json' -d '{}' # -> 401
Docker
# create your token(s) first (see "Token generation")
echo 'AUTH_TOKENS=team=PUT-A-REAL-TOKEN-HERE' > .env
docker compose up --build
curl localhost:8000/health # -> 200, container reports "healthy"
docker-compose.yml mounts ./guidelines read-only into the container,
passes config via env vars, defines a healthcheck against /health, and
restarts unless stopped. Put the container behind your reverse proxy
(Synology / Traefik / nginx) or expose it over Tailscale; terminate TLS there.
Configuration (environment variables)
All configuration is via env vars (12-factor); a .env file is read when present.
See .env.example.
| Variable | Default | Description |
|---|---|---|
GUIDELINES_PATH |
guidelines |
Directory of guideline .md files (read-only). |
AUTH_TOKENS |
(empty) | Comma-separated name=token pairs. Empty ⇒ every MCP call is 401. |
AUTH_TOKENS_FILE |
(unset) | Path to a JSON secrets file (below); entries override AUTH_TOKENS. |
LOG_LEVEL |
INFO |
DEBUG | INFO | WARNING | ERROR. |
HOST |
0.0.0.0 |
Bind address. 0.0.0.0 disables the SDK's DNS-rebind guard (intended behind a proxy). |
PORT |
8000 |
Listen port. |
RATE_LIMIT |
60 |
Requests per minute per token (0 disables). |
ISSUER_URL |
http://localhost:8000 |
OAuth issuer URL, used only for WWW-Authenticate/OAuth metadata. |
RESOURCE_SERVER_URL |
(unset) | Optional protected-resource metadata URL. |
METRICS_ENABLED |
true |
Expose Prometheus metrics at /metrics. |
Token generation
Generate a strong random token and add it to AUTH_TOKENS:
python -c "import secrets; print(secrets.token_urlsafe(32))"
# AUTH_TOKENS=alice=<token1>,bob=<token2>
Secrets file (AUTH_TOKENS_FILE)
For per-token scopes or to keep tokens out of the environment, point
AUTH_TOKENS_FILE at a JSON file. File entries override AUTH_TOKENS.
{
"tokens": [
{ "name": "alice", "token": "…", "scopes": ["read:all"] },
{ "name": "secaudit", "token": "…", "scopes": ["read:security"] }
]
}
Scopes are recorded on the token and surfaced to the audit log. Phase 1 does not enforce them — any valid token may read everything. Enforcement is a later phase (set
required_scopesinbuild_auth_settingsand/or checktok.scopesintools._begin). Swapping in real OAuth is a drop-in replacement ofStaticTokenVerifierwith an introspection verifier (sameTokenVerifierprotocol).
Guideline frontmatter schema
Each guideline is a Markdown file with a YAML frontmatter block. Place files
under category subdirectories of GUIDELINES_PATH (the directory layout is for
humans; category comes from the frontmatter, not the path).
---
id: arch-api-design # required, unique, stable slug ([a-z0-9-])
title: API Design Guidelines # required
category: architecture # required, slug (e.g. security|architecture|compliance)
tags: [rest, versioning, http] # optional
version: 2.1.0 # required, SemVer
status: active # required: draft | active | deprecated
owner: platform-team # required
updated: 2026-06-01 # required, ISO date
applies_to: [backend, api] # optional: scope/domains (drives find_applicable)
supersedes: arch-api-v1 # optional
---
# API Design Guidelines
… actual content …
idandcategorymust be slugs;versionmust be SemVer;statusis one of the three literals. Files that fail validation (bad YAML or schema) are logged and skipped — the server keeps running.- Unknown extra frontmatter keys are allowed and ignored.
status: deprecatedguidelines still appear in search, flagged with awarning(andsupersedeswhen set).
Tools and prompts
| Tool | Input | Output |
|---|---|---|
list_guidelines |
category?, tag?, status? |
summaries (id, title, category, tags, version, status) |
get_guideline |
id |
{ metadata, content, path } |
search_guidelines |
query, category?, limit? |
ranked hits with score, snippet, deprecation warning |
list_categories |
– | categories with counts |
get_guideline_metadata |
id |
frontmatter only (token-sparing) |
find_applicable |
applies_to: [...], category? |
active guidelines overlapping the context, ranked by overlap |
Prompts: apply_guideline(id, code) (check code against one guideline) and
review_against_category(category, code) (review against all active guidelines
in a category).
Connecting a client
Use any MCP client that speaks Streamable HTTP. Point it at
http://<host>:<port>/mcp with header Authorization: Bearer <token>, e.g.:
npx -y @modelcontextprotocol/inspector
# URL: http://localhost:8000/mcp Header: Authorization: Bearer <token>
Operational endpoints
| Endpoint | Method | Auth | Purpose |
|---|---|---|---|
/health |
GET | public | Liveness/readiness: {status, documents, revision} (Docker healthcheck). |
/metrics |
GET | public | Prometheus text exposition (when METRICS_ENABLED). |
/reload |
POST | Bearer | Force a full re-read of the guidelines directory (hot-reload fallback). |
/mcp |
POST | Bearer | The MCP Streamable HTTP endpoint. |
Maintaining guidelines
Guidelines live in a versioned Git repo (keep version/updated current).
To add or change one:
-
Drop or edit a
.mdfile under a category directory inGUIDELINES_PATH. -
The file watcher applies the change within moments — no restart needed.
-
If your filesystem doesn't deliver watch events (some NAS shares), trigger a reload explicitly:
curl -X POST -H 'Authorization: Bearer <token>' localhost:8000/reload
The server never writes guidelines; all maintenance is via Git/the filesystem.
Development & tests
pip install -e ".[dev]"
pytest -q
Tests cover the loader (skip-on-error), the FTS5 index (ranked search, snippets,
category filter, deprecation flagging, hot-reload add/edit/delete), auth (token
verification, env+file principal merge, rate limiter), every tool over the real
in-memory MCP protocol, and the HTTP surface (/health, the 401 auth gate,
and /reload).
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。