fix(parallel): send User-Agent on free MCP requests · openclaw/openclaw@ca2410a
NormallyGaus
·
2026-06-14
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -201,6 +201,10 @@ describe("runParallelMcpSearch", () => {
|
201 | 201 | expect(headerOf(endpointMockState.calls[2], "MCP-Protocol-Version")).toBe("2025-06-18"); |
202 | 202 | // No bearer token on the anonymous free path. |
203 | 203 | expect(headerOf(endpointMockState.calls[0], "Authorization")).toBeUndefined(); |
| 204 | +// Every call identifies OpenClaw at the HTTP layer (not just node). |
| 205 | +for (const call of endpointMockState.calls) { |
| 206 | +expect(headerOf(call, "User-Agent")).toMatch(/^openclaw-parallel\//); |
| 207 | +} |
204 | 208 | // tools/call carries the documented web_search args. |
205 | 209 | const callArgs = (readBody(endpointMockState.calls[2]).params as Record<string, unknown>) |
206 | 210 | .arguments as Record<string, unknown>; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -14,6 +14,10 @@ const MCP_TIMEOUT_SECONDS = 30;
|
14 | 14 | |
15 | 15 | const require = createRequire(import.meta.url); |
16 | 16 | const PLUGIN_VERSION = readPluginPackageVersion({ require }); |
| 17 | +// Identify free-tier traffic at the HTTP layer (mirrors the paid REST path); |
| 18 | +// without this, undici sends a generic `node` UA and OpenClaw usage is only |
| 19 | +// visible via the JSON-RPC `clientInfo` payload. |
| 20 | +const USER_AGENT = `openclaw-parallel/${PLUGIN_VERSION} (${process.platform})`; |
17 | 21 | |
18 | 22 | type JsonRpcMessage = Record<string, unknown>; |
19 | 23 | |
@@ -38,6 +42,7 @@ function mcpHeaders(params: {
|
38 | 42 | }): Record<string, string> { |
39 | 43 | const headers: Record<string, string> = { |
40 | 44 | "Content-Type": "application/json", |
| 45 | +"User-Agent": USER_AGENT, |
41 | 46 | // The Search MCP may answer either as a single JSON object or as an SSE |
42 | 47 | // stream; advertise both so the server can pick. |
43 | 48 | Accept: "application/json, text/event-stream", |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。