Compare commits

...

2 Commits

Author SHA1 Message Date
e95aeeb3a2 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
2026-07-21 22:46:26 +00:00
Michal
a1c545d21a fix(mcpd): anthropic adapter supports OAuth (sk-ant-oat) keys via Bearer
Some checks failed
CI/CD / lint (pull_request) Successful in 1m4s
CI/CD / test (pull_request) Successful in 1m19s
CI/CD / typecheck (pull_request) Successful in 2m11s
CI/CD / build (pull_request) Successful in 2m27s
CI/CD / smoke (pull_request) Failing after 2m48s
CI/CD / publish (pull_request) Has been skipped
Claude subscription / Claude Code keys are OAuth tokens and authenticate with
Authorization: Bearer, not x-api-key. mcpd's server adapter only sent x-api-key,
so registering an OAuth key as a fallback Llm 401'd ("invalid x-api-key").
Mirror the mcplocal client adapter's isOAuth switch so an OAuth key works as a
server-side anthropic fallback.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-21 23:43:56 +01: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,
};
}