fix(mcpd): anthropic adapter OAuth support (#84)
Some checks failed
CI/CD / lint (push) Successful in 1m5s
CI/CD / typecheck (push) Successful in 2m6s
CI/CD / test (push) Successful in 1m16s
CI/CD / smoke (push) Failing after 1m52s
CI/CD / build (push) Successful in 4m15s
CI/CD / publish (push) Has been skipped

This commit was merged in pull request #84.
This commit is contained in:
2026-07-21 22:46:26 +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,
};
}