@alcyone-labs/arg-parser 1.1.0 → 2.0.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.
Files changed (105) hide show
  1. package/README.md +460 -1179
  2. package/dist/assets/.dxtignore.template +38 -0
  3. package/dist/assets/logo_1_small.jpg +0 -0
  4. package/dist/assets/tsdown.dxt.config.ts +37 -0
  5. package/dist/index.cjs +23702 -2315
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.min.mjs +16360 -1725
  8. package/dist/index.min.mjs.map +1 -1
  9. package/dist/index.mjs +23694 -2315
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/src/config/ConfigurationManager.d.ts +74 -0
  12. package/dist/src/config/ConfigurationManager.d.ts.map +1 -0
  13. package/dist/src/config/plugins/ConfigPlugin.d.ts +60 -0
  14. package/dist/src/config/plugins/ConfigPlugin.d.ts.map +1 -0
  15. package/dist/src/config/plugins/ConfigPluginRegistry.d.ts +72 -0
  16. package/dist/src/config/plugins/ConfigPluginRegistry.d.ts.map +1 -0
  17. package/dist/src/config/plugins/TomlConfigPlugin.d.ts +30 -0
  18. package/dist/src/config/plugins/TomlConfigPlugin.d.ts.map +1 -0
  19. package/dist/src/config/plugins/YamlConfigPlugin.d.ts +29 -0
  20. package/dist/src/config/plugins/YamlConfigPlugin.d.ts.map +1 -0
  21. package/dist/src/config/plugins/index.d.ts +5 -0
  22. package/dist/src/config/plugins/index.d.ts.map +1 -0
  23. package/dist/src/core/ArgParser.d.ts +332 -0
  24. package/dist/src/core/ArgParser.d.ts.map +1 -0
  25. package/dist/src/{ArgParserBase.d.ts → core/ArgParserBase.d.ts} +84 -3
  26. package/dist/src/core/ArgParserBase.d.ts.map +1 -0
  27. package/dist/src/core/FlagManager.d.ts.map +1 -0
  28. package/dist/src/{types.d.ts → core/types.d.ts} +40 -0
  29. package/dist/src/core/types.d.ts.map +1 -0
  30. package/dist/src/dxt/DxtGenerator.d.ts +115 -0
  31. package/dist/src/dxt/DxtGenerator.d.ts.map +1 -0
  32. package/dist/src/index.d.ts +10 -6
  33. package/dist/src/index.d.ts.map +1 -1
  34. package/dist/src/mcp/ArgParserMcp.d.ts +21 -0
  35. package/dist/src/mcp/ArgParserMcp.d.ts.map +1 -0
  36. package/dist/src/mcp/mcp-integration.d.ts +83 -0
  37. package/dist/src/mcp/mcp-integration.d.ts.map +1 -0
  38. package/dist/src/mcp/mcp-notifications.d.ts +138 -0
  39. package/dist/src/mcp/mcp-notifications.d.ts.map +1 -0
  40. package/dist/src/mcp/mcp-prompts.d.ts +132 -0
  41. package/dist/src/mcp/mcp-prompts.d.ts.map +1 -0
  42. package/dist/src/mcp/mcp-resources.d.ts +133 -0
  43. package/dist/src/mcp/mcp-resources.d.ts.map +1 -0
  44. package/dist/src/testing/fuzzy-test-cli.d.ts +5 -0
  45. package/dist/src/testing/fuzzy-test-cli.d.ts.map +1 -0
  46. package/dist/src/{fuzzy-tester.d.ts → testing/fuzzy-tester.d.ts} +1 -1
  47. package/dist/src/testing/fuzzy-tester.d.ts.map +1 -0
  48. package/package.json +51 -17
  49. package/dist/examples/fuzzy-demo.d.ts +0 -8
  50. package/dist/examples/fuzzy-demo.d.ts.map +0 -1
  51. package/dist/examples/fuzzy-test-example.d.ts +0 -8
  52. package/dist/examples/fuzzy-test-example.d.ts.map +0 -1
  53. package/dist/examples/fzf-search-cli.d.ts +0 -8
  54. package/dist/examples/fzf-search-cli.d.ts.map +0 -1
  55. package/dist/examples/getting-started.d.ts +0 -27
  56. package/dist/examples/getting-started.d.ts.map +0 -1
  57. package/dist/examples/mcp-preset-transports.d.ts +0 -19
  58. package/dist/examples/mcp-preset-transports.d.ts.map +0 -1
  59. package/dist/examples/simple-cli.d.ts +0 -26
  60. package/dist/examples/simple-cli.d.ts.map +0 -1
  61. package/dist/examples/v1.1.0-showcase.d.ts +0 -16
  62. package/dist/examples/v1.1.0-showcase.d.ts.map +0 -1
  63. package/dist/examples/with-env-example.d.ts +0 -3
  64. package/dist/examples/with-env-example.d.ts.map +0 -1
  65. package/dist/index-6G9StDO_.js +0 -6445
  66. package/dist/index-6G9StDO_.js.map +0 -1
  67. package/dist/index-CqU7Fj3C.cjs +0 -6444
  68. package/dist/index-CqU7Fj3C.cjs.map +0 -1
  69. package/dist/index-Dx_q1msW.js +0 -4682
  70. package/dist/index-Dx_q1msW.js.map +0 -1
  71. package/dist/src/ArgParser.d.ts +0 -156
  72. package/dist/src/ArgParser.d.ts.map +0 -1
  73. package/dist/src/ArgParserBase.d.ts.map +0 -1
  74. package/dist/src/FlagManager.d.ts.map +0 -1
  75. package/dist/src/fuzzy-test-cli.d.ts +0 -5
  76. package/dist/src/fuzzy-test-cli.d.ts.map +0 -1
  77. package/dist/src/fuzzy-tester.d.ts.map +0 -1
  78. package/dist/src/mcp-integration.d.ts +0 -31
  79. package/dist/src/mcp-integration.d.ts.map +0 -1
  80. package/dist/src/types.d.ts.map +0 -1
  81. package/dist/sse-B5Jf_YpG.cjs +0 -121
  82. package/dist/sse-B5Jf_YpG.cjs.map +0 -1
  83. package/dist/sse-BDL3h2Ll.js +0 -121
  84. package/dist/sse-BDL3h2Ll.js.map +0 -1
  85. package/dist/sse-DSjLfGFo.js +0 -107
  86. package/dist/sse-DSjLfGFo.js.map +0 -1
  87. package/dist/stdio-Cf19UQO7.js +0 -70
  88. package/dist/stdio-Cf19UQO7.js.map +0 -1
  89. package/dist/stdio-DESvSONI.cjs +0 -94
  90. package/dist/stdio-DESvSONI.cjs.map +0 -1
  91. package/dist/stdio-DLOResWr.js +0 -94
  92. package/dist/stdio-DLOResWr.js.map +0 -1
  93. package/dist/streamableHttp-DXIdDSbF.js +0 -342
  94. package/dist/streamableHttp-DXIdDSbF.js.map +0 -1
  95. package/dist/streamableHttp-DsXlAnqJ.cjs +0 -456
  96. package/dist/streamableHttp-DsXlAnqJ.cjs.map +0 -1
  97. package/dist/streamableHttp-Vd4Qsgko.js +0 -456
  98. package/dist/streamableHttp-Vd4Qsgko.js.map +0 -1
  99. package/dist/types-DSxPEImy.cjs +0 -943
  100. package/dist/types-DSxPEImy.cjs.map +0 -1
  101. package/dist/types-DdsPVLQ5.js +0 -846
  102. package/dist/types-DdsPVLQ5.js.map +0 -1
  103. package/dist/types-DpK81FWv.js +0 -944
  104. package/dist/types-DpK81FWv.js.map +0 -1
  105. /package/dist/src/{FlagManager.d.ts → core/FlagManager.d.ts} +0 -0
@@ -1,156 +0,0 @@
1
- import { ArgParserBase } from "./ArgParserBase";
2
- import type { GenerateMcpToolsOptions, IMcpToolStructure } from "./mcp-integration";
3
- /**
4
- * Configuration for a single MCP transport
5
- */
6
- export type McpTransportConfig = {
7
- type: "stdio" | "sse" | "streamable-http";
8
- port?: number;
9
- host?: string;
10
- path?: string;
11
- sessionIdGenerator?: () => string;
12
- };
13
- /**
14
- * Configuration options for MCP sub-command
15
- */
16
- export type McpSubCommandOptions = {
17
- /** Preset transport configurations to use when no CLI flags are provided */
18
- defaultTransports?: McpTransportConfig[];
19
- /** Single preset transport configuration (alternative to defaultTransports) */
20
- defaultTransport?: McpTransportConfig;
21
- };
22
- /**
23
- * ArgParser with Model Context Protocol (MCP) integration capabilities.
24
- *
25
- * This class adds MCP server functionality on top of the standard ArgParser,
26
- * allowing CLI tools to be easily exposed as MCP tools with minimal boilerplate.
27
- *
28
- * @example
29
- * ```typescript
30
- * const parser = new ArgParser({
31
- * appName: "My CLI",
32
- * appCommandName: "my-cli",
33
- * handler: async (ctx) => ({ result: "success" })
34
- * })
35
- * .addFlags([...])
36
- * .addMcpSubCommand("serve", {
37
- * name: "my-cli-mcp-server",
38
- * version: "1.0.0"
39
- * });
40
- * ```
41
- */
42
- export declare class ArgParser<THandlerReturn = any> extends ArgParserBase<THandlerReturn> {
43
- #private;
44
- /**
45
- * Generate MCP tools from this ArgParser instance
46
- * @param options Optional configuration for MCP tool generation
47
- * @returns Array of MCP tool structures ready for server registration
48
- */
49
- toMcpTools(options?: GenerateMcpToolsOptions): IMcpToolStructure[];
50
- /**
51
- * Create an MCP server with tools generated from this ArgParser
52
- * @param serverInfo Server configuration
53
- * @param toolOptions Optional MCP tool generation options
54
- * @returns Configured MCP server instance
55
- */
56
- createMcpServer(serverInfo: {
57
- name: string;
58
- version: string;
59
- description?: string;
60
- }, toolOptions?: GenerateMcpToolsOptions): any;
61
- /**
62
- * Start an MCP server using stdio transport
63
- * @param serverInfo Server configuration
64
- * @param toolOptions Optional MCP tool generation options
65
- * @returns Promise that resolves when server is connected
66
- */
67
- startMcpServer(serverInfo: {
68
- name: string;
69
- version: string;
70
- description?: string;
71
- }, toolOptions?: GenerateMcpToolsOptions): Promise<void>;
72
- /**
73
- * Start an MCP server with multiple transport types simultaneously
74
- * @param serverInfo Server configuration
75
- * @param transports Array of transport configurations
76
- * @param toolOptions Optional MCP tool generation options
77
- * @returns Promise that resolves when all servers are started
78
- */
79
- startMcpServerWithMultipleTransports(serverInfo: {
80
- name: string;
81
- version: string;
82
- description?: string;
83
- }, transports: Array<{
84
- type: "stdio" | "sse" | "streamable-http";
85
- port?: number;
86
- host?: string;
87
- path?: string;
88
- sessionIdGenerator?: () => string;
89
- }>, toolOptions?: GenerateMcpToolsOptions): Promise<void>;
90
- /**
91
- * Start an MCP server with a specific transport type
92
- * @param serverInfo Server configuration
93
- * @param transportType Type of transport to use
94
- * @param transportOptions Transport-specific options
95
- * @param toolOptions Optional MCP tool generation options
96
- * @returns Promise that resolves when server is connected
97
- */
98
- startMcpServerWithTransport(serverInfo: {
99
- name: string;
100
- version: string;
101
- description?: string;
102
- }, transportType: "stdio" | "sse" | "streamable-http", transportOptions?: {
103
- port?: number;
104
- host?: string;
105
- path?: string;
106
- sessionIdGenerator?: () => string;
107
- }, toolOptions?: GenerateMcpToolsOptions): Promise<void>;
108
- /**
109
- * Override parse() to handle async handlers properly
110
- * This allows ArgParser to work with async handlers while keeping
111
- * backwards compatibility for synchronous usage
112
- */
113
- parse(processArgs: string[], options?: any): any;
114
- /**
115
- * Async version of parse for when async handlers are detected
116
- */
117
- parseAsync(processArgs: string[], options?: any): Promise<any>;
118
- /**
119
- * Add an MCP sub-command that starts an MCP server exposing this parser's functionality
120
- * @param subCommandName Name of the sub-command (default: "mcp-server")
121
- * @param serverInfo Server configuration
122
- * @param options Optional configuration including preset transports and tool options
123
- * @returns This ArgParserWithMcp instance for chaining
124
- */
125
- addMcpSubCommand(subCommandName: string | undefined, serverInfo: {
126
- name: string;
127
- version: string;
128
- description?: string;
129
- }, options?: McpSubCommandOptions & {
130
- toolOptions?: GenerateMcpToolsOptions;
131
- }): this;
132
- /**
133
- * Add an MCP sub-command that starts an MCP server exposing this parser's functionality
134
- * @param subCommandName Name of the sub-command (default: "mcp-server")
135
- * @param serverInfo Server configuration
136
- * @param toolOptions Optional MCP tool generation options (backward compatibility)
137
- * @returns This ArgParserWithMcp instance for chaining
138
- * @deprecated Use the options parameter instead for better configurability
139
- */
140
- addMcpSubCommand(subCommandName: string | undefined, serverInfo: {
141
- name: string;
142
- version: string;
143
- description?: string;
144
- }, toolOptions?: GenerateMcpToolsOptions): this;
145
- /**
146
- * Factory method to create an ArgParser instance with MCP capabilities
147
- * This provides a clean API for users who want MCP functionality from the start
148
- */
149
- static withMcp<T = any>(options?: ConstructorParameters<typeof ArgParserBase>[0], initialFlags?: ConstructorParameters<typeof ArgParserBase>[1]): ArgParser<T>;
150
- /**
151
- * Convert an existing ArgParserBase instance to ArgParser with MCP
152
- * This allows upgrading existing parsers to support MCP
153
- */
154
- static fromArgParser<T = any>(parser: ArgParserBase<T>): ArgParser<T>;
155
- }
156
- //# sourceMappingURL=ArgParser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ArgParser.d.ts","sourceRoot":"","sources":["../../src/ArgParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhD,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGpF;;GAEG;AACH,MAAM,MAAM,k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Q,CAAC,KAAK,EAAE,SAAS,KAAK,EAAE,GAAG,IAAI;IAOvC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI9B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAIhD,IAAI,KAAK,IAAI,aAAa,EAAE,CAE3B;IAED,IAAI,SAAS,IAAI,MAAM,EAAE,CAExB;CACF"}
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- import { ArgParser } from "./ArgParser";
3
- declare const fuzzyTestCli: ArgParser<void>;
4
- export { fuzzyTestCli };
5
- //# sourceMappingURL=fuzzy-test-cli.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fuzzy-test-cli.d.ts","sourceRoot":"","sources":["../../src/fuzzy-test-cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAgBxC,QAAA,MAAM,YAAY,iBAmEhB,CAAC;AAkPH,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"fuzzy-tester.d.ts","sourceRoot":"","sources":["../../src/fuzzy-tester.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD,MAAM,WAAW,gBAAgB;IAC/B,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,4CAA4C;IAC5C,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,yDAAyD;IACzD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mCAAmC;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,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
@@ -1,31 +0,0 @@
1
- import type { ZodTypeAny } from "zod";
2
- import { ArgParserBase } from "./ArgParserBase";
3
- import type { ProcessedFlag, TParsedArgs } from "./";
4
- export interface IMcpToolStructure {
5
- name: string;
6
- description?: string;
7
- inputSchema: ZodTypeAny;
8
- outputSchema?: ZodTypeAny;
9
- execute: (args: any) => Promise<any>;
10
- }
11
- export interface GenerateMcpToolsOptions {
12
- outputSchemaMap?: Record<string, ZodTypeAny>;
13
- defaultOutputSchema?: ZodTypeAny;
14
- generateToolName?: (commandPath: string[], appName?: string) => string;
15
- includeSubCommands?: boolean;
16
- toolNamePrefix?: string;
17
- toolNameSuffix?: string;
18
- }
19
- interface ISpecialParseResultProps {
20
- $commandChain?: string[];
21
- $error?: {
22
- type: string;
23
- message: string;
24
- details?: any;
25
- };
26
- handlerResponse?: any;
27
- }
28
- export type IParseExecutionResult = TParsedArgs<ProcessedFlag[]> & ISpecialParseResultProps;
29
- export declare function generateMcpToolsFromArgParser(rootParser: ArgParserBase, options?: GenerateMcpToolsOptions): IMcpToolStructure[];
30
- export {};
31
- //# sourceMappingURL=mcp-integration.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mcp-integration.d.ts","sourceRoot":"","sources":["../../src/mcp-integration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,KAAK,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAA0B,aAAa,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAK7E,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,UAAU,CAAC;IACxB,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACtC;AAqID,MAAM,WAAW,uBA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,wDAAwD;IACxD,IAAI,EAAE,mBAAmB,CAAC;IAC1B,yEAAyE;IACzE,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAChC,8DAA8D;IAC9D,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,2FAA2F;IAC3F,MAAM,EAAE,iBAAiB,CAAC;IAC1B,wEAAwE;IACxE,YAAY,CAAC,EAAE,iBAAiB,CAAC;CAGlC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,aAAa,EAAE,CAAC;AAElD;;;;;GAKG;AACH,MAAM,WAAW,WAAW,CAC1B,gBAAgB,SAAS,UAAU,GAAG,UAAU,EAChD,mBAAmB,SAAS,UAAU,GAAG,UAAU,EACnD,cAAc,GAAG,GAAG;IAEpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAE5E,MAAM,EAAE,iBAAiB,CAAC;IAC1B,4CAA4C;IAC5C,OAAO,CAAC,EAAE,CACR,GAAG,EAAE,eAAe,CAClB,WAAW,CAAC,gBAAgB,CAAC,EAC7B,WAAW,CAAC,mBAAmB,CAAC,CACjC,KACE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC9C,0FAA0F;IAC1F,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,MAAM,WAAW,CACrB,YAAY,SAAS,UAAU,GAAG,UAAU,EAC5C,kBAAkB,SAAS,UAAU,GAAG,UAAU,EAClD,cAAc,GAAG,GAAG,IAClB,CACF,GAAG,EAAE,eAAe,CAClB,WAAW,CAAC,YAAY,CAAC,EACzB,WAAW,CAAC,kBAAkB,CAAC,CAChC,KACE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC"}
@@ -1,121 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const node_crypto = require("node:crypto");
4
- const types = require("./types-DSxPEImy.cjs");
5
- const index = require("./index-CqU7Fj3C.cjs");
6
- const url = require("url");
7
- const MAXIMUM_MESSAGE_SIZE = "4mb";
8
- class SSEServerTransport {
9
- /**
10
- * Creates a new SSE server transport, which will direct the client to POST messages to the relative or absolute URL identified by `_endpoint`.
11
- */
12
- constructor(_endpoint, res) {
13
- this._endpoint = _endpoint;
14
- this.res = res;
15
- this._sessionId = node_crypto.randomUUID();
16
- }
17
- /**
18
- * Handles the initial SSE connection request.
19
- *
20
- * This should be called when a GET request is made to establish the SSE stream.
21
- */
22
- async start() {
23
- if (this._sseResponse) {
24
- throw new Error("SSEServerTransport already started! If using Server class, note that connect() calls start() automatically.");
25
- }
26
- this.res.writeHead(200, {
27
- "Content-Type": "text/event-stream",
28
- "Cache-Control": "no-cache, no-transform",
29
- Connection: "keep-alive"
30
- });
31
- const dummyBase = "http://localhost";
32
- const endpointUrl = new url.URL(this._endpoint, dummyBase);
33
- endpointUrl.searchParams.set("sessionId", this._sessionId);
34
- const relativeUrlWithSession = endpointUrl.pathname + endpointUrl.search + endpointUrl.hash;
35
- this.res.write(`event: endpoint
36
- data: ${relativeUrlWithSession}
37
-
38
- `);
39
- this._sseResponse = this.res;
40
- this.res.on("close", () => {
41
- var _a;
42
- this._sseResponse = void 0;
43
- (_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);
44
- });
45
- }
46
- /**
47
- * Handles incoming POST messages.
48
- *
49
- * This should be called when a POST request is made to send a message to the server.
50
- */
51
- async handlePostMessage(req, res, parsedBody) {
52
- var _a, _b, _c;
53
- if (!this._sseResponse) {
54
- const message = "SSE connection not established";
55
- res.writeHead(500).end(message);
56
- throw new Error(message);
57
- }
58
- const authInfo = req.auth;
59
- let body;
60
- try {
61
- const ct = index.contentType.parse((_a = req.headers["content-type"]) !== null && _a !== void 0 ? _a : "");
62
- if (ct.type !== "application/json") {
63
- throw new Error(`Unsupported content-type: ${ct}`);
64
- }
65
- body = parsedBody !== null && parsedBody !== void 0 ? parsedBody : await index.getRawBody(req, {
66
- limit: MAXIMUM_MESSAGE_SIZE,
67
- encoding: (_b = ct.parameters.charset) !== null && _b !== void 0 ? _b : "utf-8"
68
- });
69
- } catch (error) {
70
- res.writeHead(400).end(String(error));
71
- (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);
72
- return;
73
- }
74
- try {
75
- await this.handleMessage(typeof body === "string" ? JSON.parse(body) : body, { authInfo });
76
- } catch (_d) {
77
- res.writeHead(400).end(`Invalid message: ${body}`);
78
- return;
79
- }
80
- res.writeHead(202).end("Accepted");
81
- }
82
- /**
83
- * Handle a client message, regardless of how it arrived. This can be used to inform the server of messages that arrive via a means different than HTTP POST.
84
- */
85
- async handleMessage(message, extra) {
86
- var _a, _b;
87
- let parsedMessage;
88
- try {
89
- parsedMessage = types.JSONRPCMessageSchema.parse(message);
90
- } catch (error) {
91
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
92
- throw error;
93
- }
94
- (_b = this.onmessage) === null || _b === void 0 ? void 0 : _b.call(this, parsedMessage, extra);
95
- }
96
- async close() {
97
- var _a, _b;
98
- (_a = this._sseResponse) === null || _a === void 0 ? void 0 : _a.end();
99
- this._sseResponse = void 0;
100
- (_b = this.onclose) === null || _b === void 0 ? void 0 : _b.call(this);
101
- }
102
- async send(message) {
103
- if (!this._sseResponse) {
104
- throw new Error("Not connected");
105
- }
106
- this._sseResponse.write(`event: message
107
- data: ${JSON.stringify(message)}
108
-
109
- `);
110
- }
111
- /**
112
- * Returns the session ID for this transport.
113
- *
114
- * This can be used to route incoming POST requests.
115
- */
116
- get sessionId() {
117
- return this._sessionId;
118
- }
119
- }
120
- exports.SSEServerTransport = SSEServerTransport;
121
- //# sourceMappingURL=sse-B5Jf_YpG.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sse-B5Jf_YpG.cjs","sources":["../node_modules/.pnpm/@modelcontextprotocol+sdk@1.13.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sse.js"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { JSONRPCMessageSchema } from \"../types.js\";\nimport getRawBody from \"raw-body\";\nimport contentType from \"content-type\";\nimport { URL } from 'url';\nconst MAXIMUM_MESSAGE_SIZE = \"4mb\";\n/**\n * Server transport for SSE: this will send messages over an SSE connection and receive messages from HTTP POST requests.\n *\n * This transport is only available in Node.js environments.\n */\nexport class SSEServerTransport {\n /**\n * Creates a new SSE server transport, which will direct the client to POST messages to the relative or absolute URL identified by `_endpoint`.\n */\n constructor(_endpoint, res) {\n this._endpoint = _endpoint;\n this.res = res;\n this._sessionId = randomUUID();\n }\n /**\n * Handles the initial SSE connection request.\n *\n * This should be called when a GET request is made to establish the SSE stream.\n */\n async start() {\n if (this._sseResponse) {\n throw new Error(\"SSEServerTransport already started! If using Server class, note that connect() calls start() automatically.\");\n }\n this.res.writeHead(200, {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache, no-transform\",\n Connection: \"keep-alive\",\n });\n // Send the endpoint event\n // Use a dummy base URL because this._endpoint is relative.\n // This allows using URL/URLSearchParams for robust parameter handling.\n const dummyBase = 'http://localhost'; // Any valid base works\n const endpointUrl = new URL(this._endpoint, dummyBase);\n endpointUrl.searchParams.set('sessionId', this._sessionId);\n // Reconstruct the relative URL string (pathname + search + hash)\n const relativeUrlWithSession = endpointUrl.pathname + endpointUrl.search + endpointUrl.hash;\n this.res.write(`event: endpoint\\ndata: ${relativeUrlWithSession}\\n\\n`);\n this._sseResponse = this.res;\n this.res.on(\"close\", () => {\n var _a;\n this._sseResponse = undefined;\n (_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);\n });\n }\n /**\n * Handles incoming POST messages.\n *\n * This should be called when a POST request is made to send a message to the server.\n */\n async handlePostMessage(req, res, parsedBody) {\n var _a, _b, _c;\n if (!this._sseResponse) {\n const message = \"SSE connection not established\";\n res.writeHead(500).end(message);\n throw new Error(message);\n }\n const authInfo = req.auth;\n let body;\n try {\n const ct = contentType.parse((_a = req.headers[\"content-type\"]) !== null && _a !== void 0 ? _a : \"\");\n if (ct.type !== \"application/json\") {\n throw new Error(`Unsupported content-type: ${ct}`);\n }\n body = parsedBody !== null && parsedBody !== void 0 ? parsedBody : await getRawBody(req, {\n limit: MAXIMUM_MESSAGE_SIZE,\n encoding: (_b = ct.parameters.charset) !== null && _b !== void 0 ? _b : \"utf-8\",\n });\n }\n catch (error) {\n res.writeHead(400).end(String(error));\n (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);\n return;\n }\n try {\n await this.handleMessage(typeof body === 'string' ? JSON.parse(body) : body, { authInfo });\n }\n catch (_d) {\n res.writeHead(400).end(`Invalid message: ${body}`);\n return;\n }\n res.writeHead(202).end(\"Accepted\");\n }\n /**\n * Handle a client message, regardless of how it arrived. This can be used to inform the server of messages that arrive via a means different than HTTP POST.\n */\n async handleMessage(message, extra) {\n var _a, _b;\n let parsedMessage;\n try {\n parsedMessage = JSONRPCMessageSchema.parse(message);\n }\n catch (error) {\n (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);\n throw error;\n }\n (_b = this.onmessage) === null || _b === void 0 ? void 0 : _b.call(this, parsedMessage, extra);\n }\n async close() {\n var _a, _b;\n (_a = this._sseResponse) === null || _a === void 0 ? void 0 : _a.end();\n this._sseResponse = undefined;\n (_b = this.onclose) === null || _b === void 0 ? void 0 : _b.call(this);\n }\n async send(message) {\n if (!this._sseResponse) {\n throw new Error(\"Not connected\");\n }\n this._sseResponse.write(`event: message\\ndata: ${JSON.stringify(message)}\\n\\n`);\n }\n /**\n * Returns the session ID for this transport.\n *\n * This can be used to route incoming POST requests.\n */\n get sessionId() {\n return this._sessionId;\n }\n}\n//# sourceMappingURL=sse.js.map"],"names":["randomUUID","URL","contentType","getRawBody","JSONRPCMessageSchema"],"mappings":";;;;;;AAKA,MAAM,uBAAuB;AAMtB,MAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA,EAI5B,YAAY,WAAW,KAAK;AACxB,SAAK,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,SAAK,aAAa,MAAM;AAAA,QAAyB,KAAK,UAAU,OAAO,CAAC;AAAA;AAAA,CAAM;AAAA,EACtF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,YAAY;AACZ,WAAO,KAAK;AAAA,EACpB;AACA;;","x_google_ignoreList":[0]}
@@ -1,121 +0,0 @@
1
- import { randomUUID } from "node:crypto";
2
- import { J as JSONRPCMessageSchema } from "./types-DpK81FWv.js";
3
- import { c as contentType, g as getRawBody } from "./index-6G9StDO_.js";
4
- import { URL } from "url";
5
- const MAXIMUM_MESSAGE_SIZE = "4mb";
6
- class SSEServerTransport {
7
- /**
8
- * Creates a new SSE server transport, which will direct the client to POST messages to the relative or absolute URL identified by `_endpoint`.
9
- */
10
- constructor(_endpoint, res) {
11
- this._endpoint = _endpoint;
12
- this.res = res;
13
- this._sessionId = randomUUID();
14
- }
15
- /**
16
- * Handles the initial SSE connection request.
17
- *
18
- * This should be called when a GET request is made to establish the SSE stream.
19
- */
20
- async start() {
21
- if (this._sseResponse) {
22
- throw new Error("SSEServerTransport already started! If using Server class, note that connect() calls start() automatically.");
23
- }
24
- this.res.writeHead(200, {
25
- "Content-Type": "text/event-stream",
26
- "Cache-Control": "no-cache, no-transform",
27
- Connection: "keep-alive"
28
- });
29
- const dummyBase = "http://localhost";
30
- const endpointUrl = new URL(this._endpoint, dummyBase);
31
- endpointUrl.searchParams.set("sessionId", this._sessionId);
32
- const relativeUrlWithSession = endpointUrl.pathname + endpointUrl.search + endpointUrl.hash;
33
- this.res.write(`event: endpoint
34
- data: ${relativeUrlWithSession}
35
-
36
- `);
37
- this._sseResponse = this.res;
38
- this.res.on("close", () => {
39
- var _a;
40
- this._sseResponse = void 0;
41
- (_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);
42
- });
43
- }
44
- /**
45
- * Handles incoming POST messages.
46
- *
47
- * This should be called when a POST request is made to send a message to the server.
48
- */
49
- async handlePostMessage(req, res, parsedBody) {
50
- var _a, _b, _c;
51
- if (!this._sseResponse) {
52
- const message = "SSE connection not established";
53
- res.writeHead(500).end(message);
54
- throw new Error(message);
55
- }
56
- const authInfo = req.auth;
57
- let body;
58
- try {
59
- const ct = contentType.parse((_a = req.headers["content-type"]) !== null && _a !== void 0 ? _a : "");
60
- if (ct.type !== "application/json") {
61
- throw new Error(`Unsupported content-type: ${ct}`);
62
- }
63
- body = parsedBody !== null && parsedBody !== void 0 ? parsedBody : await getRawBody(req, {
64
- limit: MAXIMUM_MESSAGE_SIZE,
65
- encoding: (_b = ct.parameters.charset) !== null && _b !== void 0 ? _b : "utf-8"
66
- });
67
- } catch (error) {
68
- res.writeHead(400).end(String(error));
69
- (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);
70
- return;
71
- }
72
- try {
73
- await this.handleMessage(typeof body === "string" ? JSON.parse(body) : body, { authInfo });
74
- } catch (_d) {
75
- res.writeHead(400).end(`Invalid message: ${body}`);
76
- return;
77
- }
78
- res.writeHead(202).end("Accepted");
79
- }
80
- /**
81
- * Handle a client message, regardless of how it arrived. This can be used to inform the server of messages that arrive via a means different than HTTP POST.
82
- */
83
- async handleMessage(message, extra) {
84
- var _a, _b;
85
- let parsedMessage;
86
- try {
87
- parsedMessage = JSONRPCMessageSchema.parse(message);
88
- } catch (error) {
89
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
90
- throw error;
91
- }
92
- (_b = this.onmessage) === null || _b === void 0 ? void 0 : _b.call(this, parsedMessage, extra);
93
- }
94
- async close() {
95
- var _a, _b;
96
- (_a = this._sseResponse) === null || _a === void 0 ? void 0 : _a.end();
97
- this._sseResponse = void 0;
98
- (_b = this.onclose) === null || _b === void 0 ? void 0 : _b.call(this);
99
- }
100
- async send(message) {
101
- if (!this._sseResponse) {
102
- throw new Error("Not connected");
103
- }
104
- this._sseResponse.write(`event: message
105
- data: ${JSON.stringify(message)}
106
-
107
- `);
108
- }
109
- /**
110
- * Returns the session ID for this transport.
111
- *
112
- * This can be used to route incoming POST requests.
113
- */
114
- get sessionId() {
115
- return this._sessionId;
116
- }
117
- }
118
- export {
119
- SSEServerTransport
120
- };
121
- //# sourceMappingURL=sse-BDL3h2Ll.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sse-BDL3h2Ll.js","sources":["../node_modules/.pnpm/@modelcontextprotocol+sdk@1.13.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sse.js"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { JSONRPCMessageSchema } from \"../types.js\";\nimport getRawBody from \"raw-body\";\nimport contentType from \"content-type\";\nimport { URL } from 'url';\nconst MAXIMUM_MESSAGE_SIZE = \"4mb\";\n/**\n * Server transport for SSE: this will send messages over an SSE connection and receive messages from HTTP POST requests.\n *\n * This transport is only available in Node.js environments.\n */\nexport class SSEServerTransport {\n /**\n * Creates a new SSE server transport, which will direct the client to POST messages to the relative or absolute URL identified by `_endpoint`.\n */\n constructor(_endpoint, res) {\n this._endpoint = _endpoint;\n this.res = res;\n this._sessionId = randomUUID();\n }\n /**\n * Handles the initial SSE connection request.\n *\n * This should be called when a GET request is made to establish the SSE stream.\n */\n async start() {\n if (this._sseResponse) {\n throw new Error(\"SSEServerTransport already started! If using Server class, note that connect() calls start() automatically.\");\n }\n this.res.writeHead(200, {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache, no-transform\",\n Connection: \"keep-alive\",\n });\n // Send the endpoint event\n // Use a dummy base URL because this._endpoint is relative.\n // This allows using URL/URLSearchParams for robust parameter handling.\n const dummyBase = 'http://localhost'; // Any valid base works\n const endpointUrl = new URL(this._endpoint, dummyBase);\n endpointUrl.searchParams.set('sessionId', this._sessionId);\n // Reconstruct the relative URL string (pathname + search + hash)\n const relativeUrlWithSession = endpointUrl.pathname + endpointUrl.search + endpointUrl.hash;\n this.res.write(`event: endpoint\\ndata: ${relativeUrlWithSession}\\n\\n`);\n this._sseResponse = this.res;\n this.res.on(\"close\", () => {\n var _a;\n this._sseResponse = undefined;\n (_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);\n });\n }\n /**\n * Handles incoming POST messages.\n *\n * This should be called when a POST request is made to send a message to the server.\n */\n async handlePostMessage(req, res, parsedBody) {\n var _a, _b, _c;\n if (!this._sseResponse) {\n const message = \"SSE connection not established\";\n res.writeHead(500).end(message);\n throw new Error(message);\n }\n const authInfo = req.auth;\n let body;\n try {\n const ct = contentType.parse((_a = req.headers[\"content-type\"]) !== null && _a !== void 0 ? _a : \"\");\n if (ct.type !== \"application/json\") {\n throw new Error(`Unsupported content-type: ${ct}`);\n }\n body = parsedBody !== null && parsedBody !== void 0 ? parsedBody : await getRawBody(req, {\n limit: MAXIMUM_MESSAGE_SIZE,\n encoding: (_b = ct.parameters.charset) !== null && _b !== void 0 ? _b : \"utf-8\",\n });\n }\n catch (error) {\n res.writeHead(400).end(String(error));\n (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);\n return;\n }\n try {\n await this.handleMessage(typeof body === 'string' ? JSON.parse(body) : body, { authInfo });\n }\n catch (_d) {\n res.writeHead(400).end(`Invalid message: ${body}`);\n return;\n }\n res.writeHead(202).end(\"Accepted\");\n }\n /**\n * Handle a client message, regardless of how it arrived. This can be used to inform the server of messages that arrive via a means different than HTTP POST.\n */\n async handleMessage(message, extra) {\n var _a, _b;\n let parsedMessage;\n try {\n parsedMessage = JSONRPCMessageSchema.parse(message);\n }\n catch (error) {\n (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);\n throw error;\n }\n (_b = this.onmessage) === null || _b === void 0 ? void 0 : _b.call(this, parsedMessage, extra);\n }\n async close() {\n var _a, _b;\n (_a = this._sseResponse) === null || _a === void 0 ? void 0 : _a.end();\n this._sseResponse = undefined;\n (_b = this.onclose) === null || _b === void 0 ? void 0 : _b.call(this);\n }\n async send(message) {\n if (!this._sseResponse) {\n throw new Error(\"Not connected\");\n }\n this._sseResponse.write(`event: message\\ndata: ${JSON.stringify(message)}\\n\\n`);\n }\n /**\n * Returns the session ID for this transport.\n *\n * This can be used to route incoming POST requests.\n */\n get sessionId() {\n return this._sessionId;\n }\n}\n//# sourceMappingURL=sse.js.map"],"names":[],"mappings":";;;;AAKA,MAAM,uBAAuB;AAMtB,MAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA,EAI5B,YAAY,WAAW,KAAK;AACxB,SAAK,YAAY;AACjB,SAAK,MAAM;AACX,SAAK,aAAa,WAAU;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,MAAM,QAAQ;AACV,QAAI,KAAK,cAAc;AACnB,YAAM,IAAI,MAAM,6GAA6G;AAAA,IACzI;AACQ,SAAK,IAAI,UAAU,KAAK;AAAA,MACpB,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,MACjB,YAAY;AAAA,IACxB,CAAS;AAID,UAAM,YAAY;AAClB,UAAM,cAAc,IAAI,IAAI,KAAK,WAAW,SAAS;AACrD,gBAAY,aAAa,IAAI,aAAa,KAAK,UAAU;AAEzD,UAAM,yBAAyB,YAAY,WAAW,YAAY,SAAS,YAAY;AACvF,SAAK,IAAI,MAAM;AAAA,QAA0B,sBAAsB;AAAA;AAAA,CAAM;AACrE,SAAK,eAAe,KAAK;AACzB,SAAK,IAAI,GAAG,SAAS,MAAM;AACvB,UAAI;AACJ,WAAK,eAAe;AACpB,OAAC,KAAK,KAAK,aAAa,QAAQ,OAAO,SAAS,SAAS,GAAG,KAAK,IAAI;AAAA,IACjF,CAAS;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,MAAM,kBAAkB,KAAK,KAAK,YAAY;AAC1C,QAAI,IAAI,IAAI;AACZ,QAAI,CAAC,KAAK,cAAc;AACpB,YAAM,UAAU;AAChB,UAAI,UAAU,GAAG,EAAE,IAAI,OAAO;AAC9B,YAAM,IAAI,MAAM,OAAO;AAAA,IACnC;AACQ,UAAM,WAAW,IAAI;AACrB,QAAI;AACJ,QAAI;AACA,YAAM,KAAK,Y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ACpB,KAAC,KAAK,KAAK,aAAa,QAAQ,OAAO,SAAS,SAAS,GAAG,KAAK,IAAI;AAAA,EAC7E;AAAA,EACI,MAAM,KAAK,SAAS;AAChB,QAAI,CAAC,KAAK,cAAc;AACpB,YAAM,IAAI,MAAM,eAAe;AAAA,IAC3C;AACQ,SAAK,aAAa,MAAM;AAAA,QAAyB,KAAK,UAAU,OAAO,CAAC;AAAA;AAAA,CAAM;AAAA,EACtF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,YAAY;AACZ,WAAO,KAAK;AAAA,EACpB;AACA;","x_google_ignoreList":[0]}
@@ -1,107 +0,0 @@
1
- import { randomUUID as h } from "node:crypto";
2
- import { J as d } from "./types-DdsPVLQ5.js";
3
- import { c as l, g as p } from "./index-Dx_q1msW.js";
4
- import { URL as v } from "url";
5
- const m = "4mb";
6
- class g {
7
- /**
8
- * Creates a new SSE server transport, which will direct the client to POST messages to the relative or absolute URL identified by `_endpoint`.
9
- */
10
- constructor(s, e) {
11
- this._endpoint = s, this.res = e, this._sessionId = h();
12
- }
13
- /**
14
- * Handles the initial SSE connection request.
15
- *
16
- * This should be called when a GET request is made to establish the SSE stream.
17
- */
18
- async start() {
19
- if (this._sseResponse)
20
- throw new Error("SSEServerTransport already started! If using Server class, note that connect() calls start() automatically.");
21
- this.res.writeHead(200, {
22
- "Content-Type": "text/event-stream",
23
- "Cache-Control": "no-cache, no-transform",
24
- Connection: "keep-alive"
25
- });
26
- const s = "http://localhost", e = new v(this._endpoint, s);
27
- e.searchParams.set("sessionId", this._sessionId);
28
- const o = e.pathname + e.search + e.hash;
29
- this.res.write(`event: endpoint
30
- data: ${o}
31
-
32
- `), this._sseResponse = this.res, this.res.on("close", () => {
33
- var t;
34
- this._sseResponse = void 0, (t = this.onclose) === null || t === void 0 || t.call(this);
35
- });
36
- }
37
- /**
38
- * Handles incoming POST messages.
39
- *
40
- * This should be called when a POST request is made to send a message to the server.
41
- */
42
- async handlePostMessage(s, e, o) {
43
- var t, r, a;
44
- if (!this._sseResponse) {
45
- const n = "SSE connection not established";
46
- throw e.writeHead(500).end(n), new Error(n);
47
- }
48
- const c = s.auth;
49
- let i;
50
- try {
51
- const n = l.parse((t = s.headers["content-type"]) !== null && t !== void 0 ? t : "");
52
- if (n.type !== "application/json")
53
- throw new Error(`Unsupported content-type: ${n}`);
54
- i = o ?? await p(s, {
55
- limit: m,
56
- encoding: (r = n.parameters.charset) !== null && r !== void 0 ? r : "utf-8"
57
- });
58
- } catch (n) {
59
- e.writeHead(400).end(String(n)), (a = this.onerror) === null || a === void 0 || a.call(this, n);
60
- return;
61
- }
62
- try {
63
- await this.handleMessage(typeof i == "string" ? JSON.parse(i) : i, { authInfo: c });
64
- } catch {
65
- e.writeHead(400).end(`Invalid message: ${i}`);
66
- return;
67
- }
68
- e.writeHead(202).end("Accepted");
69
- }
70
- /**
71
- * Handle a client message, regardless of how it arrived. This can be used to inform the server of messages that arrive via a means different than HTTP POST.
72
- */
73
- async handleMessage(s, e) {
74
- var o, t;
75
- let r;
76
- try {
77
- r = d.parse(s);
78
- } catch (a) {
79
- throw (o = this.onerror) === null || o === void 0 || o.call(this, a), a;
80
- }
81
- (t = this.onmessage) === null || t === void 0 || t.call(this, r, e);
82
- }
83
- async close() {
84
- var s, e;
85
- (s = this._sseResponse) === null || s === void 0 || s.end(), this._sseResponse = void 0, (e = this.onclose) === null || e === void 0 || e.call(this);
86
- }
87
- async send(s) {
88
- if (!this._sseResponse)
89
- throw new Error("Not connected");
90
- this._sseResponse.write(`event: message
91
- data: ${JSON.stringify(s)}
92
-
93
- `);
94
- }
95
- /**
96
- * Returns the session ID for this transport.
97
- *
98
- * This can be used to route incoming POST requests.
99
- */
100
- get sessionId() {
101
- return this._sessionId;
102
- }
103
- }
104
- export {
105
- g as SSEServerTransport
106
- };
107
- //# sourceMappingURL=sse-DSjLfGFo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sse-DSjLfGFo.js","sources":["../node_modules/.pnpm/@modelcontextprotocol+sdk@1.13.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sse.js"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { JSONRPCMessageSchema } from \"../types.js\";\nimport getRawBody from \"raw-body\";\nimport contentType from \"content-type\";\nimport { URL } from 'url';\nconst MAXIMUM_MESSAGE_SIZE = \"4mb\";\n/**\n * Server transport for SSE: this will send messages over an SSE connection and receive messages from HTTP POST requests.\n *\n * This transport is only available in Node.js environments.\n */\nexport class SSEServerTransport {\n /**\n * Creates a new SSE server transport, which will direct the client to POST messages to the relative or absolute URL identified by `_endpoint`.\n */\n constructor(_endpoint, res) {\n this._endpoint = _endpoint;\n this.res = res;\n this._sessionId = randomUUID();\n }\n /**\n * Handles the initial SSE connection request.\n *\n * This should be called when a GET request is made to establish the SSE stream.\n */\n async start() {\n if (this._sseResponse) {\n throw new Error(\"SSEServerTransport already started! If using Server class, note that connect() calls start() automatically.\");\n }\n this.res.writeHead(200, {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache, no-transform\",\n Connection: \"keep-alive\",\n });\n // Send the endpoint event\n // Use a dummy base URL because this._endpoint is relative.\n // This allows using URL/URLSearchParams for robust parameter handling.\n const dummyBase = 'http://localhost'; // Any valid base works\n const endpointUrl = new URL(this._endpoint, dummyBase);\n endpointUrl.searchParams.set('sessionId', this._sessionId);\n // Reconstruct the relative URL string (pathname + search + hash)\n const relativeUrlWithSession = endpointUrl.pathname + endpointUrl.search + endpointUrl.hash;\n this.res.write(`event: endpoint\\ndata: ${relativeUrlWithSession}\\n\\n`);\n this._sseResponse = this.res;\n this.res.on(\"close\", () => {\n var _a;\n this._sseResponse = undefined;\n (_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);\n });\n }\n /**\n * Handles incoming POST messages.\n *\n * This should be called when a POST request is made to send a message to the server.\n */\n async handlePostMessage(req, res, parsedBody) {\n var _a, _b, _c;\n if (!this._sseResponse) {\n const message = \"SSE connection not established\";\n res.writeHead(500).end(message);\n throw new Error(message);\n }\n const authInfo = req.auth;\n let body;\n try {\n const ct = contentType.parse((_a = req.headers[\"content-type\"]) !== null && _a !== void 0 ? _a : \"\");\n if (ct.type !== \"application/json\") {\n throw new Error(`Unsupported content-type: ${ct}`);\n }\n body = parsedBody !== null && parsedBody !== void 0 ? parsedBody : await getRawBody(req, {\n limit: MAXIMUM_MESSAGE_SIZE,\n encoding: (_b = ct.parameters.charset) !== null && _b !== void 0 ? _b : \"utf-8\",\n });\n }\n catch (error) {\n res.writeHead(400).end(String(error));\n (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);\n return;\n }\n try {\n await this.handleMessage(typeof body === 'string' ? JSON.parse(body) : body, { authInfo });\n }\n catch (_d) {\n res.writeHead(400).end(`Invalid message: ${body}`);\n return;\n }\n res.writeHead(202).end(\"Accepted\");\n }\n /**\n * Handle a client message, regardless of how it arrived. This can be used to inform the server of messages that arrive via a means different than HTTP POST.\n */\n async handleMessage(message, extra) {\n var _a, _b;\n let parsedMessage;\n try {\n parsedMessage = JSONRPCMessageSchema.parse(message);\n }\n catch (error) {\n (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);\n throw error;\n }\n (_b = this.onmessage) === null || _b === void 0 ? void 0 : _b.call(this, parsedMessage, extra);\n }\n async close() {\n var _a, _b;\n (_a = this._sseResponse) === null || _a === void 0 ? void 0 : _a.end();\n this._sseResponse = undefined;\n (_b = this.onclose) === null || _b === void 0 ? void 0 : _b.call(this);\n }\n async send(message) {\n if (!this._sseResponse) {\n throw new Error(\"Not connected\");\n }\n this._sseResponse.write(`event: message\\ndata: ${JSON.stringify(message)}\\n\\n`);\n }\n /**\n * Returns the session ID for this transport.\n *\n * This can be used to route incoming POST requests.\n */\n get sessionId() {\n return this._sessionId;\n }\n}\n//# sourceMappingURL=sse.js.map"],"names":["MAXIMUM_MESSAGE_SIZE","SSEServerTransport","_endpoint","res","randomUUID","dummyBase","endpointUrl","URL","relativeUrlWithSession","_a","req","parsedBody","_b","_c","message","authInfo","body","ct","contentType","getRawBody","error","extra","parsedMessage","JSONRPCMessageSchema"],"mappings":";;;;AAKA,MAAMA,IAAuB;AAMtB,MAAMC,EAAmB;AAAA;AAAA;AAAA;AAAA,EAI5B,YAAYC,GAAWC,GAAK;AACxB,SAAK,YAAYD,GACjB,KAAK,MAAMC,GACX,KAAK,aAAaC,EAAU;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,MAAM,QAAQ;AACV,QAAI,KAAK;AACL,YAAM,IAAI,MAAM,6GAA6G;AAEjI,SAAK,IAAI,UAAU,KAAK;AAAA,MACpB,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,MACjB,YAAY;AAAA,IACxB,CAAS;AAID,UAAMC,IAAY,oBACZC,IAAc,IAAIC,EAAI,KAAK,WAAWF,CAAS;AACrD,IAAAC,EAAY,aAAa,IAAI,aAAa,KAAK,UAAU;AAEzD,UAAME,IAAyBF,EAAY,WAAWA,EAAY,SAASA,EAAY;AACvF,SAAK,IAAI,MAAM;AAAA,QAA0BE,CAAsB;AAAA;AAAA,CAAM,GACrE,KAAK,eAAe,KAAK,KACzB,KAAK,IAAI,GAAG,SAAS,MAAM;AACvB,UAAIC;AACJ,WAAK,eAAe,SACnBA,IAAK,KAAK,aAAa,QAAQA,MAAO,UAAkBA,EAAG,KAAK,IAAI;AAAA,IACjF,CAAS;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,MAAM,kBAAkBC,GAAKP,GAAKQ,GAAY;AAC1C,QAAIF,GAAIG,GAAIC;AACZ,QAAI,CAAC,KAAK,cAAc;AACpB,YAAMC,IAAU;AAChB,YAAAX,EAAI,UAAU,GAAG,EAAE,IAAIW,CAAO,GACxB,IAAI,MAAMA,CAAO;AAAA,IACnC;AACQ,UAAMC,IAAWL,EAAI;AACrB,QAAIM;AACJ,QAAI;AACA,YAAMC,IAAKC,EAAY,OAAOT,IAAKC,EAAI,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