@copilotkit/mcp-apps-renderer 2.0.0-rc.35 → 2.0.0-rc.36

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.
@@ -4,6 +4,25 @@ import { AbstractAgent } from "@ag-ui/client";
4
4
  import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
5
5
 
6
6
  //#region src/session.d.ts
7
+ /**
8
+ * Decode a base64 resource body as UTF-8.
9
+ *
10
+ * @internal exported for testing.
11
+ *
12
+ * `atob` alone yields a latin1 string, which mangles non-ASCII widget HTML
13
+ * (`<p>Été ☀️</p>` decoded to `<p>Été ☀ï¸</p>`). Decode to bytes first, then
14
+ * run them through a UTF-8 TextDecoder.
15
+ */
16
+ declare function ɵdecodeBase64(value: string): string;
17
+ /**
18
+ * The MCP Apps protocol version this host negotiates. Sourced directly from the
19
+ * ext-apps bridge (single source of truth, no hand-maintained literal). It lives
20
+ * here (a bridge-side module) rather than in the bridge-free `./constants` /
21
+ * `./activity` entry so the lightweight activity-registration surface stays free
22
+ * of the ext-apps bundle; consumers that need the version import it from the
23
+ * package root, which already loads the bridge.
24
+ */
25
+ declare const MCP_APPS_PROTOCOL_VERSION = "2026-01-26";
7
26
  /** A resource fetched from the MCP server via the agent proxy. */
8
27
  interface FetchedResource {
9
28
  uri: string;
@@ -143,11 +162,40 @@ interface McpAppSessionOptions {
143
162
  */
144
163
  allowSameOriginFallback?: boolean;
145
164
  }
165
+ /** Defaults every frontend inherits unless it overrides them. */
166
+ declare const MCP_APPS_SESSION_DEFAULTS: Readonly<Required<McpAppSessionOptions>>;
146
167
  /**
147
168
  * Returns the URL to open, or `undefined` to refuse. Receiving the raw string
148
169
  * (not a parsed URL) lets a policy resolve relative links itself.
149
170
  */
150
171
  type McpAppOpenLinkPolicy = (url: string) => string | undefined;
172
+ /**
173
+ * The MCP Apps link policy, shared by every frontend.
174
+ *
175
+ * Three independent rules, deliberately kept as ONE policy so a widget behaves
176
+ * the same whichever framework hosts it:
177
+ *
178
+ * 1. **Scheme denylist**, not an allowlist. Only the schemes that execute script
179
+ * or render attacker-controlled HTML are refused (`javascript:`, `data:`,
180
+ * `vbscript:`, `blob:`, `file:`). Everything else is allowed, including
181
+ * app-defined deep links (`myapp:`, `whatsapp:`), which hand off to an OS
182
+ * handler rather than executing in the page. An allowlist could never
183
+ * enumerate those, and restricting to http/https would break them.
184
+ * 2. **Embedded credentials refused** (`https://user:pw@host`): a widget must not
185
+ * hand the browser a URL carrying someone's credentials.
186
+ * 3. **Path-relative links resolved** against the host document, so `/docs`,
187
+ * `./x` and `../x` open instead of failing URL parsing. Only those three
188
+ * forms: every string is technically a valid relative reference, so anything
189
+ * else stays refused rather than becoming a navigation on the host origin.
190
+ * This does mean a widget can reach a path of the HOST application - the same
191
+ * reach a normal anchor in the page would have.
192
+ *
193
+ * Rules 2 and 3 come from the Angular host, which enforced them before it moved
194
+ * onto this session; rule 1 is the CopilotKit product decision (it matches the
195
+ * Anthropic Software Directory policy: https origins plus owned custom URI
196
+ * schemes). Merging them means no frontend overrides anything.
197
+ */
198
+ declare const denyDangerousSchemes: McpAppOpenLinkPolicy;
151
199
  interface McpAppSession {
152
200
  /** Forward the tool call input to the widget (host -> app). Buffered until ready. */
153
201
  sendToolInput(args: Record<string, unknown>): void;
@@ -167,6 +215,15 @@ interface McpAppSession {
167
215
  /** Disconnect the bridge and release listeners. Does NOT remove the iframe. */
168
216
  teardown(): void;
169
217
  }
218
+ /**
219
+ * Bind an MCP App to a host-provided sandbox iframe: fetch the widget resource
220
+ * through the agent, connect the ext-apps `AppBridge` over a PostMessage
221
+ * transport, and wire the app<->host protocol (ui/message, ui/open-link,
222
+ * tools/call + resources/read proxy, size, host context). Framework-agnostic:
223
+ * the React/Vue/Angular renderers create the iframe and wire reactive state via
224
+ * `hooks`, but all protocol logic lives here.
225
+ */
226
+ declare function bindMcpApp(opts: BindMcpAppOptions): McpAppSession;
170
227
  //#endregion
171
- export { BindMcpAppOptions, McpAppSession, McpAppSessionOptions };
228
+ export { BindMcpAppOptions, FetchedResource, MCP_APPS_PROTOCOL_VERSION, MCP_APPS_SESSION_DEFAULTS, McpAppHostInfo, McpAppOpenLinkPolicy, McpAppSession, McpAppSessionHooks, McpAppSessionOptions, bindMcpApp, denyDangerousSchemes, ɵdecodeBase64 };
172
229
  //# sourceMappingURL=session.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.mts","names":[],"sources":["../src/session.ts"],"mappings":";;;;;;;UAwIiB,eAAA;EACf,GAAA;EACA,QAAA;EACA,IAAA;EACA,IAAA;EACA,KAAA;IACE,EAAA;MACE,aAAA;MACA,GAAA;QACE,cAAA;QACA,eAAA;MAAA;IAAA;EAAA;AAAA;;UAOS,kBAAA;EAcD;EAZd,aAAA,EAAe,IAAA;IAAQ,KAAA;IAAgB,MAAA;EAAA;EAwBvC;EAtBA,aAAA;EAsBgB;EApBhB,cAAA;EAoBiC;EAlBjC,UAAA,EAAY,QAAA,EAAU,eAAA;EAqBU;;;;;EAfhC,OAAA,EAAS,GAAA,EAAK,KAAA;EA0CN;EAxCR,eAAA,EAAiB,GAAA,EAAK,KAAA;EAyDL;;;;;;;;;EA/CjB,cAAA,EAAgB,GAAA,EAAK,KAAA;AAAA;AAAA,UAGN,iBAAA;EA2Bf;;;;;;EApBA,MAAA,EAAQ,iBAAA;EA+CR;EA7CA,UAAA,QAAkB,sBAAA;EA+CS;EA7C3B,QAAA,QAAgB,aAAA;EAiDD;EA/Cf,IAAA,EAAM,gBAAA;;;;AAoDR;;;;;;;;;EAvCE,SAAA;EACA,KAAA,GAAQ,kBAAA;EAkDG;;;;;;EA3CX,OAAA,GAAU,oBAAA;EAyDa;AAmBzB;;;;;AA8DA;;;EAhIE,cAAA,GAAiB,oBAAA;EAoIM;;;;;;;EA5HvB,yBAAA;EA4HuB;EA1HvB,uBAAA;EAqIA;EAnIA,2BAAA;AAAA;;UAIe,cAAA;EACf,IAAA;EACA,OAAA;AAAA;AAAA,UAGe,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;;;;;;;;;EAvBA,cAAA,GAAiB,oBAAA;EA+CM;AAIzB;;;;;;EA3CE,yBAAA;EA2C8C;EAzC9C,uBAAA;EA0CA;EAxCA,2BAAA;AAAA;;UAIe,cAAA;EACf,IAAA;EACA,OAAA;AAAA;AAAA,UAGe,oBAAA;EAyEJ;EAvEX,aAAA;;;;AAyGF;;;;EAjGE,uBAAA;EAgHqB;EA9GrB,QAAA,GAAW,cAAA;EA8GgC;EA5G3C,gBAAA,GAAmB,MAAA;EA+FC;EA7FpB,WAAA,GAAc,MAAA;EA+Fd;;;;;;;;;EArFA,uBAAA;AAAA;;cAIW,yBAAA,EAA2B,QAAA,CACtC,QAAA,CAAS,oBAAA;;;;;KAcC,oBAAA,IAAwB,GAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4BvB,oBAAA,EAAsB,oBAAA;AAAA,UAkClB,aAAA;;EAEf,aAAA,CAAc,IAAA,EAAM,MAAA;;EAEpB,cAAA,CAAe,MAAA,EAAQ,cAAA;;;;;;;;;;;EAWvB,WAAA,CAAY,OAAA,EAAS,sBAAA;;EAErB,QAAA;AAAA;;;;;;;;;iBAWc,UAAA,CAAW,IAAA,EAAM,iBAAA,GAAoB,aAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copilotkit/mcp-apps-renderer",
3
- "version": "2.0.0-rc.35",
3
+ "version": "2.0.0-rc.36",
4
4
  "private": false,
5
5
  "description": "Framework-agnostic MCP Apps host for CopilotKit - the app<->host protocol (ext-apps AppBridge), sandbox proxy, and shared renderer consumed by the React, Vue, and Angular frontends",
6
6
  "keywords": [
@@ -51,7 +51,7 @@
51
51
  "access": "public"
52
52
  },
53
53
  "dependencies": {
54
- "@copilotkit/shared": "2.0.0-rc.35",
54
+ "@copilotkit/shared": "2.0.0-rc.36",
55
55
  "@modelcontextprotocol/ext-apps": "^1.7.5",
56
56
  "@modelcontextprotocol/sdk": "^1.29.0",
57
57
  "zod": "^4.2.0"