mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
feat(mcp): log include MCP request with error (#6778)
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
afterEach,
|
||||
Mocked,
|
||||
} from 'vitest';
|
||||
import { safeJsonStringify } from '../utils/safeJsonStringify.js';
|
||||
import { DiscoveredMCPTool, generateValidName } from './mcp-tool.js'; // Added getStringifiedResultForDisplay
|
||||
import { ToolResult, ToolConfirmationOutcome } from './tools.js'; // Added ToolConfirmationOutcome
|
||||
import { CallableTool, Part } from '@google/genai';
|
||||
@@ -200,6 +201,10 @@ describe('DiscoveredMCPTool', () => {
|
||||
inputSchema,
|
||||
);
|
||||
const params = { param: 'isErrorTrueCase' };
|
||||
const functionCall = {
|
||||
name: serverToolName,
|
||||
args: params,
|
||||
};
|
||||
|
||||
const errorResponse = { isError: isErrorValue };
|
||||
const mockMcpToolResponseParts: Part[] = [
|
||||
@@ -211,10 +216,11 @@ describe('DiscoveredMCPTool', () => {
|
||||
},
|
||||
];
|
||||
mockCallTool.mockResolvedValue(mockMcpToolResponseParts);
|
||||
const expectedErrorMessage = `MCP tool '${serverToolName}' reported tool error with response: ${JSON.stringify(
|
||||
mockMcpToolResponseParts,
|
||||
)}`;
|
||||
|
||||
const expectedErrorMessage = `MCP tool '${
|
||||
serverToolName
|
||||
}' reported tool error for function call: ${safeJsonStringify(
|
||||
functionCall,
|
||||
)} with response: ${safeJsonStringify(mockMcpToolResponseParts)}`;
|
||||
const invocation = tool.build(params);
|
||||
const result = await invocation.execute(new AbortController().signal);
|
||||
|
||||
|
||||
@@ -142,9 +142,9 @@ class DiscoveredMCPToolInvocation extends BaseToolInvocation<
|
||||
if (this.isMCPToolError(rawResponseParts)) {
|
||||
const errorMessage = `MCP tool '${
|
||||
this.serverToolName
|
||||
}' reported tool error with response: ${JSON.stringify(
|
||||
rawResponseParts,
|
||||
)}`;
|
||||
}' reported tool error for function call: ${safeJsonStringify(
|
||||
functionCalls[0],
|
||||
)} with response: ${safeJsonStringify(rawResponseParts)}`;
|
||||
return {
|
||||
llmContent: errorMessage,
|
||||
returnDisplay: `Error: MCP tool '${this.serverToolName}' reported an error.`,
|
||||
|
||||
Reference in New Issue
Block a user