fix(mcpd): anthropic adapter supports OAuth (sk-ant-oat) keys via Bearer #84
@@ -182,9 +182,15 @@ export class AnthropicAdapter implements LlmAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private headers(ctx: InferContext): Record<string, string> {
|
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 {
|
return {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'x-api-key': ctx.apiKey,
|
...(isOAuth
|
||||||
|
? { Authorization: `Bearer ${ctx.apiKey}` }
|
||||||
|
: { 'x-api-key': ctx.apiKey }),
|
||||||
'anthropic-version': ANTHROPIC_VERSION,
|
'anthropic-version': ANTHROPIC_VERSION,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user