MCP ecosystem gateway / MCP 生态网关
The gateway lets an external coding client read Datakeel facts, retrieve governance playbooks and prepare controlled plans. Every action tool only prepares a frozen plan. A person reviews its impact and digest, then approves/rejects and executes it through the Web UI or CLI. MCP has no approval, execution, workflow start or workflow resume capability, including when the client calls a hidden name directly.
外部编码客户端可以读事实、获取治理指引、准备冻结计划。签批和执行仍由人在 Web UI / CLI 完成;MCP 不提供审批、执行、启动工作流或恢复工作流的权限。
Start and connect / 启动与连接
Use an initialized, current personal/authorized Datakeel database. Existing
DATAKEEL_HOME and database settings still apply; the gateway does not migrate a
store during startup. From a checkout:
# Backward-compatible defaults: stdio, complete catalog
uv run datakeel mcp
# Streamable HTTP, a smaller delivery catalog and one dataset
uv run datakeel mcp --transport streamable-http --profile delivery --dataset DATASET_ID
# Read-only client
uv run datakeel mcp --transport streamable-http --profile readonly
# Legacy SSE remains supported
uv run datakeel mcp --transport sse
| Transport | Address / behavior |
|---|---|
stdio (default) |
JSON-RPC on stdin/stdout; no HTTP listener or startup banner |
streamable-http |
http://127.0.0.1:8766/mcp |
sse |
Legacy http://127.0.0.1:8766/sse |
Both HTTP transports default strictly to 127.0.0.1; --host and --port remain
explicit overrides. This is a local gateway: it uses the server's local actor and
existing data grants, not a client-supplied actor. It does not add remote-user
authentication. Keep the listener on loopback unless access is separately protected.
The client's name and transport session are attribution, not authorization.
两个 HTTP 入口默认只监听本机。客户端名称和会话 ID 仅用于审计,不授予权限;profile 和 dataset 用于收窄本机网关,不能代替远程身份认证。
For clients accepting a mcpServers subprocess configuration, point command at the
Datakeel executable installed from this checkout (or the release containing it):
{
"mcpServers": {
"datakeel": {
"command": "datakeel",
"args": ["mcp", "--profile", "governance", "--dataset", "DATASET_ID"]
}
}
}
For HTTP-capable clients, choose Streamable HTTP and supply the /mcp URL above.
Client-specific configuration keys differ. Restart the subprocess or reconnect to
a newly configured server after changing scope. No protocol argument can widen it.
Tool profiles and dataset scope / 工具范围
| Profile | Tools offered |
|---|---|
all (default) |
All existing reads, prepare-only actions and explicit memory operations, plus observation tools |
readonly |
Registered domain reads, memory search and discovery/observation; no plan preparation or memory writes |
delivery |
Quality, files, lineage, annotation/training checks, release/export/datasheet preparation |
governance |
Quality, evidence, KG, metrics, standards and selected remediation preparations |
production |
Production reads and preparation tools for labeling/project operations |
Every profile includes dataset discovery, memory search, tool_search and all four
observation tools. tools/list keeps full model-generated schemas and uses pages of
32. tool_search ranks only the selected catalog; a hidden tool cannot be invoked
by name, and the refusal is audited.
--dataset ID intersects that profile with tools whose targets can be reliably bound
to one dataset. Missing dataset arguments, including selection.dataset_id, are
injected; a conflicting explicit ID is rejected before domain dispatch. Existing
version/file ownership and grant checks still run. Dataset discovery returns just that
dataset, and memory reads exclude global and other-dataset entries. Memory updates by
ID, arbitrary evidence/task/metric IDs, global catalog writes and production project
operations are omitted because their arguments do not prove one dataset target.
Use a separately configured unscoped gateway for those operations.
--dataset 会收窄列表、调用、资源及 Prompt;不能可靠绑定到该数据集的工具不开放。
普通调用仍须符合已发布参数 schema;省略数据集时服务器可补入配置中的 ID。
此范围是上下文与目标约束,不改变底层数据授权策略。
Read-only resources / 只读资源
All resource bodies are JSON serialized from frozen boundary models (the two legacy resources retain their existing list shape). Reads may append existing access-usage records, but do not create plans, strengthen memories or execute work.
| URI | Content |
|---|---|
datakeel://agents |
Existing bundled specialist declarations; does not invoke them |
datakeel://memories |
Existing visible memories, narrowed to the configured dataset if set |
datakeel://datasets |
Up to 100 authorized identity/name/file-count cards, with total and truncated |
datakeel://datasets/{dataset_id}/summary |
Current measured quality, last 20 version summaries, depth-1 lineage node/edge counts, newest 20 datasheet summaries |
datakeel://workflows |
Checked workflow identities, descriptions and input contracts; scoped gateways offer dataset-input declarations |
datakeel://approvals/pending |
First page of active human approval requests, using the same model as list_pending_plans |
The summary includes version_count, datasheet_count, documentation publication and
staleness flags, and lineage_depth. It omits file manifests, raw object bytes and
private object-store paths. Quality is the current governance read, not a claim that
every historical version was rescored. Summary calls compose existing typed reads;
they are not one transactional snapshot. A concurrent human change can be seen on the
next read. Underlying version/datasheet adapters still load their histories before
the response is capped; this is not a constant-memory history API.
资源保留原有访问授权。摘要按当前事实读取,包含质量、版本数量、局部血缘统计与说明书 发布/过期状态;响应有上限,不携带 manifest 或对象内容。组合读取不是跨领域原子快照。
Governance prompts / 治理指引
prompts/list offers these reusable playbooks:
audit-dataset-delivery: evidence and readiness checks before delivery.triage-low-quality: measured issues, bounded samples and proposed remediation.investigate-metric-drift: metric definition, time window, source and baseline checks.review-kg-extraction: exact source support, verification and human review decisions.prepare-training-split: grouping, stratification, leakage and a proposed split.
Every prompt takes required dataset_id and optional metric_id string arguments.
Arguments use a frozen, extra-forbid model; missing, unknown and cross-scope arguments
are rejected. Prompt retrieval is inert: it neither starts the named workflow nor
calls a model/tool. Playbooks identify dataset text/metadata as untrusted evidence,
list the configured tools, and keep human approval and execution explicit. Use the
available schemas; a profile may omit tools needed to finish a proposed investigation.
Creating a saved split still uses the existing human CLI/Web flow.
Prompt 只是可复用操作说明;获取它不会运行工作流、调用模型或生成计划。所需工具不在当前 profile 中时,应说明证据缺口,不能虚构工具或扩大权限。
Observe a human decision / 回查人工处理状态
All four observation tools use frozen, extra-forbid input/output contracts and the
existing durable invocation audit. Invalid schemas, missing IDs, denied ownership and
out-of-scope requests produce a failed ToolOutcome with invocation_id.
| Tool | Arguments | Result |
|---|---|---|
get_plan_status |
plan_id, optional dataset_id |
Plan state, digest, impact, approval requirement, expiry flag and matching execution statuses/task IDs |
list_pending_plans |
Optional dataset_id, offset=0, limit=20 (1–100) |
Authorized, unexpired PREPARED plans requiring human approval, ordered by creation/ID, plus total/page fields |
list_workflows |
Optional dataset_id |
Checked workflow summaries; does not start runs |
get_workflow_run |
run_id, optional dataset_id |
Durable run/step statuses, pending plan ID and timestamps; omits source-bearing inputs/outputs |
After preparing a plan, retain its ID and digest. Poll get_plan_status when needed;
let the person act on the Web UI/CLI. APPROVED does not mean executed. A plan can be
EXECUTED while queued/running worker work remains; inspect runs[].status and the
task ID as well. Expiry is a separate flag, so it does not overwrite rejection or
execution history. Do not retry a write to observe progress.
Workflow polling enforces the server-selected run owner and current source grants,
including any associated plan. A PAUSED run remains paused until a person explicitly
signs and resumes it outside MCP. Observation never invokes the runtime or consumes an
approval. Pending lists omit inaccessible plans; individual reads refuse them.
观察只读,不消费签批,不触发执行。APPROVED 不等于已执行;异步任务还要看执行记录状态。
PAUSED 工作流仍须人在 MCP 之外显式恢复。状态轮询会写工具审计,请按需调用。
Track handoff / 本轮交付
Wave 1 / Track 1 changes are confined to MCP, its CLI wiring, targeted tests and this
guide. No storage schema/settings, dependencies, migration checksums, CHANGELOG.md
or web_dist changes are included. The wave integrator owns the combined changelog
and frontend artifact update after merging all tracks.
Validation commands for this track (full make check intentionally excluded):
uv run ruff check datakeel/mcp datakeel/cli tests/mcp tests/cli
uv run ruff format --check datakeel/mcp datakeel/cli tests/mcp tests/cli
uv run pyright datakeel/mcp datakeel/cli
uv run python scripts/check_size.py
uv run python scripts/check_boundaries.py
uv run python -m scripts.check_schema
uv run lint-imports
uv run pytest tests/mcp tests/cli -q
Tests cover real stdio subprocess and loopback SSE/Streamable HTTP handshakes, resource/template and prompt retrieval, human approval/execution observation, expired and rejected plans, ownership/current-grant refusals and profile/dataset bypass attempts. Remaining validation boundary: live editor clients, remote authentication and a PostgreSQL run are outside this local fixture suite. The next step is integration of all wave tracks and the integrator's combined repository gate.
Recorded local result (2026-11-28, isolated SQLite fixtures): all eight commands above
passed; pytest reported 258 passed, pyright reported 0 errors / 0 warnings,
and import-linter kept 5/5 contracts. Full make check was not run, as instructed.