@prefecthq/fastmcp-ts 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CreateMessageResult, CreateMessageResultWithTools, ContentBlock, CreateMessageRequestParams, LoggingLevel, ElicitRequestParams, ElicitResult, Tool, Resource, Prompt, ResourceTemplateType, TextResourceContents, BlobResourceContents, GetPromptResult, OAuthClientMetadata as OAuthClientMetadata$1, Root, ModelPreferences, SamplingMessage, ToolChoice } from '@modelcontextprotocol/server';
2
2
  export { BlobResourceContents, ContentBlock, CreateMessageRequestParams, CreateMessageResult, CreateMessageResultWithTools, ElicitRequestParams, ElicitResult, GetPromptResult, LoggingLevel, ModelPreferences, Prompt, PromptArgument, PromptMessage, Resource, ResourceContents, ResourceTemplateType as ResourceTemplate, Root, SamplingMessage, TextResourceContents, Tool, ToolChoice, ToolResultContent, ToolUseContent } from '@modelcontextprotocol/server';
3
- import { OAuthClientProvider, OAuthClientMetadata, OAuthClientInformationContext, StoredOAuthClientInformation, StoredOAuthTokens, OAuthDiscoveryState, ClientAuthMethod, Transport, VersionNegotiationOptions, ProtocolEra, PriorDiscovery, InputRequiredOptions, ResponseCacheStore } from '@modelcontextprotocol/client';
3
+ import { OAuthClientProvider, OAuthClientMetadata, OAuthClientInformationContext, StoredOAuthClientInformation, StoredOAuthTokens, OAuthDiscoveryState, ClientAuthMethod, Transport, VersionNegotiationOptions, ProtocolEra, PriorDiscovery, InputRequiredOptions, ResponseCacheStore, Implementation, ServerCapabilities } from '@modelcontextprotocol/client';
4
4
  import Anthropic from '@anthropic-ai/sdk';
5
5
  import OpenAI from 'openai';
6
6
  import { GoogleGenAI } from '@google/genai';
@@ -604,11 +604,14 @@ interface MultiServerOptions {
604
604
  roots?: string[];
605
605
  defaultOptions?: ClientDefaultOptions;
606
606
  /**
607
- * Opt-in protocol version negotiation, applied identically to every server
608
- * in the config (protocol revision 2026-07-28 and later). See
607
+ * Protocol version negotiation, applied identically to every server in the
608
+ * config (protocol revision 2026-07-28 and later). See
609
609
  * `ClientOptions.versionNegotiation` on the single-server `Client` — same
610
610
  * semantics, just applied per sub-client here since each connected server
611
- * negotiates its own era independently. Default `'legacy'`.
611
+ * negotiates its own era independently. Default `{ mode: 'auto' }`: each
612
+ * sub-client probes its server once and falls back to legacy when the
613
+ * server offers no modern era; `{ mode: 'legacy' }` opts every connection
614
+ * out of the probe.
612
615
  */
613
616
  versionNegotiation?: VersionNegotiationOptions;
614
617
  }
@@ -745,13 +748,20 @@ interface ClientOptions {
745
748
  autoInitialize?: boolean;
746
749
  defaultOptions?: ClientDefaultOptions;
747
750
  /**
748
- * Opt-in protocol version negotiation (protocol revision 2026-07-28 and later).
749
- * The default is `'legacy'`: connect() runs the plain 2025 sequence, byte-identical
750
- * to today's behavior (no probe, no new headers). Pass `{ mode: 'auto' }` to probe
751
- * with `server/discover` and use the modern era when the server supports it
752
- * (falling back to legacy otherwise), or `{ mode: { pin: '2026-07-28' } }` to
753
- * require the modern era outright. See `getProtocolEra()` to read the negotiated
754
- * result after connecting.
751
+ * Protocol version negotiation (protocol revision 2026-07-28 and later).
752
+ * The default is `{ mode: 'auto' }`: connect() probes the server once with
753
+ * `server/discover` and uses the modern (2026-07-28) era on definitive
754
+ * modern evidence, falling back to the plain legacy `initialize` handshake
755
+ * on anything else (a method-not-found answer, silence on a local stdio
756
+ * pipe, a probe child that exits). The probe is stall-safe in the SDK: on
757
+ * stdio it runs against a short-lived sibling process and a timeout falls
758
+ * back to legacy, while on HTTP — where silence means an outage — a probe
759
+ * timeout rejects with a typed error instead of hanging. Pass
760
+ * `{ mode: 'legacy' }` to opt out: no probe, the 2025 sequence
761
+ * byte-identical to prior behavior. Pass `{ mode: { pin: '2026-07-28' } }`
762
+ * to require the modern era outright — connect() throws if the server
763
+ * cannot speak it. See `getProtocolEra()` to read the negotiated result
764
+ * after connecting.
755
765
  */
756
766
  versionNegotiation?: VersionNegotiationOptions;
757
767
  /**
@@ -874,6 +884,29 @@ declare class Client implements IClient {
874
884
  * `undefined` before connect(). See `ClientOptions.versionNegotiation`.
875
885
  */
876
886
  getProtocolEra(): ProtocolEra | undefined;
887
+ /**
888
+ * The connected server's self-reported identity (`serverInfo`: name, version,
889
+ * and optional title / websiteUrl / icons), when it identified itself. On a
890
+ * legacy connection it comes from the `initialize` result, where it is
891
+ * required. On a modern (2026-07-28) connection it comes from the
892
+ * `server/discover` result's metadata — FastMCP servers advertise it there,
893
+ * but an anonymous modern server may omit it, leaving this `undefined`.
894
+ * `undefined` before connect().
895
+ */
896
+ getServerInfo(): Implementation | undefined;
897
+ /**
898
+ * The server's `instructions` string, when the server provided one — from
899
+ * the legacy `initialize` result or, on a modern (2026-07-28) connection,
900
+ * from the `server/discover` result. `undefined` otherwise and before
901
+ * connect().
902
+ */
903
+ getInstructions(): string | undefined;
904
+ /**
905
+ * The capabilities the server advertised during connection — on the legacy
906
+ * `initialize` result, or on the `server/discover` result for a modern
907
+ * (2026-07-28) connection. `undefined` before connect().
908
+ */
909
+ getServerCapabilities(): ServerCapabilities | undefined;
877
910
  listTools(options?: RequestOptions): Promise<Tool[]>;
878
911
  callTool<TData = unknown>(name: string, args?: Record<string, unknown>, options?: CallToolOptions): Promise<CallToolResult<TData>>;
879
912
  /** Returns the full result including isError without throwing. */
package/dist/client.js CHANGED
@@ -948,7 +948,7 @@ var MultiServerClient = class _MultiServerClient {
948
948
  sampling: options?.handlers?.sampling,
949
949
  elicitation: options?.handlers?.elicitation
950
950
  };
951
- this._versionNegotiation = options?.versionNegotiation;
951
+ this._versionNegotiation = options?.versionNegotiation ?? { mode: "auto" };
952
952
  this._roots = options?.roots;
953
953
  this._defaultOptions = options?.defaultOptions ?? {};
954
954
  }
@@ -1362,7 +1362,7 @@ ${errors.map(String).join("\n")}`);
1362
1362
  { name: "fastmcp-ts", version: "1.0.0" },
1363
1363
  {
1364
1364
  capabilities: this._buildCapabilities(),
1365
- ...this._versionNegotiation ? { versionNegotiation: this._versionNegotiation } : {}
1365
+ versionNegotiation: this._versionNegotiation
1366
1366
  }
1367
1367
  );
1368
1368
  }
@@ -1487,7 +1487,7 @@ var Client = class _Client {
1487
1487
  };
1488
1488
  this._roots = options?.roots ? normalizeRootsOption(options.roots) : void 0;
1489
1489
  this._autoInitialize = options?.autoInitialize ?? true;
1490
- this._versionNegotiation = options?.versionNegotiation;
1490
+ this._versionNegotiation = options?.versionNegotiation ?? { mode: "auto" };
1491
1491
  this._prior = options?.prior;
1492
1492
  this._inputRequired = options?.inputRequired;
1493
1493
  this._responseCacheStore = options?.responseCacheStore;
@@ -1522,7 +1522,7 @@ var Client = class _Client {
1522
1522
  {
1523
1523
  capabilities: this._buildCapabilities(),
1524
1524
  listChanged: this._buildListChangedConfig(),
1525
- ...this._versionNegotiation ? { versionNegotiation: this._versionNegotiation } : {},
1525
+ versionNegotiation: this._versionNegotiation,
1526
1526
  ...this._inputRequired ? { inputRequired: this._inputRequired } : {},
1527
1527
  ...this._responseCacheStore ? { responseCacheStore: this._responseCacheStore } : {},
1528
1528
  ...this._cachePartition !== void 0 ? { cachePartition: this._cachePartition } : {},
@@ -1546,7 +1546,10 @@ var Client = class _Client {
1546
1546
  if (err instanceof UnauthorizedError && this._auth instanceof OAuth) {
1547
1547
  const callbackParams = await this._auth.waitForCallback();
1548
1548
  await this._finishAuth(transport, callbackParams);
1549
- const retry = await resolveTransport(this._input, this._auth);
1549
+ const retry = await resolveTransport(this._input, this._auth, {
1550
+ legacySSE: this._legacySSE,
1551
+ versionNegotiation: this._versionNegotiation
1552
+ });
1550
1553
  if (retry.beforeConnect) await retry.beforeConnect();
1551
1554
  this._transport = retry.transport;
1552
1555
  await sdkClient.connect(retry.transport);
@@ -1627,6 +1630,35 @@ var Client = class _Client {
1627
1630
  getProtocolEra() {
1628
1631
  return this._sdkClient?.getProtocolEra();
1629
1632
  }
1633
+ /**
1634
+ * The connected server's self-reported identity (`serverInfo`: name, version,
1635
+ * and optional title / websiteUrl / icons), when it identified itself. On a
1636
+ * legacy connection it comes from the `initialize` result, where it is
1637
+ * required. On a modern (2026-07-28) connection it comes from the
1638
+ * `server/discover` result's metadata — FastMCP servers advertise it there,
1639
+ * but an anonymous modern server may omit it, leaving this `undefined`.
1640
+ * `undefined` before connect().
1641
+ */
1642
+ getServerInfo() {
1643
+ return this._sdkClient?.getServerVersion();
1644
+ }
1645
+ /**
1646
+ * The server's `instructions` string, when the server provided one — from
1647
+ * the legacy `initialize` result or, on a modern (2026-07-28) connection,
1648
+ * from the `server/discover` result. `undefined` otherwise and before
1649
+ * connect().
1650
+ */
1651
+ getInstructions() {
1652
+ return this._sdkClient?.getInstructions();
1653
+ }
1654
+ /**
1655
+ * The capabilities the server advertised during connection — on the legacy
1656
+ * `initialize` result, or on the `server/discover` result for a modern
1657
+ * (2026-07-28) connection. `undefined` before connect().
1658
+ */
1659
+ getServerCapabilities() {
1660
+ return this._sdkClient?.getServerCapabilities();
1661
+ }
1630
1662
  // -------------------------------------------------------------------------
1631
1663
  // Tools (IToolsClient)
1632
1664
  // -------------------------------------------------------------------------