{"record":{"id":"9bc6e126cea769b9","repo":"different-ai/openwork","slug":"toolresulterror-result","errorCode":null,"errorMessage":"${toolResultError(result)}","messagePattern":"\\$\\{toolResultError\\(result\\)\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ee/apps/den-api/src/mcp/capability-registry.ts","lineNumber":765,"sourceCode":"    return matches.map((match) => ({ ...match, scriptPath: codemodeScriptPath(\"admin\", parseAdminCapabilityName(match.name) ?? match.name) }))\n  },\n  enumerate: async (ctx) => {\n    const matches = await listAvailableAdminCapabilities(await ctx.resolvePlatformAdmin())\n    return matches.flatMap((match) => {\n      const toolName = parseAdminCapabilityName(match.name)\n      if (!toolName) return []\n      const parsed: Extract<ParsedCapability, { kind: \"admin\" }> = { kind: \"admin\", name: match.name, toolName }\n      return [contentLeaf({\n        namespace: \"admin\",\n        toolName,\n        capabilityName: match.name,\n        description: match.summary,\n        readOnly: false,\n        authority: \"den\",\n        input: isCodemodeJsonSchema(match.argumentsSchema) ? match.argumentsSchema : undefined,\n        run: async (args) => {\n          const result = await adminSource.execute(ctx, parsed, { name: match.name, body: args })\n          if (result.isError) throw toolError(toolResultError(result))\n          return toolResultValue(result)\n        },\n      })]\n    })\n  },\n  execute: async (ctx, parsed, input) => {\n    if (!parsedForKind(parsed, \"admin\") || !(await ctx.resolvePlatformAdmin())) {\n      return unknownCapabilityResult(input.name)\n    }\n    return (await executeAdminCapability(parsed.name, input.body)) ?? unknownCapabilityResult(input.name)\n  },\n}\n\nexport const CAPABILITY_SOURCES: Record<CapabilitySourceKind, CapabilitySource> = {\n  catalog: catalogSource,\n  native: nativeSource,\n  externalMcp: externalMcpSource,\n  marketplace: marketplaceSource,","sourceCodeStart":747,"sourceCodeEnd":783,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-api/src/mcp/capability-registry.ts#L747-L783","documentation":"The admin-source tool runner in capability-registry.ts executes a matched capability via adminSource.execute; if the returned tool result has isError true, it throws toolError(toolResultError(result)), embedding the provider's error text via the message '${toolResultError(result)}'. Successful results are returned as toolResultValue(result).","triggerScenarios":"Calling an admin-sourced MCP tool where adminSource.execute returns an isError tool result — the underlying capability/provider rejected the call: invalid arguments per the tool's argumentsSchema, provider-side execution failure, authz denial, or upstream service error.","commonSituations":"Arguments that don't satisfy match.argumentsSchema (missing required properties, wrong types); the admin connection's credentials lacking permission for the operation; upstream provider rejecting the operation or being down; schema drift between the registered tool and the provider's current API.","solutions":["Read the propagated toolResultError text for the underlying cause and correct the call arguments accordingly.","Validate args against the tool's declared argumentsSchema (isCodemodeJsonSchema-validated input) before invoking.","Re-sync the capability registry / connection so schemas match the provider's current API.","Verify the admin connection's credentials and scopes if the error indicates authorization failure."],"exampleFix":"// before: passing a string where the schema wants an array\nrun: execute(ctx, parsed, { name: 'crm.import', body: { rows: 'a,b,c' } })\n// after: conform to match.argumentsSchema\nrun: execute(ctx, parsed, { name: 'crm.import', body: { rows: ['a', 'b', 'c'] } })","handlingStrategy":"validation","validationCode":"if (match.argumentsSchema) {\n  const parsed = match.argumentsSchema.safeParse?.(args)\n  if (parsed && !parsed.success) throw new Error('args do not match tool argumentsSchema')\n}","typeGuard":"function isErroredToolResult(r: { isError: boolean }): r is { isError: true } {\n  return r.isError === true\n}","tryCatchPattern":"try {\n  result = await adminSource.execute(ctx, parsed, { name: match.name, body: args })\n} catch (error) {\n  // error message carries toolResultError(result); inspect and correct args/permissions\n  logToolResultError(error)\n  throw error\n}","preventionTips":["Validate arguments against the tool's argumentsSchema before every call.","Re-sync the registry after provider schema changes.","Keep admin connection credentials and scopes current.","Prefer tools whose input schema is a valid codemode JSON schema so callers can validate."],"tags":["mcp","tool-execution","admin-source","propagated-error"],"backgroundTag":"tool-result-is-error","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}