Address @claude review: format core/, typed output-validation error, document progress heuristic

- Run Prettier on the 60 core/ files this PR touched — the deterministic
  import rewrite had collapsed multi-line imports and left throws unwrapped;
  core/ is in no format gate so it slipped past CI. Now Prettier-clean.
- Default-path output-schema violation now throws
  ProtocolError(ProtocolErrorCode.InvalidParams, …) instead of a bare Error,
  matching the prior v1 contract (SDK threw a typed McpError with a code) so
  downstream `instanceof`/`.code` branching keeps working.
- Document the "assumes serial construction" invariant on pollTaskToolCall's
  progress-subscription revival (the `_progressHandlers` new-key heuristic).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
cliffhall 2026-07-15 11:08:54 -04:00
commit f9f79fff54

View file

@ -1,5 +1,12 @@
import type { OAuthClientInformation, OAuthTokens, OAuthMetadata } from "@modelcontextprotocol/client";
import { OAuthClientInformationSchema, OAuthTokensSchema } from "@modelcontextprotocol/core";
import type {
OAuthClientInformation,
OAuthTokens,
OAuthMetadata,
} from "@modelcontextprotocol/client";
import {
OAuthClientInformationSchema,
OAuthTokensSchema,
} from "@modelcontextprotocol/core";
import type { OAuthStorage } from "./storage.js";
import { type OAuthMemoryStore, type ServerOAuthState } from "./store.js";
import type { OAuthPersistBackend } from "./oauth-persist.js";
@ -173,7 +180,9 @@ export class OAuthStorageBase implements OAuthStorage {
async clearCodeVerifier(serverUrl: string): Promise<void> {
await this.ensureLoaded();
this.memory.getState().setServerState(serverUrl, { codeVerifier: undefined });
this.memory
.getState()
.setServerState(serverUrl, { codeVerifier: undefined });
await this.persist();
}
@ -206,7 +215,9 @@ export class OAuthStorageBase implements OAuthStorage {
metadata: OAuthMetadata,
): Promise<void> {
await this.ensureLoaded();
this.memory.getState().setServerState(serverUrl, { serverMetadata: metadata });
this.memory
.getState()
.setServerState(serverUrl, { serverMetadata: metadata });
await this.persist();
}