- TypeScript 82.9%
- Shell 12.3%
- Python 2.8%
- JavaScript 1.5%
- Dockerfile 0.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo/workflows | ||
| release | ||
| scripts | ||
| src | ||
| test | ||
| .dockerignore | ||
| .gitignore | ||
| .npmrc | ||
| .secretlintignore | ||
| .secretlintrc.json | ||
| AGENTS.md | ||
| CONTRIBUTING.md | ||
| Dockerfile | ||
| eslint.config.js | ||
| LICENSE | ||
| NOTICE | ||
| package.json | ||
| pnpm-lock.yaml | ||
| README.md | ||
| SECURITY.md | ||
| SUPPORT.md | ||
| tsconfig.json | ||
| tsconfig.test.json | ||
xtrape-exposure
xtrape-exposure is the AI-facing Xtrape Exposure product (Interaction Layer). It owns the AI Tool catalog/projection over Xtrape-managed Exposure Tasks and executable Action Bindings; the Platform (canonical implementation identity xtrape-platform; current physical repositories xtrape-server / xtrape-platform-ce, per xtrape-docs reference/01-migration-map.md) owns Checkpoint exposure eligibility, authorization, invocation, and audit.
Repository migration (xtrape-exposure#7): this repository was renamed
xtrape-mcp → xtrape-exposure(physical product/repository migration; 2026-07-25). MCP is preserved as the first protocol projection under Xtrape Exposure — MCP protocol method/tool/resource/prompt names are not renamed. The MCP protocol/session adapter (a Device Instance that serializes the Tool catalog issued by Xtrape Exposure) continues to be referred to asxtrape-mcpin the canonical architecture docs; whether that adapter/component identity is also renamed or retained as an internal component is a separate architecture decision (see xtrape-exposure#7).
The current implementation scope is that first MCP protocol projection, described below.
The canonical term is Exposure Task. Task may be used as shorthand only inside the exposure context; Forge Task and Studio Task remain separate product/runtime objects.
Exposure Task
+-- Skill reference
+-- Task Template(s)
+-- Action Binding(s)
`-- Protocol Projection(s)
Action Binding
-> Service + Capability + Action
-> admitted Checkpoint version
-> governed Invocation
xtrape-mcp is responsible for:
- MCP transport and protocol-session handling;
- client-capability negotiation;
- projection of executable Action Bindings to MCP Tools;
- bounded projection of Skill and Task Template material through Tool schemas, descriptions, annotations, or documented Tool sets;
- translation of Tool calls to Platform-governed invocations;
- protocol-safe result, error, progress, approval, and reauthentication projection.
The initial implementation scope is Tool discovery and Tool invocation. MCP Prompts, Resources, and Resource Templates remain deferred until their enumeration, metadata-disclosure, read-authorization, result-access, and data-flow semantics are explicitly designed and approved.
A generic client is not assumed to understand an Xtrape-specific Exposure Task registry. Baseline behavior must use approved standard MCP discovery surfaces; an optional versioned extension may provide richer metadata only to clients that explicitly support it.
xtrape-mcp does not own canonical Exposure Task, Skill, Task Template, Action, Checkpoint, exposure, authorization, routing, or audit state. It also does not guarantee interception of calls made outside the Xtrape-managed invocation path.
CE, EE, and Cloud must share the same protocol mapping, identity rules, and safe fallback behavior rather than fork incompatible MCP adapters.
Canonical documentation (published on the xtrape-docs main baseline; 0.8.0 published 2026-07-26):
xtrape-docs/docs/concepts/08-exposure-task-model.mdxtrape-docs/docs/products/mcp/00-overview.mdxtrape-docs/docs/reference/00-terminology.md
Implementation status
The repository implements the stateless Streamable HTTP MCP endpoint and the tools/list
projection (issue #14) on top of the engineering skeleton (issue #13). A local MCP client that
presents an Account Token gets back the Checkpoints the Platform says that caller may see,
projected as Tools.
Implemented: POST /mcp (initialize, notifications/initialized, ping, tools/list,
tools/call), and the
OAuth 2.1 resource server discovery surface (RFC 9728 metadata and the WWW-Authenticate
challenge that names it), which stays unpublished until an operator configures both a public URL
and an authorization server (see below).
Not implemented, deliberately: Prompts, Resources, an OAuth
authorization server and its code flow (see below — a caller presents an Account Token minted
out of band), TLS, public reachability, approval/reauthentication flows, and any caching of
discovery results.
Protocol version
The endpoint pins MCP 2025-11-25, not the newer revision that removes the handshake and the
session header — measured grounds, not preference: no shipping end-user client implements the
newer revision, and the specification's own compatibility matrix rules legacy-client x
modern-server a failure with no fall-forward path for the client.
The implementation is nevertheless stateless. The handshake and Mcp-Session-Id are accepted
and answered, and nothing depends on either: there is no per-session store, initialize computes
a constant, tools/list is answered identically with or without a preceding handshake, an inbound
session id is echoed but never read, and everything the answer depends on is re-derived from the
credential presented on that request. Moving to the newer revision is therefore a deletion, not a
rewrite. The reasoning and the individual guarantees are in src/protocol/mcp/handler.ts.
Tool naming
A Tool name is serviceId + the Checkpoint's dotted path, with a leading segment that already
names the Service elided rather than doubled. Identifiers are validated, never transformed —
case is preserved and a non-conforming identifier is excluded rather than rewritten, so a name
always maps back to the exact Checkpoint.
A name is a projection identity, never an authorization identity. Each Tool carries its full
serviceId + checkpointId + checkpointVersion in _meta so nothing has to parse the name to
recover the identity, and the invocation milestone must resolve names through the registry and let
the Platform re-decide authorization.
Room is left for version-qualified aliases: a v<digit> leading segment is reserved and refused
as a canonical name, and two admitted versions of one canonical name currently fail closed (both
excluded) rather than being silently resolved to one.
The input schema gap
The Platform's discovery projection carries inputSchema as a content-addressed SchemaRef
digest, and this adapter does not resolve it. Rather than invent a schema, each Tool is
projected with the weakest true statement available — {"type":"object"}, unconstrained rather
than empty — and the digest is carried in _meta so the binding survives.
The Platform side is not the gap: platform-ce#169 shipped schema-record storage and a
session-scoped GET /v1/access-sessions/{id}/schema-records/{digest}. What remains is this
adapter fetching those bytes and projecting them.
Xtrape Exposure verifies but does not decide: it authenticates its own callers (token
validation and audience verification are its job) and refers every authorization decision back
to the Platform. It never forwards a client's token downstream. See AGENTS.md for the full set
of red lines before changing anything here.
Installing dependencies
Requires Node 24 and pnpm 10.
The one production dependency, @xtrape/interaction, is published on the public npm registry.
.npmrc in this repository maps the @xtrape scope to https://registry.npmjs.org/, so a plain
pnpm install resolves it anonymously — no credential, no per-command flag:
pnpm install --frozen-lockfile
The container image builds the same way: docker build . needs no secret. A maintainer build may
additionally mount an internal-mirror credential as an optional BuildKit secret (see Dockerfile);
when it is absent that step is skipped. No token is ever stored in the repository.
Running it locally
pnpm install
pnpm lint && pnpm typecheck && pnpm build && pnpm test
XTRAPE_EXPOSURE_PLATFORM_URL=https://platform.example.test \
XTRAPE_EXPOSURE_WORKLOAD_TOKEN=local-dev-token-value \
XTRAPE_EXPOSURE_SERVICE_SELECTION=example-service \
XTRAPE_EXPOSURE_HTTP_HOST=127.0.0.1 \
XTRAPE_EXPOSURE_HTTP_PORT=8080 \
XTRAPE_EXPOSURE_MCP_PORT=8081 \
node dist/index.js
curl http://127.0.0.1:8080/health
# {"status":"ok","time":"..."}
npx @modelcontextprotocol/inspector --cli http://127.0.0.1:8081/mcp \
--transport http --method tools/list \
--header "Authorization: Bearer <Account Token>"
The integration test runs against a real Platform and is skipped unless one is named:
XTRAPE_E2E_PLATFORM_URL=http://127.0.0.1:18300 \
XTRAPE_E2E_ACCOUNT_TOKEN=... \
XTRAPE_E2E_WORKLOAD_TOKEN=... \
XTRAPE_E2E_SERVICES=example-service \
pnpm vitest run test/integration
Or as a container.
The build resolves @xtrape/interaction from the public npm registry, like a local install, so it
needs no credential:
docker build -t xtrape-exposure:dev .
docker run --rm -p 8080:8080 -p 8081:8081 \
-e XTRAPE_EXPOSURE_PLATFORM_URL=https://platform.example.test \
-e XTRAPE_EXPOSURE_WORKLOAD_TOKEN=local-dev-token-value \
-e XTRAPE_EXPOSURE_SERVICE_SELECTION=example-service \
xtrape-exposure:dev
The image carries no .npmrc and no token, and the final stage runs as the non-root
xtrape-exposure user. A Compose consumer builds it the same way, with no build.secrets.
Optional, maintainers only: a build that should also reach an internal npm mirror may mount a
credential as a BuildKit secret — --secret id=xtrape_npm_token,env=XTRAPE_NPM_TOKEN — never a
build ARG (an ARG is recorded in image history). The Dockerfile writes it only when the secret is
present and removes it in the same RUN; when it is absent that step is skipped. Resolution still
goes to npmjs either way.
Configuration
All configuration comes from the environment. Credentials are read from the environment only
— never from a file, and a ..._FILE indirection is rejected rather than silently ignored.
Startup validation is complete and fail-closed: a missing or malformed value exits non-zero
before any listener is opened, reporting every problem in one pass.
| Variable | Required | Default | Meaning |
|---|---|---|---|
XTRAPE_EXPOSURE_PLATFORM_URL |
yes | — | Platform base address (http/https). No embedded credentials, no query string, no fragment. A non-root base path is supported and is normalized to a trailing slash. Every authorization decision is deferred here. |
XTRAPE_EXPOSURE_WORKLOAD_TOKEN |
yes | — | This process's own credential to the Platform. At least 8 characters, so that log redaction can always remove it. Never forwarded downstream. |
XTRAPE_EXPOSURE_SERVICE_SELECTION |
yes | — | Comma-separated Service ids: the deployment's upper bound, every Service this deployment is willing to expose at all. A caller's per-request ?s= narrows inside it; see Service Selection below. No default on purpose: this product names no Service, Widget or Tool in its own source, so the reachable surface is an operator's decision, not the binary's. The Account Token's own allowedServices still applies on top. Ids must be logical Service ids (lowercase kebab); a malformed one fails startup. |
XTRAPE_EXPOSURE_HTTP_HOST |
no | 0.0.0.0 |
Listen address, shared by both listeners. |
XTRAPE_EXPOSURE_HTTP_PORT |
no | 8080 |
Health endpoint port (operator plane). |
XTRAPE_EXPOSURE_MCP_PORT |
no | 8081 |
MCP endpoint port (AI-facing plane). Must differ from the health port. |
XTRAPE_EXPOSURE_LOG_LEVEL |
no | info |
debug | info | warn | error. |
XTRAPE_EXPOSURE_INVOCATION_WAIT_MS |
no | 10000 |
Bounded wait for a tool call whose Platform outcome is non-terminal — DISPATCHED (the Platform handed the call to a Service on its command wire) or PENDING_* (a control must be satisfied first). The adapter re-reads the same invocation by id through the Platform's generic invocation read (never by naming a tool) every 500 ms until it settles or the budget ends, then answers with the current status. The budget is a hard bound: no nap or read starts past it, and each read is given only the budget that is left as its own timeout. 0 answers immediately. A non-terminal answer is not a tool error; only FAILED is. |
XTRAPE_EXPOSURE_PUBLIC_URL |
required for OAuth discovery | none | Publicly reachable base URL of this MCP endpoint, published as the OAuth canonical resource identifier. Unset, discovery metadata is refused to every caller but a loopback one; it is never derived from Host or X-Forwarded-*. May carry a path for a prefixed deployment. No fragment or query. |
XTRAPE_EXPOSURE_OAUTH_AUTHORIZATION_SERVERS |
required for OAuth discovery | none | Comma-separated issuer URLs published as authorization_servers. Unset today, because Xtrape has no authorization server yet — and with none configured no discovery metadata is published at all. See below. |
XTRAPE_EXPOSURE_OAUTH_RESOURCE_DOCUMENTATION |
no | this repository | URL published to a caller who cannot authenticate. |
OAuth discovery, and the fact that there is no authorization server yet
Xtrape Exposure is an OAuth 2.1 resource server. It can publish RFC 9728 Protected Resource
Metadata and name it in the WWW-Authenticate challenge, so a client that arrives without a
credential is told where to look instead of only that it guessed wrong:
HTTP/1.1 401 Unauthorized
www-authenticate: Bearer resource_metadata="https://mcp.example.test/.well-known/oauth-protected-resource/mcp"
It publishes nothing until two things are configured, and both are fail-closed.
1. XTRAPE_EXPOSURE_PUBLIC_URL must be pinned. Everything published is a canonical,
publicly cacheable name for this resource. Host, X-Forwarded-Host and X-Forwarded-Proto are
set by whoever dialled the socket, so they are never read: with no pinned URL a caller could decide
what this process claims to be, in a document marked public, max-age=3600. Unpinned, every
discovery path answers 503 public_url_not_configured. The single exception is a local development
run — a connection from loopback whose Host is a loopback literal — which can only ever produce
an identifier pointing back at the caller's own machine. That is not a deployment mode.
2. There must be an authorization server. MCP 2025-11-25 ("Authorization Server Location")
requires the published document to "include the authorization_servers field containing at least
one authorization server". RFC 9728 §2 makes the field optional, but the MCP profile tightens it,
and that profile is what publishing the document claims. Xtrape has no authorization server yet:
the authorization code flow is a later phase and a caller presents an Account Token minted out of
band through the governed self.* Checkpoints. So no document is published — neither a
fabricated issuer nor a document knowingly short of the profile — and the challenge is a bare
Bearer with no resource_metadata. MCP authorization is OPTIONAL for an MCP server; this
deployment does not claim it rather than claiming it badly.
A client that keeps walking the flow anyway is still answered at every hop it takes
(/.well-known/oauth-protected-resource, /.well-known/oauth-authorization-server,
/.well-known/openid-configuration, POST /register) with an OAuth-shaped body carrying the same
true explanation, so the error it finally reports to a human says what to do. Those bodies are
refusals, not metadata: none of them implements an authorization server, offers registration, or
admits anyone.
Setting XTRAPE_EXPOSURE_OAUTH_AUTHORIZATION_SERVERS alongside the public URL turns on the
conformant surface with no code change. The document is then served at each location a client may
probe, and each returns the identifier matching the URL it was fetched from, so either probe
validates. /.well-known/oauth-authorization-server on this origin mirrors that server's RFC 8414
metadata verbatim, issuer included. That mirror is a compatibility shim for clients that
probe this origin directly instead of following the metadata; a conformant client reaches the
authorization server by its own issuer URL and never asks for it here.
A deployment under a path prefix. RFC 9728 §3.1 inserts the well-known segment between the
host and the resource path, so with XTRAPE_EXPOSURE_PUBLIC_URL=https://mcp.example.test/api the
resource is https://mcp.example.test/api/mcp and its metadata lives at
https://mcp.example.test/.well-known/oauth-protected-resource/api/mcp
— at the host root, never at https://mcp.example.test/api/.well-known/.... An ingress in front of
such a deployment must therefore route /.well-known/oauth-* to this endpoint as well as the
prefix itself.
No scope parameter is advertised, and that is deliberate rather than unfinished: canonical binds
an Account Token to a structured policy object, not to scope strings, so there is no scope
vocabulary to name. Clients are told to treat challenge scopes as authoritative, and inventing one
would be a claim a client would act on.
The two listeners are on two ports on purpose: the AI-facing surface is the one that becomes publicly reachable in a later milestone, and the health endpoint must stay on the operator's side of that fence.
GET /health answers liveness only, and deliberately discloses nothing else — it is
unauthenticated, so configuration, Platform reachability, and projection state stay out of it.
POST /mcp requires Authorization: Bearer <Account Token>. A missing credential, an invalid
one, and a credential the Platform refuses all produce the same HTTP 401 with the same JSON-RPC
error, so existence never leaks. Credentials are never accepted from a URL query string. Every
response is Cache-Control: private, no-store, and the projection's own cache scope is always
private — a Tool list varies with authorization, so a shareable cache scope would mean serving
one caller's authorized surface to another.
A malformed request is refused, never normalized into a valid-looking one. A JSON-RPC id that is
present but is not a string or a number is INVALID_REQUEST (-32600) and not a notification —
only an ABSENT id makes a notification — and present-but-unstructured params is refused rather
than treated as no params.
Service Selection
Which logical Services a request is projected over is a property of the request URL, not of the deployment — one deployment serves many logical Service projections:
POST /mcp every Service in the deployment's configured bound
POST /mcp?s=self only the Platform self projection
POST /mcp?s=self,linux-ops two Services
POST /mcp?services=self `services=` is a readable alias for `s=`
The two layers compose in one direction only. XTRAPE_EXPOSURE_SERVICE_SELECTION is the upper
bound; ?s= narrows inside it; the two are intersected; and the Platform then re-applies
the Account Token's own allowedServices on top of the result. Nothing in that chain can widen —
a caller naming a Service outside the bound has it dropped, not honoured.
A selection that resolves to no reachable Service is refused, never silently ignored and never
quietly answered with the unnarrowed projection: an empty ?s=, a value that is not a logical
Service id, a selection wholly outside the bound, and two selectors that disagree all produce the
same JSON-RPC error (code -32002, service selection rejected) with HTTP 400. The refusal is
deliberately identical in every case — a per-cause taxonomy would turn ?s= into an oracle for
which Services exist. It is also answered after authentication, so an unauthenticated caller
learns nothing about the deployment's configuration.
A selection that resolves to a non-empty set of Services which happen to expose no Checkpoint to this caller right now is legal and yields an empty Tool list, not an error: emptiness of the projection is the Platform's answer about authorization, emptiness of the selection is this layer's answer about addressing, and collapsing the two would leak existence.
Ids are normalized to canonical wire order — de-duplicated, strict ascending by code unit — so two
spellings of one selection are one value. Credentials are never carried in s=, services=, or
any other query parameter.
Layout
src/
index.ts entrypoint: validated config -> logging -> health -> shutdown
config.ts environment configuration, fail-closed validation
logging.ts structured JSON logging (redaction applied at the boundary)
redact.ts credential redaction
health.ts /health endpoint
protocol/ protocol face — one adapter per Protocol Projection Profile
registry.ts which protocols this process speaks
mcp/ the MCP profile: JSON-RPC framing, stateless HTTP handler, listener
projection/ projection face — protocol-neutral projection rules
name.ts name derivation, admission, collision/version fail-closed, ordering
validity.ts cache scope and ttl upper bound
tool.ts Checkpoint -> tool descriptor (restate, never invent)
platform/ Platform port — the only outbound seam; where decisions are deferred
discovery.ts defensive parse of the Platform's projection wire shapes
client.ts access-session establish + discovery read
Dependencies
One production dependency: @xtrape/interaction, the Interaction Layer ↔ Platform interface
package, pinned to the exact version 0.8.18 — no ^, no ~. The range operators are the
mechanism by which a surface package drifts under a consumer without a commit to point at, which is
precisely what a contract-shaped dependency must not do; an intentional bump is an edit here.
It resolves anonymously from the public npm registry — see Installing dependencies above.
It is deliberately not @xtrape/contracts: that package is the widget ↔ Platform surface, and
D20 forbids an Interaction Layer surface from depending on it.