Skip to content

Commit 39fab03

Browse files
chore(mcp): clarify http auth error
1 parent d58f59b commit 39fab03

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/mcp-server/src/headers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ export const parseAuthHeaders = (req: IncomingMessage): Partial<ClientOptions> =
1111
case 'Bearer':
1212
return { apiKey: req.headers.authorization.slice('Bearer '.length) };
1313
default:
14-
throw new Error(`Unsupported authorization scheme`);
14+
throw new Error(
15+
'Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Bearer).',
16+
);
1517
}
1618
}
1719

packages/mcp-server/src/http.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ const newServer = ({
4646
},
4747
mcpOptions,
4848
});
49-
} catch {
49+
} catch (error) {
5050
res.status(401).json({
5151
jsonrpc: '2.0',
5252
error: {
5353
code: -32000,
54-
message: 'Unauthorized',
54+
message: `Unauthorized: ${error instanceof Error ? error.message : error}`,
5555
},
5656
});
5757
return null;

0 commit comments

Comments
 (0)