Skip to content

Commit e27d38f

Browse files
committed
Enhance MCP client to append structuredContent
Updates the MCP HTTP client to append structuredContent as JSON to the textual output if provided by the server. Also bumps @modelcontextprotocol/sdk dependency to version 1.21.1.
1 parent 73a6967 commit e27d38f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"@elysiajs/swagger": "^1.3.0",
7070
"@huggingface/hub": "^2.2.0",
7171
"@huggingface/inference": "^4.11.3",
72-
"@modelcontextprotocol/sdk": "^1.21.0",
72+
"@modelcontextprotocol/sdk": "^1.21.1",
7373
"@iconify-json/bi": "^1.1.21",
7474
"@resvg/resvg-js": "^2.6.2",
7575
"autoprefixer": "^10.4.14",

src/lib/server/mcp/httpClient.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,14 @@ export async function callMcpTool(
7878
return obj["type"] === "text" && typeof obj["text"] === "string";
7979
})
8080
.map((p) => p.text);
81-
return textParts.join("\n");
81+
82+
// Minimal enhancement: if the server provided structuredContent, append its JSON
83+
// to the textual output so downstream consumers can optionally parse it.
84+
const text = textParts.join("\n");
85+
const structured = (response as unknown as { structuredContent?: unknown })?.structuredContent;
86+
if (structured !== undefined) {
87+
const json = typeof structured === "string" ? structured : JSON.stringify(structured);
88+
return text ? `${text}\n\n${json}` : json;
89+
}
90+
return text;
8291
}

0 commit comments

Comments
 (0)