@revealui/mcp 0.7.0 → 0.8.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/README.md +3 -3
- package/dist/author/errors.d.ts +2 -2
- package/dist/author/errors.d.ts.map +1 -1
- package/dist/author/errors.js +2 -2
- package/dist/author/errors.js.map +1 -1
- package/dist/author/index.d.ts +1 -1
- package/dist/author/index.js +1 -1
- package/dist/cli.d.ts +17 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +41 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/oauth.d.ts +2 -52
- package/dist/oauth.d.ts.map +1 -1
- package/dist/oauth.js +2 -139
- package/dist/oauth.js.map +1 -1
- package/dist/servers/factories/contracts.d.ts +4 -2
- package/dist/servers/factories/contracts.d.ts.map +1 -1
- package/dist/servers/factories/contracts.js +0 -2
- package/dist/servers/factories/contracts.js.map +1 -1
- package/dist/servers/factories/knowledge-graph.d.ts +272 -0
- package/dist/servers/factories/knowledge-graph.d.ts.map +1 -0
- package/dist/servers/factories/knowledge-graph.js +666 -0
- package/dist/servers/factories/knowledge-graph.js.map +1 -0
- package/dist/servers/factories/revealui-content.d.ts +126 -0
- package/dist/servers/factories/revealui-content.d.ts.map +1 -1
- package/dist/servers/factories/revealui-content.js +279 -63
- package/dist/servers/factories/revealui-content.js.map +1 -1
- package/dist/servers/revealui-memory.d.ts +2 -2
- package/dist/streamable-http.d.ts +25 -2
- package/dist/streamable-http.d.ts.map +1 -1
- package/dist/streamable-http.js +16 -1
- package/dist/streamable-http.js.map +1 -1
- package/package.json +26 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge-graph.js","sourceRoot":"","sources":["../../../src/servers/factories/knowledge-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;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pD,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,WAAW,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACvE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -33,6 +33,94 @@
|
|
|
33
33
|
*/
|
|
34
34
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
35
35
|
import { z } from 'zod/v4';
|
|
36
|
+
/** Resolved REST credentials for one tool call. */
|
|
37
|
+
export interface ResolvedApiCredentials {
|
|
38
|
+
apiUrl: string;
|
|
39
|
+
apiKey: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Per-request context handed to the governed seams. Derived from the MCP
|
|
43
|
+
* request handler's `extra` (the transport threads `authInfo` from the
|
|
44
|
+
* authenticated HTTP request; `sessionId` is the routing key). `undefined`
|
|
45
|
+
* on the stdio path.
|
|
46
|
+
*/
|
|
47
|
+
export interface McpToolCallContext {
|
|
48
|
+
authInfo?: unknown;
|
|
49
|
+
sessionId?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Governed-path credential resolver. Returns the credentials to forward for a
|
|
53
|
+
* single tool call — on the governed path, the caller's own bearer token so
|
|
54
|
+
* the REST layer enforces `access.read` against the real user. May throw /
|
|
55
|
+
* reject when no per-request credential exists; the call then fails closed.
|
|
56
|
+
*/
|
|
57
|
+
export type CredentialsProvider = (ctx: McpToolCallContext) => Promise<ResolvedApiCredentials> | ResolvedApiCredentials;
|
|
58
|
+
/** Terminal outcome of a governed tool call, as recorded in the receipt. */
|
|
59
|
+
export type McpToolAuditOutcome = 'invoked' | 'denied' | 'failed';
|
|
60
|
+
/**
|
|
61
|
+
* A governed tool-call receipt. Raw arguments are NEVER included — only a
|
|
62
|
+
* sha256 digest of the canonical JSON plus an allowlisted scalar subset
|
|
63
|
+
* (`collection`, `site_id`) that is safe to store in the clear.
|
|
64
|
+
*/
|
|
65
|
+
export interface McpToolAuditRecord {
|
|
66
|
+
outcome: McpToolAuditOutcome;
|
|
67
|
+
tool: string;
|
|
68
|
+
/** sha256 (hex) of the canonical JSON of the raw arguments. */
|
|
69
|
+
argsDigest: string;
|
|
70
|
+
/** Allowlisted non-secret identifiers pulled from the validated args. */
|
|
71
|
+
scalars: Record<string, string>;
|
|
72
|
+
durationMs: number;
|
|
73
|
+
httpStatus?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Why a call was denied, when `outcome === 'denied'`. `'authz'` for a
|
|
76
|
+
* deny-by-default tool-permission miss (I-7); `'rate-limit'` when the
|
|
77
|
+
* per-user quota is exhausted (I-8). Absent for a validation/unknown-tool
|
|
78
|
+
* denial and for non-denied outcomes.
|
|
79
|
+
*/
|
|
80
|
+
reason?: string;
|
|
81
|
+
/** The MCP client that connected (from the `initialize` handshake). */
|
|
82
|
+
clientInfo?: {
|
|
83
|
+
name: string;
|
|
84
|
+
version: string;
|
|
85
|
+
};
|
|
86
|
+
context: McpToolCallContext;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Governed-path audit sink. Resolves when the receipt is durably written;
|
|
90
|
+
* rejects when the write failed. For a mutating tool a rejection fails the
|
|
91
|
+
* call (fail-closed); for a read tool it degrades to log-and-continue.
|
|
92
|
+
*/
|
|
93
|
+
export type McpToolAuditSink = (record: McpToolAuditRecord) => Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Deny-by-default per-tool authorization gate (GAP-371 Phase 2, I-7). Returns
|
|
96
|
+
* true iff the identity threaded through `ctx.authInfo` may execute `toolName`
|
|
97
|
+
* at its server-derived tier and role. Governs BOTH `tools/list` filtering and
|
|
98
|
+
* `tools/call` execution — a tool absent from the list is still independently
|
|
99
|
+
* denied on a direct call. Absent on the stdio path (every tool allowed).
|
|
100
|
+
*/
|
|
101
|
+
export type McpToolAuthorizer = (ctx: McpToolCallContext, toolName: string) => boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Per-call rate-limit gate (GAP-371 Phase 2, I-8). Consumed once per authorized
|
|
104
|
+
* `tools/call`, keyed by the caller's user + tool with limits from the
|
|
105
|
+
* server-derived tier. Returns false when the quota is exhausted. Absent on the
|
|
106
|
+
* stdio path (unlimited). Never consumed for `tools/list` or for a denied call.
|
|
107
|
+
*/
|
|
108
|
+
export type McpToolRateLimiter = (ctx: McpToolCallContext, toolName: string) => Promise<boolean> | boolean;
|
|
109
|
+
/** One usage-meter event, emitted once per EXECUTED tool call (I-8 tail). */
|
|
110
|
+
export interface McpToolMeterEvent {
|
|
111
|
+
tool: string;
|
|
112
|
+
durationMs: number;
|
|
113
|
+
/** True when the tool surfaced an error (bad args reaching the backend, throw, non-2xx). */
|
|
114
|
+
errored: boolean;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Usage-meter sink (GAP-371 Phase 2). Fired once per tool call that actually
|
|
118
|
+
* executed (success or failure) — never for an authz/rate-limit denial, which
|
|
119
|
+
* are audit events, not billable usage. Sink errors are swallowed: metering
|
|
120
|
+
* must never break the underlying tool call. Billing and audit are separate
|
|
121
|
+
* sinks by design.
|
|
122
|
+
*/
|
|
123
|
+
export type McpToolMeterSink = (ctx: McpToolCallContext, event: McpToolMeterEvent) => void | Promise<void>;
|
|
36
124
|
/**
|
|
37
125
|
* Set credential overrides for this server. Called by the hypervisor with
|
|
38
126
|
* resolved tenant credentials (or by an HTTP launcher before handing the
|
|
@@ -98,6 +186,44 @@ export interface CreateRevealuiContentServerOptions {
|
|
|
98
186
|
* directly; out-of-process subprocess consumers leave it unset.
|
|
99
187
|
*/
|
|
100
188
|
collectionsProvider?: CollectionsProvider;
|
|
189
|
+
/**
|
|
190
|
+
* Governed-path (GAP-371) per-request credential resolver. When set, it is
|
|
191
|
+
* the SOLE source of tool-call credentials — the `REVEALUI_API_KEY` /
|
|
192
|
+
* `setCredentials()` fallback is never consulted (invariant I-4). Leave
|
|
193
|
+
* unset for the stdio launcher to keep the process-global env-key model.
|
|
194
|
+
*/
|
|
195
|
+
credentialsProvider?: CredentialsProvider;
|
|
196
|
+
/**
|
|
197
|
+
* Governed-path audit sink. When set, every `tools/call` produces a receipt
|
|
198
|
+
* (invariant I-5). Mutating tools (see `mutatingTools`) fail closed if the
|
|
199
|
+
* receipt cannot be written; read tools degrade to log-and-continue.
|
|
200
|
+
*/
|
|
201
|
+
auditSink?: McpToolAuditSink;
|
|
202
|
+
/**
|
|
203
|
+
* Names of tools that mutate state and therefore require a durable receipt
|
|
204
|
+
* BEFORE they run. Phase 1 exposes read tools only, so this is empty in
|
|
205
|
+
* production; it exists so Phase 2 write tools inherit the fail-closed path
|
|
206
|
+
* (and so the branch is testable now with a simulated mutating tool).
|
|
207
|
+
*/
|
|
208
|
+
mutatingTools?: ReadonlySet<string>;
|
|
209
|
+
/**
|
|
210
|
+
* Governed-path deny-by-default per-tool authorization (I-7). When set, it
|
|
211
|
+
* gates BOTH `tools/list` (advertised set) and `tools/call` (execution). A
|
|
212
|
+
* tool the caller may not execute is neither listed nor callable. Leave unset
|
|
213
|
+
* for the stdio launcher (no per-tool authz — the OS account is the boundary).
|
|
214
|
+
*/
|
|
215
|
+
toolAuthorizer?: McpToolAuthorizer;
|
|
216
|
+
/**
|
|
217
|
+
* Governed-path per-call rate limiter (I-8). When set, an authorized
|
|
218
|
+
* `tools/call` consumes one token; exhaustion yields a JSON-RPC error and a
|
|
219
|
+
* `mcp:tool:denied` receipt with `reason: 'rate-limit'`. Unset → unlimited.
|
|
220
|
+
*/
|
|
221
|
+
rateLimiter?: McpToolRateLimiter;
|
|
222
|
+
/**
|
|
223
|
+
* Governed-path usage-meter sink. When set, one meter event fires per
|
|
224
|
+
* executed tool call (source `agent` downstream). Unset → no metering.
|
|
225
|
+
*/
|
|
226
|
+
meterSink?: McpToolMeterSink;
|
|
101
227
|
}
|
|
102
228
|
/**
|
|
103
229
|
* Create a fresh `revealui-content` MCP Server instance. Safe to call
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revealui-content.d.ts","sourceRoot":"","sources":["../../../src/servers/factories/revealui-content.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;
|
|
1
|
+
{"version":3,"file":"revealui-content.d.ts","sourceRoot":"","sources":["../../../src/servers/factories/revealui-content.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAWnE,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAe3B,mDAAmD;AACnD,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAChC,GAAG,EAAE,kBAAkB,KACpB,OAAO,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;AAE9D,4EAA4E;AAC5E,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElE;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uEAA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I,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,CAAC,oBAAoB,EAAE,GAAG,IAAI,CAAC,CAAC;AAE/E,MAAM,WAAW,kCAAkC;IACjD;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAE1C;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAE1C;;;;OAIG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAE7B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAEpC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,iBAAiB,CAAC;IAEnC;;;;OAIG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC;IAEjC;;;OAGG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAkJD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,CAAC,EAAE,kCAAkC,GAAG,MAAM,CAgZhG"}
|
|
@@ -31,10 +31,42 @@
|
|
|
31
31
|
* via `setCredentials()`. Falls back to `REVEALUI_API_URL` +
|
|
32
32
|
* `REVEALUI_API_KEY` env vars when no override is set.
|
|
33
33
|
*/
|
|
34
|
+
import { createHash } from 'node:crypto';
|
|
34
35
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
35
36
|
import { CallToolRequestSchema, ListResourcesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
36
37
|
import { z } from 'zod/v4';
|
|
37
38
|
import { validateToolArgs } from '../../validate-tool-args.js';
|
|
39
|
+
/** sha256 (hex) of the canonical JSON of an arbitrary argument object. */
|
|
40
|
+
function digestArgs(args) {
|
|
41
|
+
return createHash('sha256').update(canonicalJson(args)).digest('hex');
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Deterministic JSON with object keys sorted, so the digest of the same
|
|
45
|
+
* logical arguments is stable regardless of key order. No regex; a manual
|
|
46
|
+
* recursive serializer over the parsed value.
|
|
47
|
+
*/
|
|
48
|
+
function canonicalJson(value) {
|
|
49
|
+
if (value === null || typeof value !== 'object')
|
|
50
|
+
return JSON.stringify(value) ?? 'null';
|
|
51
|
+
if (Array.isArray(value))
|
|
52
|
+
return `[${value.map(canonicalJson).join(',')}]`;
|
|
53
|
+
const entries = Object.entries(value).sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
|
|
54
|
+
return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`).join(',')}}`;
|
|
55
|
+
}
|
|
56
|
+
/** Allowlisted, non-secret scalars safe to store in a receipt in the clear. */
|
|
57
|
+
const AUDIT_SCALAR_ALLOWLIST = ['collection', 'site_id'];
|
|
58
|
+
function pickAuditScalars(args) {
|
|
59
|
+
const out = {};
|
|
60
|
+
if (!args || typeof args !== 'object')
|
|
61
|
+
return out;
|
|
62
|
+
const record = args;
|
|
63
|
+
for (const key of AUDIT_SCALAR_ALLOWLIST) {
|
|
64
|
+
const raw = record[key];
|
|
65
|
+
if (typeof raw === 'string' && raw.length > 0)
|
|
66
|
+
out[key] = raw;
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
38
70
|
// ---------------------------------------------------------------------------
|
|
39
71
|
// Credential overrides (set by hypervisor / HTTP launcher)
|
|
40
72
|
// ---------------------------------------------------------------------------
|
|
@@ -77,9 +109,9 @@ async function apiGet(baseUrl, apiKey, path, params) {
|
|
|
77
109
|
const res = await fetch(url.toString(), { headers: apiHeaders(apiKey) });
|
|
78
110
|
const body = await res.json();
|
|
79
111
|
if (!res.ok) {
|
|
80
|
-
throw new
|
|
112
|
+
throw new ApiRequestError(body.error ??
|
|
81
113
|
body.message ??
|
|
82
|
-
`API ${res.status}
|
|
114
|
+
`API ${res.status}`, res.status);
|
|
83
115
|
}
|
|
84
116
|
return body;
|
|
85
117
|
}
|
|
@@ -195,6 +227,15 @@ const TOOLS = [
|
|
|
195
227
|
},
|
|
196
228
|
},
|
|
197
229
|
];
|
|
230
|
+
/** Error carrying the upstream HTTP status, for audit `httpStatus`. */
|
|
231
|
+
class ApiRequestError extends Error {
|
|
232
|
+
status;
|
|
233
|
+
constructor(message, status) {
|
|
234
|
+
super(message);
|
|
235
|
+
this.status = status;
|
|
236
|
+
this.name = 'ApiRequestError';
|
|
237
|
+
}
|
|
238
|
+
}
|
|
198
239
|
/**
|
|
199
240
|
* Curated fallback used when neither an injected provider nor HTTP
|
|
200
241
|
* introspection is available. These four collections exist in every admin
|
|
@@ -328,7 +369,15 @@ async function fetchCollectionsFromAdmin(apiUrl, apiKey) {
|
|
|
328
369
|
* consume this factory; the factory itself is transport-agnostic.
|
|
329
370
|
*/
|
|
330
371
|
export function createRevealuiContentServer(options) {
|
|
331
|
-
|
|
372
|
+
// A `credentialsProvider` marks the governed/hosted mount (`/api/mcp`). On
|
|
373
|
+
// that path Phase 1 exposes ONLY the five read tools (design §4-D): the
|
|
374
|
+
// resource handlers below resolve the ambient service credential rather than
|
|
375
|
+
// the caller's token and write no receipt, so on a multi-tenant mount they
|
|
376
|
+
// would be a cross-tenant, unaudited read channel. The capability is therefore
|
|
377
|
+
// structurally absent when governed — not merely credential-gated. The stdio /
|
|
378
|
+
// local mount (no options) keeps resources unchanged (single-operator trust).
|
|
379
|
+
const governed = options?.credentialsProvider !== undefined;
|
|
380
|
+
const server = new Server({ name: 'revealui-content', version: '1.0.0' }, { capabilities: governed ? { tools: {} } : { tools: {}, resources: {} } });
|
|
332
381
|
// Per-server memoization: resolve the effective collection set once and
|
|
333
382
|
// reuse across `resources/list` + `resources/read` for the lifetime of the
|
|
334
383
|
// server instance. Avoids double-fetching on every read.
|
|
@@ -357,80 +406,232 @@ export function createRevealuiContentServer(options) {
|
|
|
357
406
|
cachedCollections = [...CURATED_FALLBACK];
|
|
358
407
|
return cachedCollections;
|
|
359
408
|
}
|
|
360
|
-
server.setRequestHandler(ListToolsRequestSchema, async () =>
|
|
409
|
+
server.setRequestHandler(ListToolsRequestSchema, async (_request, extra) => {
|
|
410
|
+
const authorizer = options?.toolAuthorizer;
|
|
411
|
+
if (!authorizer)
|
|
412
|
+
return { tools: TOOLS };
|
|
413
|
+
// Filtered discovery (I-7): advertise only tools this caller may execute.
|
|
414
|
+
// This is UX; execution authz below is the security control — a tool hidden
|
|
415
|
+
// here is still independently denied on a direct `tools/call`.
|
|
416
|
+
const ctx = {
|
|
417
|
+
authInfo: extra?.authInfo,
|
|
418
|
+
sessionId: extra?.sessionId,
|
|
419
|
+
};
|
|
420
|
+
return { tools: TOOLS.filter((tool) => authorizer(ctx, tool.name)) };
|
|
421
|
+
});
|
|
361
422
|
// -------------------------------------------------------------------------
|
|
362
423
|
// Resources (Stage 4.1 + 4.2)
|
|
424
|
+
//
|
|
425
|
+
// Registered ONLY on the ungoverned (stdio / local) path. These handlers use
|
|
426
|
+
// the process-global `resolveCredentials()` and emit no receipt, so on the
|
|
427
|
+
// governed mount they are omitted entirely (see capability gate above,
|
|
428
|
+
// design §4-D). The guard and the capability advertisement must stay in
|
|
429
|
+
// lockstep: a registered handler with no advertised capability, or vice
|
|
430
|
+
// versa, reintroduces the bypass.
|
|
363
431
|
// -------------------------------------------------------------------------
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
432
|
+
if (!governed) {
|
|
433
|
+
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
434
|
+
const { apiUrl, apiKey } = resolveCredentials();
|
|
435
|
+
if (!(apiUrl && apiKey)) {
|
|
436
|
+
// Without credentials the server can't enumerate rows; advertise an
|
|
437
|
+
// empty list rather than erroring — clients still see the resources
|
|
438
|
+
// capability and can retry once creds are set.
|
|
439
|
+
return { resources: [] };
|
|
440
|
+
}
|
|
441
|
+
const collections = await resolveCollections();
|
|
442
|
+
const resources = [];
|
|
443
|
+
for (const collection of collections) {
|
|
444
|
+
try {
|
|
445
|
+
const body = await apiGet(apiUrl, apiKey, `/api/${collection.slug}`, {
|
|
446
|
+
limit: String(DEFAULT_RESOURCE_PAGE_SIZE),
|
|
447
|
+
page: '1',
|
|
448
|
+
});
|
|
449
|
+
for (const row of extractDocs(body)) {
|
|
450
|
+
resources.push(resourceForRow(collection, row));
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
catch {
|
|
454
|
+
// empty-catch-ok: an unavailable collection shouldn't blank-out the entire resource list
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return { resources };
|
|
458
|
+
});
|
|
459
|
+
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
460
|
+
const parsed = parseResourceUri(request.params.uri);
|
|
461
|
+
if (!parsed) {
|
|
462
|
+
throw new Error(`Unknown resource URI (expected ${RESOURCE_URI_PREFIX}<collection>/<id>): ${request.params.uri}`);
|
|
463
|
+
}
|
|
464
|
+
const collections = await resolveCollections();
|
|
465
|
+
const collection = collections.find((c) => c.slug === parsed.collection);
|
|
466
|
+
if (!collection) {
|
|
467
|
+
throw new Error(`Collection is not exposed as a resource: ${parsed.collection}`);
|
|
468
|
+
}
|
|
469
|
+
const { apiUrl, apiKey } = resolveCredentials();
|
|
470
|
+
if (!(apiUrl && apiKey)) {
|
|
471
|
+
throw new Error('REVEALUI_API_URL and REVEALUI_API_KEY must be set');
|
|
472
|
+
}
|
|
473
|
+
const row = await apiGet(apiUrl, apiKey, `/api/${parsed.collection}/${parsed.id}`);
|
|
474
|
+
return {
|
|
475
|
+
contents: [
|
|
476
|
+
{
|
|
477
|
+
uri: request.params.uri,
|
|
478
|
+
mimeType: 'application/json',
|
|
479
|
+
text: JSON.stringify(row, null, 2),
|
|
480
|
+
},
|
|
481
|
+
],
|
|
482
|
+
};
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
486
|
+
const startTime = Date.now();
|
|
487
|
+
const toolName = request.params.name;
|
|
488
|
+
const rawArgs = request.params.arguments;
|
|
489
|
+
const ctx = {
|
|
490
|
+
authInfo: extra?.authInfo,
|
|
491
|
+
sessionId: extra?.sessionId,
|
|
492
|
+
};
|
|
493
|
+
const auditSink = options?.auditSink;
|
|
494
|
+
const mutating = options?.mutatingTools?.has(toolName) ?? false;
|
|
495
|
+
// Write a receipt for this call. Returns whether the write succeeded; the
|
|
496
|
+
// sink itself classifies + logs a failure, so callers only decide between
|
|
497
|
+
// fail-closed (mutations) and degrade (reads). No-op when no sink is wired
|
|
498
|
+
// (the stdio path).
|
|
499
|
+
async function writeReceipt(outcome, opts) {
|
|
500
|
+
if (!auditSink)
|
|
501
|
+
return true;
|
|
502
|
+
const client = server.getClientVersion();
|
|
503
|
+
const record = {
|
|
504
|
+
outcome,
|
|
505
|
+
tool: toolName,
|
|
506
|
+
argsDigest: digestArgs(rawArgs ?? null),
|
|
507
|
+
scalars: pickAuditScalars(rawArgs),
|
|
508
|
+
durationMs: Date.now() - startTime,
|
|
509
|
+
httpStatus: opts?.httpStatus,
|
|
510
|
+
reason: opts?.reason,
|
|
511
|
+
clientInfo: client ? { name: client.name, version: client.version } : undefined,
|
|
512
|
+
context: ctx,
|
|
513
|
+
};
|
|
514
|
+
try {
|
|
515
|
+
await auditSink(record);
|
|
516
|
+
return true;
|
|
517
|
+
}
|
|
518
|
+
catch {
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
371
521
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
522
|
+
// A call rejected before it executes (unknown tool, invalid args, authz or
|
|
523
|
+
// rate-limit denial). Records a `denied` receipt (best-effort — a denial
|
|
524
|
+
// that mutates nothing degrades like a read) and returns the client error.
|
|
525
|
+
async function denied(response, reason) {
|
|
526
|
+
await writeReceipt('denied', reason ? { reason } : undefined);
|
|
527
|
+
return response;
|
|
528
|
+
}
|
|
529
|
+
// Deny-by-default collection allowlist. The content tools interpolate the
|
|
530
|
+
// `collection` arg into `/api/<collection>`, so a free-string collection
|
|
531
|
+
// would let one tool reach another tool's endpoint (e.g. `/api/users`,
|
|
532
|
+
// bypassing the admin gate on `revealui_list_users`). A collection outside
|
|
533
|
+
// the RESOLVED exposed set is denied before any REST call — the backend is
|
|
534
|
+
// never reached for an unexposed collection.
|
|
535
|
+
async function denyIfCollectionNotExposed(collection) {
|
|
536
|
+
const exposed = await resolveCollections();
|
|
537
|
+
const slugs = new Set(exposed.map((c) => c.slug));
|
|
538
|
+
if (slugs.has(collection))
|
|
539
|
+
return null;
|
|
540
|
+
return denied({
|
|
541
|
+
content: [{ type: 'text', text: `Error: collection is not exposed: ${collection}` }],
|
|
542
|
+
isError: true,
|
|
543
|
+
}, 'collection-not-exposed');
|
|
544
|
+
}
|
|
545
|
+
// Emit one usage-meter event for a call that actually executed. Swallows
|
|
546
|
+
// sink errors so metering can never break the tool call.
|
|
547
|
+
async function fireMeter(errored) {
|
|
548
|
+
if (!options?.meterSink)
|
|
549
|
+
return;
|
|
375
550
|
try {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
551
|
+
await options.meterSink(ctx, {
|
|
552
|
+
tool: toolName,
|
|
553
|
+
durationMs: Date.now() - startTime,
|
|
554
|
+
errored,
|
|
379
555
|
});
|
|
380
|
-
for (const row of extractDocs(body)) {
|
|
381
|
-
resources.push(resourceForRow(collection, row));
|
|
382
|
-
}
|
|
383
556
|
}
|
|
384
557
|
catch {
|
|
385
|
-
// empty-catch-ok:
|
|
558
|
+
// empty-catch-ok: metering is best-effort and must not affect the call
|
|
386
559
|
}
|
|
387
560
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
561
|
+
// Deny-by-default per-tool authorization (I-7). Runs before credentials are
|
|
562
|
+
// resolved, so an unauthorized caller never triggers a credential lookup or
|
|
563
|
+
// a REST call. A tool hidden from `tools/list` is still denied here.
|
|
564
|
+
if (options?.toolAuthorizer && !options.toolAuthorizer(ctx, toolName)) {
|
|
565
|
+
return denied({
|
|
566
|
+
content: [{ type: 'text', text: `Error: not authorized to call tool: ${toolName}` }],
|
|
567
|
+
isError: true,
|
|
568
|
+
}, 'authz');
|
|
394
569
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
570
|
+
// Per-user + tier rate limit (I-8). Consumed only for an authorized call,
|
|
571
|
+
// before any credential resolution or execution. A denial is audited with
|
|
572
|
+
// `reason: 'rate-limit'` and never meters (a rejected call is not usage).
|
|
573
|
+
if (options?.rateLimiter) {
|
|
574
|
+
const allowed = await options.rateLimiter(ctx, toolName);
|
|
575
|
+
if (!allowed) {
|
|
576
|
+
return denied({
|
|
577
|
+
content: [{ type: 'text', text: `Error: rate limit exceeded for tool: ${toolName}` }],
|
|
578
|
+
isError: true,
|
|
579
|
+
}, 'rate-limit');
|
|
580
|
+
}
|
|
399
581
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
582
|
+
// Resolve credentials. Governed path: the injected provider is the sole
|
|
583
|
+
// source and may throw when no per-request credential exists (I-4). Env
|
|
584
|
+
// path is unchanged for stdio.
|
|
585
|
+
let apiUrl;
|
|
586
|
+
let apiKey;
|
|
587
|
+
try {
|
|
588
|
+
if (options?.credentialsProvider) {
|
|
589
|
+
const resolved = await options.credentialsProvider(ctx);
|
|
590
|
+
apiUrl = resolved.apiUrl;
|
|
591
|
+
apiKey = resolved.apiKey;
|
|
592
|
+
}
|
|
593
|
+
else {
|
|
594
|
+
const resolved = resolveCredentials();
|
|
595
|
+
if (!(resolved.apiUrl && resolved.apiKey)) {
|
|
596
|
+
return {
|
|
597
|
+
content: [
|
|
598
|
+
{ type: 'text', text: 'Error: REVEALUI_API_URL and REVEALUI_API_KEY must be set' },
|
|
599
|
+
],
|
|
600
|
+
isError: true,
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
apiUrl = resolved.apiUrl;
|
|
604
|
+
apiKey = resolved.apiKey;
|
|
605
|
+
}
|
|
403
606
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
contents: [
|
|
407
|
-
{
|
|
408
|
-
uri: request.params.uri,
|
|
409
|
-
mimeType: 'application/json',
|
|
410
|
-
text: JSON.stringify(row, null, 2),
|
|
411
|
-
},
|
|
412
|
-
],
|
|
413
|
-
};
|
|
414
|
-
});
|
|
415
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
416
|
-
const startTime = Date.now();
|
|
417
|
-
const toolName = request.params.name;
|
|
418
|
-
const { apiUrl, apiKey } = resolveCredentials();
|
|
419
|
-
if (!(apiUrl && apiKey)) {
|
|
607
|
+
catch (err) {
|
|
608
|
+
await writeReceipt('failed');
|
|
420
609
|
return {
|
|
421
610
|
content: [
|
|
422
|
-
{ type: 'text', text:
|
|
611
|
+
{ type: 'text', text: `Error: ${err instanceof Error ? err.message : String(err)}` },
|
|
423
612
|
],
|
|
424
613
|
isError: true,
|
|
425
614
|
};
|
|
426
615
|
}
|
|
616
|
+
// Fail-closed for mutations: the receipt is written BEFORE the tool runs,
|
|
617
|
+
// so a state change can never happen without a durable record of it. If
|
|
618
|
+
// the write fails, refuse the call — nothing executes.
|
|
619
|
+
if (mutating) {
|
|
620
|
+
const recorded = await writeReceipt('invoked');
|
|
621
|
+
if (!recorded) {
|
|
622
|
+
return {
|
|
623
|
+
content: [{ type: 'text', text: 'Error: audit log unavailable; mutating tool refused' }],
|
|
624
|
+
isError: true,
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
}
|
|
427
628
|
try {
|
|
428
629
|
let data;
|
|
429
630
|
switch (toolName) {
|
|
430
631
|
case 'revealui_list_sites': {
|
|
431
|
-
const parsed = validateToolArgs(ListSitesArgsSchema,
|
|
632
|
+
const parsed = validateToolArgs(ListSitesArgsSchema, rawArgs, toolName);
|
|
432
633
|
if (!parsed.ok)
|
|
433
|
-
return parsed.error;
|
|
634
|
+
return denied(parsed.error);
|
|
434
635
|
const { limit = 20, page = 1 } = parsed.value;
|
|
435
636
|
data = await apiGet(apiUrl, apiKey, '/api/sites', {
|
|
436
637
|
limit: String(limit),
|
|
@@ -439,10 +640,13 @@ export function createRevealuiContentServer(options) {
|
|
|
439
640
|
break;
|
|
440
641
|
}
|
|
441
642
|
case 'revealui_list_content': {
|
|
442
|
-
const parsed = validateToolArgs(ListContentArgsSchema,
|
|
643
|
+
const parsed = validateToolArgs(ListContentArgsSchema, rawArgs, toolName);
|
|
443
644
|
if (!parsed.ok)
|
|
444
|
-
return parsed.error;
|
|
645
|
+
return denied(parsed.error);
|
|
445
646
|
const { site_id, collection, limit = 20, page = 1, status } = parsed.value;
|
|
647
|
+
const notExposed = await denyIfCollectionNotExposed(collection);
|
|
648
|
+
if (notExposed)
|
|
649
|
+
return notExposed;
|
|
446
650
|
const params = {
|
|
447
651
|
limit: String(limit),
|
|
448
652
|
page: String(page),
|
|
@@ -455,17 +659,20 @@ export function createRevealuiContentServer(options) {
|
|
|
455
659
|
break;
|
|
456
660
|
}
|
|
457
661
|
case 'revealui_get_content': {
|
|
458
|
-
const parsed = validateToolArgs(GetContentArgsSchema,
|
|
662
|
+
const parsed = validateToolArgs(GetContentArgsSchema, rawArgs, toolName);
|
|
459
663
|
if (!parsed.ok)
|
|
460
|
-
return parsed.error;
|
|
664
|
+
return denied(parsed.error);
|
|
461
665
|
const { collection, id } = parsed.value;
|
|
666
|
+
const notExposed = await denyIfCollectionNotExposed(collection);
|
|
667
|
+
if (notExposed)
|
|
668
|
+
return notExposed;
|
|
462
669
|
data = await apiGet(apiUrl, apiKey, `/api/${collection}/${id}`);
|
|
463
670
|
break;
|
|
464
671
|
}
|
|
465
672
|
case 'revealui_list_users': {
|
|
466
|
-
const parsed = validateToolArgs(ListUsersArgsSchema,
|
|
673
|
+
const parsed = validateToolArgs(ListUsersArgsSchema, rawArgs, toolName);
|
|
467
674
|
if (!parsed.ok)
|
|
468
|
-
return parsed.error;
|
|
675
|
+
return denied(parsed.error);
|
|
469
676
|
const { site_id, limit = 20, page = 1 } = parsed.value;
|
|
470
677
|
const params = {
|
|
471
678
|
limit: String(limit),
|
|
@@ -477,9 +684,9 @@ export function createRevealuiContentServer(options) {
|
|
|
477
684
|
break;
|
|
478
685
|
}
|
|
479
686
|
case 'revealui_site_stats': {
|
|
480
|
-
const parsed = validateToolArgs(SiteStatsArgsSchema,
|
|
687
|
+
const parsed = validateToolArgs(SiteStatsArgsSchema, rawArgs, toolName);
|
|
481
688
|
if (!parsed.ok)
|
|
482
|
-
return parsed.error;
|
|
689
|
+
return denied(parsed.error);
|
|
483
690
|
const { site_id } = parsed.value;
|
|
484
691
|
const params = {};
|
|
485
692
|
if (site_id)
|
|
@@ -488,11 +695,17 @@ export function createRevealuiContentServer(options) {
|
|
|
488
695
|
break;
|
|
489
696
|
}
|
|
490
697
|
default:
|
|
491
|
-
return {
|
|
698
|
+
return denied({
|
|
492
699
|
content: [{ type: 'text', text: `Error: Unknown tool: ${toolName}` }],
|
|
493
700
|
isError: true,
|
|
494
|
-
};
|
|
701
|
+
});
|
|
495
702
|
}
|
|
703
|
+
// Read tools record the receipt AFTER a successful call and degrade on a
|
|
704
|
+
// write failure (the data is already fetched; the sink logs + marks the
|
|
705
|
+
// degraded write). Mutations already recorded their receipt above.
|
|
706
|
+
if (!mutating)
|
|
707
|
+
await writeReceipt('invoked');
|
|
708
|
+
await fireMeter(false);
|
|
496
709
|
return {
|
|
497
710
|
content: [
|
|
498
711
|
{
|
|
@@ -511,6 +724,9 @@ export function createRevealuiContentServer(options) {
|
|
|
511
724
|
};
|
|
512
725
|
}
|
|
513
726
|
catch (err) {
|
|
727
|
+
const httpStatus = err instanceof ApiRequestError ? err.status : undefined;
|
|
728
|
+
await writeReceipt('failed', { httpStatus });
|
|
729
|
+
await fireMeter(true);
|
|
514
730
|
return {
|
|
515
731
|
content: [
|
|
516
732
|
{ type: 'text', text: `Error: ${err instanceof Error ? err.message : String(err)}` },
|