Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server/src/plugins/mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function resultText(content: unknown): {
const parts = Array.isArray(content) ? content : [];
const joined = parts
.map((part) => {
if (!part || typeof part !== "object") return "[unknown]";
const item = part as { type?: string; text?: string };
if (item.type === "text" && typeof item.text === "string") {
return item.text;
Expand Down
7 changes: 7 additions & 0 deletions server/tests/mcp-result.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ describe("a result with something in it", () => {
expect(resultText([{}]).text).toBe("[unknown]");
});

test("names a null or non-object part rather than throwing", () => {
// Content arrives from a vendor's server; a null entry must not throw.
expect(resultText([null]).text).toBe("[unknown]");
expect(resultText([undefined]).text).toBe("[unknown]");
expect(resultText([42]).text).toBe("[unknown]");
});

test("a part that is only whitespace still counts as something being there", () => {
// One blank part beside a real one must not make the whole result look empty.
expect(
Expand Down