You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f6b2e2d
Browse filesBrowse the repository at this point in the historyBrowse files
fix: [#791][#792] support bearer-auth remote MCP servers (Microsoft Fabric, etc.)
Three coupled fixes that together let altimate-code connect to MCP servers
gated by short-lived bearer tokens — most prominently Microsoft Fabric Core
MCP — without a local proxy or per-hour config edits.
Issues addressed:
- #791 (dynamic auth for remote MCP servers): static `headers` only.
- #792 (external MCP servers not auto-activated at session start): mostly
caused by OAuth dynamic-client-registration probes pre-empting valid
bearer headers and ending the connect in a non-`connected` status.
- A third defect surfaced during this work: the strict
`ListToolsResultSchema` from `@modelcontextprotocol/sdk` rejects the
`null` annotation hints that Fabric returns, causing `listTools()` to
throw and the connection to be marked failed even after a successful
initialize. None of these are altimate-specific — they all reproduce on
upstream `opencode`.
Changes:
1. `McpRemote.headersCommand: Record<string, string[]>` — header values
produced by running an argv command (executed via `execFile`, not a
shell, so values aren't subject to shell injection). Resolved on every
connect so expiring tokens refresh automatically. Example:
"headersCommand": {
"Authorization": ["sh", "-c",
"printf 'Bearer %s' \"$(az account get-access-token ... -o tsv)\""]
}
2. OAuth provider is no longer attached when the user supplies an
explicit `Authorization` header (statically or via `headersCommand`)
and `oauth` is not specified. Prevents Entra ID's DCR rejection from
short-circuiting a bearer-authenticated connection. Behavior is
unchanged when `oauth` is explicitly configured.
3. `listTools()` is wrapped to retry with a permissive Zod schema on
schema-validation errors. The fast path is unchanged for compliant
servers; non-compliant servers (Fabric returns `null` for
`annotations.{readOnlyHint,destructiveHint,idempotentHint,openWorldHint}`)
no longer fail the connection.
4. `normalizeMcpConfig` was silently dropping `oauth` and (would have
dropped) `headersCommand` when reconstructing remote entries. Both
are now passed through. This was a pre-existing latent bug that made
`oauth: false` configurations no-op at runtime.
Tests:
- 22 new tests across `test/mcp/mcp-bearer-auth.test.ts` (lenient schema,
`headersCommand` resolution + execFile-not-shell semantics, Authorization
detection, schema round-trip) and `test/mcp/headers.test.ts` (OAuth
auto-disable on static bearer, on `headersCommand`, and explicit-OAuth
override). All pass.
- Zero regressions vs `origin/main` baseline on existing 185 MCP tests.
- Live-verified end-to-end against `https://api.fabric.microsoft.com/v1/mcp/core`
using `headersCommand` + `az account get-access-token`: server connected,
29 tools registered, no proxy required.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
0 commit comments