@tmcp/transport-http 0.4.0 → 0.4.2

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/package.json CHANGED
@@ -1,19 +1,22 @@
1
1
  {
2
2
  "name": "@tmcp/transport-http",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Transport for TMCP using HTTP",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
7
- "types": "src/index.d.ts",
7
+ "types": "src/types/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
- "types": "./src/index.d.ts",
10
+ "types": "./src/types/index.d.ts",
11
11
  "default": "./src/index.js"
12
12
  },
13
13
  "./package.json": "./package.json"
14
14
  },
15
+ "files": [
16
+ "src/**/*"
17
+ ],
15
18
  "peerDependencies": {
16
- "tmcp": "^1.7.1"
19
+ "tmcp": "^1.8.1"
17
20
  },
18
21
  "keywords": [
19
22
  "tmcp",
@@ -26,15 +29,21 @@
26
29
  "directory": "packages/transport-http"
27
30
  },
28
31
  "devDependencies": {
32
+ "@modelcontextprotocol/sdk": "^1.16.0",
29
33
  "@types/node": "^24.0.15",
34
+ "dts-buddy": "^0.6.2",
30
35
  "publint": "^0.3.12",
31
- "tmcp": "^1.7.1"
36
+ "valibot": "^1.1.0",
37
+ "vitest": "^3.2.4",
38
+ "@tmcp/adapter-valibot": "^0.1.3",
39
+ "tmcp": "^1.8.1"
32
40
  },
33
41
  "publishConfig": {
34
42
  "access": "public"
35
43
  },
36
44
  "scripts": {
37
- "generate:types": "tsc ./src/*.js --declaration --emitDeclarationOnly --target esnext --allowJs --moduleresolution nodenext --module nodenext && publint",
38
- "prepublish": "pnpm generate:types"
45
+ "generate:types": "dts-buddy && publint",
46
+ "prepublish": "pnpm generate:types",
47
+ "test": "vitest --run"
39
48
  }
40
49
  }
package/src/index.js CHANGED
@@ -189,17 +189,27 @@ export class HttpTransport {
189
189
  },
190
190
  });
191
191
 
192
- const response = await this.#controller_storage.run(
193
- controller,
194
- () => this.#server.receive(body, session_id),
195
- );
192
+ const handle = async () => {
193
+ const response = await this.#controller_storage.run(
194
+ controller,
195
+ () => this.#server.receive(body, session_id),
196
+ );
197
+
198
+ controller?.enqueue(
199
+ 'data: ' + JSON.stringify(response) + '\n\n',
200
+ );
201
+ controller?.close();
202
+ };
203
+
204
+ handle();
196
205
 
197
- controller?.enqueue('data: ' + JSON.stringify(response) + '\n\n');
198
- controller?.close();
206
+ const messages = Array.isArray(body) ? body : [body];
199
207
 
200
208
  // Determine status code based on response type
201
209
  // 202 Accepted for notifications/responses, 200 OK for standard requests
202
- const status = response == null || response.id == null ? 202 : 200;
210
+ const status = !messages.some((message) => message.id != null)
211
+ ? 202
212
+ : 200;
203
213
 
204
214
  return new Response(stream, {
205
215
  headers: {
@@ -0,0 +1,18 @@
1
+ declare module '@tmcp/transport-http' {
2
+ import type { McpServer } from 'tmcp';
3
+ export class HttpTransport {
4
+
5
+ constructor(server: McpServer<any>, options?: HttpTransportOptions);
6
+
7
+ respond(request: Request): Promise<Response | null>;
8
+ #private;
9
+ }
10
+ export type HttpTransportOptions = {
11
+ getSessionId?: () => string;
12
+ path?: string;
13
+ };
14
+
15
+ export {};
16
+ }
17
+
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,15 @@
1
+ {
2
+ "version": 3,
3
+ "file": "index.d.ts",
4
+ "names": [
5
+ "HttpTransport"
6
+ ],
7
+ "sources": [
8
+ "../index.js"
9
+ ],
10
+ "sourcesContent": [
11
+ null
12
+ ],
13
+ "mappings": ";;cAaaA,aAAaA",
14
+ "ignoreList": []
15
+ }
package/CHANGELOG.md DELETED
@@ -1,43 +0,0 @@
1
- # @tmcp/transport-http
2
-
3
- ## 0.4.0
4
-
5
- ### Minor Changes
6
-
7
- - 8f09cd2: fix: send requests back on the same stream if available
8
-
9
- ## 0.3.0
10
-
11
- ### Minor Changes
12
-
13
- - 3847654: fix: answer with conflict for second SSE connection
14
-
15
- ### Patch Changes
16
-
17
- - Updated dependencies [1b50780]
18
- - tmcp@1.7.1
19
-
20
- ## 0.2.1
21
-
22
- ### Patch Changes
23
-
24
- - f5d8390: fix: optional `getSessionId`
25
-
26
- ## 0.2.0
27
-
28
- ### Minor Changes
29
-
30
- - d12964e: breaking: correctly handle http requests
31
-
32
- ### Patch Changes
33
-
34
- - Updated dependencies [d921480]
35
- - tmcp@1.7.0
36
-
37
- ## 0.1.1
38
-
39
- ### Patch Changes
40
-
41
- - 41fb096: fix: use new sessions management
42
- - Updated dependencies [41fb096]
43
- - tmcp@1.4.0
package/jsconfig.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "esnext",
4
- "module": "nodenext",
5
- "moduleResolution": "nodenext",
6
- "allowJs": true,
7
- "checkJs": true,
8
- "declaration": true,
9
- "emitDeclarationOnly": false,
10
- "strict": true,
11
- "noEmit": true,
12
- "skipLibCheck": true
13
- },
14
- "include": ["src/**/*"],
15
- "exclude": ["node_modules"]
16
- }
package/src/index.d.ts DELETED
@@ -1,20 +0,0 @@
1
- export class HttpTransport {
2
- /**
3
- *
4
- * @param {McpServer<any>} server
5
- * @param {HttpTransportOptions} [options]
6
- */
7
- constructor(server: McpServer<any>, options?: HttpTransportOptions);
8
- /**
9
- *
10
- * @param {Request} request
11
- * @returns {Promise<Response | null>}
12
- */
13
- respond(request: Request): Promise<Response | null>;
14
- #private;
15
- }
16
- export type HttpTransportOptions = {
17
- getSessionId?: () => string;
18
- path?: string;
19
- };
20
- import type { McpServer } from "tmcp";