Skip to content

feat(dev-757): set MCP user agent for API log attribution - #34

Merged
jjunqueira merged 3 commits into
mainfrom
feat/dev-757
Jul 22, 2026
Merged

feat(dev-757): set MCP user agent for API log attribution#34
jjunqueira merged 3 commits into
mainfrom
feat/dev-757

Conversation

@jjunqueira

Copy link
Copy Markdown
Contributor

Context

DEV-757. The Spur API client emitted the same User-Agent (spur/<ver> (+https://spur.us)) for every surface, so API logs couldn't distinguish MCP-originated requests from ordinary CLI usage. This adds a greppable surface token so MCP traffic can be filtered and tracked in observability.

  • New Surface field on spur.Client; userAgent() becomes a method that appends surface/<token> when set. Empty (the default) leaves the CLI User-Agent byte-for-byte unchanged.
  • spur mcp sets Surface = "mcp" on its client only. No other command is affected. Both request paths (doJSON, doStream) pick it up automatically.
  • Resulting MCP User-Agent: spur/<ver> (+https://spur.us) surface/mcp.

Test evidence

  • go build ./..., go vet ./..., go test ./... — all pass across every package.
  • New unit tests: default-surface UA unchanged, surface/mcp suffix present, and header wire-up asserted through both doJSON (TestDoJSONSendsSurfaceInUserAgent) and doStream (TestDownloadFeedSendsSurfaceInUserAgent) via httptest. Version is derived from buildinfo.Version, never hardcoded.
  • scripts/mcp-smoke.sh against a freshly built binary: initialize handshake, tools/list (all tools present), resources, and offline tool calls all pass — SMOKE OK, exit 0. No regression.

Risk

Low. Additive, behind an opt-in field defaulting to empty. The CLI User-Agent is unchanged (guarded by a test). Only the spur mcp path emits the new token; the change is transport-invisible to functionality.

Joshua Junqueira added 3 commits July 22, 2026 11:48
Add a Surface field to spur.Client and make userAgent() a method that
appends ' surface/<token>' when set, so API logs can attribute
MCP-originated requests. CLI User-Agent is unchanged.
The spur mcp command tags its Spur API client with Surface="mcp" so
its requests are attributable in API logs. Other commands are unaffected.
@jjunqueira
jjunqueira merged commit 4a2124d into main Jul 22, 2026
4 checks passed
@jjunqueira
jjunqueira deleted the feat/dev-757 branch July 22, 2026 18:21
@spurintelbot spurintelbot Bot mentioned this pull request Jul 22, 2026
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