pi-mcp-adapter 2.20.0 → 2.20.1

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/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.20.1] - 2026-08-04
11
+
12
+ ### Fixed
13
+ - Stopped server-side MCP app helper imports from requiring the legacy `@modelcontextprotocol/sdk` peer at extension load time, fixing peerless Pi installs of 2.20.0. Thanks @aryzing for issue #285 and @DevDominic, @Shinkicast, and @marceloid for confirmations.
14
+
10
15
  ## [2.20.0] - 2026-08-04
11
16
 
12
17
  ### Added
package/metadata-cache.ts CHANGED
@@ -3,7 +3,7 @@ import { existsSync, readFileSync, writeFileSync, renameSync, mkdirSync } from "
3
3
  import { dirname } from "node:path";
4
4
  import { getAgentPath } from "./agent-dir.ts";
5
5
  import { createHash } from "node:crypto";
6
- import { getToolUiResourceUri } from "@modelcontextprotocol/ext-apps/app-bridge";
6
+ import { getToolUiResourceUri } from "./ui-app-bridge-helpers.ts";
7
7
  import type {
8
8
  CachedPrompt,
9
9
  CachedResource,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-mcp-adapter",
3
- "version": "2.20.0",
3
+ "version": "2.20.1",
4
4
  "description": "MCP (Model Context Protocol) adapter extension for Pi coding agent",
5
5
  "type": "module",
6
6
  "types": "./index.ts",
@@ -81,6 +81,7 @@
81
81
  "types.ts",
82
82
  "ui-stream-types.ts",
83
83
  "ui-tool-visibility.ts",
84
+ "ui-app-bridge-helpers.ts",
84
85
  "config.ts",
85
86
  "server-manager.ts",
86
87
  "unix-socket-transport.ts",
package/tool-metadata.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { getToolUiResourceUri } from "@modelcontextprotocol/ext-apps/app-bridge";
1
+ import { getToolUiResourceUri } from "./ui-app-bridge-helpers.ts";
2
2
  import type { McpExtensionState } from "./state.ts";
3
3
  import type { ToolMetadata, McpTool, McpResource, ServerEntry, ToolPrefix } from "./types.ts";
4
4
  import { formatToolName, isToolAllowed, resolveToolPrefix } from "./types.ts";
@@ -0,0 +1,40 @@
1
+ import type { UiResourcePermissions } from "./types.ts";
2
+
3
+ export const RESOURCE_MIME_TYPE = "text/html;profile=mcp-app";
4
+
5
+ const RESOURCE_URI_META_KEY = "ui/resourceUri";
6
+
7
+ export function getToolUiResourceUri(tool: { _meta?: Record<string, unknown> | undefined }): string | undefined {
8
+ const meta = tool._meta;
9
+ let resourceUri = getNestedResourceUri(meta);
10
+ if (resourceUri === undefined) {
11
+ resourceUri = meta?.[RESOURCE_URI_META_KEY];
12
+ }
13
+
14
+ if (typeof resourceUri === "string" && resourceUri.startsWith("ui://")) {
15
+ return resourceUri;
16
+ }
17
+
18
+ if (resourceUri !== undefined) {
19
+ throw new Error(`Invalid UI resource URI: ${JSON.stringify(resourceUri)}`);
20
+ }
21
+
22
+ return undefined;
23
+ }
24
+
25
+ export function buildAllowAttribute(permissions: UiResourcePermissions | undefined): string {
26
+ if (!permissions) return "";
27
+
28
+ const allowed: string[] = [];
29
+ if (permissions.camera) allowed.push("camera");
30
+ if (permissions.microphone) allowed.push("microphone");
31
+ if (permissions.geolocation) allowed.push("geolocation");
32
+ if (permissions.clipboardWrite) allowed.push("clipboard-write");
33
+ return allowed.join("; ");
34
+ }
35
+
36
+ function getNestedResourceUri(meta: Record<string, unknown> | undefined): unknown {
37
+ const ui = meta?.ui;
38
+ if (!ui || typeof ui !== "object") return undefined;
39
+ return (ui as Record<string, unknown>).resourceUri;
40
+ }
@@ -1,4 +1,4 @@
1
- import { RESOURCE_MIME_TYPE } from "@modelcontextprotocol/ext-apps/app-bridge";
1
+ import { RESOURCE_MIME_TYPE } from "./ui-app-bridge-helpers.ts";
2
2
  import { UrlElicitationRequiredError, type ReadResourceResult } from "@modelcontextprotocol/client";
3
3
  import { ResourceFetchError, ResourceParseError } from "./errors.ts";
4
4
  import { logger } from "./logger.ts";
package/ui-server.ts CHANGED
@@ -2,7 +2,7 @@ import http, { type IncomingMessage, type ServerResponse } from "node:http";
2
2
  import fs from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { randomUUID } from "node:crypto";
5
- import { buildAllowAttribute } from "@modelcontextprotocol/ext-apps/app-bridge";
5
+ import { buildAllowAttribute } from "./ui-app-bridge-helpers.ts";
6
6
  import {
7
7
  type CallToolRequest,
8
8
  type CallToolResult,