OptionalcreateServer factory override for tests and adapters.
Build the MCP server and register the B2 tool surface.
Registration is capability-aware: when capabilities is a non-null array,
only tools the key can use are registered (per src/utils/tool-capabilities),
and Partner tools register only with a distinct master key. null/undefined
registers the full surface (operator override and legacy unit tests); an empty
array is a fail-closed capability set, not "unknown".
Credential model: B2_APPLICATION_KEY_ID / B2_APPLICATION_KEY is the
application key that drives the B2 native API, S3, and key management. Only the
Partner API tools use a master key (B2_MASTER_KEY_ID / B2_MASTER_KEY,
optional); a single non-master key covers everything else. B2's S3 endpoint
rejects master keys, which is why the application key is the primary credential.
Resolved B2 credentials and runtime policy.
Optionalcapabilities: string[] | null
Capabilities returned by B2 authorize, null for the
full-surface operator override, or an empty array to fail closed.
Optional caller-scoped controls such as verified OAuth scopes.
The configured MCP server instance.
OptionalcredentialCredential provider used to resolve B2 config for each request.
OptionalfetchCapability discovery override for tests and adapters.
Discover the B2 key capabilities used for capability-aware registration.
B2 credential and runtime configuration.
OptionalcapabilityCacheKey: string
Optional cache key override for tests or caller-specific HTTP routing.
OptionallogKey: string
Optional non-secret log key override.
A copy of the discovered capabilities, or null when registration
should expose the full tool surface.
The returned capabilities come from b2_authorize_account and decide which
tools are even registered for the credential. Setting
B2_REGISTER_ALL_TOOLS=true is the explicit operator/test escape hatch and
returns null; all other authorization failures are sanitized and thrown so
internet-facing servers fail closed.
Positive non-empty results are cached briefly by credential fingerprint and concurrent discoveries for the same key share one in-flight authorize call.
OptionalgetHook for customer middleware/tests to attach verified MCP authInfo.
OptionalidleWhether idle sweeps run on an interval or only on request handling.
OptionalmcpOptional MCP SDK handler override for tests.
OptionalsecretSecret broker used when principal credential mode is active.
Options for building the Node HTTP transport.
Remarks
Most request-policy knobs are inherited from the runtime-neutral fetch handler. The Node layer adds only a hook for middleware or tests that have already authenticated a caller and want that
authInfoattached to the MCP request.