Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.
fix(mcp): name null parts instead of throwing in resultText (#360)
Felix-Ayusha65d2fa1368f
diff --git a/server/src/plugins/mcp.ts b/server/src/plugins/mcp.tsindex eba34a06..23e5599d 100644--- a/server/src/plugins/mcp.ts+++ b/server/src/plugins/mcp.ts@@ -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;diff --git a/server/tests/mcp-result.test.ts b/server/tests/mcp-result.test.tsindex 8388c8bb..4f0a83aa 100644--- a/server/tests/mcp-result.test.ts+++ b/server/tests/mcp-result.test.ts@@ -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(