@modelcontextprotocol/server 2.0.0-alpha.2 → 2.0.0-alpha.4

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.
Files changed (36) hide show
  1. package/README.md +10 -3
  2. package/dist/{src-IKPjmxu7.mjs → ajvProvider-BQMcjynJ.mjs} +4147 -6749
  3. package/dist/ajvProvider-BQMcjynJ.mjs.map +1 -0
  4. package/dist/ajvProvider-Dzgk80kq.d.mts +1030 -0
  5. package/dist/ajvProvider-Dzgk80kq.d.mts.map +1 -0
  6. package/dist/cfWorkerProvider-BDC2rVl3.mjs +970 -0
  7. package/dist/cfWorkerProvider-BDC2rVl3.mjs.map +1 -0
  8. package/dist/cfWorkerProvider-DmvjVsvQ.d.mts +59 -0
  9. package/dist/cfWorkerProvider-DmvjVsvQ.d.mts.map +1 -0
  10. package/dist/chunk-BRhqBsOc.mjs +42 -0
  11. package/dist/{index-Bhfkexnj.d.mts → createMcpHandler-Du3hjXvf.d.mts} +4702 -2249
  12. package/dist/createMcpHandler-Du3hjXvf.d.mts.map +1 -0
  13. package/dist/index.d.mts +177 -833
  14. package/dist/index.d.mts.map +1 -1
  15. package/dist/index.mjs +1349 -2067
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/mcp-JttQJlI9.mjs +9998 -0
  18. package/dist/mcp-JttQJlI9.mjs.map +1 -0
  19. package/dist/shimsNode.d.mts +1 -1
  20. package/dist/shimsNode.mjs +1 -1
  21. package/dist/shimsWorkerd.d.mts +1 -1
  22. package/dist/shimsWorkerd.mjs +1 -1
  23. package/dist/shimsWorkerd.mjs.map +1 -1
  24. package/dist/stdio.d.mts +107 -0
  25. package/dist/stdio.d.mts.map +1 -0
  26. package/dist/stdio.mjs +561 -0
  27. package/dist/stdio.mjs.map +1 -0
  28. package/dist/types-DBYdVs-n.d.mts +1099 -0
  29. package/dist/types-DBYdVs-n.d.mts.map +1 -0
  30. package/dist/validators/ajv.d.mts +2 -0
  31. package/dist/validators/ajv.mjs +4 -0
  32. package/dist/validators/cfWorker.d.mts +2 -0
  33. package/dist/validators/cfWorker.mjs +3 -0
  34. package/package.json +33 -17
  35. package/dist/index-Bhfkexnj.d.mts.map +0 -1
  36. package/dist/src-IKPjmxu7.mjs.map +0 -1
@@ -1,3 +1,3 @@
1
- import { r as AjvJsonSchemaValidator } from "./index-Bhfkexnj.mjs";
1
+ import { t as AjvJsonSchemaValidator } from "./ajvProvider-Dzgk80kq.mjs";
2
2
  import process from "node:process";
3
3
  export { AjvJsonSchemaValidator as DefaultJsonSchemaValidator, process };
@@ -1,4 +1,4 @@
1
- import { r as AjvJsonSchemaValidator } from "./src-IKPjmxu7.mjs";
1
+ import { t as AjvJsonSchemaValidator } from "./ajvProvider-BQMcjynJ.mjs";
2
2
  import process from "node:process";
3
3
 
4
4
  export { AjvJsonSchemaValidator as DefaultJsonSchemaValidator, process };
@@ -1,4 +1,4 @@
1
- import { t as CfWorkerJsonSchemaValidator } from "./index-Bhfkexnj.mjs";
1
+ import { t as CfWorkerJsonSchemaValidator } from "./cfWorkerProvider-DmvjVsvQ.mjs";
2
2
 
3
3
  //#region src/shimsWorkerd.d.ts
4
4
 
@@ -1,4 +1,4 @@
1
- import { n as CfWorkerJsonSchemaValidator } from "./src-IKPjmxu7.mjs";
1
+ import { t as CfWorkerJsonSchemaValidator } from "./cfWorkerProvider-BDC2rVl3.mjs";
2
2
 
3
3
  //#region src/shimsWorkerd.ts
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"shimsWorkerd.mjs","names":[],"sources":["../src/shimsWorkerd.ts"],"sourcesContent":["/**\n * Cloudflare Workers runtime shims for server package\n *\n * This file is selected via package.json export conditions when running in workerd.\n */\nexport { CfWorkerJsonSchemaValidator as DefaultJsonSchemaValidator } from '@modelcontextprotocol/core';\n\n/**\n * Stub process object for non-Node.js environments.\n * StdioServerTransport is not supported in Cloudflare Workers/browser environments.\n */\nfunction notSupported(): never {\n throw new Error('StdioServerTransport is not supported in this environment. Use StreamableHTTPServerTransport instead.');\n}\n\nexport const process = {\n get stdin(): never {\n return notSupported();\n },\n get stdout(): never {\n return notSupported();\n }\n};\n"],"mappings":";;;;;;;AAWA,SAAS,eAAsB;AAC3B,OAAM,IAAI,MAAM,wGAAwG;;AAG5H,MAAa,UAAU;CACnB,IAAI,QAAe;AACf,SAAO,cAAc;;CAEzB,IAAI,SAAgB;AAChB,SAAO,cAAc;;CAE5B"}
1
+ {"version":3,"file":"shimsWorkerd.mjs","names":[],"sources":["../src/shimsWorkerd.ts"],"sourcesContent":["/**\n * Cloudflare Workers runtime shims for server package\n *\n * This file is selected via package.json export conditions when running in workerd.\n */\nexport { CfWorkerJsonSchemaValidator as DefaultJsonSchemaValidator } from '@modelcontextprotocol/core-internal/validators/cfWorker';\n\n/**\n * Stub process object for non-Node.js environments.\n * StdioServerTransport is not supported in Cloudflare Workers/browser environments.\n */\nfunction notSupported(): never {\n throw new Error('StdioServerTransport is not supported in this environment. Use StreamableHTTPServerTransport instead.');\n}\n\nexport const process = {\n get stdin(): never {\n return notSupported();\n },\n get stdout(): never {\n return notSupported();\n }\n};\n"],"mappings":";;;;;;;AAWA,SAAS,eAAsB;AAC3B,OAAM,IAAI,MAAM,wGAAwG;;AAG5H,MAAa,UAAU;CACnB,IAAI,QAAe;AACf,SAAO,cAAc;;CAEzB,IAAI,SAAgB;AAChB,SAAO,cAAc;;CAE5B"}
@@ -0,0 +1,107 @@
1
+ import { cr as JSONRPCMessage, o as McpServerFactory, rt as Transport } from "./createMcpHandler-Du3hjXvf.mjs";
2
+ import { Readable, Writable } from "node:stream";
3
+
4
+ //#region src/server/serveStdio.d.ts
5
+
6
+ /** Options for {@linkcode serveStdio}. */
7
+ interface ServeStdioOptions {
8
+ /**
9
+ * How a 2025-era opening (an `initialize` request, or any claim-less
10
+ * message) is handled:
11
+ *
12
+ * - `'serve'` (default) — the connection is pinned to a 2025-era instance
13
+ * from the same factory and served exactly as a hand-wired stdio server
14
+ * serves it today.
15
+ * - `'reject'` — the opening request is answered with the
16
+ * unsupported-protocol-version error naming the supported modern
17
+ * revisions (claim-less notifications are dropped); the connection
18
+ * stays open for a modern opening.
19
+ */
20
+ legacy?: 'serve' | 'reject';
21
+ /**
22
+ * Bring your own transport (for example a `StdioServerTransport`
23
+ * constructed over a Unix domain socket or TCP stream, per the stdio
24
+ * binding's custom-transport guidance). Defaults to a
25
+ * {@linkcode StdioServerTransport} over the current process's stdio. The
26
+ * entry owns the transport: it starts it, receives every inbound message,
27
+ * and closes it when the connection ends.
28
+ */
29
+ transport?: Transport;
30
+ /** Callback for out-of-band errors (reporting only; it never alters what is written to the wire). */
31
+ onerror?: (error: Error) => void;
32
+ /**
33
+ * Reject a new `subscriptions/listen` with `-32603` 'Subscription limit
34
+ * reached' (in-band, before the ack) when this many subscriptions are
35
+ * already open on this connection.
36
+ * @default 1024
37
+ */
38
+ maxSubscriptions?: number;
39
+ }
40
+ /** The handle returned by {@linkcode serveStdio}. */
41
+ interface StdioServerHandle {
42
+ /** Tears the connection down: closes the pinned instance (if any) and the underlying transport. */
43
+ close(): Promise<void>;
44
+ }
45
+ /**
46
+ * Serves MCP over stdio from a server factory, owning the era decision for
47
+ * the connection: the opening exchange selects the era, ONE instance from the
48
+ * factory is pinned for the connection lifetime, and everything after passes
49
+ * straight through to it. See the module documentation for the opening rules.
50
+ *
51
+ * ```ts
52
+ * import { serveStdio } from '@modelcontextprotocol/server/stdio';
53
+ *
54
+ * serveStdio(() => {
55
+ * const server = new McpServer({ name: 'my-server', version: '1.0.0' }, { capabilities: { tools: {} } });
56
+ * // register tools/resources/prompts once — the same factory serves both eras
57
+ * return server;
58
+ * });
59
+ * ```
60
+ */
61
+ declare function serveStdio(factory: McpServerFactory, options?: ServeStdioOptions): StdioServerHandle;
62
+ //#endregion
63
+ //#region src/server/stdio.d.ts
64
+ /**
65
+ * Server transport for stdio: this communicates with an MCP client by reading from the current process' `stdin` and writing to `stdout`.
66
+ *
67
+ * This transport is only available in Node.js environments.
68
+ *
69
+ * @example
70
+ * ```ts source="./stdio.examples.ts#StdioServerTransport_basicUsage"
71
+ * const server = new McpServer({ name: 'my-server', version: '1.0.0' });
72
+ * const transport = new StdioServerTransport();
73
+ * await server.connect(transport);
74
+ * ```
75
+ */
76
+ declare class StdioServerTransport implements Transport {
77
+ private _stdin;
78
+ private _stdout;
79
+ private _readBuffer;
80
+ private _started;
81
+ private _closed;
82
+ constructor(_stdin?: Readable, _stdout?: Writable, options?: {
83
+ /**
84
+ * Maximum size of the read buffer in bytes. If a single message exceeds
85
+ * this size the transport will emit an error and close.
86
+ *
87
+ * Defaults to 10 MB.
88
+ */
89
+ maxBufferSize?: number;
90
+ });
91
+ onclose?: () => void;
92
+ onerror?: (error: Error) => void;
93
+ onmessage?: (message: JSONRPCMessage) => void;
94
+ _ondata: (chunk: Buffer) => void;
95
+ _onerror: (error: Error) => void;
96
+ _onstdouterror: (error: Error) => void;
97
+ /**
98
+ * Starts listening for messages on `stdin`.
99
+ */
100
+ start(): Promise<void>;
101
+ private processReadBuffer;
102
+ close(): Promise<void>;
103
+ send(message: JSONRPCMessage): Promise<void>;
104
+ }
105
+ //#endregion
106
+ export { type ServeStdioOptions, type StdioServerHandle, StdioServerTransport, serveStdio };
107
+ //# sourceMappingURL=stdio.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdio.d.mts","names":[],"sources":["../src/server/serveStdio.ts","../src/server/stdio.ts"],"sourcesContent":[],"mappings":";;;;;;UAoFiB,iBAAA;;;;;;;;;;;;;;;;;;;;;;cAsBD;;oBAEM;;;;;;;;;;UAWL,iBAAA;;WAEJ;;;;;;;;;;;;;;;;;;iBA6PG,UAAA,UAAoB,4BAA2B,oBAAyB;;;;;AAlSxF;AAmCA;AA+PA;;;;;;;;ACpWa,cAAA,oBAAA,YAAgC,SAAX,CAAA;EAMV,QAAA,MAAA;EACC,QAAA,OAAA;EAeH,QAAA,WAAA;EACI,QAAA,QAAA;EAGJ,QAAA,OAAA;EASC,WAAA,CAAA,MAAA,CAAA,EA7BC,QA6BD,EAAA,OAAA,CAAA,EA5BE,QA4BF,EAAA,QAAA,EAAA;IAGM;;;;;;IAtCyB,aAAA,CAAA,EAAA,MAAA;;;oBAsBhC;wBACI;mBAGJ;oBASC;0BAGM;;;;WAUV;;WA4BA;gBAwBD,iBAAiB"}