fix(mcpd): anthropic adapter supports OAuth (sk-ant-oat) keys via Bearer #84

Merged
michal merged 1 commits from fix/mcpd-anthropic-oauth into main 2026-07-21 22:46:27 +00:00

View File

@@ -182,9 +182,15 @@ export class AnthropicAdapter implements LlmAdapter {
}
private headers(ctx: InferContext): Record<string, string> {
// Claude subscription / Claude Code keys are OAuth tokens (`sk-ant-oat…`)
// and authenticate via Bearer, not x-api-key — mirror the mcplocal client
// adapter so an OAuth key works as a server-side fallback Llm.
const isOAuth = ctx.apiKey.startsWith('sk-ant-oat');
return {
'Content-Type': 'application/json',
'x-api-key': ctx.apiKey,
...(isOAuth
? { Authorization: `Bearer ${ctx.apiKey}` }
: { 'x-api-key': ctx.apiKey }),
'anthropic-version': ANTHROPIC_VERSION,
};
}