@tmcp/transport-http 0.8.0 → 0.8.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/package.json +5 -5
- package/src/index.js +20 -19
- package/src/type-utils.d.ts +6 -0
- package/src/types/index.d.ts +4 -1
- package/src/types/index.d.ts.map +7 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tmcp/transport-http",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Transport for TMCP using HTTP",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"src/**/*"
|
|
17
17
|
],
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"tmcp": "^1.16.
|
|
19
|
+
"tmcp": "^1.16.3",
|
|
20
20
|
"@tmcp/auth": "^0.3.3"
|
|
21
21
|
},
|
|
22
22
|
"peerDependenciesMeta": {
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"esm-env": "^1.2.2",
|
|
39
|
-
"@tmcp/session-manager": "^0.2.
|
|
39
|
+
"@tmcp/session-manager": "^0.2.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@modelcontextprotocol/sdk": "^1.17.1",
|
|
43
|
-
"@remix-run/node-fetch-server": "^0.
|
|
43
|
+
"@remix-run/node-fetch-server": "^0.12.0",
|
|
44
44
|
"@types/node": "^24.0.15",
|
|
45
45
|
"dts-buddy": "^0.6.2",
|
|
46
46
|
"publint": "^0.3.12",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"vitest": "^4.0.0",
|
|
49
49
|
"@tmcp/adapter-valibot": "^0.1.4",
|
|
50
50
|
"@tmcp/auth": "^0.3.3",
|
|
51
|
-
"tmcp": "^1.16.
|
|
51
|
+
"tmcp": "^1.16.3"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
package/src/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* @import { AuthInfo, McpServer } from "tmcp";
|
|
3
3
|
* @import { OAuth } from "@tmcp/auth";
|
|
4
4
|
* @import { StreamSessionManager, InfoSessionManager } from "@tmcp/session-manager";
|
|
5
|
+
* @import { OptionalizeSessionManager } from "./type-utils.js"
|
|
5
6
|
*/
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
* path?: string | null
|
|
22
23
|
* oauth?: OAuth<"built">
|
|
23
24
|
* cors?: CorsConfig | boolean,
|
|
24
|
-
* sessionManager?: { streams?: StreamSessionManager, info?: InfoSessionManager }
|
|
25
|
+
* sessionManager?: { streams?: StreamSessionManager, info?: OptionalizeSessionManager<InfoSessionManager> }
|
|
25
26
|
* }} HttpTransportOptions
|
|
26
27
|
*/
|
|
27
28
|
|
|
@@ -128,10 +129,20 @@ export class HttpTransport {
|
|
|
128
129
|
);
|
|
129
130
|
});
|
|
130
131
|
|
|
131
|
-
this.#server.on('subscription', async ({ uri }) => {
|
|
132
|
+
this.#server.on('subscription', async ({ uri, action }) => {
|
|
132
133
|
const sessionId = this.#session_id_storage.getStore();
|
|
133
134
|
if (!sessionId) return;
|
|
134
|
-
|
|
135
|
+
if (action === 'remove') {
|
|
136
|
+
this.#options.sessionManager.info.removeSubscription?.(
|
|
137
|
+
sessionId,
|
|
138
|
+
uri,
|
|
139
|
+
);
|
|
140
|
+
} else {
|
|
141
|
+
this.#options.sessionManager.info.addSubscription(
|
|
142
|
+
sessionId,
|
|
143
|
+
uri,
|
|
144
|
+
);
|
|
145
|
+
}
|
|
135
146
|
});
|
|
136
147
|
|
|
137
148
|
this.#server.on('loglevelchange', ({ level }) => {
|
|
@@ -156,23 +167,13 @@ export class HttpTransport {
|
|
|
156
167
|
|
|
157
168
|
this.#server.on('send', async ({ request }) => {
|
|
158
169
|
// use the current controller if the request has an id (it means it's a request and not a notification)
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (!controller) return;
|
|
162
|
-
|
|
163
|
-
controller.enqueue(
|
|
164
|
-
this.#text_encoder.encode(
|
|
165
|
-
'data: ' + JSON.stringify(request) + '\n\n',
|
|
166
|
-
),
|
|
167
|
-
);
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
const session_id = this.#session_id_storage.getStore();
|
|
171
|
-
if (!session_id) return;
|
|
170
|
+
const controller = this.#controller_storage.getStore();
|
|
171
|
+
if (!controller) return;
|
|
172
172
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
173
|
+
controller.enqueue(
|
|
174
|
+
this.#text_encoder.encode(
|
|
175
|
+
'data: ' + JSON.stringify(request) + '\n\n',
|
|
176
|
+
),
|
|
176
177
|
);
|
|
177
178
|
});
|
|
178
179
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
|
|
2
|
+
import { InfoSessionManager } from "@tmcp/session-manager";
|
|
3
|
+
|
|
4
|
+
type ToOmit = 'removeSubscription';
|
|
5
|
+
|
|
6
|
+
export type OptionalizeSessionManager<TInfoSessionManager extends InfoSessionManager> = Omit<TInfoSessionManager, ToOmit> & Partial<Pick<TInfoSessionManager, ToOmit>>;
|
package/src/types/index.d.ts
CHANGED
|
@@ -24,9 +24,12 @@ declare module '@tmcp/transport-http' {
|
|
|
24
24
|
cors?: CorsConfig | boolean;
|
|
25
25
|
sessionManager?: {
|
|
26
26
|
streams?: StreamSessionManager;
|
|
27
|
-
info?: InfoSessionManager
|
|
27
|
+
info?: OptionalizeSessionManager<InfoSessionManager>;
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
+
type ToOmit = 'removeSubscription';
|
|
31
|
+
|
|
32
|
+
type OptionalizeSessionManager<TInfoSessionManager extends InfoSessionManager> = Omit<TInfoSessionManager, ToOmit> & Partial<Pick<TInfoSessionManager, ToOmit>>;
|
|
30
33
|
|
|
31
34
|
export {};
|
|
32
35
|
}
|
package/src/types/index.d.ts.map
CHANGED
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"file": "index.d.ts",
|
|
4
4
|
"names": [
|
|
5
|
-
"HttpTransport"
|
|
5
|
+
"HttpTransport",
|
|
6
|
+
"ToOmit",
|
|
7
|
+
"OptionalizeSessionManager"
|
|
6
8
|
],
|
|
7
9
|
"sources": [
|
|
8
|
-
"../index.js"
|
|
10
|
+
"../index.js",
|
|
11
|
+
"../type-utils.d.ts"
|
|
9
12
|
],
|
|
10
13
|
"sourcesContent": [
|
|
14
|
+
null,
|
|
11
15
|
null
|
|
12
16
|
],
|
|
13
|
-
"mappings": ";;;;
|
|
17
|
+
"mappings": ";;;;cAsCaA,aAAaA;;;;;;;;;;;;;;;;;;;;;;;;;MCnCrBC,MAAMA;;MAECC,yBAAyBA",
|
|
14
18
|
"ignoreList": []
|
|
15
19
|
}
|