@ai-sdk/mcp 1.0.41 → 1.0.42

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @ai-sdk/mcp
2
2
 
3
+ ## 1.0.42
4
+
5
+ ### Patch Changes
6
+
7
+ - 725f2ed: feat(mcp): expose server instructions to be accessible through client
8
+ - 7281592: fix(mcp): use negotiated protocol version in transport request headers
9
+
3
10
  ## 1.0.41
4
11
 
5
12
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -228,6 +228,10 @@ interface MCPTransport {
228
228
  * Event handler for received messages
229
229
  */
230
230
  onmessage?: (message: JSONRPCMessage) => void;
231
+ /**
232
+ * The protocol version negotiated during initialization.
233
+ */
234
+ protocolVersion?: string;
231
235
  }
232
236
  type MCPTransportConfig = {
233
237
  type: 'sse' | 'http';
@@ -508,6 +512,15 @@ interface MCPClient {
508
512
  * @see https://modelcontextprotocol.io/specification/2025-11-25/schema#implementation
509
513
  */
510
514
  readonly serverInfo: Configuration;
515
+ /**
516
+ * Optional instructions provided by the server during the initialize handshake.
517
+ *
518
+ * These describe how to use the server and its features, and can be used by clients
519
+ * to improve LLM interactions (e.g. by including them in the system prompt).
520
+ *
521
+ * @see https://modelcontextprotocol.io/specification/2025-11-25/schema#initializeresult
522
+ */
523
+ readonly instructions?: string;
511
524
  tools<TOOL_SCHEMAS extends ToolSchemas = 'automatic'>(options?: {
512
525
  schemas?: TOOL_SCHEMAS;
513
526
  }): Promise<McpToolSet<TOOL_SCHEMAS>>;
package/dist/index.d.ts CHANGED
@@ -228,6 +228,10 @@ interface MCPTransport {
228
228
  * Event handler for received messages
229
229
  */
230
230
  onmessage?: (message: JSONRPCMessage) => void;
231
+ /**
232
+ * The protocol version negotiated during initialization.
233
+ */
234
+ protocolVersion?: string;
231
235
  }
232
236
  type MCPTransportConfig = {
233
237
  type: 'sse' | 'http';
@@ -508,6 +512,15 @@ interface MCPClient {
508
512
  * @see https://modelcontextprotocol.io/specification/2025-11-25/schema#implementation
509
513
  */
510
514
  readonly serverInfo: Configuration;
515
+ /**
516
+ * Optional instructions provided by the server during the initialize handshake.
517
+ *
518
+ * These describe how to use the server and its features, and can be used by clients
519
+ * to improve LLM interactions (e.g. by including them in the system prompt).
520
+ *
521
+ * @see https://modelcontextprotocol.io/specification/2025-11-25/schema#initializeresult
522
+ */
523
+ readonly instructions?: string;
511
524
  tools<TOOL_SCHEMAS extends ToolSchemas = 'automatic'>(options?: {
512
525
  schemas?: TOOL_SCHEMAS;
513
526
  }): Promise<McpToolSet<TOOL_SCHEMAS>>;
package/dist/index.js CHANGED
@@ -1115,10 +1115,11 @@ var SseMCPTransport = class {
1115
1115
  this.fetchFn = fetchFn != null ? fetchFn : globalThis.fetch;
1116
1116
  }
1117
1117
  async commonHeaders(base) {
1118
+ var _a3;
1118
1119
  const headers = {
1119
1120
  ...this.headers,
1120
1121
  ...base,
1121
- "mcp-protocol-version": LATEST_PROTOCOL_VERSION
1122
+ "mcp-protocol-version": (_a3 = this.protocolVersion) != null ? _a3 : LATEST_PROTOCOL_VERSION
1122
1123
  };
1123
1124
  if (this.authProvider) {
1124
1125
  const tokens = await this.authProvider.tokens();
@@ -1329,10 +1330,11 @@ var HttpMCPTransport = class {
1329
1330
  this.fetchFn = fetchFn != null ? fetchFn : globalThis.fetch;
1330
1331
  }
1331
1332
  async commonHeaders(base) {
1333
+ var _a3;
1332
1334
  const headers = {
1333
1335
  ...this.headers,
1334
1336
  ...base,
1335
- "mcp-protocol-version": LATEST_PROTOCOL_VERSION
1337
+ "mcp-protocol-version": (_a3 = this.protocolVersion) != null ? _a3 : LATEST_PROTOCOL_VERSION
1336
1338
  };
1337
1339
  if (this.sessionId) {
1338
1340
  headers["mcp-session-id"] = this.sessionId;
@@ -1721,6 +1723,9 @@ var DefaultMCPClient = class {
1721
1723
  get serverInfo() {
1722
1724
  return this._serverInfo;
1723
1725
  }
1726
+ get instructions() {
1727
+ return this._serverInstructions;
1728
+ }
1724
1729
  async init() {
1725
1730
  try {
1726
1731
  await this.transport.start();
@@ -1748,6 +1753,8 @@ var DefaultMCPClient = class {
1748
1753
  }
1749
1754
  this.serverCapabilities = result.capabilities;
1750
1755
  this._serverInfo = result.serverInfo;
1756
+ this._serverInstructions = result.instructions;
1757
+ this.transport.protocolVersion = result.protocolVersion;
1751
1758
  await this.notification({
1752
1759
  method: "notifications/initialized"
1753
1760
  });