@particle-academy/agent-integrations 0.44.0 → 0.45.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.
Files changed (168) hide show
  1. package/README.md +32 -0
  2. package/dist/bridges/artboard.d.cts +3 -3
  3. package/dist/bridges/artboard.d.ts +3 -3
  4. package/dist/bridges/catalog.d.cts +3 -3
  5. package/dist/bridges/catalog.d.ts +3 -3
  6. package/dist/bridges/charts.d.cts +3 -3
  7. package/dist/bridges/charts.d.ts +3 -3
  8. package/dist/bridges/cms.d.cts +3 -3
  9. package/dist/bridges/cms.d.ts +3 -3
  10. package/dist/bridges/code.d.cts +3 -3
  11. package/dist/bridges/code.d.ts +3 -3
  12. package/dist/bridges/doc.d.cts +3 -3
  13. package/dist/bridges/doc.d.ts +3 -3
  14. package/dist/bridges/features.d.cts +3 -3
  15. package/dist/bridges/features.d.ts +3 -3
  16. package/dist/bridges/files.d.cts +3 -3
  17. package/dist/bridges/files.d.ts +3 -3
  18. package/dist/bridges/flow.d.cts +3 -3
  19. package/dist/bridges/flow.d.ts +3 -3
  20. package/dist/bridges/forms.d.cts +3 -3
  21. package/dist/bridges/forms.d.ts +3 -3
  22. package/dist/bridges/git.d.cts +3 -3
  23. package/dist/bridges/git.d.ts +3 -3
  24. package/dist/bridges/grid.d.cts +3 -3
  25. package/dist/bridges/grid.d.ts +3 -3
  26. package/dist/bridges/map.d.cts +3 -3
  27. package/dist/bridges/map.d.ts +3 -3
  28. package/dist/bridges/passkeys.d.cts +3 -3
  29. package/dist/bridges/passkeys.d.ts +3 -3
  30. package/dist/bridges/scene.d.cts +3 -3
  31. package/dist/bridges/scene.d.ts +3 -3
  32. package/dist/bridges/screens.d.cts +3 -3
  33. package/dist/bridges/screens.d.ts +3 -3
  34. package/dist/bridges/sheets.d.cts +3 -3
  35. package/dist/bridges/sheets.d.ts +3 -3
  36. package/dist/bridges/slides.d.cts +3 -3
  37. package/dist/bridges/slides.d.ts +3 -3
  38. package/dist/bridges/terminal.d.cts +3 -3
  39. package/dist/bridges/terminal.d.ts +3 -3
  40. package/dist/bridges/tui.d.cts +2 -2
  41. package/dist/bridges/tui.d.ts +2 -2
  42. package/dist/bridges/whiteboard.d.cts +3 -3
  43. package/dist/bridges/whiteboard.d.ts +3 -3
  44. package/dist/bridges-artboard.cjs.map +1 -1
  45. package/dist/bridges-artboard.js +2 -2
  46. package/dist/bridges-catalog.cjs.map +1 -1
  47. package/dist/bridges-catalog.js +3 -3
  48. package/dist/bridges-charts.cjs.map +1 -1
  49. package/dist/bridges-charts.js +3 -3
  50. package/dist/bridges-cms.cjs.map +1 -1
  51. package/dist/bridges-cms.js +4 -4
  52. package/dist/bridges-code.cjs.map +1 -1
  53. package/dist/bridges-code.js +3 -3
  54. package/dist/bridges-doc.cjs.map +1 -1
  55. package/dist/bridges-doc.js +3 -3
  56. package/dist/bridges-features.cjs.map +1 -1
  57. package/dist/bridges-features.js +3 -3
  58. package/dist/bridges-files.cjs.map +1 -1
  59. package/dist/bridges-files.js +3 -3
  60. package/dist/bridges-flow.cjs.map +1 -1
  61. package/dist/bridges-flow.js +2 -2
  62. package/dist/bridges-forms.cjs.map +1 -1
  63. package/dist/bridges-forms.js +3 -3
  64. package/dist/bridges-git.cjs.map +1 -1
  65. package/dist/bridges-git.js +3 -3
  66. package/dist/bridges-grid.cjs.map +1 -1
  67. package/dist/bridges-grid.js +3 -3
  68. package/dist/bridges-map.cjs.map +1 -1
  69. package/dist/bridges-map.js +3 -3
  70. package/dist/bridges-passkeys.cjs.map +1 -1
  71. package/dist/bridges-passkeys.js +3 -3
  72. package/dist/bridges-scene.cjs.map +1 -1
  73. package/dist/bridges-scene.js +3 -3
  74. package/dist/bridges-screens.cjs.map +1 -1
  75. package/dist/bridges-screens.js +3 -3
  76. package/dist/bridges-sheets.cjs.map +1 -1
  77. package/dist/bridges-sheets.js +3 -3
  78. package/dist/bridges-slides.cjs.map +1 -1
  79. package/dist/bridges-slides.js +3 -3
  80. package/dist/bridges-terminal.cjs.map +1 -1
  81. package/dist/bridges-terminal.js +3 -3
  82. package/dist/bridges-tui.cjs.map +1 -1
  83. package/dist/bridges-tui.js +2 -2
  84. package/dist/bridges-whiteboard.cjs.map +1 -1
  85. package/dist/bridges-whiteboard.js +3 -3
  86. package/dist/{chunk-5W6YOXLT.js → chunk-36MKPTVD.js} +4 -4
  87. package/dist/{chunk-5W6YOXLT.js.map → chunk-36MKPTVD.js.map} +1 -1
  88. package/dist/{chunk-SXVRIIXW.js → chunk-3HVYUMQF.js} +4 -4
  89. package/dist/{chunk-SXVRIIXW.js.map → chunk-3HVYUMQF.js.map} +1 -1
  90. package/dist/{chunk-MZ74LLDS.js → chunk-3UUF5KKZ.js} +4 -4
  91. package/dist/{chunk-MZ74LLDS.js.map → chunk-3UUF5KKZ.js.map} +1 -1
  92. package/dist/{chunk-WEXMZMJH.js → chunk-3WVXAB3D.js} +3 -3
  93. package/dist/{chunk-WEXMZMJH.js.map → chunk-3WVXAB3D.js.map} +1 -1
  94. package/dist/{chunk-Z4L2GOAK.js → chunk-5ZWNCHZS.js} +4 -4
  95. package/dist/{chunk-Z4L2GOAK.js.map → chunk-5ZWNCHZS.js.map} +1 -1
  96. package/dist/{chunk-TEB5U6Y5.js → chunk-7NVATRLE.js} +4 -4
  97. package/dist/{chunk-TEB5U6Y5.js.map → chunk-7NVATRLE.js.map} +1 -1
  98. package/dist/{chunk-PUMQDV67.js → chunk-AXWMWYH5.js} +4 -4
  99. package/dist/{chunk-PUMQDV67.js.map → chunk-AXWMWYH5.js.map} +1 -1
  100. package/dist/{chunk-NKAH67JK.js → chunk-CS3CHGYC.js} +4 -4
  101. package/dist/{chunk-NKAH67JK.js.map → chunk-CS3CHGYC.js.map} +1 -1
  102. package/dist/{chunk-QJYRWEXD.js → chunk-CZV3WUW5.js} +35 -8
  103. package/dist/chunk-CZV3WUW5.js.map +1 -0
  104. package/dist/{chunk-PCFRBVKS.js → chunk-FCXSR7I5.js} +4 -4
  105. package/dist/{chunk-PCFRBVKS.js.map → chunk-FCXSR7I5.js.map} +1 -1
  106. package/dist/{chunk-NIFPRC7P.js → chunk-GVTBMJU6.js} +4 -4
  107. package/dist/{chunk-NIFPRC7P.js.map → chunk-GVTBMJU6.js.map} +1 -1
  108. package/dist/{chunk-E2I3YVKC.js → chunk-JLHVQWOV.js} +3 -3
  109. package/dist/{chunk-E2I3YVKC.js.map → chunk-JLHVQWOV.js.map} +1 -1
  110. package/dist/{chunk-2LSU3NFO.js → chunk-LQB42OSA.js} +4 -4
  111. package/dist/{chunk-2LSU3NFO.js.map → chunk-LQB42OSA.js.map} +1 -1
  112. package/dist/{chunk-VJD3Y7E5.js → chunk-MIDZWKIF.js} +4 -4
  113. package/dist/{chunk-VJD3Y7E5.js.map → chunk-MIDZWKIF.js.map} +1 -1
  114. package/dist/{chunk-LOD77NCD.js → chunk-PWYEW6NL.js} +4 -4
  115. package/dist/{chunk-LOD77NCD.js.map → chunk-PWYEW6NL.js.map} +1 -1
  116. package/dist/{chunk-HVDHT7DM.js → chunk-R4XXOGQH.js} +3 -3
  117. package/dist/{chunk-HVDHT7DM.js.map → chunk-R4XXOGQH.js.map} +1 -1
  118. package/dist/{chunk-7LLMILTM.js → chunk-RVMM4BHK.js} +4 -4
  119. package/dist/{chunk-7LLMILTM.js.map → chunk-RVMM4BHK.js.map} +1 -1
  120. package/dist/{chunk-NIXOY473.js → chunk-SWWJUOCY.js} +3 -3
  121. package/dist/{chunk-NIXOY473.js.map → chunk-SWWJUOCY.js.map} +1 -1
  122. package/dist/{chunk-EIBV76IB.js → chunk-VFWFT3OK.js} +4 -4
  123. package/dist/{chunk-EIBV76IB.js.map → chunk-VFWFT3OK.js.map} +1 -1
  124. package/dist/{chunk-2Q4EGZHJ.js → chunk-VMRUW4B4.js} +4 -4
  125. package/dist/{chunk-2Q4EGZHJ.js.map → chunk-VMRUW4B4.js.map} +1 -1
  126. package/dist/{chunk-GT63LSPJ.js → chunk-VOCUGTZB.js} +4 -4
  127. package/dist/{chunk-GT63LSPJ.js.map → chunk-VOCUGTZB.js.map} +1 -1
  128. package/dist/{chunk-N5VOPV64.js → chunk-Z5NL5D4J.js} +4 -4
  129. package/dist/{chunk-N5VOPV64.js.map → chunk-Z5NL5D4J.js.map} +1 -1
  130. package/dist/components-shared-whiteboard.cjs +33 -6
  131. package/dist/components-shared-whiteboard.cjs.map +1 -1
  132. package/dist/components-shared-whiteboard.js +3 -3
  133. package/dist/index.cjs +33 -6
  134. package/dist/index.cjs.map +1 -1
  135. package/dist/index.d.cts +7 -7
  136. package/dist/index.d.ts +7 -7
  137. package/dist/index.js +27 -27
  138. package/dist/mcp/index.d.cts +5 -5
  139. package/dist/mcp/index.d.ts +5 -5
  140. package/dist/mcp/stdio.d.cts +94 -0
  141. package/dist/mcp/stdio.d.ts +94 -0
  142. package/dist/mcp-stdio.cjs +120 -0
  143. package/dist/mcp-stdio.cjs.map +1 -0
  144. package/dist/mcp-stdio.js +117 -0
  145. package/dist/mcp-stdio.js.map +1 -0
  146. package/dist/mcp.cjs +33 -6
  147. package/dist/mcp.cjs.map +1 -1
  148. package/dist/mcp.js +1 -1
  149. package/dist/presence/index.d.cts +1 -1
  150. package/dist/presence/index.d.ts +1 -1
  151. package/dist/{server-BJNF7pQe.d.cts → server-BIcA3ZtK.d.cts} +32 -3
  152. package/dist/{server-Dt97UxuD.d.ts → server-DnUyeavY.d.ts} +32 -3
  153. package/dist/sharing/index.d.cts +3 -3
  154. package/dist/sharing/index.d.ts +3 -3
  155. package/dist/sheets-adapter.d.cts +3 -3
  156. package/dist/sheets-adapter.d.ts +3 -3
  157. package/dist/{tool-host-BpEBqf5u.d.cts → tool-host-LVBgCN5m.d.cts} +1 -1
  158. package/dist/{tool-host-xY5F-eqG.d.ts → tool-host-Wo0pkY83.d.ts} +1 -1
  159. package/dist/{types-DSwsNTBG.d.ts → types-BxNRKSVd.d.ts} +1 -1
  160. package/dist/{types-C58ZXs4K.d.cts → types-C2DtnHIn.d.cts} +25 -1
  161. package/dist/{types-C58ZXs4K.d.ts → types-C2DtnHIn.d.ts} +25 -1
  162. package/dist/{types-C4NaIW6B.d.cts → types-EcElKOlk.d.cts} +1 -1
  163. package/dist/undo/index.d.cts +2 -2
  164. package/dist/undo/index.d.ts +2 -2
  165. package/dist/undo.cjs.map +1 -1
  166. package/dist/undo.js +3 -3
  167. package/package.json +13 -2
  168. package/dist/chunk-QJYRWEXD.js.map +0 -1
package/dist/mcp.cjs CHANGED
@@ -69,10 +69,18 @@ var MicroMcpServer = class extends ToolRegistry {
69
69
  constructor(options) {
70
70
  super();
71
71
  this.transports = /* @__PURE__ */ new Set();
72
- this.notifyListChangedScheduled = false;
72
+ /**
73
+ * Transports owed a `tools/list_changed` at the end of this tick. Empty when
74
+ * none is scheduled. See {@link scheduleListChangedNotification}.
75
+ */
76
+ this.listChangedOwed = /* @__PURE__ */ new Set();
73
77
  this.info = options.info;
74
78
  this.capabilities = options.capabilities ?? { tools: { listChanged: true } };
75
79
  this.instructions = options.instructions;
80
+ if (options.protocolVersions && options.protocolVersions.length === 0) {
81
+ throw new Error("MicroMcpServer: protocolVersions is empty \u2014 a server must speak at least one protocol revision.");
82
+ }
83
+ this.protocolVersions = options.protocolVersions ? [...options.protocolVersions] : [MCP_PROTOCOL_VERSION];
76
84
  }
77
85
  attach(transport) {
78
86
  this.transports.add(transport);
@@ -118,7 +126,7 @@ var MicroMcpServer = class extends ToolRegistry {
118
126
  switch (method) {
119
127
  case "initialize":
120
128
  return {
121
- protocolVersion: MCP_PROTOCOL_VERSION,
129
+ protocolVersion: this.negotiate(params?.protocolVersion),
122
130
  capabilities: this.capabilities,
123
131
  serverInfo: this.info,
124
132
  ...this.instructions ? { instructions: this.instructions } : {}
@@ -144,12 +152,31 @@ var MicroMcpServer = class extends ToolRegistry {
144
152
  throw rpcError(JSONRPC_METHOD_NOT_FOUND, `Unsupported method: ${method}`);
145
153
  }
146
154
  }
155
+ /** The revision to answer `initialize` with: the one asked for if spoken, else the newest. */
156
+ negotiate(requested) {
157
+ return typeof requested === "string" && this.protocolVersions.includes(requested) ? requested : this.protocolVersions[0];
158
+ }
159
+ /**
160
+ * Tell the transports that SAW the old tool list that it changed.
161
+ *
162
+ * Changes in one tick coalesce into one notification. The recipients are the
163
+ * transports attached at the moment of a change, not at the moment the
164
+ * notification goes out: a transport attached afterwards never had the old
165
+ * list, so "your list is stale" is noise to it — and on stdio, where a host
166
+ * builds the server and attaches stdin/stdout in the same tick, it was the
167
+ * first frame a client received, before it had even sent `initialize`.
168
+ */
147
169
  scheduleListChangedNotification() {
148
- if (this.notifyListChangedScheduled) return;
149
- this.notifyListChangedScheduled = true;
170
+ if (this.transports.size === 0) return;
171
+ const scheduled = this.listChangedOwed.size > 0;
172
+ for (const t of this.transports) this.listChangedOwed.add(t);
173
+ if (scheduled) return;
150
174
  queueMicrotask(() => {
151
- this.notifyListChangedScheduled = false;
152
- this.broadcast({ jsonrpc: "2.0", method: "notifications/tools/list_changed" });
175
+ const owed = this.listChangedOwed;
176
+ this.listChangedOwed = /* @__PURE__ */ new Set();
177
+ for (const t of owed) {
178
+ if (this.transports.has(t)) t.send({ jsonrpc: "2.0", method: "notifications/tools/list_changed" });
179
+ }
153
180
  });
154
181
  }
155
182
  /** Send an application notification to every client, or one attached transport. */
package/dist/mcp.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/mcp/types.ts","../src/mcp/tool-host.ts","../src/mcp/server.ts","../src/mcp/transports/in-process.ts","../src/mcp/transports/relay.ts"],"names":[],"mappings":";;;AA+CO,IAAM,mBAAA,GAAsB;AAC5B,IAAM,uBAAA,GAA0B;AAChC,IAAM,wBAAA,GAA2B;AACjC,IAAM,sBAAA,GAAyB;AAC/B,IAAM,sBAAA,GAAyB;AA2D/B,IAAM,oBAAA,GAAuB;;;ACtD7B,IAAM,eAAN,MAAuC;AAAA,EAAvC,WAAA,GAAA;AACL,IAAA,IAAA,CAAmB,KAAA,uBAAY,GAAA,EAA4B;AAgB3D;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MAAM,IAAI,MAAM,oCAAoC,CAAA;AACtE,IAAA,MAAM,UAAU,OAAO,OAAA,KAAY,WAC9B,IAAA,CAAK,KAAA,CAAM,OAAO,CAAA,GACnB,OAAA;AACJ,IAAA,MAAM,IAAA,CAAK,MAAA,CAAO,OAAA,CAAQ,IAAA,EAAM,OAAO,CAAA;AAAA,EACzC;AAAA,EAEA,KAAA,GAAc;AACZ,IAAA,IAAA,CAAK,QAAQ,OAAA,IAAU;AAAA,EACzB;AACF;AAKO,SAAS,WAAA,CAAY,QAAwB,OAAA,EAAuC;AACzF,EAAA,MAAM,SAAA,GAAY,IAAI,cAAA,CAAe,OAAO,CAAA;AAC5C,EAAA,SAAA,CAAU,WAAW,MAAM,CAAA;AAC3B,EAAA,MAAA,CAAO,OAAO,SAAS,CAAA;AACvB,EAAA,OAAO,SAAA;AACT","file":"mcp.cjs","sourcesContent":["/**\n * Minimal MCP (Model Context Protocol) types — covers the subset this\n * package implements: initialize, tools/list, tools/call, plus JSON-RPC.\n *\n * Aligned with the public MCP spec but trimmed to v0.1 needs. See\n * https://spec.modelcontextprotocol.io/ for the full surface.\n */\n\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | { [key: string]: JsonValue }\n | JsonValue[];\n\nexport type JsonObject = { [key: string]: JsonValue };\n\nexport type JsonRpcId = string | number | null;\n\nexport type JsonRpcRequest = {\n jsonrpc: \"2.0\";\n id: JsonRpcId;\n method: string;\n params?: JsonObject;\n};\n\nexport type JsonRpcNotification = {\n jsonrpc: \"2.0\";\n method: string;\n params?: JsonObject;\n};\n\nexport type JsonRpcSuccess = {\n jsonrpc: \"2.0\";\n id: JsonRpcId;\n result: JsonValue;\n};\n\nexport type JsonRpcError = {\n jsonrpc: \"2.0\";\n id: JsonRpcId;\n error: { code: number; message: string; data?: JsonValue };\n};\n\nexport type JsonRpcMessage = JsonRpcRequest | JsonRpcNotification | JsonRpcSuccess | JsonRpcError;\n\nexport const JSONRPC_PARSE_ERROR = -32700;\nexport const JSONRPC_INVALID_REQUEST = -32600;\nexport const JSONRPC_METHOD_NOT_FOUND = -32601;\nexport const JSONRPC_INVALID_PARAMS = -32602;\nexport const JSONRPC_INTERNAL_ERROR = -32603;\n\nexport type ServerCapabilities = {\n tools?: { listChanged?: boolean };\n resources?: { listChanged?: boolean; subscribe?: boolean };\n prompts?: { listChanged?: boolean };\n logging?: Record<string, never>;\n experimental?: Record<string, JsonValue>;\n};\n\nexport type ServerInfo = {\n name: string;\n version: string;\n title?: string;\n};\n\nexport type InitializeResult = {\n protocolVersion: string;\n capabilities: ServerCapabilities;\n serverInfo: ServerInfo;\n instructions?: string;\n};\n\nexport type ToolInputSchema = {\n type: \"object\";\n properties?: Record<string, JsonValue>;\n required?: string[];\n additionalProperties?: boolean;\n};\n\nexport type ToolDefinition = {\n name: string;\n title?: string;\n description?: string;\n inputSchema: ToolInputSchema;\n};\n\nexport type ContentBlock =\n | { type: \"text\"; text: string }\n | { type: \"image\"; data: string; mimeType: string }\n | { type: \"resource\"; resource: { uri: string; text?: string; mimeType?: string } };\n\nexport type CallToolResult = {\n content: ContentBlock[];\n isError?: boolean;\n /** Structured tool output — non-spec but useful for typed bridges. */\n structuredContent?: JsonValue;\n};\n\n/** Handler signature for a tool registered on the MicroMcpServer. */\nexport type ToolCallContext = { transport?: unknown };\nexport type ToolHandler = (args: JsonObject, context?: ToolCallContext) => Promise<CallToolResult> | CallToolResult;\n\n/** Internal record kept by the server. */\nexport type RegisteredTool = {\n definition: ToolDefinition;\n handler: ToolHandler;\n};\n\nexport const MCP_PROTOCOL_VERSION = \"2025-06-18\";\n","import type {\n CallToolResult,\n JsonObject,\n RegisteredTool,\n ToolDefinition,\n ToolHandler,\n} from \"./types\";\n\n/**\n * ToolHost — the minimal surface a bridge needs to register its tools.\n *\n * Bridges (whiteboard, flow, sheets, code, charts, screens, scene, form)\n * speak only through this interface. The MCP server implements it\n * alongside its transport / JSON-RPC duties, and the standalone\n * {@link ToolRegistry} implements it for in-process agents that don't\n * need any of MCP's wire framing.\n *\n * Net effect: every bridge works equally well behind an MCP server\n * (browser ↔ external agents over SSE) or behind a plain registry\n * (in-process agent calling `host.callTool(\"sheet_set_cell\", { … })`).\n */\nexport interface ToolHost {\n /** Register a tool. Returns a disposer that unregisters it. */\n registerTool(definition: ToolDefinition, handler: ToolHandler): () => void;\n\n /** Look up an already-registered tool's definition + handler, or null. */\n getTool(name: string): RegisteredTool | null;\n\n /** Snapshot of all currently-registered tool definitions. */\n listTools(): ToolDefinition[];\n\n /**\n * Invoke a registered tool directly, bypassing any transport layer.\n * Throws if no tool is registered under `name`.\n *\n * This is the single entry point in-process agents use to drive the\n * surface — no JSON-RPC framing, no transport plumbing.\n */\n callTool(name: string, args?: JsonObject): Promise<CallToolResult>;\n}\n\n/**\n * Standalone in-memory ToolHost. Use this when no MCP server is needed —\n * e.g. an in-process agent that just wants to register the same bridges\n * and call them directly.\n *\n * Example:\n *\n * const host = new ToolRegistry();\n * registerSheetsBridge(host, { adapter });\n * const result = await host.callTool(\"sheet_set_cell\", { address: \"B3\", value: 42 });\n *\n * Pair with a MicroMcpServer in the same app to expose the same tools\n * to remote agents over SSE while in-process agents still get\n * zero-overhead direct calls.\n */\nexport class ToolRegistry implements ToolHost {\n protected readonly tools = new Map<string, RegisteredTool>();\n\n /**\n * Tools that existed and were withdrawn, kept so a call that races an unmount\n * can say WHICH thing happened.\n *\n * The tool surface is dynamic by design — \"site tools always, page tools while\n * mounted\" — so an agent deciding to call a tool while the human navigates\n * away is normal traffic, not an edge case. Reporting that as `Unknown tool`\n * is the least useful thing available: it reads as \"the agent is broken\" or\n * \"you asked for something imaginary\", when the truth is \"that surface just\n * closed\".\n *\n * Names only. Nothing about the handler is retained, so this cannot keep a\n * disposed surface alive.\n */\n protected readonly withdrawn = new Set<string>();\n\n registerTool(definition: ToolDefinition, handler: ToolHandler): () => void {\n this.tools.set(definition.name, { definition, handler });\n // A remounted surface must stop apologising for a previous unmount.\n this.withdrawn.delete(definition.name);\n this.onToolsChanged();\n return () => {\n if (this.tools.delete(definition.name)) {\n this.withdrawn.add(definition.name);\n this.onToolsChanged();\n }\n };\n }\n\n /** Why `name` is not callable, phrased for whoever has to act on it. */\n protected missingToolMessage(name: string): string {\n return this.withdrawn.has(name)\n ? `Tool \"${name}\" was withdrawn: the surface it targets is no longer mounted. `\n + `Call tools/list for the current surface — the site-wide tools remain available.`\n : `Unknown tool: ${name}`;\n }\n\n getTool(name: string): RegisteredTool | null {\n return this.tools.get(name) ?? null;\n }\n\n listTools(): ToolDefinition[] {\n return Array.from(this.tools.values()).map((t) => t.definition);\n }\n\n async callTool(name: string, args: JsonObject = {}): Promise<CallToolResult> {\n const tool = this.tools.get(name);\n if (!tool) {\n throw new Error(this.missingToolMessage(name));\n }\n return tool.handler(args);\n }\n\n /**\n * Hook for subclasses (e.g. MicroMcpServer) to notify subscribers\n * when the tool catalog changes. Default no-op.\n */\n protected onToolsChanged(): void {}\n}\n","import {\n type CallToolResult,\n type JsonObject,\n type JsonRpcMessage,\n type JsonRpcRequest,\n type JsonRpcId,\n type RegisteredTool,\n type ServerCapabilities,\n type ServerInfo,\n type ToolDefinition,\n type ToolHandler,\n JSONRPC_INTERNAL_ERROR,\n JSONRPC_INVALID_PARAMS,\n JSONRPC_METHOD_NOT_FOUND,\n MCP_PROTOCOL_VERSION,\n} from \"./types\";\nimport { ToolRegistry } from \"./tool-host\";\n\nexport type McpServerOptions = {\n info: ServerInfo;\n /** Defaults to { tools: { listChanged: true } } */\n capabilities?: ServerCapabilities;\n /** Free-text instructions surfaced to clients during initialize. */\n instructions?: string;\n};\n\nexport type Transport = {\n /** Called by the server when it has a message to deliver to the client. */\n send: (message: JsonRpcMessage) => void;\n /** Called by the server when it's torn down so the transport can clean up. */\n close?: () => void;\n};\n\n/**\n * MicroMcpServer — protocol-level MCP server, transport-agnostic.\n *\n * Use it like:\n *\n * const server = new MicroMcpServer({ info: { name: \"session\", version: \"0.1\" } });\n * server.registerTool({ name: \"...\", inputSchema: { type: \"object\" } }, async (args) => ({...}));\n * const transport = new InProcessTransport();\n * server.attach(transport);\n * transport.deliver({ ... }); // client → server frames\n *\n * The same server can serve multiple transports (e.g. an in-process agent\n * AND a relayed external client) by attaching each one.\n */\nexport class MicroMcpServer extends ToolRegistry {\n private transports = new Set<Transport>();\n private notifyListChangedScheduled = false;\n\n readonly info: ServerInfo;\n readonly capabilities: ServerCapabilities;\n readonly instructions?: string;\n\n constructor(options: McpServerOptions) {\n super();\n this.info = options.info;\n this.capabilities = options.capabilities ?? { tools: { listChanged: true } };\n this.instructions = options.instructions;\n }\n\n attach(transport: Transport): () => void {\n this.transports.add(transport);\n return () => this.detach(transport);\n }\n\n detach(transport: Transport): void {\n if (this.transports.delete(transport)) {\n transport.close?.();\n }\n }\n\n unregisterTool(name: string): void {\n if (this.tools.delete(name)) {\n this.scheduleListChangedNotification();\n }\n }\n\n protected onToolsChanged(): void {\n this.scheduleListChangedNotification();\n }\n\n /**\n * Receive a JSON-RPC frame from a client (called by the transport).\n * The transport is responsible for sending the response back.\n */\n async receive(transport: Transport, message: JsonRpcMessage): Promise<void> {\n if (!(\"method\" in message)) return; // It's a response, not a request — ignore.\n\n const isNotification = !(\"id\" in message);\n if (isNotification) {\n // Notifications are fire-and-forget. We ignore unknown methods.\n return;\n }\n\n const request = message as JsonRpcRequest;\n try {\n const result = await this.handle(request, transport);\n transport.send({ jsonrpc: \"2.0\", id: request.id, result });\n } catch (err) {\n transport.send({\n jsonrpc: \"2.0\",\n id: request.id,\n error: this.toRpcError(err),\n });\n }\n }\n\n private async handle(request: JsonRpcRequest, transport: Transport): Promise<any> {\n const { method, params } = request;\n switch (method) {\n case \"initialize\":\n return {\n protocolVersion: MCP_PROTOCOL_VERSION,\n capabilities: this.capabilities,\n serverInfo: this.info,\n ...(this.instructions ? { instructions: this.instructions } : {}),\n };\n\n case \"tools/list\":\n return { tools: this.listTools() };\n\n case \"tools/call\": {\n const name = params?.name;\n const args = (params?.arguments ?? {}) as JsonObject;\n if (typeof name !== \"string\") {\n throw rpcError(JSONRPC_INVALID_PARAMS, \"tools/call requires `name`\");\n }\n const tool = this.tools.get(name);\n if (!tool) {\n throw rpcError(JSONRPC_METHOD_NOT_FOUND, this.missingToolMessage(name));\n }\n const result = await tool.handler(args, { transport });\n return result satisfies CallToolResult;\n }\n\n case \"ping\":\n return {};\n\n default:\n throw rpcError(JSONRPC_METHOD_NOT_FOUND, `Unsupported method: ${method}`);\n }\n }\n\n private scheduleListChangedNotification(): void {\n if (this.notifyListChangedScheduled) return;\n this.notifyListChangedScheduled = true;\n queueMicrotask(() => {\n this.notifyListChangedScheduled = false;\n this.broadcast({ jsonrpc: \"2.0\", method: \"notifications/tools/list_changed\" });\n });\n }\n\n /** Send an application notification to every client, or one attached transport. */\n notify(message: JsonRpcMessage, transport?: Transport): void {\n if (transport) transport.send(message);\n else this.broadcast(message);\n }\n\n private broadcast(message: JsonRpcMessage): void {\n for (const t of this.transports) t.send(message);\n }\n\n private toRpcError(err: unknown): { code: number; message: string; data?: any } {\n if (err && typeof err === \"object\" && \"code\" in err && \"message\" in err) {\n return err as any;\n }\n return {\n code: JSONRPC_INTERNAL_ERROR,\n message: err instanceof Error ? err.message : String(err),\n };\n }\n}\n\nexport function rpcError(code: number, message: string, data?: any) {\n return { code, message, ...(data !== undefined ? { data } : {}) };\n}\n\n/**\n * Helper to build a CallToolResult from a string or structured value.\n */\nexport function textResult(text: string, structured?: any): CallToolResult {\n return {\n content: [{ type: \"text\", text }],\n ...(structured !== undefined ? { structuredContent: structured } : {}),\n };\n}\n\nexport function errorResult(text: string): CallToolResult {\n return { content: [{ type: \"text\", text }], isError: true };\n}\n\n// Internal helper so the JsonRpcId import isn't dropped by tsup\ntype _KeepIdImport = JsonRpcId;\n","import type { JsonRpcMessage } from \"../types\";\nimport type { MicroMcpServer, Transport } from \"../server\";\n\n/**\n * InProcessTransport — direct function-call wiring between an in-page MCP\n * client (e.g. an embedded chat agent) and a MicroMcpServer running in\n * the same JS context. No serialization, no network.\n *\n * Usage:\n *\n * const t = new InProcessTransport();\n * server.attach(t);\n * t.onServerMessage((msg) => { ... }); // client subscribes\n * t.send({ jsonrpc: \"2.0\", id: 1, method: \"tools/list\" }); // client → server\n */\nexport class InProcessTransport implements Transport {\n private server?: MicroMcpServer;\n private listeners = new Set<(msg: JsonRpcMessage) => void>();\n\n /** Bind to a server. Called from the client's setup, not directly. */\n bindServer(server: MicroMcpServer): void {\n this.server = server;\n }\n\n /** Server → client (delivered to subscribed listeners). */\n send(message: JsonRpcMessage): void {\n for (const l of this.listeners) l(message);\n }\n\n /** Client → server. Awaitable so callers can flush. */\n async deliver(message: JsonRpcMessage): Promise<void> {\n if (!this.server) throw new Error(\"InProcessTransport has no bound server\");\n await this.server.receive(this, message);\n }\n\n /** Subscribe to messages the server pushes to this client. */\n onServerMessage(listener: (msg: JsonRpcMessage) => void): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n close(): void {\n this.listeners.clear();\n }\n}\n\n/**\n * Convenience: create a server-attached in-process transport in one call.\n */\nexport function attachInProcess(server: MicroMcpServer): InProcessTransport {\n const transport = new InProcessTransport();\n transport.bindServer(server);\n server.attach(transport);\n return transport;\n}\n","import type { JsonRpcMessage } from \"../types\";\nimport type { MicroMcpServer, Transport } from \"../server\";\n\n/**\n * RelayTransport — wraps any duplex JSON-frame channel (e.g. a Reverb\n * websocket private channel, a WebRTC data channel) so external agents\n * can talk to a browser-side MicroMcpServer.\n *\n * The host app owns the actual channel. This class only handles framing\n * (JSON.stringify / JSON.parse) and the server contract.\n *\n * Channel contract:\n * - host calls `transport.deliverFromRemote(payload)` with each frame\n * it receives from the remote agent\n * - host implements `sendToRemote(frame)` so the transport can deliver\n * server → client frames outward\n *\n * See docs/relay-protocol.md for the wire format.\n */\nexport type RelayChannel = {\n sendToRemote: (frame: JsonRpcMessage) => void;\n /** Optional: notify the channel that the server is gone. */\n onClose?: () => void;\n};\n\nexport class RelayTransport implements Transport {\n private server?: MicroMcpServer;\n constructor(private channel: RelayChannel) {}\n\n bindServer(server: MicroMcpServer): void {\n this.server = server;\n }\n\n send(message: JsonRpcMessage): void {\n this.channel.sendToRemote(message);\n }\n\n /**\n * Host calls this with each frame received from the remote agent. Accepts\n * either a parsed object or a raw JSON string.\n */\n async deliverFromRemote(payload: JsonRpcMessage | string): Promise<void> {\n if (!this.server) throw new Error(\"RelayTransport has no bound server\");\n const message = typeof payload === \"string\"\n ? (JSON.parse(payload) as JsonRpcMessage)\n : payload;\n await this.server.receive(this, message);\n }\n\n close(): void {\n this.channel.onClose?.();\n }\n}\n\n/**\n * Convenience wiring. Returns the bound transport.\n */\nexport function attachRelay(server: MicroMcpServer, channel: RelayChannel): RelayTransport {\n const transport = new RelayTransport(channel);\n transport.bindServer(server);\n server.attach(transport);\n return transport;\n}\n"]}
1
+ {"version":3,"sources":["../src/mcp/types.ts","../src/mcp/tool-host.ts","../src/mcp/server.ts","../src/mcp/transports/in-process.ts","../src/mcp/transports/relay.ts"],"names":[],"mappings":";;;AA+CO,IAAM,mBAAA,GAAsB;AAC5B,IAAM,uBAAA,GAA0B;AAChC,IAAM,wBAAA,GAA2B;AACjC,IAAM,sBAAA,GAAyB;AAC/B,IAAM,sBAAA,GAAyB;AAgF/B,IAAM,oBAAA,GAAuB;;;AC3E7B,IAAM,eAAN,MAAuC;AAAA,EAAvC,WAAA,GAAA;AACL,IAAA,IAAA,CAAmB,KAAA,uBAAY,GAAA,EAA4B;AAgB3D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA,IAAA,CAAmB,SAAA,uBAAgB,GAAA,EAAY;AAAA,EAAA;AAAA,EAE/C,YAAA,CAAa,YAA4B,OAAA,EAAkC;AACzE,IAAA,IAAA,CAAK,MAAM,GAAA,CAAI,UAAA,CAAW,MAAM,EAAE,UAAA,EAAY,SAAS,CAAA;AAEvD,IAAA,IAAA,CAAK,SAAA,CAAU,MAAA,CAA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ers the subset this\n * package implements: initialize, tools/list, tools/call, plus JSON-RPC.\n *\n * Aligned with the public MCP spec but trimmed to v0.1 needs. See\n * https://spec.modelcontextprotocol.io/ for the full surface.\n */\n\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | { [key: string]: JsonValue }\n | JsonValue[];\n\nexport type JsonObject = { [key: string]: JsonValue };\n\nexport type JsonRpcId = string | number | null;\n\nexport type JsonRpcRequest = {\n jsonrpc: \"2.0\";\n id: JsonRpcId;\n method: string;\n params?: JsonObject;\n};\n\nexport type JsonRpcNotification = {\n jsonrpc: \"2.0\";\n method: string;\n params?: JsonObject;\n};\n\nexport type JsonRpcSuccess = {\n jsonrpc: \"2.0\";\n id: JsonRpcId;\n result: JsonValue;\n};\n\nexport type JsonRpcError = {\n jsonrpc: \"2.0\";\n id: JsonRpcId;\n error: { code: number; message: string; data?: JsonValue };\n};\n\nexport type JsonRpcMessage = JsonRpcRequest | JsonRpcNotification | JsonRpcSuccess | JsonRpcError;\n\nexport const JSONRPC_PARSE_ERROR = -32700;\nexport const JSONRPC_INVALID_REQUEST = -32600;\nexport const JSONRPC_METHOD_NOT_FOUND = -32601;\nexport const JSONRPC_INVALID_PARAMS = -32602;\nexport const JSONRPC_INTERNAL_ERROR = -32603;\n\nexport type ServerCapabilities = {\n tools?: { listChanged?: boolean };\n resources?: { listChanged?: boolean; subscribe?: boolean };\n prompts?: { listChanged?: boolean };\n logging?: Record<string, never>;\n experimental?: Record<string, JsonValue>;\n};\n\nexport type ServerInfo = {\n name: string;\n version: string;\n title?: string;\n};\n\nexport type InitializeResult = {\n protocolVersion: string;\n capabilities: ServerCapabilities;\n serverInfo: ServerInfo;\n instructions?: string;\n};\n\nexport type ToolInputSchema = {\n /** The JSON Schema dialect, when a server states it (e.g. draft-07). */\n $schema?: string;\n type: \"object\";\n properties?: Record<string, JsonValue>;\n required?: string[];\n additionalProperties?: boolean;\n};\n\n/** Behaviour hints a client may use when presenting or gating a tool. */\nexport type ToolAnnotations = {\n title?: string;\n readOnlyHint?: boolean;\n destructiveHint?: boolean;\n idempotentHint?: boolean;\n openWorldHint?: boolean;\n};\n\n/**\n * A tool as `tools/list` reports it. Every field is passed to the client\n * verbatim, so the optional ones below are the spec's, not extensions.\n */\nexport type ToolDefinition = {\n name: string;\n title?: string;\n description?: string;\n inputSchema: ToolInputSchema;\n /** JSON Schema for `structuredContent`, when the tool returns it. */\n outputSchema?: ToolInputSchema;\n annotations?: ToolAnnotations;\n /** 2025-11-25: whether the tool may run as a task. */\n execution?: { taskSupport?: \"forbidden\" | \"optional\" | \"required\" };\n _meta?: { [key: string]: JsonValue };\n};\n\nexport type ContentBlock =\n | { type: \"text\"; text: string }\n | { type: \"image\"; data: string; mimeType: string }\n | { type: \"resource\"; resource: { uri: string; text?: string; mimeType?: string } };\n\nexport type CallToolResult = {\n content: ContentBlock[];\n isError?: boolean;\n /** Structured tool output — non-spec but useful for typed bridges. */\n structuredContent?: JsonValue;\n};\n\n/** Handler signature for a tool registered on the MicroMcpServer. */\nexport type ToolCallContext = { transport?: unknown };\nexport type ToolHandler = (args: JsonObject, context?: ToolCallContext) => Promise<CallToolResult> | CallToolResult;\n\n/** Internal record kept by the server. */\nexport type RegisteredTool = {\n definition: ToolDefinition;\n handler: ToolHandler;\n};\n\nexport const MCP_PROTOCOL_VERSION = \"2025-06-18\";\n","import type {\n CallToolResult,\n JsonObject,\n RegisteredTool,\n ToolDefinition,\n ToolHandler,\n} from \"./types\";\n\n/**\n * ToolHost — the minimal surface a bridge needs to register its tools.\n *\n * Bridges (whiteboard, flow, sheets, code, charts, screens, scene, form)\n * speak only through this interface. The MCP server implements it\n * alongside its transport / JSON-RPC duties, and the standalone\n * {@link ToolRegistry} implements it for in-process agents that don't\n * need any of MCP's wire framing.\n *\n * Net effect: every bridge works equally well behind an MCP server\n * (browser ↔ external agents over SSE) or behind a plain registry\n * (in-process agent calling `host.callTool(\"sheet_set_cell\", { … })`).\n */\nexport interface ToolHost {\n /** Register a tool. Returns a disposer that unregisters it. */\n registerTool(definition: ToolDefinition, handler: ToolHandler): () => void;\n\n /** Look up an already-registered tool's definition + handler, or null. */\n getTool(name: string): RegisteredTool | null;\n\n /** Snapshot of all currently-registered tool definitions. */\n listTools(): ToolDefinition[];\n\n /**\n * Invoke a registered tool directly, bypassing any transport layer.\n * Throws if no tool is registered under `name`.\n *\n * This is the single entry point in-process agents use to drive the\n * surface — no JSON-RPC framing, no transport plumbing.\n */\n callTool(name: string, args?: JsonObject): Promise<CallToolResult>;\n}\n\n/**\n * Standalone in-memory ToolHost. Use this when no MCP server is needed —\n * e.g. an in-process agent that just wants to register the same bridges\n * and call them directly.\n *\n * Example:\n *\n * const host = new ToolRegistry();\n * registerSheetsBridge(host, { adapter });\n * const result = await host.callTool(\"sheet_set_cell\", { address: \"B3\", value: 42 });\n *\n * Pair with a MicroMcpServer in the same app to expose the same tools\n * to remote agents over SSE while in-process agents still get\n * zero-overhead direct calls.\n */\nexport class ToolRegistry implements ToolHost {\n protected readonly tools = new Map<string, RegisteredTool>();\n\n /**\n * Tools that existed and were withdrawn, kept so a call that races an unmount\n * can say WHICH thing happened.\n *\n * The tool surface is dynamic by design — \"site tools always, page tools while\n * mounted\" — so an agent deciding to call a tool while the human navigates\n * away is normal traffic, not an edge case. Reporting that as `Unknown tool`\n * is the least useful thing available: it reads as \"the agent is broken\" or\n * \"you asked for something imaginary\", when the truth is \"that surface just\n * closed\".\n *\n * Names only. Nothing about the handler is retained, so this cannot keep a\n * disposed surface alive.\n */\n protected readonly withdrawn = new Set<string>();\n\n registerTool(definition: ToolDefinition, handler: ToolHandler): () => void {\n this.tools.set(definition.name, { definition, handler });\n // A remounted surface must stop apologising for a previous unmount.\n this.withdrawn.delete(definition.name);\n this.onToolsChanged();\n return () => {\n if (this.tools.delete(definition.name)) {\n this.withdrawn.add(definition.name);\n this.onToolsChanged();\n }\n };\n }\n\n /** Why `name` is not callable, phrased for whoever has to act on it. */\n protected missingToolMessage(name: string): string {\n return this.withdrawn.has(name)\n ? `Tool \"${name}\" was withdrawn: the surface it targets is no longer mounted. `\n + `Call tools/list for the current surface — the site-wide tools remain available.`\n : `Unknown tool: ${name}`;\n }\n\n getTool(name: string): RegisteredTool | null {\n return this.tools.get(name) ?? null;\n }\n\n listTools(): ToolDefinition[] {\n return Array.from(this.tools.values()).map((t) => t.definition);\n }\n\n async callTool(name: string, args: JsonObject = {}): Promise<CallToolResult> {\n const tool = this.tools.get(name);\n if (!tool) {\n throw new Error(this.missingToolMessage(name));\n }\n return tool.handler(args);\n }\n\n /**\n * Hook for subclasses (e.g. MicroMcpServer) to notify subscribers\n * when the tool catalog changes. Default no-op.\n */\n protected onToolsChanged(): void {}\n}\n","import {\n type CallToolResult,\n type JsonObject,\n type JsonRpcMessage,\n type JsonRpcRequest,\n type JsonRpcId,\n type RegisteredTool,\n type ServerCapabilities,\n type ServerInfo,\n type ToolDefinition,\n type ToolHandler,\n JSONRPC_INTERNAL_ERROR,\n JSONRPC_INVALID_PARAMS,\n JSONRPC_METHOD_NOT_FOUND,\n MCP_PROTOCOL_VERSION,\n} from \"./types\";\nimport { ToolRegistry } from \"./tool-host\";\n\nexport type McpServerOptions = {\n info: ServerInfo;\n /** Defaults to { tools: { listChanged: true } } */\n capabilities?: ServerCapabilities;\n /** Free-text instructions surfaced to clients during initialize. */\n instructions?: string;\n /**\n * The protocol revisions this server speaks, NEWEST FIRST.\n *\n * `initialize` echoes the client's requested revision when it is in this\n * list, and answers the first entry otherwise — the spec's rule, which leaves\n * the client to decide whether it can live with the answer.\n *\n * Defaults to `[MCP_PROTOCOL_VERSION]`: one revision, answered whatever the\n * client asks, which is exactly what this server did before the option\n * existed. Only list a revision the tools you register are correct under.\n */\n protocolVersions?: readonly string[];\n};\n\nexport type Transport = {\n /** Called by the server when it has a message to deliver to the client. */\n send: (message: JsonRpcMessage) => void;\n /** Called by the server when it's torn down so the transport can clean up. */\n close?: () => void;\n};\n\n/**\n * MicroMcpServer — protocol-level MCP server, transport-agnostic.\n *\n * Use it like:\n *\n * const server = new MicroMcpServer({ info: { name: \"session\", version: \"0.1\" } });\n * server.registerTool({ name: \"...\", inputSchema: { type: \"object\" } }, async (args) => ({...}));\n * const transport = new InProcessTransport();\n * server.attach(transport);\n * transport.deliver({ ... }); // client → server frames\n *\n * The same server can serve multiple transports (e.g. an in-process agent\n * AND a relayed external client) by attaching each one.\n */\nexport class MicroMcpServer extends ToolRegistry {\n private transports = new Set<Transport>();\n /**\n * Transports owed a `tools/list_changed` at the end of this tick. Empty when\n * none is scheduled. See {@link scheduleListChangedNotification}.\n */\n private listChangedOwed = new Set<Transport>();\n\n readonly info: ServerInfo;\n readonly capabilities: ServerCapabilities;\n readonly instructions?: string;\n readonly protocolVersions: readonly string[];\n\n constructor(options: McpServerOptions) {\n super();\n this.info = options.info;\n this.capabilities = options.capabilities ?? { tools: { listChanged: true } };\n this.instructions = options.instructions;\n if (options.protocolVersions && options.protocolVersions.length === 0) {\n // No answer exists for a client's initialize. Fail here, next to the\n // mistake, rather than in a handshake nobody is watching.\n throw new Error(\"MicroMcpServer: protocolVersions is empty — a server must speak at least one protocol revision.\");\n }\n this.protocolVersions = options.protocolVersions ? [...options.protocolVersions] : [MCP_PROTOCOL_VERSION];\n }\n\n attach(transport: Transport): () => void {\n this.transports.add(transport);\n return () => this.detach(transport);\n }\n\n detach(transport: Transport): void {\n if (this.transports.delete(transport)) {\n transport.close?.();\n }\n }\n\n unregisterTool(name: string): void {\n if (this.tools.delete(name)) {\n this.scheduleListChangedNotification();\n }\n }\n\n protected onToolsChanged(): void {\n this.scheduleListChangedNotification();\n }\n\n /**\n * Receive a JSON-RPC frame from a client (called by the transport).\n * The transport is responsible for sending the response back.\n */\n async receive(transport: Transport, message: JsonRpcMessage): Promise<void> {\n if (!(\"method\" in message)) return; // It's a response, not a request — ignore.\n\n const isNotification = !(\"id\" in message);\n if (isNotification) {\n // Notifications are fire-and-forget. We ignore unknown methods.\n return;\n }\n\n const request = message as JsonRpcRequest;\n try {\n const result = await this.handle(request, transport);\n transport.send({ jsonrpc: \"2.0\", id: request.id, result });\n } catch (err) {\n transport.send({\n jsonrpc: \"2.0\",\n id: request.id,\n error: this.toRpcError(err),\n });\n }\n }\n\n private async handle(request: JsonRpcRequest, transport: Transport): Promise<any> {\n const { method, params } = request;\n switch (method) {\n case \"initialize\":\n return {\n protocolVersion: this.negotiate(params?.protocolVersion),\n capabilities: this.capabilities,\n serverInfo: this.info,\n ...(this.instructions ? { instructions: this.instructions } : {}),\n };\n\n case \"tools/list\":\n return { tools: this.listTools() };\n\n case \"tools/call\": {\n const name = params?.name;\n const args = (params?.arguments ?? {}) as JsonObject;\n if (typeof name !== \"string\") {\n throw rpcError(JSONRPC_INVALID_PARAMS, \"tools/call requires `name`\");\n }\n const tool = this.tools.get(name);\n if (!tool) {\n throw rpcError(JSONRPC_METHOD_NOT_FOUND, this.missingToolMessage(name));\n }\n const result = await tool.handler(args, { transport });\n return result satisfies CallToolResult;\n }\n\n case \"ping\":\n return {};\n\n default:\n throw rpcError(JSONRPC_METHOD_NOT_FOUND, `Unsupported method: ${method}`);\n }\n }\n\n /** The revision to answer `initialize` with: the one asked for if spoken, else the newest. */\n private negotiate(requested: unknown): string {\n return typeof requested === \"string\" && this.protocolVersions.includes(requested)\n ? requested\n : this.protocolVersions[0];\n }\n\n /**\n * Tell the transports that SAW the old tool list that it changed.\n *\n * Changes in one tick coalesce into one notification. The recipients are the\n * transports attached at the moment of a change, not at the moment the\n * notification goes out: a transport attached afterwards never had the old\n * list, so \"your list is stale\" is noise to it — and on stdio, where a host\n * builds the server and attaches stdin/stdout in the same tick, it was the\n * first frame a client received, before it had even sent `initialize`.\n */\n private scheduleListChangedNotification(): void {\n if (this.transports.size === 0) return;\n const scheduled = this.listChangedOwed.size > 0;\n for (const t of this.transports) this.listChangedOwed.add(t);\n if (scheduled) return;\n queueMicrotask(() => {\n const owed = this.listChangedOwed;\n this.listChangedOwed = new Set();\n for (const t of owed) {\n // Detached since the change: it is not listening any more.\n if (this.transports.has(t)) t.send({ jsonrpc: \"2.0\", method: \"notifications/tools/list_changed\" });\n }\n });\n }\n\n /** Send an application notification to every client, or one attached transport. */\n notify(message: JsonRpcMessage, transport?: Transport): void {\n if (transport) transport.send(message);\n else this.broadcast(message);\n }\n\n private broadcast(message: JsonRpcMessage): void {\n for (const t of this.transports) t.send(message);\n }\n\n private toRpcError(err: unknown): { code: number; message: string; data?: any } {\n if (err && typeof err === \"object\" && \"code\" in err && \"message\" in err) {\n return err as any;\n }\n return {\n code: JSONRPC_INTERNAL_ERROR,\n message: err instanceof Error ? err.message : String(err),\n };\n }\n}\n\nexport function rpcError(code: number, message: string, data?: any) {\n return { code, message, ...(data !== undefined ? { data } : {}) };\n}\n\n/**\n * Helper to build a CallToolResult from a string or structured value.\n */\nexport function textResult(text: string, structured?: any): CallToolResult {\n return {\n content: [{ type: \"text\", text }],\n ...(structured !== undefined ? { structuredContent: structured } : {}),\n };\n}\n\nexport function errorResult(text: string): CallToolResult {\n return { content: [{ type: \"text\", text }], isError: true };\n}\n\n// Internal helper so the JsonRpcId import isn't dropped by tsup\ntype _KeepIdImport = JsonRpcId;\n","import type { JsonRpcMessage } from \"../types\";\nimport type { MicroMcpServer, Transport } from \"../server\";\n\n/**\n * InProcessTransport — direct function-call wiring between an in-page MCP\n * client (e.g. an embedded chat agent) and a MicroMcpServer running in\n * the same JS context. No serialization, no network.\n *\n * Usage:\n *\n * const t = new InProcessTransport();\n * server.attach(t);\n * t.onServerMessage((msg) => { ... }); // client subscribes\n * t.send({ jsonrpc: \"2.0\", id: 1, method: \"tools/list\" }); // client → server\n */\nexport class InProcessTransport implements Transport {\n private server?: MicroMcpServer;\n private listeners = new Set<(msg: JsonRpcMessage) => void>();\n\n /** Bind to a server. Called from the client's setup, not directly. */\n bindServer(server: MicroMcpServer): void {\n this.server = server;\n }\n\n /** Server → client (delivered to subscribed listeners). */\n send(message: JsonRpcMessage): void {\n for (const l of this.listeners) l(message);\n }\n\n /** Client → server. Awaitable so callers can flush. */\n async deliver(message: JsonRpcMessage): Promise<void> {\n if (!this.server) throw new Error(\"InProcessTransport has no bound server\");\n await this.server.receive(this, message);\n }\n\n /** Subscribe to messages the server pushes to this client. */\n onServerMessage(listener: (msg: JsonRpcMessage) => void): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n close(): void {\n this.listeners.clear();\n }\n}\n\n/**\n * Convenience: create a server-attached in-process transport in one call.\n */\nexport function attachInProcess(server: MicroMcpServer): InProcessTransport {\n const transport = new InProcessTransport();\n transport.bindServer(server);\n server.attach(transport);\n return transport;\n}\n","import type { JsonRpcMessage } from \"../types\";\nimport type { MicroMcpServer, Transport } from \"../server\";\n\n/**\n * RelayTransport — wraps any duplex JSON-frame channel (e.g. a Reverb\n * websocket private channel, a WebRTC data channel) so external agents\n * can talk to a browser-side MicroMcpServer.\n *\n * The host app owns the actual channel. This class only handles framing\n * (JSON.stringify / JSON.parse) and the server contract.\n *\n * Channel contract:\n * - host calls `transport.deliverFromRemote(payload)` with each frame\n * it receives from the remote agent\n * - host implements `sendToRemote(frame)` so the transport can deliver\n * server → client frames outward\n *\n * See docs/relay-protocol.md for the wire format.\n */\nexport type RelayChannel = {\n sendToRemote: (frame: JsonRpcMessage) => void;\n /** Optional: notify the channel that the server is gone. */\n onClose?: () => void;\n};\n\nexport class RelayTransport implements Transport {\n private server?: MicroMcpServer;\n constructor(private channel: RelayChannel) {}\n\n bindServer(server: MicroMcpServer): void {\n this.server = server;\n }\n\n send(message: JsonRpcMessage): void {\n this.channel.sendToRemote(message);\n }\n\n /**\n * Host calls this with each frame received from the remote agent. Accepts\n * either a parsed object or a raw JSON string.\n */\n async deliverFromRemote(payload: JsonRpcMessage | string): Promise<void> {\n if (!this.server) throw new Error(\"RelayTransport has no bound server\");\n const message = typeof payload === \"string\"\n ? (JSON.parse(payload) as JsonRpcMessage)\n : payload;\n await this.server.receive(this, message);\n }\n\n close(): void {\n this.channel.onClose?.();\n }\n}\n\n/**\n * Convenience wiring. Returns the bound transport.\n */\nexport function attachRelay(server: MicroMcpServer, channel: RelayChannel): RelayTransport {\n const transport = new RelayTransport(channel);\n transport.bindServer(server);\n server.attach(transport);\n return transport;\n}\n"]}
package/dist/mcp.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { RelayTransport, attachRelay } from './chunk-G6N2TQVO.js';
2
2
  export { InProcessTransport, attachInProcess } from './chunk-AFUULW5E.js';
3
- export { JSONRPC_INTERNAL_ERROR, JSONRPC_INVALID_PARAMS, JSONRPC_INVALID_REQUEST, JSONRPC_METHOD_NOT_FOUND, JSONRPC_PARSE_ERROR, MCP_PROTOCOL_VERSION, MicroMcpServer, errorResult, rpcError, textResult } from './chunk-QJYRWEXD.js';
3
+ export { JSONRPC_INTERNAL_ERROR, JSONRPC_INVALID_PARAMS, JSONRPC_INVALID_REQUEST, JSONRPC_METHOD_NOT_FOUND, JSONRPC_PARSE_ERROR, MCP_PROTOCOL_VERSION, MicroMcpServer, errorResult, rpcError, textResult } from './chunk-CZV3WUW5.js';
4
4
  //# sourceMappingURL=mcp.js.map
5
5
  //# sourceMappingURL=mcp.js.map
@@ -1,6 +1,6 @@
1
1
  import { AutoTarget, ActivityFilter, AutoActivityEvent } from '@particle-academy/fancy-auto-common';
2
2
  export { ActivityFilter, AutoActivityEvent as AgentActivityEvent, AutoActivityListener as AgentActivityListener, AutoTarget as AgentTarget, AutoTargetKind as AgentTargetKind, emitActivity, onActivity, readActivityHistory, resetActivityRegistry } from '@particle-academy/fancy-auto-common';
3
- import { C as CallToolResult } from '../types-C58ZXs4K.cjs';
3
+ import { C as CallToolResult } from '../types-C2DtnHIn.cjs';
4
4
 
5
5
  type ActivityAgent = {
6
6
  id: string;
@@ -1,6 +1,6 @@
1
1
  import { AutoTarget, ActivityFilter, AutoActivityEvent } from '@particle-academy/fancy-auto-common';
2
2
  export { ActivityFilter, AutoActivityEvent as AgentActivityEvent, AutoActivityListener as AgentActivityListener, AutoTarget as AgentTarget, AutoTargetKind as AgentTargetKind, emitActivity, onActivity, readActivityHistory, resetActivityRegistry } from '@particle-academy/fancy-auto-common';
3
- import { C as CallToolResult } from '../types-C58ZXs4K.js';
3
+ import { C as CallToolResult } from '../types-C2DtnHIn.js';
4
4
 
5
5
  type ActivityAgent = {
6
6
  id: string;
@@ -1,5 +1,5 @@
1
- import { S as ServerInfo, a as ServerCapabilities, b as JsonRpcMessage, C as CallToolResult } from './types-C58ZXs4K.cjs';
2
- import { a as ToolRegistry } from './tool-host-BpEBqf5u.cjs';
1
+ import { S as ServerInfo, c as ServerCapabilities, a as JsonRpcMessage, C as CallToolResult } from './types-C2DtnHIn.cjs';
2
+ import { a as ToolRegistry } from './tool-host-LVBgCN5m.cjs';
3
3
 
4
4
  type McpServerOptions = {
5
5
  info: ServerInfo;
@@ -7,6 +7,18 @@ type McpServerOptions = {
7
7
  capabilities?: ServerCapabilities;
8
8
  /** Free-text instructions surfaced to clients during initialize. */
9
9
  instructions?: string;
10
+ /**
11
+ * The protocol revisions this server speaks, NEWEST FIRST.
12
+ *
13
+ * `initialize` echoes the client's requested revision when it is in this
14
+ * list, and answers the first entry otherwise — the spec's rule, which leaves
15
+ * the client to decide whether it can live with the answer.
16
+ *
17
+ * Defaults to `[MCP_PROTOCOL_VERSION]`: one revision, answered whatever the
18
+ * client asks, which is exactly what this server did before the option
19
+ * existed. Only list a revision the tools you register are correct under.
20
+ */
21
+ protocolVersions?: readonly string[];
10
22
  };
11
23
  type Transport = {
12
24
  /** Called by the server when it has a message to deliver to the client. */
@@ -30,10 +42,15 @@ type Transport = {
30
42
  */
31
43
  declare class MicroMcpServer extends ToolRegistry {
32
44
  private transports;
33
- private notifyListChangedScheduled;
45
+ /**
46
+ * Transports owed a `tools/list_changed` at the end of this tick. Empty when
47
+ * none is scheduled. See {@link scheduleListChangedNotification}.
48
+ */
49
+ private listChangedOwed;
34
50
  readonly info: ServerInfo;
35
51
  readonly capabilities: ServerCapabilities;
36
52
  readonly instructions?: string;
53
+ readonly protocolVersions: readonly string[];
37
54
  constructor(options: McpServerOptions);
38
55
  attach(transport: Transport): () => void;
39
56
  detach(transport: Transport): void;
@@ -45,6 +62,18 @@ declare class MicroMcpServer extends ToolRegistry {
45
62
  */
46
63
  receive(transport: Transport, message: JsonRpcMessage): Promise<void>;
47
64
  private handle;
65
+ /** The revision to answer `initialize` with: the one asked for if spoken, else the newest. */
66
+ private negotiate;
67
+ /**
68
+ * Tell the transports that SAW the old tool list that it changed.
69
+ *
70
+ * Changes in one tick coalesce into one notification. The recipients are the
71
+ * transports attached at the moment of a change, not at the moment the
72
+ * notification goes out: a transport attached afterwards never had the old
73
+ * list, so "your list is stale" is noise to it — and on stdio, where a host
74
+ * builds the server and attaches stdin/stdout in the same tick, it was the
75
+ * first frame a client received, before it had even sent `initialize`.
76
+ */
48
77
  private scheduleListChangedNotification;
49
78
  /** Send an application notification to every client, or one attached transport. */
50
79
  notify(message: JsonRpcMessage, transport?: Transport): void;
@@ -1,5 +1,5 @@
1
- import { S as ServerInfo, a as ServerCapabilities, b as JsonRpcMessage, C as CallToolResult } from './types-C58ZXs4K.js';
2
- import { a as ToolRegistry } from './tool-host-xY5F-eqG.js';
1
+ import { S as ServerInfo, c as ServerCapabilities, a as JsonRpcMessage, C as CallToolResult } from './types-C2DtnHIn.js';
2
+ import { a as ToolRegistry } from './tool-host-Wo0pkY83.js';
3
3
 
4
4
  type McpServerOptions = {
5
5
  info: ServerInfo;
@@ -7,6 +7,18 @@ type McpServerOptions = {
7
7
  capabilities?: ServerCapabilities;
8
8
  /** Free-text instructions surfaced to clients during initialize. */
9
9
  instructions?: string;
10
+ /**
11
+ * The protocol revisions this server speaks, NEWEST FIRST.
12
+ *
13
+ * `initialize` echoes the client's requested revision when it is in this
14
+ * list, and answers the first entry otherwise — the spec's rule, which leaves
15
+ * the client to decide whether it can live with the answer.
16
+ *
17
+ * Defaults to `[MCP_PROTOCOL_VERSION]`: one revision, answered whatever the
18
+ * client asks, which is exactly what this server did before the option
19
+ * existed. Only list a revision the tools you register are correct under.
20
+ */
21
+ protocolVersions?: readonly string[];
10
22
  };
11
23
  type Transport = {
12
24
  /** Called by the server when it has a message to deliver to the client. */
@@ -30,10 +42,15 @@ type Transport = {
30
42
  */
31
43
  declare class MicroMcpServer extends ToolRegistry {
32
44
  private transports;
33
- private notifyListChangedScheduled;
45
+ /**
46
+ * Transports owed a `tools/list_changed` at the end of this tick. Empty when
47
+ * none is scheduled. See {@link scheduleListChangedNotification}.
48
+ */
49
+ private listChangedOwed;
34
50
  readonly info: ServerInfo;
35
51
  readonly capabilities: ServerCapabilities;
36
52
  readonly instructions?: string;
53
+ readonly protocolVersions: readonly string[];
37
54
  constructor(options: McpServerOptions);
38
55
  attach(transport: Transport): () => void;
39
56
  detach(transport: Transport): void;
@@ -45,6 +62,18 @@ declare class MicroMcpServer extends ToolRegistry {
45
62
  */
46
63
  receive(transport: Transport, message: JsonRpcMessage): Promise<void>;
47
64
  private handle;
65
+ /** The revision to answer `initialize` with: the one asked for if spoken, else the newest. */
66
+ private negotiate;
67
+ /**
68
+ * Tell the transports that SAW the old tool list that it changed.
69
+ *
70
+ * Changes in one tick coalesce into one notification. The recipients are the
71
+ * transports attached at the moment of a change, not at the moment the
72
+ * notification goes out: a transport attached afterwards never had the old
73
+ * list, so "your list is stale" is noise to it — and on stdio, where a host
74
+ * builds the server and attaches stdin/stdout in the same tick, it was the
75
+ * first frame a client received, before it had even sent `initialize`.
76
+ */
48
77
  private scheduleListChangedNotification;
49
78
  /** Send an application notification to every client, or one attached transport. */
50
79
  notify(message: JsonRpcMessage, transport?: Transport): void;
@@ -1,8 +1,8 @@
1
1
  export { S as SessionDescriptor, b as buildShareConfig, a as buildShareUrl, e as constantTimeEqual, c as createSessionDescriptor, d as describeSession, r as readSessionFromUrl } from '../token-BZ8doMam.cjs';
2
- import { b as JsonRpcMessage } from '../types-C58ZXs4K.cjs';
3
- import { T as Transport, M as MicroMcpServer } from '../server-BJNF7pQe.cjs';
2
+ import { a as JsonRpcMessage } from '../types-C2DtnHIn.cjs';
3
+ import { T as Transport, M as MicroMcpServer } from '../server-BIcA3ZtK.cjs';
4
4
  import { AutoActivityEvent } from '@particle-academy/fancy-auto-common';
5
- import '../tool-host-BpEBqf5u.cjs';
5
+ import '../tool-host-LVBgCN5m.cjs';
6
6
 
7
7
  /**
8
8
  * SseRelayTransport — bridges the in-page MicroMcpServer to a host-app
@@ -1,8 +1,8 @@
1
1
  export { S as SessionDescriptor, b as buildShareConfig, a as buildShareUrl, e as constantTimeEqual, c as createSessionDescriptor, d as describeSession, r as readSessionFromUrl } from '../token-BZ8doMam.js';
2
- import { b as JsonRpcMessage } from '../types-C58ZXs4K.js';
3
- import { T as Transport, M as MicroMcpServer } from '../server-Dt97UxuD.js';
2
+ import { a as JsonRpcMessage } from '../types-C2DtnHIn.js';
3
+ import { T as Transport, M as MicroMcpServer } from '../server-DnUyeavY.js';
4
4
  import { AutoActivityEvent } from '@particle-academy/fancy-auto-common';
5
- import '../tool-host-xY5F-eqG.js';
5
+ import '../tool-host-Wo0pkY83.js';
6
6
 
7
7
  /**
8
8
  * SseRelayTransport — bridges the in-page MicroMcpServer to a host-app
@@ -1,7 +1,7 @@
1
1
  import { SheetsBridgeAdapter } from './bridges/sheets.cjs';
2
- import './tool-host-BpEBqf5u.cjs';
3
- import './types-C58ZXs4K.cjs';
4
- import './types-C4NaIW6B.cjs';
2
+ import './tool-host-LVBgCN5m.cjs';
3
+ import './types-C2DtnHIn.cjs';
4
+ import './types-EcElKOlk.cjs';
5
5
  import '@particle-academy/fancy-sheets';
6
6
 
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  import { SheetsBridgeAdapter } from './bridges/sheets.js';
2
- import './tool-host-xY5F-eqG.js';
3
- import './types-C58ZXs4K.js';
4
- import './types-DSwsNTBG.js';
2
+ import './tool-host-Wo0pkY83.js';
3
+ import './types-C2DtnHIn.js';
4
+ import './types-BxNRKSVd.js';
5
5
  import '@particle-academy/fancy-sheets';
6
6
 
7
7
  /**
@@ -1,4 +1,4 @@
1
- import { T as ToolDefinition, c as ToolHandler, R as RegisteredTool, J as JsonObject, C as CallToolResult } from './types-C58ZXs4K.cjs';
1
+ import { T as ToolDefinition, b as ToolHandler, R as RegisteredTool, J as JsonObject, C as CallToolResult } from './types-C2DtnHIn.cjs';
2
2
 
3
3
  /**
4
4
  * ToolHost — the minimal surface a bridge needs to register its tools.
@@ -1,4 +1,4 @@
1
- import { T as ToolDefinition, c as ToolHandler, R as RegisteredTool, J as JsonObject, C as CallToolResult } from './types-C58ZXs4K.js';
1
+ import { T as ToolDefinition, b as ToolHandler, R as RegisteredTool, J as JsonObject, C as CallToolResult } from './types-C2DtnHIn.js';
2
2
 
3
3
  /**
4
4
  * ToolHost — the minimal surface a bridge needs to register its tools.
@@ -1,4 +1,4 @@
1
- import { T as ToolHost } from './tool-host-xY5F-eqG.js';
1
+ import { T as ToolHost } from './tool-host-Wo0pkY83.js';
2
2
 
3
3
  /**
4
4
  * Bridge — registers a cohesive set of MCP tools/resources for a single
@@ -69,16 +69,40 @@ type InitializeResult = {
69
69
  instructions?: string;
70
70
  };
71
71
  type ToolInputSchema = {
72
+ /** The JSON Schema dialect, when a server states it (e.g. draft-07). */
73
+ $schema?: string;
72
74
  type: "object";
73
75
  properties?: Record<string, JsonValue>;
74
76
  required?: string[];
75
77
  additionalProperties?: boolean;
76
78
  };
79
+ /** Behaviour hints a client may use when presenting or gating a tool. */
80
+ type ToolAnnotations = {
81
+ title?: string;
82
+ readOnlyHint?: boolean;
83
+ destructiveHint?: boolean;
84
+ idempotentHint?: boolean;
85
+ openWorldHint?: boolean;
86
+ };
87
+ /**
88
+ * A tool as `tools/list` reports it. Every field is passed to the client
89
+ * verbatim, so the optional ones below are the spec's, not extensions.
90
+ */
77
91
  type ToolDefinition = {
78
92
  name: string;
79
93
  title?: string;
80
94
  description?: string;
81
95
  inputSchema: ToolInputSchema;
96
+ /** JSON Schema for `structuredContent`, when the tool returns it. */
97
+ outputSchema?: ToolInputSchema;
98
+ annotations?: ToolAnnotations;
99
+ /** 2025-11-25: whether the tool may run as a task. */
100
+ execution?: {
101
+ taskSupport?: "forbidden" | "optional" | "required";
102
+ };
103
+ _meta?: {
104
+ [key: string]: JsonValue;
105
+ };
82
106
  };
83
107
  type ContentBlock = {
84
108
  type: "text";
@@ -113,4 +137,4 @@ type RegisteredTool = {
113
137
  };
114
138
  declare const MCP_PROTOCOL_VERSION = "2025-06-18";
115
139
 
116
- export { type CallToolResult as C, type InitializeResult as I, type JsonObject as J, MCP_PROTOCOL_VERSION as M, type RegisteredTool as R, type ServerInfo as S, type ToolDefinition as T, type ServerCapabilities as a, type JsonRpcMessage as b, type ToolHandler as c, type ContentBlock as d, type JsonRpcNotification as e, type JsonRpcRequest as f, type JsonValue as g, type ToolCallContext as h, JSONRPC_INTERNAL_ERROR as i, JSONRPC_INVALID_PARAMS as j, JSONRPC_INVALID_REQUEST as k, JSONRPC_METHOD_NOT_FOUND as l, JSONRPC_PARSE_ERROR as m, type JsonRpcError as n, type JsonRpcId as o, type JsonRpcSuccess as p, type ToolInputSchema as q };
140
+ export { type CallToolResult as C, type InitializeResult as I, type JsonObject as J, MCP_PROTOCOL_VERSION as M, type RegisteredTool as R, type ServerInfo as S, type ToolDefinition as T, type JsonRpcMessage as a, type ToolHandler as b, type ServerCapabilities as c, type ContentBlock as d, type JsonRpcNotification as e, type JsonRpcRequest as f, type JsonValue as g, type ToolCallContext as h, JSONRPC_INTERNAL_ERROR as i, JSONRPC_INVALID_PARAMS as j, JSONRPC_INVALID_REQUEST as k, JSONRPC_METHOD_NOT_FOUND as l, JSONRPC_PARSE_ERROR as m, type JsonRpcError as n, type JsonRpcId as o, type JsonRpcSuccess as p, type ToolAnnotations as q, type ToolInputSchema as r };
@@ -69,16 +69,40 @@ type InitializeResult = {
69
69
  instructions?: string;
70
70
  };
71
71
  type ToolInputSchema = {
72
+ /** The JSON Schema dialect, when a server states it (e.g. draft-07). */
73
+ $schema?: string;
72
74
  type: "object";
73
75
  properties?: Record<string, JsonValue>;
74
76
  required?: string[];
75
77
  additionalProperties?: boolean;
76
78
  };
79
+ /** Behaviour hints a client may use when presenting or gating a tool. */
80
+ type ToolAnnotations = {
81
+ title?: string;
82
+ readOnlyHint?: boolean;
83
+ destructiveHint?: boolean;
84
+ idempotentHint?: boolean;
85
+ openWorldHint?: boolean;
86
+ };
87
+ /**
88
+ * A tool as `tools/list` reports it. Every field is passed to the client
89
+ * verbatim, so the optional ones below are the spec's, not extensions.
90
+ */
77
91
  type ToolDefinition = {
78
92
  name: string;
79
93
  title?: string;
80
94
  description?: string;
81
95
  inputSchema: ToolInputSchema;
96
+ /** JSON Schema for `structuredContent`, when the tool returns it. */
97
+ outputSchema?: ToolInputSchema;
98
+ annotations?: ToolAnnotations;
99
+ /** 2025-11-25: whether the tool may run as a task. */
100
+ execution?: {
101
+ taskSupport?: "forbidden" | "optional" | "required";
102
+ };
103
+ _meta?: {
104
+ [key: string]: JsonValue;
105
+ };
82
106
  };
83
107
  type ContentBlock = {
84
108
  type: "text";
@@ -113,4 +137,4 @@ type RegisteredTool = {
113
137
  };
114
138
  declare const MCP_PROTOCOL_VERSION = "2025-06-18";
115
139
 
116
- export { type CallToolResult as C, type InitializeResult as I, type JsonObject as J, MCP_PROTOCOL_VERSION as M, type RegisteredTool as R, type ServerInfo as S, type ToolDefinition as T, type ServerCapabilities as a, type JsonRpcMessage as b, type ToolHandler as c, type ContentBlock as d, type JsonRpcNotification as e, type JsonRpcRequest as f, type JsonValue as g, type ToolCallContext as h, JSONRPC_INTERNAL_ERROR as i, JSONRPC_INVALID_PARAMS as j, JSONRPC_INVALID_REQUEST as k, JSONRPC_METHOD_NOT_FOUND as l, JSONRPC_PARSE_ERROR as m, type JsonRpcError as n, type JsonRpcId as o, type JsonRpcSuccess as p, type ToolInputSchema as q };
140
+ export { type CallToolResult as C, type InitializeResult as I, type JsonObject as J, MCP_PROTOCOL_VERSION as M, type RegisteredTool as R, type ServerInfo as S, type ToolDefinition as T, type JsonRpcMessage as a, type ToolHandler as b, type ServerCapabilities as c, type ContentBlock as d, type JsonRpcNotification as e, type JsonRpcRequest as f, type JsonValue as g, type ToolCallContext as h, JSONRPC_INTERNAL_ERROR as i, JSONRPC_INVALID_PARAMS as j, JSONRPC_INVALID_REQUEST as k, JSONRPC_METHOD_NOT_FOUND as l, JSONRPC_PARSE_ERROR as m, type JsonRpcError as n, type JsonRpcId as o, type JsonRpcSuccess as p, type ToolAnnotations as q, type ToolInputSchema as r };
@@ -1,4 +1,4 @@
1
- import { T as ToolHost } from './tool-host-BpEBqf5u.cjs';
1
+ import { T as ToolHost } from './tool-host-LVBgCN5m.cjs';
2
2
 
3
3
  /**
4
4
  * Bridge — registers a cohesive set of MCP tools/resources for a single
@@ -1,7 +1,7 @@
1
1
  import * as _particle_academy_fancy_auto_common from '@particle-academy/fancy-auto-common';
2
2
  export { UndoEntry, clearStack, pushUndoEntry, readHistory, redoOne, resetAllUndoStacks, undoOne } from '@particle-academy/fancy-auto-common';
3
- import { T as ToolHost } from '../tool-host-BpEBqf5u.cjs';
4
- import '../types-C58ZXs4K.cjs';
3
+ import { T as ToolHost } from '../tool-host-LVBgCN5m.cjs';
4
+ import '../types-C2DtnHIn.cjs';
5
5
 
6
6
  type UndoToolsOptions = {
7
7
  /** Default agent id when the caller doesn't pass one. */
@@ -1,7 +1,7 @@
1
1
  import * as _particle_academy_fancy_auto_common from '@particle-academy/fancy-auto-common';
2
2
  export { UndoEntry, clearStack, pushUndoEntry, readHistory, redoOne, resetAllUndoStacks, undoOne } from '@particle-academy/fancy-auto-common';
3
- import { T as ToolHost } from '../tool-host-xY5F-eqG.js';
4
- import '../types-C58ZXs4K.js';
3
+ import { T as ToolHost } from '../tool-host-Wo0pkY83.js';
4
+ import '../types-C2DtnHIn.js';
5
5
 
6
6
  type UndoToolsOptions = {
7
7
  /** Default agent id when the caller doesn't pass one. */