mcp-data-platform
CLAUDE.md9 starsChanged 4 months agoApache-2.0View on GitHub
This file provides guidance to Claude Code when working with this project. mcp-data-platform is a semantic data platform MCP server that composes multiple txn2 MCP libraries (mcp-trino, mcp-s3, mcp-datahub) with semantic layer integration. The key differentiator is bidirectional cross-enrichment where tool responses automatically include critical context from other services. Cross-enrichment requires a semantic provider. The rest of the platform does not: createSemanticProvider (and its query/storage counterparts) returns a noop for the empty and noop cases, so a deployment with no…
- Reads credentials
In this repository4 other files it gives its agents.
- docs/llms-full.txtllms.txt
- docs/llms.txtllms.txt
- migrate-radix-to-baseSkill
- shadcnSkill
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
34 rules. About 0 are common, 21 are distinctive, and 13 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈21
Distinctive · estimate
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Semantic-first: All data access includes business context from the semantic layer
- Distinctive: line 60
Trino → DataHub: When describing a table in Trino, the response includes DataHub metadata (owners, tags, glossary terms, deprecation …
- Distinctive: line 62
DataHub → Trino: When searching DataHub, results include query availability (can this be queried?
- Distinctive: line 72
Never pad or embellish: If you made two fixes, describe two fixes.
- Distinctive: line 74
Uncertainty must be explicit: Use "I believe," "possibly," or "I haven't verified" when uncertain.
- Distinctive: line 76
When reviewing, verify claims against evidence: Treat PR descriptions and commit messages as claims to be fact-checked, not trusted context.
- Very specific: line 82
Idiomatic Go: All code must follow idiomatic Go patterns and conventions.
- Very specific: line 85
New code must have >80% coverage: Run go test -coverprofile=coverage.out ./...
- Very specific: line 86
Use go tool cover -func=coverage.out | grep <function_name> to check specific functions
- Very specific: line 89
Testing Definition: When asked to "test" or "testing" the code, this means running make verify, which executes the full CI-equivalent suite:
- Distinctive: line 108
All checks must pass locally before considering code "tested"
- Distinctive: line 122
CRITICAL - Coverage Verification Before Completion: Before declaring ANY implementation task complete:
- Very specific: line 123
Run go test -coverprofile=coverage.out ./...
- Distinctive: line 135
If you cannot write a full integration test (e.g., requires external services), document exactly what manual verification steps the human …
- Distinctive: line 137
CRITICAL - Acceptance Criteria Before Implementation: Before writing code for any feature or fix:
- Distinctive: line 139
Write the test assertions FIRST, then implement the code to make them pass
- Distinctive: line 141
If you find yourself testing that "function X returns Y when given Z" but never testing that "Z actually arrives from the real system," the …
- Very specific: line 151
gofmt: All code must be formatted with gofmt
- Very specific: line 152
go vet: No issues from go vet
- Distinctive: line 153
gocyclo: All functions must have cyclomatic complexity ≤10
- Distinctive: line 154
golint: No lint issues
- Distinctive: line 155
ineffassign: No ineffectual assignments
- Distinctive: line 157
misspell: No spelling errors in comments/strings
- Distinctive: line 159
Diagrams: Use Mermaid for all diagrams.
- Distinctive: line 161
Pinned Dependencies: All external dependencies must be pinned to specific versions with SHA digests for reproducibility and security:
- Very specific: line 166
Documentation Updates: When modifying documentation in docs/, also update the LLM-readable files:
- Very specific: line 181
Before adding a package under pkg/, note that TestPublicSurfacePolicy (#1076) refuses a package that is outside the supported import …
- Very specific: line 579
All four are enabled by default (*bool field, nil = enabled).
- Very specific: line 666
MCPWorkflowGateMiddleware: - Search-first hard gate (#787): refuses query tools until search is called in the session, short-circuiting …
- Distinctive: line 696
When AI (Claude Code or similar) contributes code, the following additional checks apply:
- Very specific: line 702
Mutation Survival Review: After adding tests, run make mutate on the affected packages.
- Very specific: line 704
Dead Code Audit: Run make dead-code before submitting.
- Distinctive: line 711
Do not create migrations, packages, or interfaces "for future use" — code that isn't wired into the running application is dead code …
- Distinctive: line 716
Verify the external dependency supports the required operations
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code when working with this project.
Project Overview
mcp-data-platform is a semantic data platform MCP server that composes multiple txn2 MCP libraries (mcp-trino, mcp-s3, mcp-datahub) with semantic layer integration. The key differentiator is bidirectional cross-enrichment where tool responses automatically include critical context from other services.
Cross-enrichment requires a semantic provider. The rest of the platform does not: createSemanticProvider (and its query/storage counterparts) returns a noop for the empty and noop cases, so a deployment with no semantic: or query: block starts normally and the database-backed surfaces (gateways, knowledge, memory, portal, search/fetch) run on PostgreSQL alone. See docs/server/deployment-shapes.md.
Key Design Goals:
- Semantic-first: All data access includes business context from the semantic layer
- Composable: Integrates multiple MCP toolkits (Trino, DataHub, S3) into a unified platform
- Secure: OAuth 2.1 authentication, role-based personas, and comprehensive audit logging
- Extensible: Plugin-based toolkit registry with middleware chain architecture
Architecture
graph TB
subgraph "MCP Data Platform"
subgraph "Authentication"
OIDC[OIDC Provider]
APIKey[API Keys]
OAuth[OAuth 2.1 Server]
end
subgraph "Authorization"
Persona[Persona Registry]
Filter[Tool Filter]
end
subgraph "Middleware Chain"
Auth[Auth Middleware]
Authz[Authz Middleware]
Enrich[Semantic Enrichment]
Audit[Audit Middleware]
end
subgraph "Providers"
Semantic[Semantic Provider]
Query[Query Provider]
end
subgraph "Toolkits"
Trino[Trino Toolkit]
DataHub[DataHub Toolkit]
S3[S3 Toolkit]
end
end
Client --> Auth --> Authz --> Toolkits
Toolkits --> Enrich --> Audit --> Client
Enrich --> Semantic
Enrich --> QueryCross-Enrichment Pattern
Trino → DataHub: When describing a table in Trino, the response includes DataHub metadata (owners, tags, glossary terms, deprecation warnings, quality scores).
DataHub → Trino: When searching DataHub, results include query availability (can this be queried? how many rows? sample SQL).
CRITICAL - Factual Integrity (No Confabulation)
AI-generated prose (PR descriptions, commit messages, reviews, explanations) is held to the same verification standard as code. Unverified claims are as unacceptable as untested code.
- Never assert facts you haven't verified. Before stating that a file contains X, a config is missing Y, or a system behaves in way Z — READ the file, CHECK the config, VERIFY the behavior. If you haven't looked, say "I haven't verified this" or say nothing.
- Every claim must be evidence-linked. PR descriptions, commit messages, and work summaries may only include claims that are either: (a) directly visible in the diff, or (b) verified by reading a specific file (cite file:line). No exceptions.
- Never pad or embellish. If you made two fixes, describe two fixes. Do not invent a third to make the work look more complete. Do not present hypotheses as confirmed diagnoses.
- Uncertainty must be explicit. Use "I believe," "possibly," or "I haven't verified" when uncertain. Never upgrade a guess to a fact.
- When reviewing, verify claims against evidence. Treat PR descriptions and commit messages as claims to be fact-checked, not trusted context.
- Omission over fabrication. A gap stated honestly is better than a fabricated answer stated confidently. When in doubt, leave it out.
Code Standards
- Idiomatic Go: All code must follow idiomatic Go patterns and conventions. Use
gofmt, follow Effective Go guidelines, and adhere to Go Code Review Comments. - Test Coverage: Project must maintain ≥82% total unit test coverage (
COVERAGE_MINin the Makefile, matched bycodecov.ymland the CI workflow). Build mocks where necessary to achieve this. Use table-driven tests where appropriate.- New code must have >80% coverage: Run
go test -coverprofile=coverage.out ./...and verify new/modified functions meet the threshold - Use
go tool cover -func=coverage.out | grep <function_name>to check specific functions - Framework callbacks (e.g., MCP handlers that require client connections) may be excluded if the actual logic is extracted and tested separately
- New code must have >80% coverage: Run
Testing Definition: When asked to "test" or "testing" the code, this means running
make verify, which executes the full CI-equivalent suite:- Tools-check (parity gate) — verifies local
golangci-lintandgosecversions equalGOLANGCI_LINT_VERSIONandGOSEC_VERSIONin the Makefile (which mirror.github/workflows/ci.yml). Drifting local tool versions are the most insidious parity gap: a newer local gosec can silently relax a rule that CI's pinned version still enforces, letting a real bug ship to PR.make verifyrefuses to run until local matches CI. Override withTOOLS_CHECK_STRICT=0only with explicit reason. - Diff-scoped gates first (
make preverify-fast, #1856) —semgrep-diff,doc-check,acceptance-check,state-readers-check,e2e-copy-checkanddead-coderun in verify's serial preamble, about fifteen seconds, and the Go lane starts with the changed-package schedule lane rather than ending with it. They used to run after the full race+coverage unit run, so a finding surfaced thirteen minutes in and needed a second full run. The patch-scopedlintfollows them in the same serial preamble, before any lane starts, so a lint finding fails verify in its first minutes rather than beside the unit run.make preverifyruns those plus the patch-scoped lint, both halves of the schedule lane,schedule-lanethenschedule-lane-ui(#1929), andrealdb-lane(#1947), the RealDB tests of every changed package and every package importing one, against one Postgres, since nothing else before verify compiles a test behind the integration tag: run it beforemake verify, and a verify that follows a green preverify fails only on the full unit run, coverage, security, the real-DB lane or the UI lane.TestVerifyReportsTheCheapGatesFirst(test/gates/verify_order_test.go) pins the order. - Code formatting (
gofmt -s -w .) - Tagged build (
make vet-tags, #1799) —go vet -tags=integration ./..., run in verify's serial preamble before the lanes fan out. Nothing else cheap compiles a file behind//go:build integration: every other consumer of the tag wants a machine (test-realdbDocker and a migrated Postgres,acceptancea dev stack and a renderer,smokea running server),.golangci.ymlsets no build tags, andnpm run buildis not Go. So a one-character compile error in a tagged file used to be reported byverify-dockerafter the daemon was up and the migrations had replayed: on #1794 three tagged files referenced two deleted constants, every cheap gate passed, and the Docker lane failed six minutes in. This answers the same question in about a second. Run it yourself beforemake verify, besidemake lintandmake patch-coverage— those two are the gates the pre-verify list already names, and neither reads a tagged file. - Unit tests with race detection (
go test -race ./...) - Schedule lane (
make schedule-lane, #1711) — every Go package with a changed file againstmainrunsgo test -race -cpu=1,2 -count=5, and fails with the command that reproduces a failure; CI runs the same target on every pull request.make testruns each test once at this machine's CPU count, which is not the schedule a loaded CI runner chooses:TestWithRevocations_WiredLatepassed twomake verifyruns on 18 cores and fails 140 of 300 runs at-cpu=1. The frontend half (make schedule-lane-ui, in place offrontend-test) runs every changed*.test.ts(x)file five times beside the full vitest suite. - Coverage verification — total must be ≥82% (hard gate,
COVERAGE_MIN) - Patch coverage — changed lines vs main must be ≥80% (mirrors codecov patch check). Which paths sit outside it is written twice, in
scripts/patch-coverage.shand incodecov.yml'signore:, andTestCoverageExclusionsAgree(test/structure/pins_test.go) resolves both against the repository's real Go files and fails when they describe different sets. #1747 read 88.8% here and 64.20% in CI off one diff because they did - Linting (
golangci-lint run ./...plus--new-from-rev=$MERGE_BASEto mirror CI'sonly-new-issues: true) — cyclomatic complexity ≤10, cognitive complexity ≤15 - Security scanning (
gosec ./...+govulncheck, whose report is judged against.govulncheck-allow.txtbyscripts/govulncheck-gate.py: an advisory with no patched release may be accepted with a written reason, and the gate fails when an accepted advisory gains a fix or stops being reported) - Semgrep SAST —
p/golangruleset + custom.semgrep/rules (unbounded allocations, etc.), plusmake semgrep-diff, which runs.semgrep-diff/against the lines this branch changed. That directory holds the rules that refuse a SHAPE a diff-scoped CI check rejects using reasoning Semgrep does not have:go/allocation-size-overflowrejectedmake(map[string]any, len(fields)+1)on #1747 after a green local verify, and the syntactic form it refuses appears 55 times in this tree without being a defect once. Scoping those to the diff is what CI already does with them, and whatmake lintdoes with--new-from-patch - Real-Postgres gate (
make test-realdb, in the Docker lane) — every test named*RealDB*against a migrated database, including the statement gateinternal/sqlgateadded by #1512: each SQL statement in the module is handed to PostgreSQL to parse and plan. sqlmock matches a statement as a string and returns rows the test supplies, so it rubber-stamps SQL the database rejects; #1506 shipped an ambiguous column reference with 100% patch coverage and a green CI. A statement assembled at run time has no text to prepare, so its package renders it throughSQLSamples(seepkg/resource/sqlsamples_integration.go) or is recorded ininternal/sqlgate/templated_pending.txt— a package that does neither fails rather than being skipped. - Documentation check — warns when documentation-worthy changes lack doc updates (soft warning)
- Acceptance check (
make acceptance-check) — warns when production Go underpkg/,internal/orcmd/changed againstmainand notest/acceptance/*_test.gochanged (soft warning; blocking for AI agents, see rule 6), and FAILS when an acceptance file did change and its criteria have no passing run recorded atbuild/<n>/acceptance.jsonl, or the diff registers a tool no criterion calls - State-readers check (
make state-readers-check, #1709) — warns when ajson:"..."field on a struct underinternal/admin,internal/httpserver,pkg/admin,pkg/portalorinternal/portalwas added, removed or retyped, orinternal/apidocs/swagger.jsonchanged (a route or definition, its description included), and nothing underui/srcchanged (soft warning; blocking for AI agents). It lists the changes either way; the PR names the readers it checked for each under "Readers of this state". #1676 changed only a route description and left the Schema card behind (#1689) along with the other replica (#1703) - E2E copy check (
make e2e-copy-check, #1977) — FAILS when a Playwright spec underui/e2e/interactiveorui/e2e/public-viewerasserts a string or JSX text the diff removed fromui/srcand noui/srcsource shows any longer, naming the spec line; a text one changed file shows fewer times but another still shows (theAutomationsfilter option beside theAutomationsheading, #1970) is listed for a look, not failed, and so is a spec literal that still reads a whole text on show (/Open/against a removed "Open the print dialog" tooltip while an Open button stays, #1983). The Playwright suite runs only inside verify, after the full unit run - Dead code analysis
- GoReleaser dry-run — validates build, Docker, and release config
- All checks must pass locally before considering code "tested"
CodeQL is deliberately not part of
make verify, and this list claimed it was until #1327. The Makefile removed it: ~4 minutes of serial wall clock, more than the whole concurrent phase, on the reasoning that.github/workflows/codeql.ymlruns the same suite on every pull request.Running
make codeqllocally is not a substitute, and does not clear you to push. On #1327 GitHub Code Scanning reportedgo/log-injection(medium) atinternal/httpserver/tablehttp/tablehttp.go:179; a localmake codeqlon the identical unsanitized source produced zero log-injection results and exited 0. The file was in the database (it is listed in the SARIF artifacts), so this is not a coverage gap — the local CLI's bundled query pack does not reproduce what GitHub's scanning reports. Treat local CodeQL as advisory for this class.A GHAS finding is a review comment, not a failing check.
gh pr checksshowed CodeQLpasson #1427 whilego/log-injectionwas open against the diff. After every push, readgh api repos/<owner>/<repo>/pulls/<n>/commentsand look forgithub-advanced-security[bot]; a green check list does not mean Advanced Security is clean.Sanitize every value that reaches a log sink with
internal/logsan.SanitizeForLog— includingerr.Error(), since a wrapped error carries whatever caller-supplied names the layers below put in it.Mutation testing (
gremlins unleash --threshold-efficacy 60, ≥60% kill rate) is deliberately not part ofmake verify— it is too slow for a per-commit gate (the Makefileverifytarget carries a comment forbidding its re-addition). It runs inmake verify-release(pre-tag, local) and on a weekly schedule in CI via.github/workflows/mutation.yml; gremlins is version-pinned byGREMLINS_VERSIONand enforced by tools-check like the other tools.Parity-gap incident (2026-05-08, PR #377): local
gosec 2.26.1silently dropped the G704 SSRF taint rule that CI's pinnedv2.22.0enforces.make verifypassed locally; CI rejected the same diff with a real SSRF bug. The tools-check version pin is the structural fix — discipline alone has been insufficient.- Tools-check (parity gate) — verifies local
- CRITICAL - Coverage Verification Before Completion: Before declaring ANY implementation task complete:
- Run
go test -coverprofile=coverage.out ./...(note:./...not./pkg/...— coverscmd/too) - For EVERY new function or method added, run:
go tool cover -func=coverage.out | grep <function_name> - If ANY new function shows less than 80% coverage (or 0.0%), you MUST add tests before declaring done
- This is a BLOCKING requirement - do not tell the user the work is complete until all new code has adequate test coverage
- The CI/CD pipeline includes Codecov patch coverage checks that will fail if new code lacks tests
- Run
- CRITICAL - Integration Tests for Cross-Component Behavior: Unit tests are NOT sufficient for features that span multiple components (middleware chains, provider pipelines, context propagation). Before declaring such work complete:
- Write an integration test that exercises the real assembled system, not just individual functions with hand-crafted inputs
- For middleware: wire up the actual
mcp.Serverwith all middleware viaAddReceivingMiddleware, send a real request, and assert the end-to-end result (e.g., audit store received a complete event with non-empty fields) - For context propagation: verify that values set by one component are actually readable by downstream components through the real call chain
- For provider enrichment: verify that cross-service enrichment actually produces enriched output, not just that the enrichment function works in isolation
- A unit test that passes because it manually constructs the correct input does NOT prove the system works. The integration test must prove that component A's output actually reaches component B through the real wiring.
- If you cannot write a full integration test (e.g., requires external services), document exactly what manual verification steps the human should perform before release, with expected outputs
- CRITICAL - Acceptance Criteria Before Implementation: Before writing code for any feature or fix:
- State the specific, observable acceptance criteria (e.g., "a tool call produces an audit_logs row with non-null user_id, duration_ms, and tool_name")
- Write the test assertions FIRST, then implement the code to make them pass
- The acceptance criteria must test the actual user-visible behavior, not internal implementation details
- If you find yourself testing that "function X returns Y when given Z" but never testing that "Z actually arrives from the real system," the test is incomplete
- CRITICAL - The criteria are then executed through the real surface, locally, before
make verify. Write them astest/acceptance/issue_<n>_test.go: a real MCP client against a running platform, calling the tool or route a user calls, asserting the ticket's acceptance sentences. Run it with the local stack up (make dev;make e2e-upwhen Trino or S3 are involved) viamake acceptance, and keep the transcript underbuild/<n>/acceptance.md.make verify-releaserequires the acceptance suite (make acceptance-release, which starts the dev stack for the run when none answers, #1969);make verifywarns (acceptance-check) when production Go changed with no acceptance file, and for an AI agent that warning is blocking. Production is never the first place a feature runs: 1.126.5 shipped four defects (#1543-#1546) from features whose unit, integration and real-database gates were all green, each found within minutes of the first call through the real surface. Where the platform integrates with an upstream the deployments run (the api-test and mcp-test fixtures, SeaweedFS, Trino, Keycloak), the acceptance test uses that upstream, not a stand-in written for the test. - CRITICAL - The acceptance test sends every JSON form the schema admits. MCP is JSON-RPC:
tools/callparams are JSON, and a parameter whose schema is untyped oranyaccepts more than one form (api_invoke_endpoint.bodytakes an object and a string of JSON). #1548 shipped in 1.126.6 withTestIssue1544_*green because every check sent the body as an object and the client sent it as a string. Before writing the test, list each touched parameter and the forms its schema admits; the acceptance test sends each one as literal params and asserts the same result for all. The transcript of the run is kept atbuild/<n>/acceptance.md, opening with aWire forms:line naming the forms sent.make acceptance-checkfails when atest/acceptance/issue_<n>_test.gochanged and that transcript is absent: no transcript, no check. - CRITICAL - A criterion that did not run blocks the PR. It is not a paragraph in the transcript.
make acceptancerecords the run as ago test -jsonstream atbuild/<n>/acceptance.jsonl, andmake acceptance-checkfails unless everyfunc TestIssue<n>_in each changedtest/acceptance/issue_<n>_test.gohas a terminal pass event in it — absent, skipped and failed are one verdict. When the acceptance upstream cannot be started, the PR waits for the upstream: unit, integration and real-database coverage are never offered in its place, and neither is a section headed "not executed here". #1663 shipped behind exactly that section and 1.131.0 shipped the tool it covered unknown to every server (#1675).make verify-releaseapplies the same rule to every acceptance file changed since the last tag, andmake acceptance ISSUE=<n>records one ticket's run. - CRITICAL - Every tool a ticket registers has a criterion that calls it through the real client. #1277 registered three tools and closed with criteria for two, which is how
graphql_exportreached a release having never been called.make acceptance-checkfails when the diff registers a tool name that no changed acceptance file names. On the running side, the platform compares each toolkit'sTools()list with the tools its MCP server holds afterWireRuntimeand refuses to start on a name it cannot honor, so a dependency wired after registration is a crash at boot rather than a tool listed everywhere and callable nowhere.
- Human Review Required: A human must review and approve every line of code before it is committed. Therefore, commits are always performed by a human, not by Claude.
- Go Report Card: The project MUST always maintain 100% across all categories on Go Report Card. This includes:
- gofmt: All code must be formatted with
gofmt - go vet: No issues from
go vet - gocyclo: All functions must have cyclomatic complexity ≤10
- golint: No lint issues
- ineffassign: No ineffectual assignments
- license: Valid license file present
- misspell: No spelling errors in comments/strings
- gofmt: All code must be formatted with
- Diagrams: Use Mermaid for all diagrams. Never use ASCII art.
- Pinned Dependencies: All external dependencies must be pinned to specific versions with SHA digests for reproducibility and security:
- Docker base images:
alpine:3.21@sha256:... - GitHub Actions:
actions/checkout@sha256:... - Go modules are pinned via
go.sum
- Docker base images:
- Documentation Updates: When modifying documentation in
docs/, also update the LLM-readable files:docs/llms.txt- Index of documentation with brief descriptionsdocs/llms-full.txt- Full documentation content for AI consumption These files follow the llmstxt.org specification.
- CRITICAL - Documentation Completeness:
make doc-checkwarns when documentation-worthy changes (new packages, config changes, new toolkits, new CLI flags, new Makefile targets, new migrations) are present butREADME.md,docs/,docs/llms.txt, anddocs/llms-full.txtwere not updated. While this is a soft warning for human developers, it is a blocking requirement for AI agents: ifmake doc-checkemits a WARNING, you MUST update the relevant documentation before declaring the task complete.
Project Structure
pkg/ holds 43 top-level packages (all public API). Depth-2 subdirectories are
shown where they represent a distinct implementation (a storage backend, an
adapter); helper subpackages are omitted for brevity. Regenerate this list with
find pkg -mindepth 1 -maxdepth 1 -type d | sort and diff against the packages
below when adding or removing a pkg/ directory.
Before adding a package under pkg/, note that TestPublicSurfacePolicy
(#1076) refuses a package that is outside the supported import surface named in
docs/library/stability.md and has a single first-party importer: that shape is
an implementation seam and belongs under internal/.
mcp-data-platform/
├── cmd/mcp-data-platform/ # Entry point (main.go)
├── pkg/ # PUBLIC API (43 top-level packages)
│ ├── admin/ # REST API endpoints for administrative operations
│ ├── audit/ # Audit logging (postgres/ = PostgreSQL implementation)
│ ├── auth/ # Authentication: OIDC, API keys, claims, middleware
│ ├── authevents/ # Durable audit history for the OAuth authorization flow
│ ├── blobserve/ # Raw-content HTTP writer: sanitized type, nosniff, disposition, byte ranges
│ ├── browsersession/ # Browser-based OIDC authentication (cookie sessions)
│ ├── configstore/ # Granular key/value storage for platform config (postgres/)
│ ├── connoauth/ # Shared OAuth-to-upstream-MCP implementation across connection kinds
│ ├── connreconcile/ # Shared remove/add reconcile of a DB connection onto live toolkits (admin hot-reload + reload bus)
│ ├── connid/ # Connection identity: the instance a connection is stored under, the name a call binds it by, the toolkit serving it, and which half of the config owns it — one Resolver, distinct types
│ ├── connview/ # Builds the list_connections view (configured + discovered)
│ ├── contenttype/ # Media-type detection and normalization for every content write path
│ ├── database/ # Database utilities (migrate/ = golang-migrate runner + 176 embedded SQL migrations)
│ ├── embedding/ # Text embedding generation for memory vector search
│ ├── indexjobs/ # Postgres-backed, source-kind-agnostic background indexer
│ ├── knowledge/ # Unified read path for platform knowledge (federation/ = live toolkit registry adapter)
│ ├── mcpcontext/ # Context helpers for MCP session state
│ ├── memory/ # Persistent memory storage for agent/analyst sessions
│ ├── middleware/ # MCP protocol middleware chain (auth, authz, enrichment, audit, rules)
│ ├── notification/ # Email-notification domain: event/preference model, store contracts, enqueue path (smtp/ = admin mail-server settings, validation and store; delivery layers live under internal/notification/) — decomposed by #1080
│ ├── oauth/ # OAuth 2.1 authorization server (postgres/ = storage implementation)
│ ├── observability/ # OpenTelemetry metrics (proxy/ = authenticated PromQL query proxy)
│ ├── oidcdiscovery/ # Shared OIDC discovery-document fetch/parse (used by auth JWKS + oauth broker)
│ ├── persona/ # Persona-based access control and customization
│ ├── pkcestore/ # In-flight PKCE state for outbound OAuth (oauth-start → callback)
│ ├── platform/ # Core orchestration: facade, config, options, lifecycle (fieldcrypt/, instructions/, personastore/ = seams shared with pkg/admin; other facade-internal seams live under internal/platform/)
│ ├── portal/ # Asset portal HTTP surface + aliases over its seams (knowledgepage/, mention/, shareaccess/, shareguest/, threads/, ...)
│ ├── prompt/ # Prompt management: versioned store contract, review gate (attachserve/, postgres/)
│ ├── query/ # Query execution provider abstraction (trino/ = Trino adapter)
│ ├── ratelimit/ # Shared per-IP token-bucket limiter + trusted-proxy client-IP resolver (portal viewer, OAuth endpoints)
│ ├── registry/ # Toolkit registration and management
│ ├── resource/ # Managed resources: human-uploaded reference files
│ ├── script/ # Managed-script domain: record, typed params, version history, edit funnel (engine + MCP surface live under internal/platform/)
│ ├── searchgate/ # Per-session discovery signal for the search-first gate (postgres/ = replica-shared backend)
│ ├── semantic/ # Semantic layer abstraction (datahub/ = DataHub adapter)
│ ├── session/ # Session externalization (postgres/ = multi-replica backend)
│ ├── storage/ # Storage provider abstraction (s3/ = S3 adapter)
│ ├── textpatch/ # Kind-agnostic anchored text editing: outline, locate, patch, unified diff (patchmcp/ = MCP error adapter)
│ ├── toolkit/ # Shared types for toolkit implementations
│ ├── toolkits/ # Toolkit adapters registered with the platform:
│ │ ├── apigateway/ # HTTP API gateway proxy toolkit
│ │ ├── datahub/ # DataHub toolkit
│ │ ├── gateway/ # MCP gateway toolkit (proxies tools from upstream MCP servers)
│ │ ├── graphql/ # GraphQL connection kind: one endpoint, an introspected schema kept per connection, graphql_discover/query/export
│ │ ├── knowledge/ # Knowledge capture toolkit
│ │ ├── memory/ # memory_manage / memory_capture tools
│ │ ├── portal/ # Save/manage-asset toolkit
│ │ ├── s3/ # S3 toolkit
│ │ ├── search/ # Universal, topology-free discovery entry point
│ │ ├── tools/ # toolsindex/ = tools-discovery indexjobs consumer
│ │ └── trino/ # Trino toolkit
│ ├── tuning/ # AI tuning: prompts, hints, operational rules
│ ├── urnbuild/ # Constructs DataHub dataset URNs from query-engine table identifiers
│ └── user/ # Directory of known people keyed by email
├── internal/ # Non-exported implementation (not part of the supported library surface)
│ ├── agentinstructions/ # The deployment's customized agent-instruction layer as a policy rather than a config value (#1607): the byte bound and size advisory both its writers enforce, the config-store adapter it is read and written through, and the `mcp:knowledge_page:<slug>` index-entry form BOTH instruction layers point at a page with
│ ├── admin/ # Admin-API seams built only by pkg/admin: auditapi/ (events + metrics), callapi/ (the call catalog + its review actions), catalogapi/ (OpenAPI spec bundles + embedding jobs), connoauthapi/ (connection OAuth, unified + legacy per-kind), graphqlapi/ (a graphql connection's schema: read the state, re-read it from the endpoint, or take the one an operator pastes for an endpoint that disables introspection), notifyapi/ (notification delivery history + status counts), settingsapi/ (SMTP + review-queue-alert settings REST) — extracted by #1078
│ ├── apigwmetrics/ # The api gateway's outbound HTTP instrumentation as an http.RoundTripper: the connection/status labels, and the persona the call was authorized under, read off the request context the tool call carries (#1615). Holds no gateway types, and was extracted when pkg/toolkits/apigateway reached its package-size budget
│ ├── gqlschema/ # The GraphQL schema machinery the graphql kind is built on: the compatibility-floor introspection query, introspection JSON rendered to SDL, the namespace descent that walks a schema into dotted operation ids, the runnable skeleton and variables stub a caller edits, and what a document is allowed to be (parse, validate, depth, the operations it invokes). Knows nothing about connections or HTTP, which is what makes descent testable against a hand-authored schema
│ ├── opranking/ # The relevance arithmetic both operation-ranking kinds score with: the lexical AND filter, the hybrid blend and its weight, and where a ranked result stops being relevant. Holds no record type — a caller ranks Candidates carrying an opaque id — which is what keeps the OpenAPI operation and the GraphQL operation out of it
│ ├── apigwtls/ # The TLS material an HTTP upstream connection carries: what its mTLS keypair and CA bundle must satisfy, and the *tls.Config its outbound transport is built with. Knows nothing about API connections — it takes the values one carries, including the kind name its refusals speak in — and is reached through internal/upstreamauth (#1626, #1647)
│ ├── upstreamauth/ # What every HTTP-based connection kind does to reach its upstream, in one copy: the Authenticator and its modes (none, bearer, api_key, basic, oauth, mtls), the operator-owned static headers and the header names a model may not claim, the connect/call timeouts and response read cap, and the TLS material. Owns the config keys those rules belong to and validates them; error text is the caller's, through Config.ErrPrefix. Extracted from pkg/toolkits/apigateway so a second kind reuses it instead of forking it (#1647)
│ ├── hmacsig/ # The one definition of a webhook HMAC signature (#1996): the bytes signed (body, timestamp.body, id.timestamp.body), the signature header written and read back (prefix, space-separated signatures, Stripe's t=,v1= format), the Standard Webhooks whsec_ key, and the standard_webhooks/github/stripe/platform presets. Inbound sources verify with it (internal/webhook/whauth) and an outbound auth_mode=hmac connection signs with it (internal/upstreamauth), so the two agree by construction
│ ├── buildinfo/ # The identity of the running binary: the version, commit and build date the release stamps in through ldflags. The one place those live, so --version, the admin system route and the outbound User-Agent report the same build; it imports nothing first-party because the transport seam needs it and cannot import internal/server (#1679)
│ ├── useragent/ # The User-Agent the platform presents to an upstream (`mcp-data-platform/<version>`) and the one rule for when it is sent: on every outbound request that does not already carry one, applied as an http.RoundTripper over every client internal/upstreamauth and pkg/connoauth build. A static_headers or per-call value is already on the request and is left alone (#1679)
│ ├── scratchcatalog/ # The query engine's refusals of the scratch catalog's partition procedures read into the setting that fixes each (#1888): a procedure access control denies the connection's Trino user (add a procedures rule) and register_partition disabled by the catalog (set hive.allow-register-partition-procedure). One copy for the webhook source pre-check and the Trino connection test
│ ├── connprobe/ # Opening one of a toolkit's connections on request and reporting what its upstream said: the Prober a kind implements, the Result an operator reads, and the scrub that keeps a DSN's password out of it. Its own package rather than a corner of pkg/toolkit, which describes what a toolkit reports about a connection WITHOUT being asked (#1805)
│ ├── cfgmap/ # The typed readers over the map[string]any a connection is stored as: the tolerant String/Duration/Int64/Bool/StringMap that absorb what a JSON round-trip did to an operator's value, in one place so two kinds cannot disagree about what `"call_timeout": 30` means (#1647)
│ ├── httpjson/ # RFC 9457 Problem Details responder + admin list-query param parsing, shared by the admin/portal decomposition seams (#1078)
│ ├── httpserver/ # HTTP composition root: mux/route assembly (MCP streamable+SSE, OAuth, admin/portal/resources/gateway/observability REST, portal UI), CORS, drain/shutdown sequencing — extracted from main.go (#895). Subpackages are the adapters it mounts: accessgate/, attachhttp/, datahubapi/, gatewayhttp/, health/, httpauth/, instanceheader/ (the `X-Platform-Instance` response header naming the process that served a request, #1708), mentionhttp/, notifyhttp/ (self-scoped notification prefs), scripthttp/ (managed-script admin + portal routes, including the administrator's owner transfer; its subpackages statehttp/, exclusivehttp/, granthttp/, outputshttp/ and fireshttp/ serve a script's state, whether it runs one at a time (#1986), its run grants (#1846), the outputs of the caller's runs (#1848) and when every visible schedule fires, laid out on the viewer's day, week and three months with each fire expanded by the scheduler's own parse (#1891); draftview/ renders what the draft routes report; flowhttp/ serves a version's flow diagram and its comparison with another version (#1906, #1908), a run drawn on it (#1907) and a script's tile (#1909)), sources/, thumbwire/ (assembles and starts the tile worker from the platform's stores, buckets and the assembled mux, #1787), unsubhttp/ (no-login unsubscribe + its tokens), versionhttp/ (#1076, #1080)
│ ├── sqlgate/ # Collects the module's SQL and hands each statement to a real PostgreSQL to parse and plan (#1512); integration-tagged, so it is absent from the default build
│ ├── sqltables/ # The one lexical extractor of the tables a SQL statement reads (enrichment + call targets)
│ ├── tabletype/ # The one model of a column type a table is declared with or a typed file is written from (#1833): the Trino types, the parse of the type text Trino reports for a query column, the ordered JSON decode, and the type inference a JSON-lines registration and a script's Parquet export share
│ ├── tableparquet/ # Parquet for registered tables (#1833): a file's columns from its footer alone (read by range), the Parquet-to-Trino mapping and its refusals, and the writer trino_export and platform.export write Parquet through (ordered columns, Dremel levels, ZSTD)
│ ├── tablexlsx/ # Excel workbooks a script exports (#1849): the sheet/column/type model and its checks (sheet-name rules, 15-significant-digit limit, exact decimal currency, the cell cap), and the deterministic excelize writer
│ ├── tablecsv/ # CSV inspection and correction for a table registration: the defects a query engine cannot read through, the reason and remedy a refusal names, the corrected version, and the columns a header declares (extracted from tableregister for its size budget)
│ ├── toolnames/ # Does a piece of written guidance name a tool this deployment does not register? Prefixes are derived from the live inventory plus a floor list, so a retired `api_`/`manage_`/`memory_`/`save_` name is caught as readily as a `trino_` one (#1607). Asked by the startup instructions lint and by the apply_knowledge agent_instructions sink
│ ├── thumbtypes/ # The one Go definition of which content families get a tile and which need a second dark one; the browser's counterpart is ui/src/lib/thumbnailSupport.ts and a test holds the two together (#1568)
│ ├── headless/ # The platform's client for the headless Chrome every thumbnail is drawn in (#1787): a hand-written DevTools-protocol client over one WebSocket, and Render, which draws one page in a fresh browser context behind a dead proxy, answers every request the page, its frames and its workers make (its own files in-process, a public URL through internal/egressguard), removes the socket constructors before any script runs, and screenshots it once the page reports itself drawn
│ ├── egressguard/ # The SSRF guard for a fetch whose destination a caller or a document chose: resolve, refuse private/loopback/link-local/CGNAT/metadata addresses, dial the address that was checked. Shared by the util connection and the thumbnail renderer (#1787)
│ ├── pagewalk/ # The api gateway's page walk behind `paginate` (#1535): pagination-signal detection, the address a walk moves (path+query, or the util fetch body url), the follow step, the Retry-After pause, and the loop over a Requester the gateway supplies
│ ├── scriptcallsite/ # Where in a managed script a host call was made (#1907): the line:col of each script frame on the Starlark stack, outermost first, carried on the run's context, on the MCP request's _meta to the audit row (audit_logs.call_site) and on a run output, and read back from a failed run's backtrace. The flow graph records the same positions per card, which is how a run's calls land on the card that made them
│ ├── openrun/ # The refusal a script set to run one at a time answers with (#1986): the open run a new run collides with, the error naming it (id, what started it, since when) that run_script and the portal return, and the words a skipped fire's reason uses. Its own package so pkg/script's public surface does not carry it
│ ├── runstate/ # The vocabulary of a managed-script run's queue history (#1859, #1860): how each attempt ended (finished, retried, released, shed, lease_expired, unresponsive), why a failed run failed (script, upstream, memory, worker_lost, platform, state_conflict) and whether a retry is expected to help, a running run's liveness, the heartbeat window and the reclaim default. Its own package so pkg/script's run record carries it without growing that package's public surface
│ ├── scriptdest/ # Resolves the destination a script names for an output to the address configuration declares; the one resolution the run and validate share
│ ├── upstreamretry/ # The one reading of when an upstream HTTP answer is worth asking again (#1859): 429 any method, 503 to a read, Retry-After in both RFC 9110 forms; the advice the api gateway reports on a result, the host-side wait a script's host makes on it (at most three retries within the deadline), and the upstream_unavailable error code/category. The gateway's page walk pauses by the same Retry-After parse
│ ├── webhook/ # Inbound webhook sources (#1870): whsource (the source record, its validation and its Postgres store with encrypted secrets), whauth (hmac/header_token/basic/path_token verification, secret rotation), whevent (a request's JSON as events, and the gzipped JSON-lines segment), whlayout (where a source's objects live), jsonpath (the path subset a source names its id/type/key/split with), receiver (POST /hooks/{source}: verify, buffer, write the segment, answer 202 only after), whstore (per-window compaction state, request counts, rejections), whtable (the raw and compacted tables and the view, partition registration), compactor (one Parquet file per compaction window into a managed resource, dedup, retention), whadmin (create/update/delete a source with its tables), whconfig (the `webhooks:` section)
│ ├── unarchive/ # The members of a zip, gzip or gzipped tar as streams (#1879): format by magic bytes, zip-slip/encryption/method refusals, the resources.managed.extract limits (member, total, entries, ratio) checked before the first member where the format allows, and a two-block range-read cache so a zip is opened where it is stored. Knows nothing about where members go; resourcewrite.Extractor lands them
│ ├── swagger2/ # A Swagger 2.0 document (JSON or YAML) converted to the OpenAPI 3 the API gateway reads (#2005): the one conversion a catalog spec saved or refreshed as 2.0 and the platform's own admin API document go through
│ ├── formdata/ # The multipart/form-data body encoder the api gateway sends an operation that takes form data through (#1296), extracted from pkg/toolkits/apigateway for its size budget
│ ├── procload/ # How much of the memory and CPU the container allows this process it is using now: Go runtime memory against the cgroup limit or GOMEMLIMIT, getrusage CPU over a one-second window against the cgroup quota or GOMAXPROCS, and "unknown" where either cannot be read. The managed-script run worker's adaptive admission reads it before every claim (#1843)
│ ├── resourcetemplates/ # The three read-only MCP resource templates (schema://, glossary://, availability://) and the URI patterns they are addressed by, which the completion layer also matches on. Answers from the two providers and the URN mapping alone and writes nothing, which is why it needed no part of the platform facade; extracted from pkg/platform for its size budget (#1628)
│ ├── storeresync/ # A replica's live connections and personas made to match the database: the reload bus's peer handlers (a delete without a store read, an upsert that reads and decides, a catalog rebuild) and the full re-read the bus runs when its LISTEN connection comes back, since a notification sent while it was down is lost (#1902)
│ ├── listenbridge/ # Delivers the broadcaster's list_changed events to the `subscriptions/listen` streams 2026-07-28 clients hold on this replica, stamped with each stream's subscription id; records listens from the SDK's acknowledgement in a sending middleware and leaves a gateway tool change to the SDK's own notify (#1967)
│ ├── pglisten/ # Shared LISTEN adapter: one goroutine per pg_notify channel waking the workers registered on it (notification delivery, managed-script runs)
│ ├── notification/ # Notification delivery layers built only by internal/platform/notifydelivery, extracted by #1080: notifyprefs/ (preference persistence), notifyqueue/ (queue persistence + LISTEN wakeup), notifyrender/ (branded templates), notifysend/ (SMTP transport), notifyworker/ (send worker)
│ ├── platform/ # Facade-internal seams composed only by pkg/platform (mwchain, iam, sessionsync, oauthserver, auditwiring (the audit store + delivery writer + call-record decorator + provenance capturer, assembled in one place), callrecord (the call catalog: records, derived outcomes, reuse, promotion), the indexjobs consumers (including datasetindex, the catalog-dataset semantic index, and scriptindex, the managed-script one), mcpapps, connbackfill, reviewalert, the managed-script seams scriptlayer/scriptrun/scriptsession/scriptstore/scriptexec/scriptdraft/scriptauto/scriptadmit/scriptlex (authoring tools, engine, the in-memory MCP session a run's calls go through and the refusal it reads off a failed result, Postgres stores, run worker + script principal + output writer, the one draft-run implementation the `manage_script` tool and the portal editor share, the automatic approval of a personal script for its own owner, how many runs a replica executes at once and the `scripts.worker` capacity settings (#1843), and the lexical source checks `validate` runs over code with strings and comments blanked (#1853)), scriptlint + scriptfmt + scriptexamples (the authoring gates every save of a script's source passes through -- the canonical format, the main() entry point, the structural lint and limits, refusing a script saved before them only for what an edit adds -- and the built-in worked scripts held to them, #1913), scriptrec (every run's and draft's host calls with the answers they were given, and the replay a test and a save are answered from; recstore/ is its Postgres store, #1939), scripttest (a script's test_* functions: the testing and assert modules, statement coverage, and the altered-rows check that refuses a test blind to its data, #1939, #1940), scriptbehavior (what a new version does differently: the replay comparison of recent runs and the reach diff, #1942), scriptsave (the one gate a source save crosses from the tool and the portal: lint, tests, coverage, and a behavior change needing an agreed summary), scriptsql (platform.query's parameter binding), scriptcontract (the dialect contract help returns), scriptout (the output serializers platform.export writes through: rows, documents, workbooks, the append=True spool that pages rows into one output (#1861), and the tags=/metadata= reader, #1848/#1849; exportrecord/ is what one export call did and the dict the script is handed back), scriptguard (what stops a run apart from its own logic and what that is recorded as: the per-run memory budget measured over the Starlark values a run can reach at every host call, and the failure cause read from the error's type, #1859/#1861), scriptgrant (who other than the owner may run a script, and the binding of a caller.<claim> parameter from the caller's claims, #1846), scriptflow (the Flow diagram derived from a script's source, #1906; flowcompare/ marks one version's graph against an older one, #1908, and flowrun/ draws a run on it from its audited calls and outputs, #1907), scripttiles (the script_tiles store the tile worker claims a script's flow tile through, and the reader that serves it, #1909), thumbworker (the tile worker: claims the assets, resources, collections and scripts owed a tile, draws each through internal/headless, records the tile or the reason it could not be drawn; also owns the `thumbnails:` config section), connreach (the one connection enumeration a picker is filled from and an automatic approval is checked against), the graphql kind's seams graphqlwiring/graphqlstore/graphqlindex (the dependency attachment and first schema read, the Postgres schema store + vector reader, and the indexjobs consumer that embeds a connection's operations), apikeystore, retention (the daily sweeps over deleted portal items, archived memory, orphaned producer records and superseded GraphQL embeddings, each under its own advisory lock, #1904; it also runs assetbucket, the pass that names the portal bucket on asset and version rows an early release wrote with none, ahead of the purge, #1931), ... — moved out of the public surface by #894 and #1076)
│ ├── portal/ # Portal seams built only by pkg/portal, extracted by #1121: callapi/ (the caller's own call catalog), portaldomain/ (domain types, store contracts, validation, and BuildShare — the one share constructor, also called by the asset toolkit's share action; aliased back so portal.Asset etc. are unchanged), portalstore/ (PostgreSQL asset/share/collection stores + ranked search), portalversions/ (version history store), contenturl/ (the expiring signed URL that reads one asset version without a session, #1848), portalnoop/ (no-database stores), access/ (the authorization core + the User principal), feedbackapi/ (threads, activity, worklists, sign-off, validation, capture-as-insight), assetrefs/ + assetrefstore/ (the managed resources an asset's content references: the URL, the serve-time rewrite, the serving route, the declaration check, and their Postgres store), contentrefs/ (the lexical reading of a document body for references: the ones it names, the ones its asset does not declare, and the ones it uses as a link target, which a write refuses, #1875), plus portalpurge/ (the hard purge of soft-deleted assets, collections, threads and knowledge pages past portal.deleted_retention_days, objects first, #1904), publicviewer/ (embedded public share templates + CSP), viewerlimit/, sharecache/
│ └── server/ # Server factory (server.go)
├── configs/ # Example configurations
│ └── platform.yaml
├── go.mod
├── LICENSE
└── README.mdKey Dependencies
github.com/modelcontextprotocol/go-sdk- Official MCP SDK for Go (same as txn2 MCP ecosystem)github.com/txn2/mcp-trino- Trino MCP toolkitgithub.com/txn2/mcp-datahub- DataHub MCP toolkitgithub.com/txn2/mcp-s3- S3 MCP toolkitgolang.org/x/crypto- Cryptographic utilities (bcrypt for OAuth)gopkg.in/yaml.v3- YAML configuration parsing
Building and Running
# Build
go build -o mcp-data-platform ./cmd/mcp-data-platform
# Run with stdio transport (default)
./mcp-data-platform
# Run with config file
./mcp-data-platform --config configs/platform.yaml
# Run with HTTP transport (serves both SSE and Streamable HTTP)
./mcp-data-platform --transport http --address :8080Configuration Reference
Configuration is loaded from YAML with environment variable expansion (${VAR_NAME}).
Server Configuration
server:
name: mcp-data-platform
transport: stdio # stdio, http
address: ":8080"Authentication
auth:
oidc:
enabled: true
issuer: "https://auth.example.com/realms/platform"
client_id: "mcp-data-platform"
audience: "mcp-data-platform"
role_claim_path: "realm_access.roles"
role_prefix: "dp_"
api_keys:
enabled: true
keys:
- key: "${API_KEY_ADMIN}"
name: "admin"
roles: ["admin"]Personas
personas:
analyst:
display_name: "Data Analyst"
roles: ["analyst", "data_engineer"]
tools:
# Prefer "*" with a targeted deny. An enumerated allow-list silently
# loses every tool a later upgrade adds, and it drops the tools others
# depend on: the search-first gate refuses trino_query until "search" is
# called, and "fetch" is the only tool that dereferences a search result's
# reference. See docs/personas/overview.md#some-tools-are-a-unit.
allow: ["*"]
deny: ["*_delete_*"]
connections:
allow: ["*"]
context:
description_prefix: "You are helping a data analyst."
admin:
display_name: "Administrator"
roles: ["admin"]
tools:
allow: ["*"]
connections:
allow: ["*"]PersonasConfig.Definitions is an inline map (pkg/platform/config.go), so
persona names go directly under personas: — not under a definitions: key.
Connections are deny-by-default (pkg/persona/filter.go), so every persona
needs its own connections: block; personas.default_persona was removed and
a config that still sets it is refused at startup (pkg/platform/config.go).
Semantic Layer
semantic:
provider: datahub
instance: primary
cache:
enabled: true
ttl: 5m
enrichment:
trino_semantic_enrichment: true
datahub_query_enrichment: true
unwrap_json: true # Auto-unwrap single-row VARCHAR-of-JSON results (default: true)
column_context_filtering: true # Only enrich columns referenced in SQL (default: true)
semantic_fallback: false # Issue #444: fall back to similarity search on URN miss (default: false)
semantic_fallback_top_k: 1 # Suggested matches per URN miss (default: 1, clamped to [1,10])Managed Resources
resources:
managed:
enabled: true # auto-enabled when database is available; set false to disable
uri_scheme: "mcp" # URI prefix for resource URIs (default: "mcp")
s3_connection: "primary" # name of S3 toolkit instance for blob storage
s3_bucket: "resources" # S3 bucket for uploaded files
extract: # manage_resource extract limits (#1879); independent of max_upload_bytes
max_member_bytes: 2147483648 # default 2 GiB
max_total_bytes: 4294967296 # default 4 GiB
max_members: 10000
max_ratio: 500Export to Asset
portal:
export:
enabled: true # auto-enabled when portal + trino are configured
max_rows: 100000 # hard row cap per export
max_bytes: 104857600 # hard byte cap (100 MB)
default_timeout: "5m" # default query timeout
max_timeout: "10m" # maximum allowed timeoutAudit Logging
Both enabled and log_tool_calls are *bool defaulting to on when a database is available; with no audit: block a DB-backed deployment logs tool calls out of the box. Set enabled: false to disable audit entirely, or log_tool_calls: false to keep audit on but skip per-tool-call rows.
audit:
enabled: false # opt out of audit logging
log_tool_calls: false # keep audit on but skip per-tool-call rows
retention_days: 90
database:
dsn: "${DATABASE_URL}"Email Notifications
Enabled by default when a database is available (*bool, nil = enabled). The
YAML controls only enqueue/delivery; SMTP host/credentials are admin-configured
at runtime (portal Admin > Settings or /api/v1/admin/settings/smtp,
password encrypted via FieldEncryptor, write-only in the API).
notifications:
enabled: false # opt out of email notifications
digest_hour_utc: 13 # UTC hour (0-23) daily digests are sentCall Catalog
Nothing here turns the catalog on: it is written from the audit pipeline and exists wherever audit does. What a deployment chooses is how long a call that came to nothing is kept, and whose calls are worth keeping at all. A record an asset or a capture cites, one that was promoted or declined, and one another session re-ran are evidence and are never swept, whatever their age.
calls:
retention_days: 90 # how long an UNUSED call record is kept (default 90)
exclude_personas: # personas whose calls are machinery: audited, not cataloged
- ingest-serviceAn automated system driving ingestion through the same tools people use writes
a record per fetch that nobody will re-run, and every one of them is embedded
(#1614). Naming its persona stops the record being written, and sweeps the ones
written before it was named, evidence clauses intact, and withholds the
mcp:call:<id> reference such a call would otherwise be told to cite. The audit
row, its retention and the API gateway's metrics are untouched, so what an
automated system did stays fully visible. Persona is the discriminator because
it is the layer an operator already assigns per API key. Empty catalogs every
call.
The same rule is a setting on the persona itself (#1980): service_account: true
in a file persona, the persona_definitions.service_account column for a
database one, and the "Service account" checkbox in the portal persona editor.
calls.exclude_personas stays as its file-config form and both apply. The
exclusion reads the live persona registry (callrecord.ServiceAccounts) on
every call and sweep, never a startup snapshot, and saving a persona marked
through the admin API asks the catalog for a sweep at once
(PostgresStore.RequestSweep). The sweep deletes in batches of 5,000, each its
own statement, and deletes the removed records' index_jobs units of kind
calls in the same statement. The admin Indexing page lists the Top callers
(GET /api/v1/admin/calls/top-callers, counts cached five minutes) so an
operator can see one automated caller holding most of the catalog.
A managed script run's calls are not cataloged either, and that one takes no
knob (#1624). The scheduler is the automated system, a run is by construction
the re-run, and a run presents its author's persona, so exclude_personas
cannot name it: the rule is keyed on the audit event's source being script.
The calls are audited in full, the run is handed no mcp:call:<id> reference,
and the sweep's third arm (user_id LIKE 'script:%') clears the rows written
before this existed. A person's call in the same persona is cataloged as
before.
Managed Scripts
The portal names this section Automations (/portal/automations and /portal/admin/automations; the old /portal/scripts paths redirect with the rest of the path intact, #1912). A script is the one kind of automation that exists: the MCP tools, the REST API under /api/v1/*/scripts, mcp:script: references, script: principals, tables, metrics and config keys keep the script name.
Authoring needs no configuration and is available wherever there is a database.
A saved script runs: run_script and a schedule execute the latest saved
version, presenting the roles its author held at the save, and the persona
filter authorizes every call at run time. A script is personal: its owner sees
it, edits it, runs it, and schedules it, administrators do all four on every
script, and an administrator can move a script to another owner (which
re-captures the run identity from the administrator making the move). Its
definition -- source and version history, without the authors' roles -- is
readable by everyone signed in (#1866); acting on it and reading its runs stay
the owner's and an administrator's. The knobs
are how long the record of a run is kept, whether this replica executes runs at
all, and which bucket destinations a script's output may be delivered to.
scripts:
run_retention_days: 365 # how long a FINISHED run is kept (default 365)
worker:
enabled: false # this replica enqueues runs but never claims them
concurrency: adaptive # default; claims while memory/CPU have headroom; a number fixes it, 1 is serial
run_timeout: 15m # wall-clock cap for one platform run (lease = timeout + 5m)
max_run_memory: 50% # default; what one run may hold: a size, a share of the memory limit, or unlimited
max_reclaims: 2 # default; take-overs from a dead worker before the run is failed
destinations: # named bucket destinations platform.export may write to
- name: acme-drop
connection: acme-s3
bucket: acme-exports
prefix: weeklyA script carries one JSON object of state between runs (run.state in,
platform.save_state out, 64 KiB): applied when the run succeeds, in the
transaction that marks it so, under a compare-and-set on the revision the run
read at creation; a failed run leaves it alone, the loser of two runs that read
one revision fails naming the winner, and the owner or an administrator resets
it with manage_script command=state or on the script's page.
A run still pending or running is never swept. The default is far longer than
the notification queue's because a scheduled script's run history is its refresh
history — product surface, not queue residue. worker.concurrency is adaptive
by default (#1843): a replica claims another run only while its memory and CPU
are under max_memory_percent/max_cpu_percent of the container's limits,
between min_concurrency and max_concurrency, and stops and requeues its
newest run past shed_memory_percent, failing the run instead when it is the
only one executing (#1861); see docs/scripts/running.md. A run is measured at
every host call -- walked whenever the process's heap growth since the last
walk could cross the budget, and once more when it ends (#1867) -- and fails
with cause memory past max_run_memory; a run whose
worker died is taken over at most max_reclaims times, then failed with cause
worker_lost (#1860). A failed run records its cause (script, upstream,
memory, worker_lost, platform, state_conflict) and whether it is
retryable; the platform never re-executes a run on its own (#1859).
worker.enabled is a *bool
defaulting to on: one process serves and executes unless a deployment splits
them, and a worker-off replica still registers run_script, enqueues, and waits
on the result a worker deployment produces. A destination is resolved by name at
run time, so repointing one here takes effect on the next run; the portal is
built in and never declared. See docs/scripts/running.md and
docs/scripts/security.md.
Thumbnails
The platform draws every asset, resource and collection tile itself, in a headless Chrome (chromedp/headless-shell, pinned by digest) that runs as a second container in the platform's pod (#1787). Enabled by default (*bool); the default renderer address is the container beside it, so a deployment sets nothing.
thumbnails:
enabled: false # opt out; stored tiles keep serving
renderer_url: "http://127.0.0.1:9222" # defaultThe platform dials the renderer and answers every request a page makes (its own routes in-process, public URLs through internal/egressguard); the renderer is never given an address to call. With no renderer answering, tiles keep their content-type icons. A document that cannot be drawn is recorded (thumbnail_failure) and held until it changes or its owner clears the tile. Every claim charges an attempt (thumbnail_attempts); an attempt that does not finish (renderer gone mid-render, stored file unreadable) holds the row back with backoff and, at max_attempts, records it as not drawable (#1868). Pages load with their animation timeline stopped and are settled before capture. concurrency, render_timeout, batch, lease, poll, max_attempts and retry_backoff pace the worker. make dev runs the renderer as the renderer service in dev/docker-compose.yml.
Progress, Client Logging, Icons & Elicitation
All four are enabled by default (*bool field, nil = enabled); set enabled: false to opt out. No block is needed to turn them on.
progress:
enabled: false # opt out of Trino query progress notifications
client_logging:
enabled: false # opt out of server-to-client log messages
icons:
enabled: false # opt out of icon injection middleware
elicitation:
enabled: false # opt out of all elicitation (also disables the two below)
cost_estimation:
enabled: false # opt out of pre-query cost-estimation prompts
row_threshold: 1000000
pii_consent:
enabled: false # opt out of PII-access consent promptsElicitation is user-facing: with no config at all, cost-estimation and PII-consent prompts fire out of the box (cost_estimation still respects row_threshold, so it only prompts above 1M estimated rows).
Core Interfaces
SemanticMetadataProvider
type Provider interface {
Name() string
GetTableContext(ctx context.Context, table TableIdentifier) (*TableContext, error)
GetColumnContext(ctx context.Context, column ColumnIdentifier) (*ColumnContext, error)
GetColumnsContext(ctx context.Context, table TableIdentifier) (map[string]*ColumnContext, error)
GetLineage(ctx context.Context, table TableIdentifier, direction LineageDirection, maxDepth int) (*LineageInfo, error)
GetGlossaryTerm(ctx context.Context, urn string) (*GlossaryTerm, error)
SearchTables(ctx context.Context, filter SearchFilter) ([]TableSearchResult, error)
Close() error
}QueryExecutionProvider
type Provider interface {
Name() string
ResolveTable(ctx context.Context, urn string) (*TableIdentifier, error)
GetTableAvailability(ctx context.Context, urn string) (*TableAvailability, error)
GetQueryExamples(ctx context.Context, urn string) ([]QueryExample, error)
GetExecutionContext(ctx context.Context, urns []string) (*ExecutionContext, error)
GetTableSchema(ctx context.Context, table TableIdentifier) (*TableSchema, error)
Close() error
}Resource Store
type Store interface {
Insert(ctx context.Context, r Resource) error
Get(ctx context.Context, id string) (*Resource, error)
GetByURI(ctx context.Context, uri string) (*Resource, error)
List(ctx context.Context, filter Filter) ([]Resource, int, error)
Update(ctx context.Context, id string, u Update) error
Delete(ctx context.Context, id string) error
}Toolkit Interface
type Toolkit interface {
Kind() string
Name() string
RegisterTools(server *mcp.Server)
Tools() []string
SetSemanticProvider(provider semantic.Provider)
SetQueryProvider(provider query.Provider)
Close() error
}MCP Protocol Middleware
Request processing flows through MCP protocol-level middleware registered via server.AddReceivingMiddleware().
IMPORTANT: AddReceivingMiddleware wraps the current handler — each call makes the new middleware the outermost layer. The LAST middleware added runs FIRST. In finalizeSetup(), middleware is added innermost-first:
Execution order (outermost to innermost):
0. MCPResultTypeMiddleware - Outermost: types every tools/call, prompts/get and resources/read result with the resultType the negotiated protocol revision requires (#1382, #1383). The SDK stamps only the result its own handler returns; a gate's refusal, the error contract's rebuild and the managed resource read are built by the layers below and are typed here. The list decorators (icons, descriptions, visibility, session-handle and purpose schemas, MCPOutputSchemaMiddleware opening every advertised output schema to the platform's keys (#1381)) sit between it and MCPAppsMetadataMiddleware.
- MCPAppsMetadataMiddleware - Injects
_meta.uiinto tools/list responses - MCPToolCallMiddleware - Authenticates user, authorizes tool access, creates PlatformContext
- MCPWorkflowGateMiddleware - Search-first hard gate (#787): refuses query tools until
searchis called in the session, short-circuiting with aSEARCH_REQUIREDerror before the handler runs. Default-on; disabled byworkflow.require_search: false. - MCPAuditMiddleware - Logs tool calls asynchronously (reads PlatformContext from ctx)
- MCPSemanticEnrichmentMiddleware - Adds cross-service context to results
All middleware intercepts tools/call requests at the MCP protocol level. MCPToolCallMiddleware must be outer to MCPAuditMiddleware so that PlatformContext (set via context.WithValue) is present in the ctx that MCPAuditMiddleware receives. MCPWorkflowGateMiddleware is inner to MCPToolCallMiddleware (needs PlatformContext and the recorded tool call) and outer to Audit/enrichment so a gated call never reaches them, mirroring the session gate.
Testing
# Run all tests with race detection
go test -race ./...
# Run linter
golangci-lint run ./...
# Run security scan
gosec ./...
# Run specific package tests
go test -race ./pkg/platform/...
# Run dead code analysis (informational)
make dead-code
# Run mutation testing (informational)
make mutateAI Verification Requirements
When AI (Claude Code or similar) contributes code, the following additional checks apply:
- No Tautological Tests: Tests must verify behavior, not struct field assignment. A test that sets
x.Field = "value"then assertsx.Field == "value"tests the Go compiler, not the application. Delete such tests on sight. - Integration Tests for Multi-Component Features: Unit tests alone are insufficient for features that span middleware chains, provider pipelines, or context propagation. Require an integration test that wires up the real assembled system (e.g.,
mcp.Server+AddReceivingMiddleware+ in-memory transport + realCallTool). - Mutation Survival Review: After adding tests, run
make mutateon the affected packages. Surviving mutants in security-critical paths (auth, audit, encryption) must be addressed with targeted tests. Informational mutants in logging or formatting may be deferred. - Dead Code Audit: Run
make dead-codebefore submitting. Functions reported as dead should be either deleted or moved to test files. Public API functions may be false positives (library exports) and can be ignored with justification. No Vaporware: Every database migration table must have corresponding DML (INSERT/SELECT/UPDATE/DELETE) in non-test Go source code. Every Go package under
pkg/must be imported by at least one non-test file. Every interface with a noop implementation must also have a real (non-noop) implementation. These invariants are enforced by three tests:TestMigrationTablesHaveConsumers(pkg/database/migrate/) — no orphaned migration tablesTestNoDeadPackages(test/structure/verify_test.go) — no unimported packagesTestNoopOnlyInterfaces(test/structure/verify_test.go) — no interfaces where the only implementation is a noop
Do not create migrations, packages, or interfaces "for future use" — code that isn't wired into the running application is dead code regardless of whether it has its own unit tests.
The Noop Loophole: A noop implementation satisfies compile checks, passes tests (returns nil), gets imported (not dead), and wires into the platform — yet does nothing. This is the most insidious form of vaporware because every automated gate reports green.
TestNoopOnlyInterfacescloses this loophole by requiring that any interface with a noop also has a real implementation that performs actual work.Dependency-First Verification: Before implementing features that depend on external system capabilities (writing to DataHub, calling a third-party API, etc.), VERIFY that the dependency actually supports the required operations. If the upstream library lacks the needed functionality, that gap must be surfaced IMMEDIATELY — do not build scaffolding (handlers, stores, migrations, admin APIs) around a capability that doesn't exist. The correct order is:
- Verify the external dependency supports the required operations
- Implement or extend the client for those operations
- Build the feature on top of the working client
Building top-down from handlers to stores to admin APIs while leaving the actual external integration as a noop is prohibited. If the external system can't do what the feature requires, stop and report the gap instead of building theater around it.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

