mock-mcp-server
A test MCP server that validates gateway connectivity, identity propagation, and provides mock tools for testing purposes.
README
mock-mcp-server
A test MCP server that runs behind mcp-auth-gateway.
It exists to validate the platform plumbing — not to be a real product.
Purpose
This server is used to verify:
- gateway → backend MCP server connectivity
- path-based
/mock/mcprouting - gateway-signed
X-MCP-Identityverification - propagation of the user
loginid - the Streamable HTTP MCP transport
- GitOps / Kubernetes deployment
How it fits in
client ──TLS──> mcp-auth-gateway ──/mock/mcp──> mock-mcp-server (this repo)
(Keycloak / OAuth, (verifies X-MCP-Identity,
mints X-MCP-Identity) runs MCP tools)
- It runs only behind the gateway. External clients reach it exclusively via
https://gateway.mcp.aidev.samsungds.net/mock/mcp. - It does NOT do Keycloak / OAuth verification itself. All external auth is the gateway's job.
- It DOES verify the gateway's internal
X-MCP-IdentityJWT on every/mcprequest and rejects anything missing or invalid with401. - Tools read the caller's identity — especially
loginid— through a sharedget_current_user()helper; they never parse HTTP headers directly.
Identity: X-MCP-Identity
The gateway injects a signed internal JWT:
X-MCP-Identity: <gateway-signed-internal-jwt>
Example payload:
{
"iss": "mcp-auth-gateway",
"aud": "mock-mcp-server",
"sub": "keycloak-user-sub",
"loginid": "user.loginid",
"username": "user.name",
"email": "user@example.com",
"groups": ["engineering"],
"scopes": ["mcp:mock:use"],
"request_id": "01J...",
"iat": 1730000000,
"exp": 1730000060
}
Verified on every /mcp request:
- JWT signature
iss == mcp-auth-gatewayaud == mock-mcp-serverexp(not expired)loginidpresentsubpresent
The MVP uses shared-secret HS256 via MCP_IDENTITY_JWT_SECRET. The verifier
lives behind a small abstraction (identity.IdentityVerifier) so a production
RS256 / JWKS implementation can be dropped in without touching tools or
middleware.
loginid usage
loginid is the primary per-user key. Tools use it to build deterministic,
user-scoped mock data (mock_profile, mock_search) and to echo the caller's
identity (echo, whoami).
Endpoints
| Method | Path | Auth | Purpose |
|---|---|---|---|
| GET | /healthz |
none | liveness |
| GET | /readyz |
none | readiness |
| ANY | /mcp |
X-MCP-Identity (JWT) |
Streamable HTTP MCP endpoint |
Requests to /mcp without a valid X-MCP-Identity are rejected at the HTTP layer
with 401 Unauthorized before reaching any tool.
MCP tools
| Tool | Input | Returns |
|---|---|---|
whoami |
– | full identity asserted by the gateway |
echo |
message: str |
{ loginid, message } |
mock_profile |
– | deterministic mock profile derived from loginid |
mock_search |
query: str |
deterministic, user-scoped mock search results |
Configuration
All configuration is via environment variables.
| Variable | Default | Notes |
|---|---|---|
APP_HOST |
0.0.0.0 |
|
APP_PORT |
8080 |
container port |
MCP_ENDPOINT |
/mcp |
Streamable HTTP path |
MCP_IDENTITY_ISSUER |
mcp-auth-gateway |
required iss |
MCP_IDENTITY_AUDIENCE |
mock-mcp-server |
required aud |
MCP_IDENTITY_ALGORITHM |
HS256 |
verifier algorithm |
MCP_IDENTITY_JWT_SECRET |
– | required unless dev mode is on |
MCP_IDENTITY_DEV_MODE |
false |
if true, unauthenticated calls get a dummy user |
LOG_LEVEL |
info |
MCP_IDENTITY_JWT_SECRETis mandatory in production; the server refuses to start without it.MCP_IDENTITY_DEV_MODE=trueis only for local development. It defaults tofalseand must never be enabled in the cluster.
Local development
Requirements: Python ≥ 3.11 and uv (or pip).
# 1. install
uv venv
uv pip install -e ".[dev]"
# (pip fallback: pip install -r requirements.txt && pip install -e .)
# 2. run the server
export MCP_IDENTITY_JWT_SECRET=dev-secret
export MCP_IDENTITY_DEV_MODE=false
python -m mock_mcp_server.main
Generate a dev identity token
Without the gateway you must supply your own X-MCP-Identity JWT:
export MCP_IDENTITY_JWT_SECRET=dev-secret
python scripts/make-dev-identity-token.py \
--loginid test.user \
--subject test-sub \
--aud mock-mcp-server
# -> export X_MCP_IDENTITY='<jwt>'
eval "$(python scripts/make-dev-identity-token.py --loginid test.user --subject test-sub)"
Test with curl
/mcp speaks Streamable HTTP (JSON-RPC). In stateless JSON mode you can call a
tool directly:
# health (no auth)
curl -s localhost:8080/healthz
# whoami (requires identity)
curl -s localhost:8080/mcp \
-H "Accept: application/json, text/event-stream" \
-H "Content-Type: application/json" \
-H "X-MCP-Identity: ${X_MCP_IDENTITY}" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"whoami","arguments":{}}}'
# missing identity -> 401
curl -i -s localhost:8080/mcp \
-H "Accept: application/json, text/event-stream" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
Test with MCP Inspector
npx @modelcontextprotocol/inspector
In the Inspector UI: choose Streamable HTTP transport, set the URL to
http://localhost:8080/mcp, and add a header X-MCP-Identity with your dev token.
Run the tests
uv run pytest # or: .venv/bin/python -m pytest
Docker
Image name (pushed to cr.aidev.samsungds.net/mcp-platform):
cr.aidev.samsungds.net/mcp-platform/mock-mcp-server:<commit-sha>
Build & push:
COMMIT_SHA=$(git rev-parse --short HEAD)
docker build -t cr.aidev.samsungds.net/mcp-platform/mock-mcp-server:${COMMIT_SHA} .
docker push cr.aidev.samsungds.net/mcp-platform/mock-mcp-server:${COMMIT_SHA}
The image runs as a non-root user, exposes 8080, and ships a HEALTHCHECK
against /healthz. Tag images by commit SHA (no latest in the cluster) so
GitOps pins an exact, reproducible build.
Deployment (mcp-platform-gitops)
Full Kubernetes / GitOps manifests live in mcp-platform-gitops, not here.
This repo only ships the app and image. The gitops repo should deploy it as a
ClusterIP Service with these values:
| Setting | Value |
|---|---|
| Namespace | mcp-gateway |
| Service name | mcp-mock |
| Service type | ClusterIP |
| Container port | 8080 |
| Internal DNS | http://mcp-mock.mcp-gateway.svc.cluster.local:8080 |
| Internal MCP URL | http://mcp-mock.mcp-gateway.svc.cluster.local:8080/mcp |
| External MCP URL | https://gateway.mcp.aidev.samsungds.net/mock/mcp (gateway) |
Required Secret (mcp-identity-jwt, key secret) holds the shared HS256 secret,
which must match the gateway's signing secret.
Container env:
env:
- name: MCP_IDENTITY_JWT_SECRET
valueFrom:
secretKeyRef:
name: mcp-identity-jwt
key: secret
- name: MCP_IDENTITY_ISSUER
value: mcp-auth-gateway
- name: MCP_IDENTITY_AUDIENCE
value: mock-mcp-server
Probes: GET /healthz (liveness), GET /readyz (readiness), both on 8080.
Do NOT create a public Ingress
This service must never be exposed with its own public Ingress / LoadBalancer.
- It performs no external authentication (no Keycloak, no OAuth). It only trusts
the gateway-signed
X-MCP-Identity. A direct public route would let anyone reach/mcpwhile bypassing the gateway's real authentication. - All external access must go through the gateway, which authenticates the user,
mints
X-MCP-Identity, and routes/mock/mcpto thisClusterIPService.
The only external entry point is:
https://gateway.mcp.aidev.samsungds.net/mock/mcp
Project layout
src/mock_mcp_server/
__init__.py
main.py # ASGI app factory + uvicorn entrypoint
settings.py # env-based configuration (fails fast)
identity.py # X-MCP-Identity JWT verification (HS256; RS256-ready)
middleware.py # pure-ASGI identity enforcement (401) + scope injection
context.py # McpUserContext + get_current_user()
tools.py # whoami / echo / mock_profile / mock_search
scripts/
make-dev-identity-token.py
tests/
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。