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 <i@junho.io>
This commit is contained in:
@@ -5,14 +5,21 @@ import type { McpName } from "./types"
|
|||||||
|
|
||||||
export { McpNameSchema, type McpName } from "./types"
|
export { McpNameSchema, type McpName } from "./types"
|
||||||
|
|
||||||
const allBuiltinMcps: Record<McpName, { type: "remote"; url: string; enabled: boolean }> = {
|
type RemoteMcpConfig = {
|
||||||
|
type: "remote"
|
||||||
|
url: string
|
||||||
|
enabled: boolean
|
||||||
|
headers?: Record<string, string>
|
||||||
|
}
|
||||||
|
|
||||||
|
const allBuiltinMcps: Record<McpName, RemoteMcpConfig> = {
|
||||||
websearch,
|
websearch,
|
||||||
context7,
|
context7,
|
||||||
grep_app,
|
grep_app,
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createBuiltinMcps(disabledMcps: string[] = []) {
|
export function createBuiltinMcps(disabledMcps: string[] = []) {
|
||||||
const mcps: Record<string, { type: "remote"; url: string; enabled: boolean }> = {}
|
const mcps: Record<string, RemoteMcpConfig> = {}
|
||||||
|
|
||||||
for (const [name, config] of Object.entries(allBuiltinMcps)) {
|
for (const [name, config] of Object.entries(allBuiltinMcps)) {
|
||||||
if (!disabledMcps.includes(name)) {
|
if (!disabledMcps.includes(name)) {
|
||||||
|
|||||||
@@ -2,4 +2,7 @@ export const websearch = {
|
|||||||
type: "remote" as const,
|
type: "remote" as const,
|
||||||
url: "https://mcp.exa.ai/mcp?tools=web_search_exa",
|
url: "https://mcp.exa.ai/mcp?tools=web_search_exa",
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
headers: process.env.EXA_API_KEY
|
||||||
|
? { "x-api-key": process.env.EXA_API_KEY }
|
||||||
|
: undefined,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user