Skip to content

Commit 38a6ea5

Browse files
committed
avoid spreads
1 parent 105e8b5 commit 38a6ea5

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

packages/core/src/integrations/mcp-server/resultExtraction.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { isValidContentItem } from './validation';
1717
* @param content - Array of content items from tool result
1818
* @returns Attributes extracted from each content item including type, text, mime type, URI, and resource info
1919
*/
20-
function buildAllContentItemAttributes(content: unknown[]): Record<string, string | number> {
20+
function buildAllContentItemAttributes(content: unknown[]): Record<string, string | number | boolean> {
2121
const attributes: Record<string, string | number> = {
2222
[MCP_TOOL_RESULT_CONTENT_COUNT_ATTRIBUTE]: content.length,
2323
};
@@ -64,17 +64,16 @@ function buildAllContentItemAttributes(content: unknown[]): Record<string, strin
6464
* @returns Attributes extracted from tool result content
6565
*/
6666
export function extractToolResultAttributes(result: unknown): Record<string, string | number | boolean> {
67-
let attributes: Record<string, string | number | boolean> = {};
6867
if (!isValidContentItem(result)) {
69-
return attributes;
68+
return {};
7069
}
7170

71+
const attributes = Array.isArray(result.content) ? buildAllContentItemAttributes(result.content) : {};
72+
7273
if (typeof result.isError === 'boolean') {
7374
attributes[MCP_TOOL_RESULT_IS_ERROR_ATTRIBUTE] = result.isError;
7475
}
75-
if (Array.isArray(result.content)) {
76-
attributes = { ...attributes, ...buildAllContentItemAttributes(result.content) };
77-
}
76+
7877
return attributes;
7978
}
8079

0 commit comments

Comments
 (0)