@tmcp/transport-http 0.5.0 → 0.5.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 +4 -4
- package/src/index.js +14 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tmcp/transport-http",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
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.9.
|
|
19
|
+
"tmcp": "^1.9.1"
|
|
20
20
|
},
|
|
21
21
|
"keywords": [
|
|
22
22
|
"tmcp",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"valibot": "^1.1.0",
|
|
37
37
|
"vitest": "^3.2.4",
|
|
38
38
|
"@tmcp/adapter-valibot": "^0.1.3",
|
|
39
|
-
"@tmcp/auth": "^0.
|
|
40
|
-
"tmcp": "^1.9.
|
|
39
|
+
"@tmcp/auth": "^0.3.2",
|
|
40
|
+
"tmcp": "^1.9.1"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
package/src/index.js
CHANGED
|
@@ -47,6 +47,8 @@ export class HttpTransport {
|
|
|
47
47
|
*/
|
|
48
48
|
#oauth;
|
|
49
49
|
|
|
50
|
+
#text_encoder = new TextEncoder();
|
|
51
|
+
|
|
50
52
|
/**
|
|
51
53
|
*
|
|
52
54
|
* @param {McpServer<any>} server
|
|
@@ -72,16 +74,21 @@ export class HttpTransport {
|
|
|
72
74
|
// use the current controller if the request has an id (it means it's a request and not a notification)
|
|
73
75
|
if (request.id != null) {
|
|
74
76
|
const controller = this.#controller_storage.getStore();
|
|
75
|
-
if (!controller)
|
|
76
|
-
throw new Error('Controller not found in storage');
|
|
77
|
+
if (!controller) return;
|
|
77
78
|
|
|
78
|
-
controller.enqueue(
|
|
79
|
+
controller.enqueue(
|
|
80
|
+
this.#text_encoder.encode(
|
|
81
|
+
'data: ' + JSON.stringify(request) + '\n\n',
|
|
82
|
+
),
|
|
83
|
+
);
|
|
79
84
|
return;
|
|
80
85
|
}
|
|
81
86
|
for (let [session_id, controller] of this.#session.entries()) {
|
|
82
87
|
if (sessions === undefined || sessions.includes(session_id)) {
|
|
83
88
|
controller.enqueue(
|
|
84
|
-
|
|
89
|
+
this.#text_encoder.encode(
|
|
90
|
+
'data: ' + JSON.stringify(request) + '\n\n',
|
|
91
|
+
),
|
|
85
92
|
);
|
|
86
93
|
}
|
|
87
94
|
}
|
|
@@ -215,7 +222,9 @@ export class HttpTransport {
|
|
|
215
222
|
);
|
|
216
223
|
|
|
217
224
|
controller?.enqueue(
|
|
218
|
-
|
|
225
|
+
this.#text_encoder.encode(
|
|
226
|
+
'data: ' + JSON.stringify(response) + '\n\n',
|
|
227
|
+
),
|
|
219
228
|
);
|
|
220
229
|
controller?.close();
|
|
221
230
|
};
|