From 7981c86613752126836452c4f37a58c706095040 Mon Sep 17 00:00:00 2001 From: Ruirui Wan <139067258+raydocs@users.noreply.github.com> Date: Tue, 6 Jan 2026 14:12:22 -0700 Subject: [PATCH] fix: add EXA_API_KEY header support for websearch_exa MCP (#499) The remote MCP endpoint https://mcp.exa.ai/mcp requires API key authentication via x-api-key header. Without this, the connection times out waiting for auth. This change: - Reads EXA_API_KEY from environment variable - Passes it as x-api-key header when available - Updates RemoteMcpConfig type to support optional headers Co-authored-by: Junho Yeo --- src/mcp/index.ts | 11 +++++++++-- src/mcp/websearch.ts | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mcp/index.ts b/src/mcp/index.ts index a3ec2da..a887d8d 100644 --- a/src/mcp/index.ts +++ b/src/mcp/index.ts @@ -5,14 +5,21 @@ import type { McpName } from "./types" export { McpNameSchema, type McpName } from "./types" -const allBuiltinMcps: Record = { +type RemoteMcpConfig = { + type: "remote" + url: string + enabled: boolean + headers?: Record +} + +const allBuiltinMcps: Record = { websearch, context7, grep_app, } export function createBuiltinMcps(disabledMcps: string[] = []) { - const mcps: Record = {} + const mcps: Record = {} for (const [name, config] of Object.entries(allBuiltinMcps)) { if (!disabledMcps.includes(name)) { diff --git a/src/mcp/websearch.ts b/src/mcp/websearch.ts index 60584e9..afc4d2b 100644 --- a/src/mcp/websearch.ts +++ b/src/mcp/websearch.ts @@ -2,4 +2,7 @@ export const websearch = { type: "remote" as const, url: "https://mcp.exa.ai/mcp?tools=web_search_exa", enabled: true, + headers: process.env.EXA_API_KEY + ? { "x-api-key": process.env.EXA_API_KEY } + : undefined, }