Skip to content

Commit ca2410a

Browse files
authored
fix(parallel): send User-Agent on free MCP requests
Adds the OpenClaw Parallel User-Agent to free Parallel Search MCP requests so the zero-config web_search path is identifiable at the HTTP layer, matching the paid REST transport.\n\nProof: local focused format/lint/Vitest; live anonymous Parallel MCP handshake; autoreview clean; Crabbox AWS run_bf41ce86e862 focused regression; Crabbox AWS run_ee9b8954b081 check:changed; exact-head GitHub CI green on b7e45e3.
1 parent d20fdf3 commit ca2410a

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

extensions/parallel/src/parallel-mcp-search.runtime.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ describe("runParallelMcpSearch", () => {
201201
expect(headerOf(endpointMockState.calls[2], "MCP-Protocol-Version")).toBe("2025-06-18");
202202
// No bearer token on the anonymous free path.
203203
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+
}
204208
// tools/call carries the documented web_search args.
205209
const callArgs = (readBody(endpointMockState.calls[2]).params as Record<string, unknown>)
206210
.arguments as Record<string, unknown>;

extensions/parallel/src/parallel-mcp-search.runtime.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ const MCP_TIMEOUT_SECONDS = 30;
1414

1515
const require = createRequire(import.meta.url);
1616
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})`;
1721

1822
type JsonRpcMessage = Record<string, unknown>;
1923

@@ -38,6 +42,7 @@ function mcpHeaders(params: {
3842
}): Record<string, string> {
3943
const headers: Record<string, string> = {
4044
"Content-Type": "application/json",
45+
"User-Agent": USER_AGENT,
4146
// The Search MCP may answer either as a single JSON object or as an SSE
4247
// stream; advertise both so the server can pick.
4348
Accept: "application/json, text/event-stream",

0 commit comments

Comments
 (0)