fix(mcpd): anthropic adapter OAuth support (#84)
Some checks failed
Some checks failed
This commit was merged in pull request #84.
This commit is contained in:
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user