Skip to content

fix(mcp): make native web_search work end-to-end via Kiro MCP#5

Merged
severity1 merged 1 commit into
mainfrom
fix/mcp-websearch-complete
Jun 11, 2026
Merged

fix(mcp): make native web_search work end-to-end via Kiro MCP#5
severity1 merged 1 commit into
mainfrom
fix/mcp-websearch-complete

Conversation

@severity1

Copy link
Copy Markdown
Owner

Summary

Makes Claude Code's native web_search server-side tool work end-to-end through the gateway to runtime.kiro.dev/mcp. This is the complete fix applied to the fork; the client-identity-headers half is upstreamed surgically in jwadow#213.

Two server-side gates had to be cleared, in order:

  1. 400 profileArn is requiredcall_kiro_mcp_api omitted the profileArn that every other Kiro call sends. Added to the MCP request body (auth_manager.profile_arn or PROFILE_ARN), mirroring the completion paths. (Same field is contributed upstream in fix(mcp): add profileArn to MCP web_search request body jwadow/kiro-gateway#180 / fix(mcp): include profileArn for Enterprise accounts in web_search jwadow/kiro-gateway#189 / fix: handle profileArn runtime endpoint regressions (#168, #173) jwadow/kiro-gateway#175.)

  2. 403 User is not authorized to make this call — the MCP request sent only Authorization / x-amzn-codewhisperer-optout / Content-Type, omitting the Kiro client-identity headers (User-Agent w/ KiroIDE-<version>-<fingerprint>, x-amz-user-agent, x-amzn-kiro-agent-mode, amz-sdk-*) that the completion path sends via get_kiro_headers. The /mcp endpoint gates authorization on these signals. Built the MCP headers from the canonical get_kiro_headers and overrode the three fields that differ for /mcp: Content-Type: application/json (JSON-RPC, not x-amz-json), drop x-amz-target, set optout false.

Also includes response.text in the non-200 error log — decisive in diagnosing the 403, low-noise (fires only on failure).

Why both pieces are here

The fork needs web_search to actually work, which requires clearing both the 400 and the 403. profileArn alone (the upstream PRs) gets past the 400 but still 403s on enterprise SSO; the headers alone never get past the 400. The novel contribution (headers) is upstreamed separately and surgically in jwadow#213; this PR keeps the fork whole.

Testing

  • Verified end-to-end: native web_search returns live results through the gateway on an enterprise SSO OIDC (kiro-cli) account that previously 403'd.
  • Regression tests assert the MCP request includes profileArn and the Kiro client-identity headers.
  • tests/unit/test_mcp_tools.py passes (23 tests).

Complete fix for Claude Code's native web_search server-side tool routed
through the gateway to runtime.kiro.dev/mcp. Two server-side gates had to
be cleared:

1. 400 "profileArn is required" - call_kiro_mcp_api omitted the
   profileArn that every other Kiro call includes. Add it to the MCP
   request body (auth_manager.profile_arn or PROFILE_ARN), mirroring the
   completion paths. (Same field contributed upstream in jwadow#180/jwadow#189/jwadow#175.)

2. 403 "User is not authorized to make this call" - the MCP request sent
   only Authorization/optout/Content-Type, omitting the Kiro
   client-identity headers (User-Agent w/ KiroIDE-<version>-<fingerprint>,
   x-amz-user-agent, x-amzn-kiro-agent-mode, amz-sdk-*) that the
   completion path sends via get_kiro_headers. The /mcp endpoint gates
   authorization on these signals. Build the MCP headers from the
   canonical get_kiro_headers and override the three fields that differ
   for /mcp: Content-Type application/json (JSON-RPC, not x-amz-json),
   drop x-amz-target, set optout false.

Also include response.text in the non-200 error log - it was decisive in
diagnosing the 403 and is low-noise (fires only on failure).

Verified end-to-end: native web_search returns live results on an
enterprise SSO OIDC (kiro-cli) account that previously 403'd.

Add regression tests asserting the MCP request includes profileArn and
the Kiro client-identity headers.
@severity1 severity1 force-pushed the fix/mcp-websearch-complete branch from 9754172 to 33ae507 Compare June 11, 2026 05:20
@severity1 severity1 merged commit 78d15d2 into main Jun 11, 2026
1 check passed
@severity1 severity1 deleted the fix/mcp-websearch-complete branch June 11, 2026 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant