Skip to content

feat(sdk): send X-Goog-Api-Client surface header on SDK and proxy calls - #388

Merged
samelhusseini merged 1 commit into
mainfrom
samelh/sdk-client-surface-header
Nov 5, 2026
Merged

samelhusseini merged 1 commit into
mainfrom
samelh/sdk-client-surface-header

Conversation

@samelhusseini

Copy link
Copy Markdown
Contributor

Summary

Identify outbound @google/stitch-sdk and StitchProxy requests with Google's standard X-Goog-Api-Client header so Stitch API endpoints can distinguish programmatic SDK traffic from MCP proxy and CLI callers without CORS-unsafe User-Agent overrides:

  • Emit X-Goog-Api-Client: gccl/<SDK_VERSION> client/sdk by default in StitchToolClient across both MCP StreamableHTTPClientTransport connections and httpPost REST requests (screens:batchCreate).
  • Emit X-Goog-Api-Client: gccl/<SDK_VERSION> client/mcp when StitchProxy instantiates its upstream StitchToolClient.
  • Support optional headers on StitchConfig (StitchToolClient, getOrCreateClient) and StitchProxyConfig merged case-insensitively (mergeHeadersCaseInsensitive), allowing downstream wrappers (such as @_davideast/stitch-mcp / CLI callers) to override X-Goog-Api-Client cleanly regardless of header casing without producing duplicate header keys.

Testing

  • Added unit coverage across auth.test.ts, client.test.ts, proxy.test.ts, and singleton.test.ts verifying default client/sdk and client/mcp headers, httpPost propagation, case-insensitive header override replacement, wrapper spread compatibility, and singleton cache-key invalidation.

@samelhusseini
samelhusseini merged commit f6aa86c into main Nov 5, 2026
12 checks passed
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.

2 participants