Skip to main content
mcp(spec) from @bijectionhq/library-mcp returns a subtree. Place it in your app tree: its path names the server, and its route is POST /<path>, with . written as /. A server placed at mcp answers at /mcp, and one placed at support.mcp answers at /support/mcp. Set path to choose another route.
The subtree holds the route reaction mcp.handle and the internal query mcp.follow. The reaction holds no roles of its own: each request runs as the principal the server’s verifier admitted, so a tool reaches only what that principal may reach. Authenticate MCP requests and Expose tools describe the caller and the tool contract. under sets the label the route commits under, and the public label is the default. A mutation tool must commit under exactly that label. A query tool must answer under it or under a label below it. bijection check reports a mutation tool at another label (ToolUnder) or a query tool above the server’s label (ToolAbove), and the host refuses such a call.
Here the public mine query is a tool of the vaulted server because the public label is below vault. Only callers whose roles clear vault can use that server.

Declare prompts and resources

prompts holds named prompts with string arguments. A prompt’s messages are literal text or content, or a read-only handler (ctx, args) that returns them. resources holds named text or binary data, keyed by URI, or a read(ctx, uri) handler. resourceTemplates holds parameterized URIs keyed by RFC 6570 expression. Give a template a match callback for expressions beyond {name} and {+path}. pageSize (1 to 100, default 32) sets how many entries a list method returns. A complete source on a prompt or template argument offers suggestions.
A handler reads with the ordinary ctx reads, in the caller’s frame. A read handler that returns null answers that the URI is absent. The ui:// and skill:// schemes are reserved for the server’s views and skills.

Mirror routing arguments in headers

tool(fn, { headers: { tenant: "Tenant" } }) marks a primitive argument as an HTTP routing field. Dotted paths select nested properties. Clients mirror the value in Mcp-Param-Tenant, and the server checks the header against the arguments. Use this only for values that may be visible to HTTP infrastructure.

Ask for more input

round: { handle, key } asks for more input before a tool, prompt or resource runs. handle(ctx, request) is read-only. It returns an inputRequests map, a state value, or both, or nothing to proceed. The library checks client capabilities before returning form elicitation, URL elicitation, sampling or roots requests. A state value needs key, a MAC key, and an admitted principal. The library signs the state and binds it to the principal, method, arguments and an expiry five minutes after ctx.frame.now.entry. Keep sensitive state in your tables and put only its key in the signed payload. The handler owns how it reads the answers and any single-use rule.

Publish skills

A server can publish authored Agent Skills with the MCP Skills extension. Declare them beside tools:
The skills key, the directory name and the frontmatter name must agree. The path is relative to the directory that holds app.ts. Authored files are served byte for byte at skill://<name>/<path>. A tool: link, or a references/tools.md#<tool> link, declares that the skill uses a tool. At deploy, the library generates references/tools.md with a section for each linked tool: its description, kind, visibility, argument and result schemas, and the codes it refuses with. Deploy fails if a skill links a tool the server does not offer, authors references/tools.md, nests another SKILL.md, or declares allowed-tools in its frontmatter. skills/list and skills/get return each skill’s verbatim frontmatter and the list of its files with SHA-256 digests. A skill is never "dynamic". A host’s approval binds to that file list, so a deploy that changes neither the skill nor a tool it links keeps the approval. bijection.lock records every file digest, so a changed instruction is a reviewed diff. The digests are not a trust anchor; the committed lock file and npm integrity are.

Trace requests

trace(ctx, { method, log }) emits diagnostic messages for requests that set params._meta["io.modelcontextprotocol/logLevel"]. log(level, data, logger?) takes a syslog severity. Messages are released after the transaction settles and arrive before the final JSON-RPC response on the request’s event stream.

Describe the declared contract

From the app project, name the server by its tree path. The CLI reads its server card and tool schemas from the analyzed app.
The optional URL adds the streamable-http remote to the JSON card. The card lists each view with its URI, digest, CSP and permissions, and each skill with its files. bijection check records the same facts in bijection.lock. Use a live server/discover to see the deployed endpoint as the caller sees it. See Connect an MCP client.