summaryrefslogtreecommitdiff
path: root/packages/core/src/tools/mcp-tool.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/core/src/tools/mcp-tool.ts')
-rw-r--r--packages/core/src/tools/mcp-tool.ts17
1 files changed, 14 insertions, 3 deletions
diff --git a/packages/core/src/tools/mcp-tool.ts b/packages/core/src/tools/mcp-tool.ts
index baa517f6..6ad1da78 100644
--- a/packages/core/src/tools/mcp-tool.ts
+++ b/packages/core/src/tools/mcp-tool.ts
@@ -16,6 +16,7 @@ import {
ToolResult,
} from './tools.js';
import { CallableTool, FunctionCall, Part } from '@google/genai';
+import { ToolErrorType } from './tool-error.js';
type ToolParams = Record<string, unknown>;
@@ -139,9 +140,19 @@ class DiscoveredMCPToolInvocation extends BaseToolInvocation<
// Ensure the response is not an error
if (this.isMCPToolError(rawResponseParts)) {
- throw new Error(
- `MCP tool '${this.serverToolName}' reported tool error with response: ${JSON.stringify(rawResponseParts)}`,
- );
+ const errorMessage = `MCP tool '${
+ this.serverToolName
+ }' reported tool error with response: ${JSON.stringify(
+ rawResponseParts,
+ )}`;
+ return {
+ llmContent: errorMessage,
+ returnDisplay: `Error: MCP tool '${this.serverToolName}' reported an error.`,
+ error: {
+ message: errorMessage,
+ type: ToolErrorType.MCP_TOOL_ERROR,
+ },
+ };
}
const transformedParts = transformMcpContentToParts(rawResponseParts);