Skip to content

Commit ab6b15f

Browse files
committed
chore: update version to 0.2.0-beta.5 and add optional headers support in transport configurations
1 parent fbfb98b commit ab6b15f

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

packages/core/deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mcpc/core",
3-
"version": "0.2.0-beta.4",
3+
"version": "0.2.0-beta.5",
44
"exports": {
55
".": "./mod.ts",
66
"./plugins": "./plugins.ts",

packages/core/src/service/tools.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ export const SseConfigSchema: z.ZodObject<Record<string, z.ZodTypeAny>> =
1414
BaseConfigSchema.extend({
1515
url: z.string().url(),
1616
transportType: z.literal("sse").optional(),
17+
headers: z.record(z.string()).optional(),
1718
});
1819

1920
export const StreamableHTTPSchema: z.ZodObject<Record<string, z.ZodTypeAny>> =
2021
BaseConfigSchema.extend({
2122
url: z.string().url(),
23+
headers: z.record(z.string()).optional(),
2224
});
2325

2426
export const StdioConfigSchema: z.ZodObject<Record<string, z.ZodTypeAny>> =

packages/core/src/utils/common/mcp.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,21 @@ async function getOrCreateMcpClient(
5757
typeof (def as any).transportType === "string" &&
5858
(def as any).transportType === "sse"
5959
) {
60-
transport = new SSEClientTransport(new URL((def as any).url));
60+
const options: any = {};
61+
if ((def as any).headers) {
62+
options.requestInit = { headers: (def as any).headers };
63+
options.eventSourceInit = { headers: (def as any).headers };
64+
}
65+
transport = new SSEClientTransport(new URL((def as any).url), options);
6166
} else if ("url" in (def as any) && typeof (def as any).url === "string") {
62-
transport = new StreamableHTTPClientTransport(new URL((def as any).url));
67+
const options: any = {};
68+
if ((def as any).headers) {
69+
options.requestInit = { headers: (def as any).headers };
70+
}
71+
transport = new StreamableHTTPClientTransport(
72+
new URL((def as any).url),
73+
options,
74+
);
6375
} else if (
6476
(typeof (def as any).transportType === "string" &&
6577
(def as any).transportType === "stdio") ||

0 commit comments

Comments
 (0)