feat(dev-757): set MCP user agent for API log attribution - #34
Merged
Conversation
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.
jaredpiedt
approved these changes
Jul 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.Surfacefield onspur.Client;userAgent()becomes a method that appendssurface/<token>when set. Empty (the default) leaves the CLI User-Agent byte-for-byte unchanged.spur mcpsetsSurface = "mcp"on its client only. No other command is affected. Both request paths (doJSON,doStream) pick it up automatically.spur/<ver> (+https://spur.us) surface/mcp.Test evidence
go build ./...,go vet ./...,go test ./...— all pass across every package.surface/mcpsuffix present, and header wire-up asserted through bothdoJSON(TestDoJSONSendsSurfaceInUserAgent) anddoStream(TestDownloadFeedSendsSurfaceInUserAgent) via httptest. Version is derived frombuildinfo.Version, never hardcoded.scripts/mcp-smoke.shagainst 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 mcppath emits the new token; the change is transport-invisible to functionality.