@ultimat3/mcp 31.31.0 → 31.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/mcp",
3
- "version": "31.31.0",
3
+ "version": "31.33.0",
4
4
  "description": "MCP server, dev tools, and the action-to-tool projection \u2014 one authz system, two surfaces",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -44,15 +44,15 @@
44
44
  "test": "bun test"
45
45
  },
46
46
  "dependencies": {
47
- "@ultimat3/action": "31.31.0",
48
- "@ultimat3/auth": "31.31.0",
49
- "@ultimat3/core": "31.31.0",
50
- "@ultimat3/db": "31.31.0",
51
- "@ultimat3/entity": "31.31.0",
52
- "@ultimat3/http": "31.31.0",
53
- "@ultimat3/jobs": "31.31.0",
54
- "@ultimat3/policy": "31.31.0",
55
- "@ultimat3/query": "31.31.0",
56
- "@ultimat3/schema": "31.31.0"
47
+ "@ultimat3/action": "31.33.0",
48
+ "@ultimat3/auth": "31.33.0",
49
+ "@ultimat3/core": "31.33.0",
50
+ "@ultimat3/db": "31.33.0",
51
+ "@ultimat3/entity": "31.33.0",
52
+ "@ultimat3/http": "31.33.0",
53
+ "@ultimat3/jobs": "31.33.0",
54
+ "@ultimat3/policy": "31.33.0",
55
+ "@ultimat3/query": "31.33.0",
56
+ "@ultimat3/schema": "31.33.0"
57
57
  }
58
58
  }
package/src/audit-hook.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  // `onAudit`: the gate's decisions, as data, handed on AFTER `audit.ts` has written the log line —
2
- // one audit path with a second destination, never a second path. Core's `AuditSink` records what
3
- // an action or query DID (`surface: 'mcp'`); this records what the MCP gate decided, mostly before
4
- // any primitive ran: hidden, scope-denied, invalid-args, a refused token. No `AuditRecord` can
5
- // carry those — there is no `ctx`, often no primitive, and nothing ran.
2
+ // one audit path with a second destination, never a second path.
3
+ //
4
+ // Core's `AuditSink` records what an action or query DID (`surface: 'mcp'`); this records what the
5
+ // MCP gate decided, mostly before any primitive ran: hidden, scope-denied, invalid-args, a refused
6
+ // token. No `AuditRecord` can carry those — there is no `ctx`, often no primitive, and nothing ran.
6
7
 
7
8
  import type { Clock, Logger } from '@ultimat3/core';
8
9
  import { addressNetwork, logger, stringField, systemClock } from '@ultimat3/core';
@@ -81,6 +82,7 @@ export function mcpAuditor(input: McpAuditorInput = {}): McpAuditor {
81
82
  path: facts.path,
82
83
  ...(facts.address === null ? {} : { address: addressNetwork(facts.address) }),
83
84
  };
85
+ // info: the auth audit trail records every refusal; no token is its least severe rung, never a warn.
84
86
  if (reason === 'missing-token') log.info(`mcp.auth.${reason}`, line);
85
87
  else log.warn(`mcp.auth.${reason}`, line);
86
88
  if (hook !== undefined) {
@@ -1,9 +1,11 @@
1
1
  // `mcpConfirmations` — human confirmation for named MCP tools, as a FACTORY OVER `action`, never a
2
- // ninth primitive. What it returns IS the decision action (`{ id, decision: 'approve' | 'reject' }`):
3
- // registered like any other, it has its route, OpenAPI operation, typed client and audit record, and
4
- // its policy is decided by `guard()` like every other write. The gate the agent meets lives in
5
- // `confirmation-gate.ts`, applied by `defineAppMcp({ confirmations })` for an MCP server and registered
6
- // by name for an in-app agent's `agent({ tools })`.
2
+ // ninth primitive.
3
+ //
4
+ // What it returns IS the decision action (`{ id, decision: 'approve' | 'reject' }`): registered
5
+ // like any other, it has its route, OpenAPI operation, typed client and audit record, and its
6
+ // policy is decided by `guard()` like every other write. The gate the agent meets lives in
7
+ // `confirmation-gate.ts`, applied by `defineAppMcp({ confirmations })` for an MCP server and
8
+ // registered by name for an in-app agent's `agent({ tools })`.
7
9
 
8
10
  import type { Action } from '@ultimat3/action';
9
11
  import { action, registerToolGate } from '@ultimat3/action';
@@ -1,8 +1,9 @@
1
1
  // `ui.interact` — the dev server's hand. An agent that needs the ⌘K palette open, a dialog up or a
2
- // field filled before the picture is worth taking drives the route through a BOUNDED list of
3
- // steps, and gets the picture, the verdict and (on request) `ui.inspect`'s facts in ONE
4
- // navigation. Its own file for the reason `dev-ui-tools.ts` has one: that file stands near the
5
- // 500-line ceiling, and this tool's step schema alone is a screen. `dev-server.ts` spreads both.
2
+ // field filled before the picture is worth taking drives the route through a BOUNDED list of steps,
3
+ // and gets the picture, the verdict and (on request) `ui.inspect`'s facts in ONE navigation.
4
+ //
5
+ // Its own file for the reason `dev-ui-tools.ts` has one: that file stands near the 500-line
6
+ // ceiling, and this tool's step schema alone is a screen. `dev-server.ts` spreads both.
6
7
  //
7
8
  // Every bound lives in the HANDLER's contract, not the schema — a placement, no longer a limit:
8
9
  // `validate-args.ts` enforces `maxItems` now, so the count COULD move into the schema; it has not.
@@ -1,10 +1,11 @@
1
1
  // The dev server's eyes: `ui.shot` (a route), `ui.island` (a component's states), `ui.inspect`
2
2
  // (DOM, computed-style and accessibility facts for a set of selectors, in ONE navigation) and
3
- // `ui.diff` (two captures the others wrote, compared without a browser). Split
4
- // out of `dev-server.ts` because that file stood at 439 lines against the 500-line ceiling and a
5
- // third `ui.*` literal would have crossed it — the catalog is still one array; `devTools` spreads
6
- // this one in. Every type here is re-exported from `dev-server.ts`, so the CLI and the package
7
- // index import what they always did.
3
+ // `ui.diff` (two captures the others wrote, compared without a browser).
4
+ //
5
+ // Split out of `dev-server.ts` because that file stood at 439 lines against the 500-line ceiling
6
+ // and a third `ui.*` literal would have crossed it — the catalog is still one array; `devTools`
7
+ // spreads this one in. Every type here is re-exported from `dev-server.ts`, so the CLI and the
8
+ // package index import what they always did.
8
9
  //
9
10
  // A browser is the expensive half of every call here, which is why `ui.inspect` reads MANY
10
11
  // selectors per navigation and bounds each answer in the handler: a model that asks for a
@@ -63,7 +63,7 @@ export function asFrameworkError(error: unknown): FrameworkError | undefined {
63
63
  // A substituted fix is still a fix an agent will act on, so it has to be runnable. `see docs`
64
64
  // named no docs and no command; `code` is already narrowed to an `X_` string by the guard
65
65
  // above, so the substitute is the one command that explains exactly this code.
66
- fix: stringField(error, 'fix') ?? `x errors explain ${code}`,
66
+ fix: stringField(error, 'fix') ?? `x errors explain ${renderFixShellArg(code, '<code>')}`,
67
67
  ...(callerFix === undefined ? {} : { callerFix }),
68
68
  // A recipe link nothing serves is dropped (and logged): an agent is never sent nowhere.
69
69
  ...(docs === undefined || docs === '' || docs === ERROR_DOCS_URL
@@ -1,9 +1,11 @@
1
- // The MCP half of `idempotent: true`: the Idempotency-Key an HTTP caller sends as a header, sent
2
- // by an MCP caller as one reserved, optional tool ARGUMENT. An argument and not `params._meta`:
3
- // `_meta` is protocol metadata a host fills (a progress token), and no model-driven client lets the
4
- // model set it — the retry that needs a key is the agent's own, so the key goes where the agent
5
- // writes. It is advertised in `tools/list`, enforced by `validate-args.ts` like every other field,
6
- // and taken back out before `invoke`, so the action's own input parse never sees it.
1
+ // The MCP half of `idempotent: true`: the Idempotency-Key an HTTP caller sends as a header, sent by
2
+ // an MCP caller as one reserved, optional tool ARGUMENT.
3
+ //
4
+ // An argument and not `params._meta`: `_meta` is protocol metadata a host fills (a progress token),
5
+ // and no model-driven client lets the model set it — the retry that needs a key is the agent's own,
6
+ // so the key goes where the agent writes. It is advertised in `tools/list`, enforced by
7
+ // `validate-args.ts` like every other field, and taken back out before `invoke`, so the action's
8
+ // own input parse never sees it.
7
9
 
8
10
  import { MAX_IDEMPOTENCY_KEY_LENGTH } from '@ultimat3/action';
9
11
  import { McpIdempotencyKeyShadowedError } from './errors';
package/src/meta-split.ts CHANGED
@@ -1,7 +1,8 @@
1
- // The `'meta-split'` surface's dispatchers: `read_resource`, `write_resource`, `delete_resource`
2
- // in place of the one `manage_resource`, each picked from the action's declared effect. A client
3
- // decides whether to ask its user from a TOOL's annotations alone, and a directory refuses a tool
4
- // that both reads and writes — so the split is by tool, never by a flag inside the envelope.
1
+ // The `'meta-split'` surface's dispatchers: `read_resource`, `write_resource`, `delete_resource` in
2
+ // place of the one `manage_resource`, each picked from the action's declared effect.
3
+ //
4
+ // A client decides whether to ask its user from a TOOL's annotations alone, and a directory refuses
5
+ // a tool that both reads and writes — so the split is by tool, never by a flag inside the envelope.
5
6
  // Catalog and boot check here; the dispatch is `meta-split-call.ts`, on the shared path.
6
7
 
7
8
  import type { McpEffect } from '@ultimat3/core';
@@ -1,9 +1,11 @@
1
1
  // The META surface: three tools — `list_resources`, `describe_resource`, `manage_resource` — in
2
2
  // place of one tool per primitive, so `tools/list` stays the same size however many primitives an
3
- // app grows. The catalog, the lazy schemas and the address book live here; the DISPATCH stays in
4
- // `server.ts`, on the same resolve → run → audit path a flat `tools/call` takes, so the three
5
- // security outcomes, the policy inside `invoke` and the synchronous audit line are one code path
6
- // reached through two doors — never a second implementation.
3
+ // app grows.
4
+ //
5
+ // The catalog, the lazy schemas and the address book live here; the DISPATCH stays in `server.ts`,
6
+ // on the same resolve → run → audit path a flat `tools/call` takes, so the three security outcomes,
7
+ // the policy inside `invoke` and the synchronous audit line are one code path reached through two
8
+ // doors — never a second implementation.
7
9
  //
8
10
  // A grouped tool is reachable ONLY through `manage_resource` for a meta caller, and a flat caller
9
11
  // never sees the meta tools: what `tools/list` shows is what `tools/call` answers, per caller.
@@ -1,14 +1,17 @@
1
- // OAuth 2.0 Protected Resource Metadata (RFC 9728) for the MCP endpoint — the framework half of
2
- // the MCP authorization spec's discovery, which the revisions this transport serves (`wire.ts`)
3
- // do not define alike. The revisions served are 2026-07-28 (`MCP_MODERN_VERSIONS`) and 2025-11-25 /
4
- // 2025-06-18 / 2025-03-26 (`MCP_LEGACY_VERSIONS`). All but 2025-03-26 require RFC 9728: a 401 names
5
- // where the metadata lives (`WWW-Authenticate: Bearer resource_metadata="…"`), the metadata names
6
- // the authorization server(s) a client goes to for a token. 2025-11-25 made that header optional
7
- // with a `.well-known` fallback (SEP-985); 2025-06-18 required it. 2025-03-26 defines no
1
+ // OAuth 2.0 Protected Resource Metadata (RFC 9728) for the MCP endpoint — the framework half of the
2
+ // MCP authorization spec's discovery, which the revisions this transport serves (`wire.ts`) do not
3
+ // define alike.
4
+ //
5
+ // The revisions served are 2026-07-28 (`MCP_MODERN_VERSIONS`) and 2025-11-25 / 2025-06-18 /
6
+ // 2025-03-26 (`MCP_LEGACY_VERSIONS`). All but 2025-03-26 require RFC 9728: a 401 names where the
7
+ // metadata lives (`WWW-Authenticate: Bearer resource_metadata="…"`), the metadata names the
8
+ // authorization server(s) a client goes to for a token. 2025-11-25 made that header optional with a
9
+ // `.well-known` fallback (SEP-985); 2025-06-18 required it. 2025-03-26 defines no
8
10
  // protected-resource metadata at all — its discovery is RFC 8414 authorization-server metadata at
9
11
  // the origin — so it reads none of this. The server itself is `@ultimat3/auth`'s
10
12
  // `authorizationServer`, bound to one endpoint by `mcpAuthorizationServer` (`oauth-server.ts`).
11
13
 
14
+ import { trimTrailingSlashes } from '@ultimat3/core';
12
15
  import { McpOAuthInvalidError } from './errors-transport';
13
16
 
14
17
  /** The well-known suffix RFC 9728 §3 defines. */
@@ -67,7 +70,7 @@ export function assertMcpOAuth(oauth: McpOAuth): void {
67
70
 
68
71
  /** The resource this request addresses: the declared one, else `<origin><path>`. */
69
72
  export function resourceUrl(oauth: McpOAuth, origin: string, path: string): string {
70
- return oauth.resource ?? `${origin.replace(/\/+$/, '')}${path}`;
73
+ return oauth.resource ?? `${trimTrailingSlashes(origin)}${path}`;
71
74
  }
72
75
 
73
76
  /**
@@ -76,7 +79,7 @@ export function resourceUrl(oauth: McpOAuth, origin: string, path: string): stri
76
79
  */
77
80
  export function metadataUrlFor(resource: string): string {
78
81
  const url = new URL(resource);
79
- const path = url.pathname === '/' ? '' : url.pathname.replace(/\/+$/, '');
82
+ const path = url.pathname === '/' ? '' : trimTrailingSlashes(url.pathname);
80
83
  return `${url.origin}${PROTECTED_RESOURCE_WELL_KNOWN}${path}`;
81
84
  }
82
85
 
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import { pkcePair, randomToken } from '@ultimat3/auth';
8
- import { isJsonObject, timingSafeEqual } from '@ultimat3/core';
8
+ import { isJsonObject, timingSafeEqual, trimTrailingSlashes } from '@ultimat3/core';
9
9
  import type { OutboundFetch } from '@ultimat3/core/outbound';
10
10
  import { outboundResponse } from '@ultimat3/core/outbound';
11
11
  import { McpRemoteRefusedError } from './remote-errors';
@@ -263,14 +263,14 @@ function secureEndpoint(url: URL): boolean {
263
263
 
264
264
  /** RFC 9728 §3.1: the suffix goes between host and path, then the root as a fallback. */
265
265
  function wellKnown(url: URL, suffix: string): readonly string[] {
266
- const path = url.pathname === '/' ? '' : url.pathname.replace(/\/+$/, '');
266
+ const path = url.pathname === '/' ? '' : trimTrailingSlashes(url.pathname);
267
267
  const root = `${url.origin}/.well-known/${suffix}`;
268
268
  return path === '' ? [root] : [`${root}${path}`, root];
269
269
  }
270
270
 
271
271
  /** RFC 8414 first, then OIDC discovery in both placements the MCP spec lists. */
272
272
  function authServerCandidates(issuer: URL): readonly string[] {
273
- const path = issuer.pathname === '/' ? '' : issuer.pathname.replace(/\/+$/, '');
273
+ const path = issuer.pathname === '/' ? '' : trimTrailingSlashes(issuer.pathname);
274
274
  return [
275
275
  `${issuer.origin}/.well-known/oauth-authorization-server${path}`,
276
276
  `${issuer.origin}/.well-known/openid-configuration${path}`,
@@ -1,8 +1,10 @@
1
1
  // The size of what an agent READS from this server, measured off the wire, and a budget an app's
2
- // test holds it to. `tools/list` is re-sent with every step of every turn and `list_resources` is
3
- // read once a session and then sits in the transcript — both are standing context the model pays
4
- // for whether or not it uses them, so a number with a test beside it is the only way they stay
5
- // small (gold standard: context-budget.md, "guard the numbers with tests").
2
+ // test holds it to.
3
+ //
4
+ // `tools/list` is re-sent with every step of every turn and `list_resources` is read once a session
5
+ // and then sits in the transcript — both are standing context the model pays for whether or not it
6
+ // uses them, so a number with a test beside it is the only way they stay small (gold standard:
7
+ // context-budget.md, "guard the numbers with tests").
6
8
 
7
9
  import { McpSurfaceOverBudgetError } from './errors';
8
10
  import { LIST_RESOURCES } from './meta-surface';