@modelcontextprotocol/sdk 1.0.4 → 1.1.1
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/README.md +8 -0
- package/dist/client/sse.d.ts +6 -1
- package/dist/client/sse.d.ts.map +1 -1
- package/dist/client/sse.js +14 -10
- package/dist/client/sse.js.map +1 -1
- package/dist/server/stdio.d.ts.map +1 -1
- package/dist/server/stdio.js +9 -0
- package/dist/server/stdio.js.map +1 -1
- package/dist/types.d.ts +87 -81
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -3
- package/dist/types.js.map +1 -1
- package/package.json +14 -5
- package/dist/client/index.test.d.ts +0 -2
- package/dist/client/index.test.d.ts.map +0 -1
- package/dist/client/index.test.js +0 -393
- package/dist/client/index.test.js.map +0 -1
- package/dist/client/stdio.test.d.ts +0 -2
- package/dist/client/stdio.test.d.ts.map +0 -1
- package/dist/client/stdio.test.js +0 -51
- package/dist/client/stdio.test.js.map +0 -1
- package/dist/inMemory.test.d.ts +0 -2
- package/dist/inMemory.test.d.ts.map +0 -1
- package/dist/inMemory.test.js +0 -74
- package/dist/inMemory.test.js.map +0 -1
- package/dist/server/index.test.d.ts +0 -2
- package/dist/server/index.test.d.ts.map +0 -1
- package/dist/server/index.test.js +0 -408
- package/dist/server/index.test.js.map +0 -1
- package/dist/server/stdio.test.d.ts +0 -2
- package/dist/server/stdio.test.d.ts.map +0 -1
- package/dist/server/stdio.test.js +0 -87
- package/dist/server/stdio.test.js.map +0 -1
- package/dist/shared/stdio.test.d.ts +0 -2
- package/dist/shared/stdio.test.d.ts.map +0 -1
- package/dist/shared/stdio.test.js +0 -27
- package/dist/shared/stdio.test.js.map +0 -1
package/README.md
CHANGED
|
@@ -24,6 +24,10 @@ npm install @modelcontextprotocol/sdk
|
|
|
24
24
|
```typescript
|
|
25
25
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
26
26
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
27
|
+
import {
|
|
28
|
+
ListResourcesRequestSchema,
|
|
29
|
+
ReadResourceRequestSchema,
|
|
30
|
+
} from "@modelcontextprotocol/sdk/types.js";
|
|
27
31
|
|
|
28
32
|
const transport = new StdioClientTransport({
|
|
29
33
|
command: "path/to/server",
|
|
@@ -61,6 +65,10 @@ const resourceContent = await client.request(
|
|
|
61
65
|
```typescript
|
|
62
66
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
63
67
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
68
|
+
import {
|
|
69
|
+
ListResourcesRequestSchema,
|
|
70
|
+
ReadResourceRequestSchema,
|
|
71
|
+
} from "@modelcontextprotocol/sdk/types.js";
|
|
64
72
|
|
|
65
73
|
const server = new Server({
|
|
66
74
|
name: "example-server",
|
package/dist/client/sse.d.ts
CHANGED
|
@@ -11,10 +11,15 @@ export declare class SSEClientTransport implements Transport {
|
|
|
11
11
|
private _endpoint?;
|
|
12
12
|
private _abortController?;
|
|
13
13
|
private _url;
|
|
14
|
+
private _eventSourceInit?;
|
|
15
|
+
private _requestInit?;
|
|
14
16
|
onclose?: () => void;
|
|
15
17
|
onerror?: (error: Error) => void;
|
|
16
18
|
onmessage?: (message: JSONRPCMessage) => void;
|
|
17
|
-
constructor(url: URL
|
|
19
|
+
constructor(url: URL, opts?: {
|
|
20
|
+
eventSourceInit?: EventSourceInit;
|
|
21
|
+
requestInit?: RequestInit;
|
|
22
|
+
});
|
|
18
23
|
start(): Promise<void>;
|
|
19
24
|
close(): Promise<void>;
|
|
20
25
|
send(message: JSONRPCMessage): Promise<void>;
|
package/dist/client/sse.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../src/client/sse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAwB,MAAM,aAAa,CAAC;AAEnE;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,SAAS;IAClD,OAAO,CAAC,YAAY,CAAC,CAAc;IACnC,OAAO,CAAC,SAAS,CAAC,CAAM;IACxB,OAAO,CAAC,gBAAgB,CAAC,CAAkB;IAC3C,OAAO,CAAC,IAAI,CAAM;
|
|
1
|
+
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../src/client/sse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAwB,MAAM,aAAa,CAAC;AAEnE;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,SAAS;IAClD,OAAO,CAAC,YAAY,CAAC,CAAc;IACnC,OAAO,CAAC,SAAS,CAAC,CAAM;IACxB,OAAO,CAAC,gBAAgB,CAAC,CAAkB;IAC3C,OAAO,CAAC,IAAI,CAAM;IAClB,OAAO,CAAC,gBAAgB,CAAC,CAAkB;IAC3C,OAAO,CAAC,YAAY,CAAC,CAAc;IAEnC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;gBAElC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,eAAe,CAAC;QAAC,WAAW,CAAC,EAAE,WAAW,CAAA;KAAE;IAM7F,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAyDhB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAMtB,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CA6BnD"}
|
package/dist/client/sse.js
CHANGED
|
@@ -6,15 +6,17 @@ import { JSONRPCMessageSchema } from "../types.js";
|
|
|
6
6
|
* This uses the EventSource API in browsers. You can install the `eventsource` package for Node.js.
|
|
7
7
|
*/
|
|
8
8
|
export class SSEClientTransport {
|
|
9
|
-
constructor(url) {
|
|
9
|
+
constructor(url, opts) {
|
|
10
10
|
this._url = url;
|
|
11
|
+
this._eventSourceInit = opts === null || opts === void 0 ? void 0 : opts.eventSourceInit;
|
|
12
|
+
this._requestInit = opts === null || opts === void 0 ? void 0 : opts.requestInit;
|
|
11
13
|
}
|
|
12
14
|
start() {
|
|
13
15
|
if (this._eventSource) {
|
|
14
16
|
throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");
|
|
15
17
|
}
|
|
16
18
|
return new Promise((resolve, reject) => {
|
|
17
|
-
this._eventSource = new EventSource(this._url.href);
|
|
19
|
+
this._eventSource = new EventSource(this._url.href, this._eventSourceInit);
|
|
18
20
|
this._abortController = new AbortController();
|
|
19
21
|
this._eventSource.onerror = (event) => {
|
|
20
22
|
var _a;
|
|
@@ -64,26 +66,28 @@ export class SSEClientTransport {
|
|
|
64
66
|
(_c = this.onclose) === null || _c === void 0 ? void 0 : _c.call(this);
|
|
65
67
|
}
|
|
66
68
|
async send(message) {
|
|
67
|
-
var _a, _b;
|
|
69
|
+
var _a, _b, _c;
|
|
68
70
|
if (!this._endpoint) {
|
|
69
71
|
throw new Error("Not connected");
|
|
70
72
|
}
|
|
71
73
|
try {
|
|
72
|
-
const
|
|
74
|
+
const headers = new Headers((_a = this._requestInit) === null || _a === void 0 ? void 0 : _a.headers);
|
|
75
|
+
headers.set("content-type", "application/json");
|
|
76
|
+
const init = {
|
|
77
|
+
...this._requestInit,
|
|
73
78
|
method: "POST",
|
|
74
|
-
headers
|
|
75
|
-
"Content-Type": "application/json",
|
|
76
|
-
},
|
|
79
|
+
headers,
|
|
77
80
|
body: JSON.stringify(message),
|
|
78
|
-
signal: (
|
|
79
|
-
}
|
|
81
|
+
signal: (_b = this._abortController) === null || _b === void 0 ? void 0 : _b.signal
|
|
82
|
+
};
|
|
83
|
+
const response = await fetch(this._endpoint, init);
|
|
80
84
|
if (!response.ok) {
|
|
81
85
|
const text = await response.text().catch(() => null);
|
|
82
86
|
throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
|
|
83
87
|
}
|
|
84
88
|
}
|
|
85
89
|
catch (error) {
|
|
86
|
-
(
|
|
90
|
+
(_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);
|
|
87
91
|
throw error;
|
|
88
92
|
}
|
|
89
93
|
}
|
package/dist/client/sse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.js","sourceRoot":"","sources":["../../src/client/sse.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,OAAO,kBAAkB;
|
|
1
|
+
{"version":3,"file":"sse.js","sourceRoot":"","sources":["../../src/client/sse.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,OAAO,kBAAkB;IAY7B,YAAY,GAAQ,EAAE,IAAuE;QAC3F,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,gBAAgB,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,eAAe,CAAC;QAC9C,IAAI,CAAC,YAAY,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC;IACxC,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CACb,6GAA6G,CAC9G,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,YAAY,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;YAC3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"file":"stdio.d.ts","sourceRoot":"","sources":["../../src/server/stdio.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD;;;;GAIG;AACH,qBAAa,oBAAqB,YAAW,SAAS;IAKlD,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,OAAO;IALjB,OAAO,CAAC,WAAW,CAAgC;IACnD,OAAO,CAAC,QAAQ,CAAS;gBAGf,MAAM,GAAE,QAAwB,EAChC,OAAO,GAAE,QAAyB;IAG5C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IAG9C,OAAO,UAAW,MAAM,UAGtB;IACF,QAAQ,UAAW,KAAK,UAEtB;IAEF;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAY5B,OAAO,CAAC,iBAAiB;IAenB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAkB5B,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAU7C"}
|
package/dist/server/stdio.js
CHANGED
|
@@ -49,8 +49,17 @@ export class StdioServerTransport {
|
|
|
49
49
|
}
|
|
50
50
|
async close() {
|
|
51
51
|
var _a;
|
|
52
|
+
// Remove our event listeners first
|
|
52
53
|
this._stdin.off("data", this._ondata);
|
|
53
54
|
this._stdin.off("error", this._onerror);
|
|
55
|
+
// Check if we were the only data listener
|
|
56
|
+
const remainingDataListeners = this._stdin.listenerCount('data');
|
|
57
|
+
if (remainingDataListeners === 0) {
|
|
58
|
+
// Only pause stdin if we were the only listener
|
|
59
|
+
// This prevents interfering with other parts of the application that might be using stdin
|
|
60
|
+
this._stdin.pause();
|
|
61
|
+
}
|
|
62
|
+
// Clear the buffer and notify closure
|
|
54
63
|
this._readBuffer.clear();
|
|
55
64
|
(_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
56
65
|
}
|
package/dist/server/stdio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["../../src/server/stdio.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAIlE;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IAI/B,YACU,SAAmB,OAAO,CAAC,KAAK,EAChC,UAAoB,OAAO,CAAC,MAAM;QADlC,WAAM,GAAN,MAAM,CAA0B;QAChC,YAAO,GAAP,OAAO,CAA2B;QALpC,gBAAW,GAAe,IAAI,UAAU,EAAE,CAAC;QAC3C,aAAQ,GAAG,KAAK,CAAC;QAWzB,gFAAgF;QAChF,YAAO,GAAG,CAAC,KAAa,EAAE,EAAE;YAC1B,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC/B,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC3B,CAAC,CAAC;QACF,aAAQ,GAAG,CAAC,KAAY,EAAE,EAAE;;YAC1B,MAAA,IAAI,CAAC,OAAO,qDAAG,KAAK,CAAC,CAAC;QACxB,CAAC,CAAC;IAbC,CAAC;IAeJ;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACb,+GAA+G,CAChH,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC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,CAAC;QACjE,IAAI,sBAAsB,KAAK,CAAC,EAAE,CAAC;YACjC,gDAAgD;YAChD,0FAA0F;YAC1F,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC;QAED,sCAAsC;QACtC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QACzB,MAAA,IAAI,CAAC,OAAO,oDAAI,CAAC;IACnB,CAAC;IAED,IAAI,CAAC,OAAuB;QAC1B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,MAAM,IAAI,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;YACvC,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC7B,OAAO,EAAE,CAAC;YACZ,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACtC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
1
|
+
import { z, ZodTypeAny } from "zod";
|
|
2
2
|
export declare const LATEST_PROTOCOL_VERSION = "2024-11-05";
|
|
3
3
|
export declare const SUPPORTED_PROTOCOL_VERSIONS: string[];
|
|
4
4
|
export declare const JSONRPC_VERSION = "2.0";
|
|
@@ -347,11 +347,11 @@ export declare const JSONRPCResponseSchema: z.ZodObject<{
|
|
|
347
347
|
};
|
|
348
348
|
}>;
|
|
349
349
|
/**
|
|
350
|
-
*
|
|
350
|
+
* Error codes defined by the JSON-RPC specification.
|
|
351
351
|
*/
|
|
352
352
|
export declare enum ErrorCode {
|
|
353
|
-
ConnectionClosed = -
|
|
354
|
-
RequestTimeout = -
|
|
353
|
+
ConnectionClosed = -32000,
|
|
354
|
+
RequestTimeout = -32001,
|
|
355
355
|
ParseError = -32700,
|
|
356
356
|
InvalidRequest = -32600,
|
|
357
357
|
MethodNotFound = -32601,
|
|
@@ -26345,81 +26345,87 @@ export declare class McpError extends Error {
|
|
|
26345
26345
|
readonly data?: unknown;
|
|
26346
26346
|
constructor(code: number, message: string, data?: unknown);
|
|
26347
26347
|
}
|
|
26348
|
-
|
|
26349
|
-
|
|
26350
|
-
|
|
26351
|
-
|
|
26352
|
-
|
|
26353
|
-
export type
|
|
26354
|
-
export type
|
|
26355
|
-
export type
|
|
26356
|
-
export type
|
|
26357
|
-
export type
|
|
26358
|
-
export type
|
|
26359
|
-
export type
|
|
26360
|
-
export type
|
|
26361
|
-
export type
|
|
26362
|
-
export type
|
|
26363
|
-
export type
|
|
26364
|
-
export type
|
|
26365
|
-
export type
|
|
26366
|
-
export type
|
|
26367
|
-
export type
|
|
26368
|
-
export type
|
|
26369
|
-
export type
|
|
26370
|
-
export type
|
|
26371
|
-
export type
|
|
26372
|
-
export type
|
|
26373
|
-
export type
|
|
26374
|
-
export type
|
|
26375
|
-
export type
|
|
26376
|
-
export type
|
|
26377
|
-
export type
|
|
26378
|
-
export type
|
|
26379
|
-
export type
|
|
26380
|
-
export type
|
|
26381
|
-
export type
|
|
26382
|
-
export type
|
|
26383
|
-
export type
|
|
26384
|
-
export type
|
|
26385
|
-
export type
|
|
26386
|
-
export type
|
|
26387
|
-
export type
|
|
26388
|
-
export type
|
|
26389
|
-
export type
|
|
26390
|
-
export type
|
|
26391
|
-
export type
|
|
26392
|
-
export type
|
|
26393
|
-
export type
|
|
26394
|
-
export type
|
|
26395
|
-
export type
|
|
26396
|
-
export type
|
|
26397
|
-
export type
|
|
26398
|
-
export type
|
|
26399
|
-
export type
|
|
26400
|
-
export type
|
|
26401
|
-
export type
|
|
26402
|
-
export type
|
|
26403
|
-
export type
|
|
26404
|
-
export type
|
|
26405
|
-
export type
|
|
26406
|
-
export type
|
|
26407
|
-
export type
|
|
26408
|
-
export type
|
|
26409
|
-
export type
|
|
26410
|
-
export type
|
|
26411
|
-
export type
|
|
26412
|
-
export type
|
|
26413
|
-
export type
|
|
26414
|
-
export type
|
|
26415
|
-
export type
|
|
26416
|
-
export type
|
|
26417
|
-
export type
|
|
26418
|
-
export type
|
|
26419
|
-
export type
|
|
26420
|
-
export type
|
|
26421
|
-
export type
|
|
26422
|
-
export type
|
|
26423
|
-
export type
|
|
26424
|
-
export type
|
|
26348
|
+
type Primitive = string | number | boolean | bigint | null | undefined;
|
|
26349
|
+
type Flatten<T> = T extends Primitive ? T : T extends Array<infer U> ? Array<Flatten<U>> : T extends Set<infer U> ? Set<Flatten<U>> : T extends Map<infer K, infer V> ? Map<Flatten<K>, Flatten<V>> : T extends object ? {
|
|
26350
|
+
[K in keyof T]: Flatten<T[K]>;
|
|
26351
|
+
} : T;
|
|
26352
|
+
type Infer<Schema extends ZodTypeAny> = Flatten<z.infer<Schema>>;
|
|
26353
|
+
export type ProgressToken = Infer<typeof ProgressTokenSchema>;
|
|
26354
|
+
export type Cursor = Infer<typeof CursorSchema>;
|
|
26355
|
+
export type Request = Infer<typeof RequestSchema>;
|
|
26356
|
+
export type Notification = Infer<typeof NotificationSchema>;
|
|
26357
|
+
export type Result = Infer<typeof ResultSchema>;
|
|
26358
|
+
export type RequestId = Infer<typeof RequestIdSchema>;
|
|
26359
|
+
export type JSONRPCRequest = Infer<typeof JSONRPCRequestSchema>;
|
|
26360
|
+
export type JSONRPCNotification = Infer<typeof JSONRPCNotificationSchema>;
|
|
26361
|
+
export type JSONRPCResponse = Infer<typeof JSONRPCResponseSchema>;
|
|
26362
|
+
export type JSONRPCError = Infer<typeof JSONRPCErrorSchema>;
|
|
26363
|
+
export type JSONRPCMessage = Infer<typeof JSONRPCMessageSchema>;
|
|
26364
|
+
export type EmptyResult = Infer<typeof EmptyResultSchema>;
|
|
26365
|
+
export type CancelledNotification = Infer<typeof CancelledNotificationSchema>;
|
|
26366
|
+
export type Implementation = Infer<typeof ImplementationSchema>;
|
|
26367
|
+
export type ClientCapabilities = Infer<typeof ClientCapabilitiesSchema>;
|
|
26368
|
+
export type InitializeRequest = Infer<typeof InitializeRequestSchema>;
|
|
26369
|
+
export type ServerCapabilities = Infer<typeof ServerCapabilitiesSchema>;
|
|
26370
|
+
export type InitializeResult = Infer<typeof InitializeResultSchema>;
|
|
26371
|
+
export type InitializedNotification = Infer<typeof InitializedNotificationSchema>;
|
|
26372
|
+
export type PingRequest = Infer<typeof PingRequestSchema>;
|
|
26373
|
+
export type Progress = Infer<typeof ProgressSchema>;
|
|
26374
|
+
export type ProgressNotification = Infer<typeof ProgressNotificationSchema>;
|
|
26375
|
+
export type PaginatedRequest = Infer<typeof PaginatedRequestSchema>;
|
|
26376
|
+
export type PaginatedResult = Infer<typeof PaginatedResultSchema>;
|
|
26377
|
+
export type ResourceContents = Infer<typeof ResourceContentsSchema>;
|
|
26378
|
+
export type TextResourceContents = Infer<typeof TextResourceContentsSchema>;
|
|
26379
|
+
export type BlobResourceContents = Infer<typeof BlobResourceContentsSchema>;
|
|
26380
|
+
export type Resource = Infer<typeof ResourceSchema>;
|
|
26381
|
+
export type ResourceTemplate = Infer<typeof ResourceTemplateSchema>;
|
|
26382
|
+
export type ListResourcesRequest = Infer<typeof ListResourcesRequestSchema>;
|
|
26383
|
+
export type ListResourcesResult = Infer<typeof ListResourcesResultSchema>;
|
|
26384
|
+
export type ListResourceTemplatesRequest = Infer<typeof ListResourceTemplatesRequestSchema>;
|
|
26385
|
+
export type ListResourceTemplatesResult = Infer<typeof ListResourceTemplatesResultSchema>;
|
|
26386
|
+
export type ReadResourceRequest = Infer<typeof ReadResourceRequestSchema>;
|
|
26387
|
+
export type ReadResourceResult = Infer<typeof ReadResourceResultSchema>;
|
|
26388
|
+
export type ResourceListChangedNotification = Infer<typeof ResourceListChangedNotificationSchema>;
|
|
26389
|
+
export type SubscribeRequest = Infer<typeof SubscribeRequestSchema>;
|
|
26390
|
+
export type UnsubscribeRequest = Infer<typeof UnsubscribeRequestSchema>;
|
|
26391
|
+
export type ResourceUpdatedNotification = Infer<typeof ResourceUpdatedNotificationSchema>;
|
|
26392
|
+
export type PromptArgument = Infer<typeof PromptArgumentSchema>;
|
|
26393
|
+
export type Prompt = Infer<typeof PromptSchema>;
|
|
26394
|
+
export type ListPromptsRequest = Infer<typeof ListPromptsRequestSchema>;
|
|
26395
|
+
export type ListPromptsResult = Infer<typeof ListPromptsResultSchema>;
|
|
26396
|
+
export type GetPromptRequest = Infer<typeof GetPromptRequestSchema>;
|
|
26397
|
+
export type TextContent = Infer<typeof TextContentSchema>;
|
|
26398
|
+
export type ImageContent = Infer<typeof ImageContentSchema>;
|
|
26399
|
+
export type EmbeddedResource = Infer<typeof EmbeddedResourceSchema>;
|
|
26400
|
+
export type PromptMessage = Infer<typeof PromptMessageSchema>;
|
|
26401
|
+
export type GetPromptResult = Infer<typeof GetPromptResultSchema>;
|
|
26402
|
+
export type PromptListChangedNotification = Infer<typeof PromptListChangedNotificationSchema>;
|
|
26403
|
+
export type Tool = Infer<typeof ToolSchema>;
|
|
26404
|
+
export type ListToolsRequest = Infer<typeof ListToolsRequestSchema>;
|
|
26405
|
+
export type ListToolsResult = Infer<typeof ListToolsResultSchema>;
|
|
26406
|
+
export type CallToolResult = Infer<typeof CallToolResultSchema>;
|
|
26407
|
+
export type CompatibilityCallToolResult = Infer<typeof CompatibilityCallToolResultSchema>;
|
|
26408
|
+
export type CallToolRequest = Infer<typeof CallToolRequestSchema>;
|
|
26409
|
+
export type ToolListChangedNotification = Infer<typeof ToolListChangedNotificationSchema>;
|
|
26410
|
+
export type LoggingLevel = Infer<typeof LoggingLevelSchema>;
|
|
26411
|
+
export type SetLevelRequest = Infer<typeof SetLevelRequestSchema>;
|
|
26412
|
+
export type LoggingMessageNotification = Infer<typeof LoggingMessageNotificationSchema>;
|
|
26413
|
+
export type SamplingMessage = Infer<typeof SamplingMessageSchema>;
|
|
26414
|
+
export type CreateMessageRequest = Infer<typeof CreateMessageRequestSchema>;
|
|
26415
|
+
export type CreateMessageResult = Infer<typeof CreateMessageResultSchema>;
|
|
26416
|
+
export type ResourceReference = Infer<typeof ResourceReferenceSchema>;
|
|
26417
|
+
export type PromptReference = Infer<typeof PromptReferenceSchema>;
|
|
26418
|
+
export type CompleteRequest = Infer<typeof CompleteRequestSchema>;
|
|
26419
|
+
export type CompleteResult = Infer<typeof CompleteResultSchema>;
|
|
26420
|
+
export type Root = Infer<typeof RootSchema>;
|
|
26421
|
+
export type ListRootsRequest = Infer<typeof ListRootsRequestSchema>;
|
|
26422
|
+
export type ListRootsResult = Infer<typeof ListRootsResultSchema>;
|
|
26423
|
+
export type RootsListChangedNotification = Infer<typeof RootsListChangedNotificationSchema>;
|
|
26424
|
+
export type ClientRequest = Infer<typeof ClientRequestSchema>;
|
|
26425
|
+
export type ClientNotification = Infer<typeof ClientNotificationSchema>;
|
|
26426
|
+
export type ClientResult = Infer<typeof ClientResultSchema>;
|
|
26427
|
+
export type ServerRequest = Infer<typeof ServerRequestSchema>;
|
|
26428
|
+
export type ServerNotification = Infer<typeof ServerNotificationSchema>;
|
|
26429
|
+
export type ServerResult = Infer<typeof ServerResultSchema>;
|
|
26430
|
+
export {};
|
|
26425
26431
|
//# sourceMappingURL=types.d.ts.map
|