MCPcopy
hub / github.com/claude-code-best/claude-code / getUserAgent

Function getUserAgent

src/utils/http.ts:18–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16// WARNING: We rely on `claude-cli` in the user agent for log filtering.
17// Please do NOT change this without making sure that logging also gets updated!
18export function getUserAgent(): string {
19 const agentSdkVersion = process.env.CLAUDE_AGENT_SDK_VERSION
20 ? `, agent-sdk/${process.env.CLAUDE_AGENT_SDK_VERSION}`
21 : ''
22 // SDK consumers can identify their app/library via CLAUDE_AGENT_SDK_CLIENT_APP
23 // e.g., "my-app/1.0.0" or "my-library/2.1"
24 const clientApp = process.env.CLAUDE_AGENT_SDK_CLIENT_APP
25 ? `, client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}`
26 : ''
27 // Turn-/process-scoped workload tag for cron-initiated requests. 1P-only
28 // observability — proxies strip HTTP headers; QoS routing uses cc_workload
29 // in the billing-header attribution block instead (see constants/system.ts).
30 // getAnthropicClient (client.ts:98) calls this per-request inside withRetry,
31 // so the read picks up the same setWorkload() value as getAttributionHeader.
32 const workload = getWorkload()
33 const workloadSuffix = workload ? `, workload/${workload}` : ''
34 return `claude-cli/${MACRO.VERSION} (${process.env.USER_TYPE}, ${process.env.CLAUDE_CODE_ENTRYPOINT ?? 'cli'}${agentSdkVersion}${clientApp}${workloadSuffix})`
35}
36
37export function getMCPUserAgent(): string {
38 const parts: string[] = []

Callers 6

submitFeedbackFunction · 0.85
submitTranscriptShareFunction · 0.85
callBuddyReactAPIFunction · 0.85
connectVoiceStreamFunction · 0.85
grove.tsFile · 0.85
getAnthropicClientFunction · 0.85

Calls 1

getWorkloadFunction · 0.85

Tested by

no test coverage detected