@ggui-ai/mcp-server 0.1.0-rc.3 → 0.2.0-alpha.3
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 +1 -1
- package/dist/build-mcp.d.ts +8 -8
- package/dist/build-mcp.d.ts.map +1 -1
- package/dist/build-mcp.js +53 -12
- package/dist/console-auth.d.ts +7 -7
- package/dist/console-auth.d.ts.map +1 -1
- package/dist/console-auth.js +4 -4
- package/dist/console-cache.d.ts +2 -2
- package/dist/console-cache.d.ts.map +1 -1
- package/dist/console-cache.js +10 -10
- package/dist/console-headers.d.ts +2 -2
- package/dist/console-headers.js +2 -2
- package/dist/console-payloads.d.ts +3 -3
- package/dist/console-payloads.d.ts.map +1 -1
- package/dist/console-payloads.js +10 -10
- package/dist/console-timeline.d.ts +12 -30
- package/dist/console-timeline.d.ts.map +1 -1
- package/dist/console-timeline.js +44 -45
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/instructions-presets.d.ts +1 -1
- package/dist/instructions-presets.d.ts.map +1 -1
- package/dist/instructions-presets.js +40 -22
- package/dist/llm-backed-negotiator.d.ts +6 -6
- package/dist/llm-backed-negotiator.d.ts.map +1 -1
- package/dist/llm-backed-negotiator.js +92 -91
- package/dist/mcp-apps-inbound.d.ts +3 -3
- package/dist/mcp-apps-inbound.d.ts.map +1 -1
- package/dist/mcp-apps-inbound.js +28 -23
- package/dist/mcp-apps-outbound.d.ts +136 -121
- package/dist/mcp-apps-outbound.d.ts.map +1 -1
- package/dist/mcp-apps-outbound.js +384 -414
- package/dist/mcp-mounts.d.ts +21 -20
- package/dist/mcp-mounts.d.ts.map +1 -1
- package/dist/mcp-mounts.js +25 -29
- package/dist/{session-channel.d.ts → render-channel.d.ts} +145 -102
- package/dist/render-channel.d.ts.map +1 -0
- package/dist/{session-channel.js → render-channel.js} +481 -462
- package/dist/schema-compat.d.ts +11 -11
- package/dist/schema-compat.d.ts.map +1 -1
- package/dist/schema-compat.js +6 -6
- package/dist/server.d.ts +224 -219
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1498 -1963
- package/dist/storage.d.ts +7 -7
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +12 -12
- package/package.json +12 -11
- package/dist/render-gate.d.ts +0 -87
- package/dist/render-gate.d.ts.map +0 -1
- package/dist/render-gate.js +0 -77
- package/dist/render-rate-limit.d.ts +0 -59
- package/dist/render-rate-limit.d.ts.map +0 -1
- package/dist/render-rate-limit.js +0 -73
- package/dist/render-signing.d.ts +0 -98
- package/dist/render-signing.d.ts.map +0 -1
- package/dist/render-signing.js +0 -113
- package/dist/session-channel.d.ts.map +0 -1
package/dist/mcp-mounts.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* mcp-mounts — aggregate external MCP tool handler bundles onto the
|
|
3
3
|
* ggui `/mcp` surface so one session can see ggui-native tools (e.g.
|
|
4
|
-
* `
|
|
4
|
+
* `ggui_render`) AND mounted tools (e.g. `tasks_*`) through a single
|
|
5
5
|
* MCP connection.
|
|
6
6
|
*
|
|
7
7
|
* Scope lock: a **mount** is a named bundle of `SharedHandler`
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
* `buildMcpServer` registration, `toolCount`, telemetry, and logging
|
|
21
21
|
* all Just Work.
|
|
22
22
|
*/
|
|
23
|
-
import type {
|
|
24
|
-
import type {
|
|
25
|
-
import type { WiredActionContext, WiredActionRouter } from
|
|
23
|
+
import type { HandlerContext, SharedHandler } from "@ggui-ai/mcp-server-handlers";
|
|
24
|
+
import type { ZodRawShape } from "zod";
|
|
25
|
+
import type { WiredActionContext, WiredActionRouter } from "./render-channel.js";
|
|
26
26
|
/**
|
|
27
27
|
* Runtime ctx the mount-router hands the mount handler. Structurally a
|
|
28
28
|
* superset of `HandlerContext` (so the mount's `handler(input, ctx)`
|
|
@@ -30,7 +30,7 @@ import type { WiredActionContext, WiredActionRouter } from './session-channel.js
|
|
|
30
30
|
* {@link WiredActionContext}.
|
|
31
31
|
*
|
|
32
32
|
* Why the type is exported: TS-authored mount tools that want to read
|
|
33
|
-
* `ctx.sendPropsUpdate` / `ctx.
|
|
33
|
+
* `ctx.sendPropsUpdate` / `ctx.renderId` import this and narrow their
|
|
34
34
|
* `handler` parameter (e.g. `async handler(input, ctx) { const wired =
|
|
35
35
|
* ctx as WiredMountContext; … }`). JS-authored mounts (.mjs) read the
|
|
36
36
|
* fields structurally — they're present on the runtime object whether
|
|
@@ -40,25 +40,25 @@ import type { WiredActionContext, WiredActionRouter } from './session-channel.js
|
|
|
40
40
|
* narrow on `HandlerContext`. Widening that type would force every
|
|
41
41
|
* shared handler (ggui-native + mounted) to acknowledge a wired-only
|
|
42
42
|
* surface, even handlers that never run through the wired-action path
|
|
43
|
-
* (e.g. `
|
|
43
|
+
* (e.g. `ggui_render`, blueprint search). The structural superset here
|
|
44
44
|
* keeps the canonical contract narrow without sacrificing access for
|
|
45
45
|
* mount tools that opt in.
|
|
46
46
|
*/
|
|
47
47
|
/**
|
|
48
48
|
* Intersection (not interface-extension) because `HandlerContext` declares
|
|
49
|
-
* `
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
49
|
+
* `renderId?` as optional — the canonical context shape any handler may
|
|
50
|
+
* see — whereas `WiredActionContext` declares it as required (the
|
|
51
|
+
* wired-action dispatcher always knows the active render at invocation
|
|
52
|
+
* time). Interface-extends rejects "narrowing optional → required" via
|
|
53
|
+
* TS2320 ("cannot simultaneously extend"), but an intersection composes
|
|
54
|
+
* the two perfectly: optional ∧ required ≡ required.
|
|
55
55
|
*
|
|
56
56
|
* Surface for consumers stays identical — a TS-authored mount that types
|
|
57
|
-
* its `handler` parameter as `WiredMountContext` reads `
|
|
58
|
-
*
|
|
57
|
+
* its `handler` parameter as `WiredMountContext` reads `renderId: string`
|
|
58
|
+
* (no `| undefined`) + every `HandlerContext` field
|
|
59
59
|
* (`appId`, `requestId`, optional `apiKeyHash`).
|
|
60
60
|
*/
|
|
61
|
-
export type WiredMountContext = Omit<HandlerContext,
|
|
61
|
+
export type WiredMountContext = Omit<HandlerContext, "renderId"> & WiredActionContext;
|
|
62
62
|
/**
|
|
63
63
|
* One named bundle of tool handlers the server should aggregate onto
|
|
64
64
|
* its MCP surface.
|
|
@@ -78,7 +78,7 @@ export interface McpServerMount {
|
|
|
78
78
|
readonly name: string;
|
|
79
79
|
/**
|
|
80
80
|
* Tool handler bundle. Each entry is a `SharedHandler` — the same
|
|
81
|
-
* shape ggui-native handlers (blueprint family,
|
|
81
|
+
* shape ggui-native handlers (blueprint family, renders,
|
|
82
82
|
* threads) already use. The server calls {@link SharedHandler.handler}
|
|
83
83
|
* through `buildMcpServer`'s regular registration path; validation,
|
|
84
84
|
* logging, and output-schema parsing all happen uniformly.
|
|
@@ -90,7 +90,7 @@ export interface McpServerMount {
|
|
|
90
90
|
* raw string via {@link validateServicePath}.
|
|
91
91
|
*/
|
|
92
92
|
export type ServicePath = string & {
|
|
93
|
-
readonly __brand:
|
|
93
|
+
readonly __brand: "ServicePath";
|
|
94
94
|
};
|
|
95
95
|
/**
|
|
96
96
|
* Validate + brand a service HTTP path. Throws on malformed input or
|
|
@@ -209,9 +209,9 @@ export declare function composeHandlersWithMounts(baseHandlers: ReadonlyArray<Sh
|
|
|
209
209
|
*
|
|
210
210
|
* Ownership + scoping:
|
|
211
211
|
* - Only MOUNT handlers participate. ggui-native handlers
|
|
212
|
-
* (`
|
|
212
|
+
* (`ggui_render`, `ggui_handshake`, etc.) are platform tools and
|
|
213
213
|
* deliberately NOT exposed as wire-dispatchable actions — a
|
|
214
|
-
* component that tried to dispatch `
|
|
214
|
+
* component that tried to dispatch `ggui_render` would bypass the
|
|
215
215
|
* agentic-loop contract.
|
|
216
216
|
* - Name collisions across mounts are prevented at aggregation
|
|
217
217
|
* time by {@link composeHandlersWithMounts}, so the first-match
|
|
@@ -226,7 +226,8 @@ export declare function composeHandlersWithMounts(baseHandlers: ReadonlyArray<Sh
|
|
|
226
226
|
* {@link WiredActionContext}. The runtime ctx the mount handler
|
|
227
227
|
* sees is a structural superset
|
|
228
228
|
* ({@link WiredMountContext}) so a JS-authored mount can call
|
|
229
|
-
* `ctx.sendPropsUpdate(
|
|
229
|
+
* `ctx.sendPropsUpdate({...})` directly (closed over `ctx.renderId`).
|
|
230
|
+
* The static
|
|
230
231
|
* `SharedHandler.handler(input, ctx: HandlerContext)` shape stays
|
|
231
232
|
* untouched — tooling that doesn't read the wired fields keeps its
|
|
232
233
|
* existing types.
|
package/dist/mcp-mounts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-mounts.d.ts","sourceRoot":"","sources":["../src/mcp-mounts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"mcp-mounts.d.ts","sourceRoot":"","sources":["../src/mcp-mounts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEjF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,GAAG,kBAAkB,CAAC;AAEtF;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,aAAa,C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
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
* silently swallow OAuth discovery / health / per-app traffic.
|
|
5
5
|
*/
|
|
6
6
|
const RESERVED_SERVICE_PATHS = new Set([
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
"/",
|
|
8
|
+
"/mcp",
|
|
9
|
+
"/protocol",
|
|
10
|
+
"/ops",
|
|
11
|
+
"/ws",
|
|
12
|
+
"/health",
|
|
13
|
+
"/.well-known",
|
|
14
|
+
"/oauth",
|
|
15
|
+
"/_ggui",
|
|
16
|
+
"/ggui",
|
|
17
17
|
]);
|
|
18
18
|
const SERVICE_PATH_REGEX = /^\/[a-zA-Z0-9_/-]+$/;
|
|
19
19
|
/**
|
|
@@ -31,7 +31,7 @@ export function validateServicePath(p) {
|
|
|
31
31
|
if (!SERVICE_PATH_REGEX.test(p)) {
|
|
32
32
|
throw new Error(`createGguiServer: mcpServices path "${p}" is malformed — must start with "/" and contain only letters, digits, "-", "_", and "/".`);
|
|
33
33
|
}
|
|
34
|
-
if (p.length > 1 && p.endsWith(
|
|
34
|
+
if (p.length > 1 && p.endsWith("/")) {
|
|
35
35
|
throw new Error(`createGguiServer: mcpServices path "${p}" must not end with "/" (use "${p.slice(0, -1)}" instead).`);
|
|
36
36
|
}
|
|
37
37
|
if (RESERVED_SERVICE_PATHS.has(p)) {
|
|
@@ -57,8 +57,8 @@ export function validateMcpServices(services) {
|
|
|
57
57
|
return services ?? [];
|
|
58
58
|
const seenPaths = new Set();
|
|
59
59
|
for (const svc of services) {
|
|
60
|
-
if (typeof svc.name !==
|
|
61
|
-
throw new Error(
|
|
60
|
+
if (typeof svc.name !== "string" || svc.name.length === 0) {
|
|
61
|
+
throw new Error("createGguiServer: every `mcpServices` entry must carry a non-empty string `name` (for validation-error clarity).");
|
|
62
62
|
}
|
|
63
63
|
validateServicePath(svc.path);
|
|
64
64
|
if (seenPaths.has(svc.path)) {
|
|
@@ -67,7 +67,7 @@ export function validateMcpServices(services) {
|
|
|
67
67
|
seenPaths.add(svc.path);
|
|
68
68
|
const seenTools = new Set();
|
|
69
69
|
for (const h of svc.handlers) {
|
|
70
|
-
if (typeof h.outputSchema !==
|
|
70
|
+
if (typeof h.outputSchema !== "object" ||
|
|
71
71
|
h.outputSchema === null ||
|
|
72
72
|
Object.keys(h.outputSchema).length === 0) {
|
|
73
73
|
throw new Error(`createGguiServer: service "${svc.name}" handler "${h.name}" declares an empty \`outputSchema\` — this silently strips \`structuredContent\` at the MCP SDK boundary. Declare the fields the handler returns (e.g. \`outputSchema: { items: z.array(...) }\`).`);
|
|
@@ -104,13 +104,11 @@ export function composeHandlersWithMounts(baseHandlers, mounts) {
|
|
|
104
104
|
// any other string = the mount's `name` that first claimed the tool.
|
|
105
105
|
const owner = new Map();
|
|
106
106
|
for (const h of baseHandlers)
|
|
107
|
-
owner.set(h.name,
|
|
108
|
-
const aggregated = [
|
|
109
|
-
...baseHandlers,
|
|
110
|
-
];
|
|
107
|
+
owner.set(h.name, "ggui");
|
|
108
|
+
const aggregated = [...baseHandlers];
|
|
111
109
|
for (const mount of mounts) {
|
|
112
|
-
if (typeof mount.name !==
|
|
113
|
-
throw new Error(
|
|
110
|
+
if (typeof mount.name !== "string" || mount.name.length === 0) {
|
|
111
|
+
throw new Error("createGguiServer: every `mcpMounts` entry must carry a non-empty string `name` (for diagnostic telemetry + collision-error clarity).");
|
|
114
112
|
}
|
|
115
113
|
for (const mh of mount.handlers) {
|
|
116
114
|
// `outputSchema: {}` (empty `ZodRawShape`) silently strips
|
|
@@ -126,16 +124,14 @@ export function composeHandlersWithMounts(baseHandlers, mounts) {
|
|
|
126
124
|
// legitimate no-output tool ever lands in a mount, declare
|
|
127
125
|
// `{ ok: z.literal(true) }` or equivalent — the zero-field
|
|
128
126
|
// case is never what you want over the wire.
|
|
129
|
-
if (typeof mh.outputSchema !==
|
|
127
|
+
if (typeof mh.outputSchema !== "object" ||
|
|
130
128
|
mh.outputSchema === null ||
|
|
131
129
|
Object.keys(mh.outputSchema).length === 0) {
|
|
132
130
|
throw new Error(`createGguiServer: mount "${mount.name}" handler "${mh.name}" declares an empty \`outputSchema\` — this silently strips \`structuredContent\` at the MCP SDK boundary. Declare the fields the handler returns (e.g. \`outputSchema: { items: z.array(...) }\`). If the tool genuinely returns nothing, declare a sentinel like \`{ ok: z.literal(true) }\`.`);
|
|
133
131
|
}
|
|
134
132
|
const prior = owner.get(mh.name);
|
|
135
133
|
if (prior !== undefined) {
|
|
136
|
-
const priorLabel = prior ===
|
|
137
|
-
? 'a ggui-native tool'
|
|
138
|
-
: `mount "${prior}"`;
|
|
134
|
+
const priorLabel = prior === "ggui" ? "a ggui-native tool" : `mount "${prior}"`;
|
|
139
135
|
throw new Error(`createGguiServer: mount "${mount.name}" registers tool "${mh.name}" which collides with ${priorLabel}. Rename the tool or drop the duplicate mount.`);
|
|
140
136
|
}
|
|
141
137
|
owner.set(mh.name, mount.name);
|
|
@@ -153,9 +149,9 @@ export function composeHandlersWithMounts(baseHandlers, mounts) {
|
|
|
153
149
|
*
|
|
154
150
|
* Ownership + scoping:
|
|
155
151
|
* - Only MOUNT handlers participate. ggui-native handlers
|
|
156
|
-
* (`
|
|
152
|
+
* (`ggui_render`, `ggui_handshake`, etc.) are platform tools and
|
|
157
153
|
* deliberately NOT exposed as wire-dispatchable actions — a
|
|
158
|
-
* component that tried to dispatch `
|
|
154
|
+
* component that tried to dispatch `ggui_render` would bypass the
|
|
159
155
|
* agentic-loop contract.
|
|
160
156
|
* - Name collisions across mounts are prevented at aggregation
|
|
161
157
|
* time by {@link composeHandlersWithMounts}, so the first-match
|
|
@@ -170,7 +166,8 @@ export function composeHandlersWithMounts(baseHandlers, mounts) {
|
|
|
170
166
|
* {@link WiredActionContext}. The runtime ctx the mount handler
|
|
171
167
|
* sees is a structural superset
|
|
172
168
|
* ({@link WiredMountContext}) so a JS-authored mount can call
|
|
173
|
-
* `ctx.sendPropsUpdate(
|
|
169
|
+
* `ctx.sendPropsUpdate({...})` directly (closed over `ctx.renderId`).
|
|
170
|
+
* The static
|
|
174
171
|
* `SharedHandler.handler(input, ctx: HandlerContext)` shape stays
|
|
175
172
|
* untouched — tooling that doesn't read the wired fields keeps its
|
|
176
173
|
* existing types.
|
|
@@ -212,8 +209,7 @@ export function composeWiredActionRouterFromMounts(mounts, resolveContext) {
|
|
|
212
209
|
const baseCtx = resolveContext();
|
|
213
210
|
const ctx = {
|
|
214
211
|
...baseCtx,
|
|
215
|
-
|
|
216
|
-
stackItemId: wiredCtx.stackItemId,
|
|
212
|
+
renderId: wiredCtx.renderId,
|
|
217
213
|
sendPropsUpdate: wiredCtx.sendPropsUpdate,
|
|
218
214
|
};
|
|
219
215
|
return handler.handler(input, ctx);
|