Skip to content

Commit 839d999

Browse files
feat(mcp): add unix socket option for remote MCP
1 parent 8b40da7 commit 839d999

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

packages/mcp-server/src/headers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const parseAuthHeaders = (req: IncomingMessage): Partial<ClientOptions> =
1010
const value = req.headers.authorization.slice(scheme.length + 1);
1111
switch (scheme) {
1212
case 'Basic':
13-
const rawValue = Buffer.from(value).toString('base64');
13+
const rawValue = Buffer.from(value, 'base64').toString();
1414
return {
1515
tokenId: rawValue.slice(0, rawValue.search(':')),
1616
tokenSecret: rawValue.slice(rawValue.search(':') + 1),

packages/mcp-server/src/http.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const streamableHTTPApp = (options: McpOptions) => {
8383
export const launchStreamableHTTPServer = async (
8484
options: McpOptions,
8585
endpoints: Endpoint[],
86-
port: number | undefined,
86+
port: number | string | undefined,
8787
) => {
8888
const app = streamableHTTPApp(options);
8989
const server = app.listen(port);

packages/mcp-server/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async function main() {
2626
await launchStdioServer(options, selectedTools);
2727
break;
2828
case 'http':
29-
await launchStreamableHTTPServer(options, selectedTools, options.port);
29+
await launchStreamableHTTPServer(options, selectedTools, options.port ?? options.socket);
3030
break;
3131
}
3232
}

packages/mcp-server/src/options.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export type CLIOptions = McpOptions & {
77
list: boolean;
88
transport: 'stdio' | 'http';
99
port: number | undefined;
10+
socket: string | undefined;
1011
};
1112

1213
export type McpOptions = {
@@ -141,6 +142,10 @@ export function parseOptions(): CLIOptions {
141142
type: 'number',
142143
description: 'Port to serve on if using http transport',
143144
})
145+
.option('socket', {
146+
type: 'string',
147+
description: 'Unix socket to serve on if using http transport',
148+
})
144149
.help();
145150

146151
for (const [command, desc] of examples()) {
@@ -262,6 +267,7 @@ export function parseOptions(): CLIOptions {
262267
list: argv.list || false,
263268
transport,
264269
port: argv.port,
270+
socket: argv.socket,
265271
};
266272
}
267273

0 commit comments

Comments
 (0)