@prefecthq/fastmcp-ts 1.0.0 → 1.2.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,7 @@
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, ClientCapabilities, VersionNegotiationOptions, PriorDiscovery, InputRequiredOptions, ResponseCacheStore, ProtocolEra, Implementation, ServerCapabilities } from '@modelcontextprotocol/client';
4
+ export { ClientCapabilities } from '@modelcontextprotocol/client';
4
5
  import Anthropic from '@anthropic-ai/sdk';
5
6
  import OpenAI from 'openai';
6
7
  import { GoogleGenAI } from '@google/genai';
@@ -598,17 +599,139 @@ declare class StdioTransport {
598
599
  }
599
600
  type ClientTransportInput = string | McpServerLike | McpConfig | StdioTransport | Transport;
600
601
 
602
+ interface ClientDefaultOptions {
603
+ /** Global fallback timeout in seconds for all requests. */
604
+ timeout?: number;
605
+ tool?: {
606
+ timeout?: number;
607
+ };
608
+ resource?: {
609
+ timeout?: number;
610
+ };
611
+ prompt?: {
612
+ timeout?: number;
613
+ };
614
+ }
615
+ /** A single element of the roots option: a URI string or a full Root object. */
616
+ type RootInput = string | Root;
617
+ /**
618
+ * Static list of roots, or an async callback invoked on each roots/list request.
619
+ * URI strings are normalised to file:// URIs automatically; relative paths are
620
+ * resolved against process.cwd().
621
+ */
622
+ type RootsValue = RootInput[] | (() => RootInput[] | Promise<RootInput[]>);
623
+ interface ClientOptions {
624
+ /**
625
+ * Authentication to attach to HTTP requests.
626
+ * A plain string is treated as a Bearer token.
627
+ */
628
+ auth?: BearerAuth | OAuth | AsyncHeaderAuth | string;
629
+ handlers?: ClientHandlers;
630
+ /**
631
+ * Additional capabilities to advertise to the server. FastMCP preserves
632
+ * their settings while adding capabilities inferred from handlers and roots.
633
+ */
634
+ capabilities?: ClientCapabilities;
635
+ /**
636
+ * Filesystem roots to advertise to the server.
637
+ * Accepts a static array of strings / Root objects, or an async callback
638
+ * invoked on each roots/list request (useful for dynamic root sets).
639
+ */
640
+ roots?: RootsValue;
641
+ /**
642
+ * When true (default), the MCP initialize handshake is performed
643
+ * automatically inside connect().
644
+ */
645
+ autoInitialize?: boolean;
646
+ defaultOptions?: ClientDefaultOptions;
647
+ /**
648
+ * Protocol version negotiation (protocol revision 2026-07-28 and later).
649
+ * The default is `{ mode: 'auto' }`: connect() probes the server once with
650
+ * `server/discover` and uses the modern (2026-07-28) era on definitive
651
+ * modern evidence, falling back to the plain legacy `initialize` handshake
652
+ * on anything else (a method-not-found answer, silence on a local stdio
653
+ * pipe, a probe child that exits). The probe is stall-safe in the SDK: on
654
+ * stdio it runs against a short-lived sibling process and a timeout falls
655
+ * back to legacy, while on HTTP — where silence means an outage — a probe
656
+ * timeout rejects with a typed error instead of hanging. Pass
657
+ * `{ mode: 'legacy' }` to opt out: no probe, the 2025 sequence
658
+ * byte-identical to prior behavior. Pass `{ mode: { pin: '2026-07-28' } }`
659
+ * to require the modern era outright — connect() throws if the server
660
+ * cannot speak it. See `getProtocolEra()` to read the negotiated result
661
+ * after connecting.
662
+ */
663
+ versionNegotiation?: VersionNegotiationOptions;
664
+ /**
665
+ * A cached era verdict from a previous connection to the same server, so
666
+ * connect() can skip the `server/discover` probe entirely. Takes precedence
667
+ * over `versionNegotiation`. `{ kind: 'modern', discover }` adopts a prior
668
+ * `DiscoverResult` with zero round trips; `{ kind: 'legacy' }` skips the probe
669
+ * and runs the plain legacy `initialize` handshake. Freshness is the caller's
670
+ * responsibility — a stale modern verdict fails loudly at the first request; a
671
+ * stale legacy verdict succeeds silently forever. Reuse only within one
672
+ * authorization context.
673
+ */
674
+ prior?: PriorDiscovery;
675
+ /**
676
+ * Multi-round-trip auto-fulfilment (protocol revision 2026-07-28). On the
677
+ * modern era, servers obtain client input (elicitation, sampling, roots) by
678
+ * answering a request with an `input_required` result instead of a
679
+ * server→client request. By default the client fulfils these automatically
680
+ * through the same `handlers.sampling`/`handlers.elicitation` callbacks,
681
+ * retrying up to `maxRounds` times. Set `autoFulfill: false` for manual mode.
682
+ * Has no effect on legacy-era connections. Passed through verbatim to the SDK
683
+ * client.
684
+ */
685
+ inputRequired?: InputRequiredOptions;
686
+ /**
687
+ * The response-cache store backing cacheable results (SEP-2549 `ttlMs`/
688
+ * `cacheScope` hints on `listTools`/`listResources`/`listResourceTemplates`/
689
+ * `listPrompts`/`readResource`). Defaults to a fresh in-memory store per
690
+ * client (the SDK's own default) when omitted. Passed through verbatim.
691
+ */
692
+ responseCacheStore?: ResponseCacheStore;
693
+ /**
694
+ * Opaque per-principal identifier for response-cache writes whose
695
+ * server-reported `cacheScope` is `'private'`. Set this to a stable identity
696
+ * of the authorization context (e.g. the auth subject) when one
697
+ * `responseCacheStore` backs several principals. Passed through verbatim.
698
+ */
699
+ cachePartition?: string;
700
+ /**
701
+ * TTL (ms) applied when a cacheable result arrives without a `ttlMs` field.
702
+ * Default `0` (never served from cache, but still stored). Passed through
703
+ * verbatim.
704
+ */
705
+ defaultCacheTtlMs?: number;
706
+ /**
707
+ * Allow the deprecated SSE transport when a target URL's path indicates SSE
708
+ * (e.g. ends in `/sse`). Default `false` — such URLs throw a clear error
709
+ * pointing at Streamable HTTP and this flag, rather than silently connecting
710
+ * over a transport the MCP SDK itself marks `@deprecated`. When enabled, a
711
+ * one-time deprecation warning is logged via `console.warn`.
712
+ */
713
+ legacySSE?: boolean;
714
+ }
715
+
601
716
  interface MultiServerOptions {
602
717
  handlers?: ClientHandlers;
718
+ /**
719
+ * Additional capabilities to advertise to every server. FastMCP combines
720
+ * them with capabilities inferred from handlers and roots.
721
+ */
722
+ capabilities?: ClientCapabilities;
603
723
  /** file:// URIs to advertise to all servers as accessible roots. */
604
724
  roots?: string[];
605
725
  defaultOptions?: ClientDefaultOptions;
606
726
  /**
607
- * Opt-in protocol version negotiation, applied identically to every server
608
- * in the config (protocol revision 2026-07-28 and later). See
727
+ * Protocol version negotiation, applied identically to every server in the
728
+ * config (protocol revision 2026-07-28 and later). See
609
729
  * `ClientOptions.versionNegotiation` on the single-server `Client` — same
610
730
  * semantics, just applied per sub-client here since each connected server
611
- * negotiates its own era independently. Default `'legacy'`.
731
+ * negotiates its own era independently. Default `{ mode: 'auto' }`: each
732
+ * sub-client probes its server once and falls back to legacy when the
733
+ * server offers no modern era; `{ mode: 'legacy' }` opts every connection
734
+ * out of the probe.
612
735
  */
613
736
  versionNegotiation?: VersionNegotiationOptions;
614
737
  }
@@ -621,6 +744,7 @@ declare class MultiServerClient implements IClient {
621
744
  private readonly _config;
622
745
  private readonly _handlers;
623
746
  private readonly _roots;
747
+ private readonly _capabilities;
624
748
  private readonly _defaultOptions;
625
749
  private readonly _versionNegotiation;
626
750
  private _resourceSubscriptions;
@@ -691,7 +815,6 @@ declare class MultiServerClient implements IClient {
691
815
  private _parseNamespacedName;
692
816
  private _sdkForServer;
693
817
  private _buildSdkClient;
694
- private _buildCapabilities;
695
818
  private _registerHandlers;
696
819
  /** See Client._metaParams's docs — the same purpose, per server name, since
697
820
  * each connected server may be on a different era and have a different
@@ -704,107 +827,6 @@ declare class ToolCallError extends Error {
704
827
  readonly content: ContentBlock[];
705
828
  constructor(message: string, content: ContentBlock[]);
706
829
  }
707
- interface ClientDefaultOptions {
708
- /** Global fallback timeout in seconds for all requests. */
709
- timeout?: number;
710
- tool?: {
711
- timeout?: number;
712
- };
713
- resource?: {
714
- timeout?: number;
715
- };
716
- prompt?: {
717
- timeout?: number;
718
- };
719
- }
720
- /** A single element of the roots option: a URI string or a full Root object. */
721
- type RootInput = string | Root;
722
- /**
723
- * Static list of roots, or an async callback invoked on each roots/list request.
724
- * URI strings are normalised to file:// URIs automatically; relative paths are
725
- * resolved against process.cwd().
726
- */
727
- type RootsValue = RootInput[] | (() => RootInput[] | Promise<RootInput[]>);
728
- interface ClientOptions {
729
- /**
730
- * Authentication to attach to HTTP requests.
731
- * A plain string is treated as a Bearer token.
732
- */
733
- auth?: BearerAuth | OAuth | AsyncHeaderAuth | string;
734
- handlers?: ClientHandlers;
735
- /**
736
- * Filesystem roots to advertise to the server.
737
- * Accepts a static array of strings / Root objects, or an async callback
738
- * invoked on each roots/list request (useful for dynamic root sets).
739
- */
740
- roots?: RootsValue;
741
- /**
742
- * When true (default), the MCP initialize handshake is performed
743
- * automatically inside connect().
744
- */
745
- autoInitialize?: boolean;
746
- defaultOptions?: ClientDefaultOptions;
747
- /**
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.
755
- */
756
- versionNegotiation?: VersionNegotiationOptions;
757
- /**
758
- * A cached era verdict from a previous connection to the same server, so
759
- * connect() can skip the `server/discover` probe entirely. Takes precedence
760
- * over `versionNegotiation`. `{ kind: 'modern', discover }` adopts a prior
761
- * `DiscoverResult` with zero round trips; `{ kind: 'legacy' }` skips the probe
762
- * and runs the plain legacy `initialize` handshake. Freshness is the caller's
763
- * responsibility — a stale modern verdict fails loudly at the first request; a
764
- * stale legacy verdict succeeds silently forever. Reuse only within one
765
- * authorization context.
766
- */
767
- prior?: PriorDiscovery;
768
- /**
769
- * Multi-round-trip auto-fulfilment (protocol revision 2026-07-28). On the
770
- * modern era, servers obtain client input (elicitation, sampling, roots) by
771
- * answering a request with an `input_required` result instead of a
772
- * server→client request. By default the client fulfils these automatically
773
- * through the same `handlers.sampling`/`handlers.elicitation` callbacks,
774
- * retrying up to `maxRounds` times. Set `autoFulfill: false` for manual mode.
775
- * Has no effect on legacy-era connections. Passed through verbatim to the SDK
776
- * client.
777
- */
778
- inputRequired?: InputRequiredOptions;
779
- /**
780
- * The response-cache store backing cacheable results (SEP-2549 `ttlMs`/
781
- * `cacheScope` hints on `listTools`/`listResources`/`listResourceTemplates`/
782
- * `listPrompts`/`readResource`). Defaults to a fresh in-memory store per
783
- * client (the SDK's own default) when omitted. Passed through verbatim.
784
- */
785
- responseCacheStore?: ResponseCacheStore;
786
- /**
787
- * Opaque per-principal identifier for response-cache writes whose
788
- * server-reported `cacheScope` is `'private'`. Set this to a stable identity
789
- * of the authorization context (e.g. the auth subject) when one
790
- * `responseCacheStore` backs several principals. Passed through verbatim.
791
- */
792
- cachePartition?: string;
793
- /**
794
- * TTL (ms) applied when a cacheable result arrives without a `ttlMs` field.
795
- * Default `0` (never served from cache, but still stored). Passed through
796
- * verbatim.
797
- */
798
- defaultCacheTtlMs?: number;
799
- /**
800
- * Allow the deprecated SSE transport when a target URL's path indicates SSE
801
- * (e.g. ends in `/sse`). Default `false` — such URLs throw a clear error
802
- * pointing at Streamable HTTP and this flag, rather than silently connecting
803
- * over a transport the MCP SDK itself marks `@deprecated`. When enabled, a
804
- * one-time deprecation warning is logged via `console.warn`.
805
- */
806
- legacySSE?: boolean;
807
- }
808
830
  declare class Client implements IClient {
809
831
  private _sdkClient;
810
832
  private _refCount;
@@ -832,6 +854,7 @@ declare class Client implements IClient {
832
854
  private readonly _auth;
833
855
  private readonly _handlers;
834
856
  private readonly _roots;
857
+ private readonly _capabilities;
835
858
  private readonly _autoInitialize;
836
859
  private readonly _versionNegotiation;
837
860
  private readonly _prior;
@@ -874,6 +897,29 @@ declare class Client implements IClient {
874
897
  * `undefined` before connect(). See `ClientOptions.versionNegotiation`.
875
898
  */
876
899
  getProtocolEra(): ProtocolEra | undefined;
900
+ /**
901
+ * The connected server's self-reported identity (`serverInfo`: name, version,
902
+ * and optional title / websiteUrl / icons), when it identified itself. On a
903
+ * legacy connection it comes from the `initialize` result, where it is
904
+ * required. On a modern (2026-07-28) connection it comes from the
905
+ * `server/discover` result's metadata — FastMCP servers advertise it there,
906
+ * but an anonymous modern server may omit it, leaving this `undefined`.
907
+ * `undefined` before connect().
908
+ */
909
+ getServerInfo(): Implementation | undefined;
910
+ /**
911
+ * The server's `instructions` string, when the server provided one — from
912
+ * the legacy `initialize` result or, on a modern (2026-07-28) connection,
913
+ * from the `server/discover` result. `undefined` otherwise and before
914
+ * connect().
915
+ */
916
+ getInstructions(): string | undefined;
917
+ /**
918
+ * The capabilities the server advertised during connection — on the legacy
919
+ * `initialize` result, or on the `server/discover` result for a modern
920
+ * (2026-07-28) connection. `undefined` before connect().
921
+ */
922
+ getServerCapabilities(): ServerCapabilities | undefined;
877
923
  listTools(options?: RequestOptions): Promise<Tool[]>;
878
924
  callTool<TData = unknown>(name: string, args?: Record<string, unknown>, options?: CallToolOptions): Promise<CallToolResult<TData>>;
879
925
  /** Returns the full result including isError without throwing. */
@@ -1052,7 +1098,6 @@ declare class Client implements IClient {
1052
1098
  */
1053
1099
  private _metaParams;
1054
1100
  private _toSdkOptions;
1055
- private _buildCapabilities;
1056
1101
  private _buildListChangedConfig;
1057
1102
  private _registerHandlers;
1058
1103
  /**
package/dist/client.js CHANGED
@@ -916,6 +916,28 @@ async function resolveTransport(input, auth, options) {
916
916
  // src/client/client.ts
917
917
  import { UnauthorizedError, Client as SdkClient2, LOG_LEVEL_META_KEY as LOG_LEVEL_META_KEY2 } from "@modelcontextprotocol/client";
918
918
 
919
+ // src/client/capabilities.ts
920
+ function buildClientCapabilities(supplied, inferred) {
921
+ const capabilities = { ...supplied };
922
+ if (inferred.sampling) {
923
+ capabilities.sampling = {
924
+ ...supplied?.sampling,
925
+ tools: supplied?.sampling?.tools ?? {}
926
+ };
927
+ }
928
+ if (inferred.elicitation) {
929
+ const elicitation = supplied?.elicitation;
930
+ capabilities.elicitation = elicitation ? { ...elicitation, form: elicitation.form ?? {} } : {};
931
+ }
932
+ if (inferred.rootsListChanged !== void 0) {
933
+ capabilities.roots = {
934
+ ...supplied?.roots,
935
+ listChanged: inferred.rootsListChanged
936
+ };
937
+ }
938
+ return capabilities;
939
+ }
940
+
919
941
  // src/client/multi-server.ts
920
942
  import { Client as SdkClient, LOG_LEVEL_META_KEY } from "@modelcontextprotocol/client";
921
943
  var MultiServerClient = class _MultiServerClient {
@@ -927,6 +949,7 @@ var MultiServerClient = class _MultiServerClient {
927
949
  _config;
928
950
  _handlers;
929
951
  _roots;
952
+ _capabilities;
930
953
  _defaultOptions;
931
954
  _versionNegotiation;
932
955
  _resourceSubscriptions = /* @__PURE__ */ new Map();
@@ -948,8 +971,13 @@ var MultiServerClient = class _MultiServerClient {
948
971
  sampling: options?.handlers?.sampling,
949
972
  elicitation: options?.handlers?.elicitation
950
973
  };
951
- this._versionNegotiation = options?.versionNegotiation;
974
+ this._versionNegotiation = options?.versionNegotiation ?? { mode: "auto" };
952
975
  this._roots = options?.roots;
976
+ this._capabilities = buildClientCapabilities(options?.capabilities, {
977
+ sampling: this._handlers.sampling !== void 0,
978
+ elicitation: this._handlers.elicitation !== void 0,
979
+ rootsListChanged: this._roots === void 0 ? void 0 : false
980
+ });
953
981
  this._defaultOptions = options?.defaultOptions ?? {};
954
982
  }
955
983
  // -------------------------------------------------------------------------
@@ -1361,18 +1389,11 @@ ${errors.map(String).join("\n")}`);
1361
1389
  return new SdkClient(
1362
1390
  { name: "fastmcp-ts", version: "1.0.0" },
1363
1391
  {
1364
- capabilities: this._buildCapabilities(),
1365
- ...this._versionNegotiation ? { versionNegotiation: this._versionNegotiation } : {}
1392
+ capabilities: this._capabilities,
1393
+ versionNegotiation: this._versionNegotiation
1366
1394
  }
1367
1395
  );
1368
1396
  }
1369
- _buildCapabilities() {
1370
- return {
1371
- ...this._handlers.sampling ? { sampling: { tools: {} } } : {},
1372
- ...this._handlers.elicitation ? { elicitation: {} } : {},
1373
- ...this._roots ? { roots: { listChanged: false } } : {}
1374
- };
1375
- }
1376
1397
  _registerHandlers(sdk) {
1377
1398
  sdk.setNotificationHandler("notifications/message", (notification) => {
1378
1399
  void this._handlers.log({
@@ -1459,6 +1480,7 @@ var Client = class _Client {
1459
1480
  _auth;
1460
1481
  _handlers;
1461
1482
  _roots;
1483
+ _capabilities;
1462
1484
  _autoInitialize;
1463
1485
  _versionNegotiation;
1464
1486
  _prior;
@@ -1486,8 +1508,13 @@ var Client = class _Client {
1486
1508
  onPromptsListChanged: options?.handlers?.onPromptsListChanged
1487
1509
  };
1488
1510
  this._roots = options?.roots ? normalizeRootsOption(options.roots) : void 0;
1511
+ this._capabilities = buildClientCapabilities(options?.capabilities, {
1512
+ sampling: this._handlers.sampling !== void 0,
1513
+ elicitation: this._handlers.elicitation !== void 0,
1514
+ rootsListChanged: this._roots === void 0 ? void 0 : true
1515
+ });
1489
1516
  this._autoInitialize = options?.autoInitialize ?? true;
1490
- this._versionNegotiation = options?.versionNegotiation;
1517
+ this._versionNegotiation = options?.versionNegotiation ?? { mode: "auto" };
1491
1518
  this._prior = options?.prior;
1492
1519
  this._inputRequired = options?.inputRequired;
1493
1520
  this._responseCacheStore = options?.responseCacheStore;
@@ -1520,9 +1547,9 @@ var Client = class _Client {
1520
1547
  const sdkClient = new SdkClient2(
1521
1548
  { name: "fastmcp-ts", version: "1.0.0" },
1522
1549
  {
1523
- capabilities: this._buildCapabilities(),
1550
+ capabilities: this._capabilities,
1524
1551
  listChanged: this._buildListChangedConfig(),
1525
- ...this._versionNegotiation ? { versionNegotiation: this._versionNegotiation } : {},
1552
+ versionNegotiation: this._versionNegotiation,
1526
1553
  ...this._inputRequired ? { inputRequired: this._inputRequired } : {},
1527
1554
  ...this._responseCacheStore ? { responseCacheStore: this._responseCacheStore } : {},
1528
1555
  ...this._cachePartition !== void 0 ? { cachePartition: this._cachePartition } : {},
@@ -1546,7 +1573,10 @@ var Client = class _Client {
1546
1573
  if (err instanceof UnauthorizedError && this._auth instanceof OAuth) {
1547
1574
  const callbackParams = await this._auth.waitForCallback();
1548
1575
  await this._finishAuth(transport, callbackParams);
1549
- const retry = await resolveTransport(this._input, this._auth);
1576
+ const retry = await resolveTransport(this._input, this._auth, {
1577
+ legacySSE: this._legacySSE,
1578
+ versionNegotiation: this._versionNegotiation
1579
+ });
1550
1580
  if (retry.beforeConnect) await retry.beforeConnect();
1551
1581
  this._transport = retry.transport;
1552
1582
  await sdkClient.connect(retry.transport);
@@ -1627,6 +1657,35 @@ var Client = class _Client {
1627
1657
  getProtocolEra() {
1628
1658
  return this._sdkClient?.getProtocolEra();
1629
1659
  }
1660
+ /**
1661
+ * The connected server's self-reported identity (`serverInfo`: name, version,
1662
+ * and optional title / websiteUrl / icons), when it identified itself. On a
1663
+ * legacy connection it comes from the `initialize` result, where it is
1664
+ * required. On a modern (2026-07-28) connection it comes from the
1665
+ * `server/discover` result's metadata — FastMCP servers advertise it there,
1666
+ * but an anonymous modern server may omit it, leaving this `undefined`.
1667
+ * `undefined` before connect().
1668
+ */
1669
+ getServerInfo() {
1670
+ return this._sdkClient?.getServerVersion();
1671
+ }
1672
+ /**
1673
+ * The server's `instructions` string, when the server provided one — from
1674
+ * the legacy `initialize` result or, on a modern (2026-07-28) connection,
1675
+ * from the `server/discover` result. `undefined` otherwise and before
1676
+ * connect().
1677
+ */
1678
+ getInstructions() {
1679
+ return this._sdkClient?.getInstructions();
1680
+ }
1681
+ /**
1682
+ * The capabilities the server advertised during connection — on the legacy
1683
+ * `initialize` result, or on the `server/discover` result for a modern
1684
+ * (2026-07-28) connection. `undefined` before connect().
1685
+ */
1686
+ getServerCapabilities() {
1687
+ return this._sdkClient?.getServerCapabilities();
1688
+ }
1630
1689
  // -------------------------------------------------------------------------
1631
1690
  // Tools (IToolsClient)
1632
1691
  // -------------------------------------------------------------------------
@@ -1960,13 +2019,6 @@ var Client = class _Client {
1960
2019
  }
1961
2020
  return sdkOptions;
1962
2021
  }
1963
- _buildCapabilities() {
1964
- return {
1965
- ...this._handlers.sampling ? { sampling: { tools: {} } } : {},
1966
- ...this._handlers.elicitation ? { elicitation: {} } : {},
1967
- ...this._roots ? { roots: { listChanged: true } } : {}
1968
- };
1969
- }
1970
2022
  _buildListChangedConfig() {
1971
2023
  const { onToolsListChanged, onResourcesListChanged, onPromptsListChanged } = this._handlers;
1972
2024
  if (!onToolsListChanged && !onResourcesListChanged && !onPromptsListChanged) return void 0;