pi-mcp-extension 1.5.2 → 1.5.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/package.json +1 -1
- package/src/tool-bridge.ts +9 -5
package/package.json
CHANGED
package/src/tool-bridge.ts
CHANGED
|
@@ -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
|
|
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
|
+
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: "
|
|
239
|
-
|
|
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,9 @@ 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
|
|
450
|
+
const errorText = content
|
|
451
|
+
.map((c) => (c.type === "text" ? c.text : ""))
|
|
452
|
+
.join("\n");
|
|
449
453
|
throw new McpError(
|
|
450
454
|
errorText || "Tool reported an error",
|
|
451
455
|
serverName,
|