Skip to content

Commit 5ff4803

Browse files
committed
support headers in mcpServers
1 parent 03c02e8 commit 5ff4803

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

.agents/types/util-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ export const mcpConfigRemoteSchema = z.strictObject({
218218
type: z.enum(['http', 'sse']).default('http'),
219219
url: z.string(),
220220
params: z.record(z.string(), z.string()).default(() => ({})),
221+
headers: z.record(z.string(), z.string()).default(() => ({})),
221222
})
222223

223224
export const mcpConfigSchema = z.union([

common/src/mcp/client.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,17 @@ export async function getMCPClient(config: MCPConfig): Promise<string> {
6262
url.searchParams.set(key, value)
6363
}
6464
if (config.type === 'http') {
65-
transport = new StreamableHTTPClientTransport(url)
65+
transport = new StreamableHTTPClientTransport(url, {
66+
requestInit: {
67+
headers: config.headers,
68+
},
69+
})
6670
} else if (config.type === 'sse') {
67-
transport = new SSEClientTransport(url)
71+
transport = new SSEClientTransport(url, {
72+
requestInit: {
73+
headers: config.headers,
74+
},
75+
})
6876
} else {
6977
config.type satisfies never
7078
throw new Error(`Internal error: invalid MCP config type ${config.type}`)

common/src/templates/initial-agents-dir/types/util-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ export const mcpConfigStdioSchema = z.strictObject({
212212
.array()
213213
.default(() => []),
214214
env: z.record(z.string(), z.string()).default(() => ({})),
215+
headers: z.record(z.string(), z.string()).default(() => ({})),
215216
})
216217

217218
export const mcpConfigRemoteSchema = z.strictObject({

common/src/types/mcp.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const mcpConfigRemoteSchema = z.strictObject({
1414
type: z.enum(['http', 'sse']).default('http'),
1515
url: z.string(),
1616
params: z.record(z.string(), z.string()).default(() => ({})),
17+
headers: z.record(z.string(), z.string()).default(() => ({})),
1718
})
1819

1920
export const mcpConfigSchema = z.union([

0 commit comments

Comments
 (0)