pi-mcp-extension 1.5.2 → 1.5.4

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/tool-bridge.ts +10 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-mcp-extension",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
4
4
  "description": "MCP (Model Context Protocol) client extension for the Pi coding agent — connect Pi to any MCP server",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -9,7 +9,7 @@
9
9
  * - AbortSignal → SDK's built-in cancellation (notifications/cancelled)
10
10
  * - Protocol error vs tool execution error distinction
11
11
  * - Activate/deactivate pattern (register once, toggle on server state change)
12
- * - Image/audio/resource content → text description passthrough
12
+ * - Image content → ImageContent passthrough; audio/resource → text description
13
13
  */
14
14
 
15
15
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
@@ -224,8 +224,9 @@ export function buildToolName(prefix: string, serverName: string, toolName: stri
224
224
  // ─── Content Conversion ───────────────────────────────────────────────────────
225
225
 
226
226
  type PiTextContent = { type: "text"; text: string };
227
+ type PiImageContent = { type: "image"; data: string; mimeType: string };
227
228
 
228
- function convertMcpContent(items: unknown[]): PiTextContent[] {
229
+ export function convertMcpContent(items: unknown[]): (PiTextContent | PiImageContent)[] {
229
230
  return items.map((item: any) => {
230
231
  if (!item || typeof item !== "object") {
231
232
  return { type: "text", text: String(item) };
@@ -235,8 +236,9 @@ function convertMcpContent(items: unknown[]): PiTextContent[] {
235
236
  return { type: "text", text: String(item.text ?? "") };
236
237
  case "image":
237
238
  return {
238
- type: "text",
239
- text: `[Image: ${item.mimeType ?? "unknown"}, base64 encoded]`,
239
+ type: "image",
240
+ data: String(item.data ?? ""),
241
+ mimeType: String(item.mimeType ?? "image/png"),
240
242
  };
241
243
  case "audio":
242
244
  return {
@@ -445,7 +447,10 @@ export class ToolBridge {
445
447
 
446
448
  // Tool execution errors (isError: true) — distinct from protocol errors
447
449
  if (result.isError) {
448
- const errorText = content.map((c) => c.text).join("\n");
450
+ const errorText = content
451
+ .filter((c): c is PiTextContent => c.type === "text")
452
+ .map((c) => c.text)
453
+ .join("\n");
449
454
  throw new McpError(
450
455
  errorText || "Tool reported an error",
451
456
  serverName,