@opentiny/next 0.0.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/LICENSE +21 -0
- package/README.md +1 -0
- package/client.js +369 -0
- package/package.json +25 -0
- package/server.js +219 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019-present, OpenTiny contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
OpenTiny NEXT
|
package/client.js
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { JSONRPCMessageSchema as L } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import { McpServer as G } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { Client as E } from "@modelcontextprotocol/sdk/client/index.js";
|
|
4
|
+
import { z as R } from "zod";
|
|
5
|
+
import { SSEClientTransport as D } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
6
|
+
import { StreamableHTTPClientTransport as Z } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
7
|
+
function d(r, t) {
|
|
8
|
+
const x = l();
|
|
9
|
+
return d = function(e, n) {
|
|
10
|
+
return e = e - (5798 + -1555 * -2 + -8483), x[e];
|
|
11
|
+
}, d(r, t);
|
|
12
|
+
}
|
|
13
|
+
const f = d;
|
|
14
|
+
(function(r, t) {
|
|
15
|
+
const x = d, e = r();
|
|
16
|
+
for (; ; )
|
|
17
|
+
try {
|
|
18
|
+
if (parseInt(x(457)) / 1 + -parseInt(x(462)) / 2 * (-parseInt(x(435)) / 3) + -parseInt(x(446)) / 4 + parseInt(x(443)) / 5 * (-parseInt(x(455)) / 6) + -parseInt(x(466)) / 7 * (-parseInt(x(431)) / 8) + parseInt(x(430)) / 9 * (-parseInt(x(463)) / 10) + parseInt(x(427)) / 11 * (-parseInt(x(450)) / 12) === t) break;
|
|
19
|
+
e.push(e.shift());
|
|
20
|
+
} catch {
|
|
21
|
+
e.push(e.shift());
|
|
22
|
+
}
|
|
23
|
+
})(l, 700627 + -132 * 2359);
|
|
24
|
+
function l() {
|
|
25
|
+
const r = ["4764UdwdOM", "KSmUX", "createChannelPair", "lprlU", "onclose", "2479686gjPOzS", "onmessage", "493467GsCYxh", "randomUUID", "1.0.0", "mcp-client", "eNzLV", "2awWUUf", "123690KoCruP", "port1", "KcgGf", "7490XpuFCp", "close", "send", "121kxxemZ", "parse", "_port", "531rMpYcy", "5672GJAyCg", "mcp-server", "RQiAv", "connect", "1917633HBFRij", "Cannot send on a closed MessageChannel Transport", "GESyW", "MessageChannel Transport already started! If using Client or Server class, note that connect() calls start() automatically.", "_started", "stringify", "onerror", "sessionId", "5KgRBLO", "Failed to parse message: ", "_sessionId", "1418600zQvqgX", "_closed", "start", "MessagePort error: "];
|
|
26
|
+
return l = function() {
|
|
27
|
+
return r;
|
|
28
|
+
}, l();
|
|
29
|
+
}
|
|
30
|
+
class h {
|
|
31
|
+
constructor(t, x) {
|
|
32
|
+
const e = d, n = { GESyW: function(a, s) {
|
|
33
|
+
return a || s;
|
|
34
|
+
} };
|
|
35
|
+
if (this[e(439)] = !1, this._closed = !1, n[e(437)](!t, !x)) throw new Error("MessagePort and sessionId are required");
|
|
36
|
+
this[e(429)] = t, this[e(445)] = x, this[e(429)][e(456)] = (a) => {
|
|
37
|
+
var c, o;
|
|
38
|
+
const s = e;
|
|
39
|
+
try {
|
|
40
|
+
const i = L[s(428)](a.data);
|
|
41
|
+
(c = this[s(456)]) == null || c.call(this, i);
|
|
42
|
+
} catch (i) {
|
|
43
|
+
const b = new Error(s(444) + i);
|
|
44
|
+
(o = this[s(441)]) == null || o.call(this, b);
|
|
45
|
+
}
|
|
46
|
+
}, this._port.onmessageerror = (a) => {
|
|
47
|
+
var o;
|
|
48
|
+
const s = e, c = new Error(s(449) + JSON[s(440)](a));
|
|
49
|
+
(o = this[s(441)]) == null || o.call(this, c);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
async [f(448)]() {
|
|
53
|
+
const t = f, x = { KcgGf: t(438), lprlU: "Cannot start a closed MessageChannel Transport" };
|
|
54
|
+
if (this[t(439)]) throw new Error(x[t(465)]);
|
|
55
|
+
if (this[t(447)]) throw new Error(x[t(453)]);
|
|
56
|
+
this[t(439)] = !0, this._port[t(448)]();
|
|
57
|
+
}
|
|
58
|
+
async [f(426)](t) {
|
|
59
|
+
const x = f, e = { KSmUX: function(n, a) {
|
|
60
|
+
return n(a);
|
|
61
|
+
}, RQiAv: x(436) };
|
|
62
|
+
if (this[x(447)]) throw new Error(e[x(433)]);
|
|
63
|
+
return new Promise((n, a) => {
|
|
64
|
+
var c;
|
|
65
|
+
const s = x;
|
|
66
|
+
try {
|
|
67
|
+
this[s(429)].postMessage(t), n();
|
|
68
|
+
} catch (o) {
|
|
69
|
+
const i = o instanceof Error ? o : new Error(String(o));
|
|
70
|
+
(c = this[s(441)]) == null || c.call(this, i), e[s(451)](a, i);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
async [f(425)]() {
|
|
75
|
+
var x;
|
|
76
|
+
const t = f;
|
|
77
|
+
this[t(447)] || (this[t(447)] = !0, this._port[t(425)](), (x = this[t(454)]) == null || x.call(this));
|
|
78
|
+
}
|
|
79
|
+
get [f(442)]() {
|
|
80
|
+
return this._sessionId;
|
|
81
|
+
}
|
|
82
|
+
static [f(452)]() {
|
|
83
|
+
const t = f, x = new MessageChannel(), e = crypto[t(458)]();
|
|
84
|
+
return [new h(x[t(464)], e), new h(x.port2, e)];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const Y = (r = () => {
|
|
88
|
+
}) => {
|
|
89
|
+
const t = f, x = { LdcbZ: t(432), RWaMs: t(460), eNzLV: function(o, i, b) {
|
|
90
|
+
return o(i, b);
|
|
91
|
+
} }, e = { prompts: {}, resources: {}, tools: {}, logging: {} }, n = new G({ name: x.LdcbZ, version: "1.0.0" }, { capabilities: e }), a = new E({ name: x.RWaMs, version: t(459) }), [s, c] = h[t(452)]();
|
|
92
|
+
return x[t(461)](r, n, R), n[t(434)](c), a[t(434)](s), { server: n, client: a };
|
|
93
|
+
};
|
|
94
|
+
function m() {
|
|
95
|
+
const r = ["dZsKq", "complete", "1502725XnlLTC", "1101600usBKvN", "resources/read", "2.0", "resources/list", "listPrompts", "MwbTE", "_client", "resources/templates/list", "1633935QzcGvG", "2724148UFeanL", "12eZtXdU", "zKeUL", "DumHR", "785422kiepnW", "call", "resources/unsubscribe", "10953ViJeCs", "ping", "unsubscribeResource", "getPrompt", "TrrDq", "setLoggingLevel", "onmessage", "iEjtz", "1482502TeKCuw", "16280BsGJPx", "logging/setLevel", "prompts/get", "zjAvw", "tools/list", "SADBi", "ubZKy", "yliVD", "resources/subscribe", "subscribeResource"];
|
|
96
|
+
return m = function() {
|
|
97
|
+
return r;
|
|
98
|
+
}, m();
|
|
99
|
+
}
|
|
100
|
+
(function(r, t) {
|
|
101
|
+
const x = p, e = r();
|
|
102
|
+
for (; ; )
|
|
103
|
+
try {
|
|
104
|
+
if (-parseInt(x(397)) / 1 + parseInt(x(408)) / 2 + -parseInt(x(422)) / 3 + -parseInt(x(393)) / 4 + -parseInt(x(392)) / 5 + parseInt(x(394)) / 6 * (-parseInt(x(421)) / 7) + parseInt(x(409)) / 8 * (parseInt(x(400)) / 9) === t) break;
|
|
105
|
+
e.push(e.shift());
|
|
106
|
+
} catch {
|
|
107
|
+
e.push(e.shift());
|
|
108
|
+
}
|
|
109
|
+
})(m, 628050);
|
|
110
|
+
const B = async (r, t) => {
|
|
111
|
+
const x = p, e = { SADBi: x(413), DumHR: x(391), ubZKy: x(385), zKeUL: x(417), zjAvw: x(399), TrrDq: x(411), yliVD: "completion/complete", xDswn: x(410), dZsKq: x(386) };
|
|
112
|
+
let n;
|
|
113
|
+
const { id: a, method: s, params: c } = t;
|
|
114
|
+
switch (s) {
|
|
115
|
+
case e[x(414)]:
|
|
116
|
+
n = await r[x(390)].listTools(c);
|
|
117
|
+
break;
|
|
118
|
+
case "tools/call":
|
|
119
|
+
n = await r._client.callTool(c);
|
|
120
|
+
break;
|
|
121
|
+
case x(387):
|
|
122
|
+
n = await r[x(390)].listResources(c);
|
|
123
|
+
break;
|
|
124
|
+
case e[x(396)]:
|
|
125
|
+
n = await r[x(390)].listResourceTemplates(c);
|
|
126
|
+
break;
|
|
127
|
+
case e[x(415)]:
|
|
128
|
+
n = await r[x(390)].readResource(c);
|
|
129
|
+
break;
|
|
130
|
+
case e[x(395)]:
|
|
131
|
+
n = await r[x(390)][x(418)](c);
|
|
132
|
+
break;
|
|
133
|
+
case e[x(412)]:
|
|
134
|
+
n = await r._client[x(402)](c);
|
|
135
|
+
break;
|
|
136
|
+
case e[x(404)]:
|
|
137
|
+
n = await r[x(390)][x(403)](c);
|
|
138
|
+
break;
|
|
139
|
+
case "prompts/list":
|
|
140
|
+
n = await r[x(390)][x(388)](c);
|
|
141
|
+
break;
|
|
142
|
+
case x(401):
|
|
143
|
+
n = await r[x(390)][x(401)]();
|
|
144
|
+
break;
|
|
145
|
+
case e[x(416)]:
|
|
146
|
+
n = await r._client[x(420)](c);
|
|
147
|
+
break;
|
|
148
|
+
case e.xDswn:
|
|
149
|
+
n = await r[x(390)][x(405)](c);
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
return n && await r.send({ result: n, jsonrpc: e[x(419)], id: a }), n;
|
|
153
|
+
}, W = (r) => {
|
|
154
|
+
const t = p, x = { MwbTE: function(n, a, s) {
|
|
155
|
+
return n(a, s);
|
|
156
|
+
}, iEjtz: function(n, a) {
|
|
157
|
+
return n === a;
|
|
158
|
+
} }, e = r[t(406)];
|
|
159
|
+
r[t(406)] = async (n) => {
|
|
160
|
+
const a = t;
|
|
161
|
+
if (r[a(390)]) {
|
|
162
|
+
const s = await x[a(389)](B, r, n);
|
|
163
|
+
x[a(407)](s, void 0) && e && e[a(398)](r, n);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
function p(r, t) {
|
|
168
|
+
const x = m();
|
|
169
|
+
return p = function(e, n) {
|
|
170
|
+
return e = e - (1 * 6661 + -1044 + -654 * 8), x[e];
|
|
171
|
+
}, p(r, t);
|
|
172
|
+
}
|
|
173
|
+
var I = v;
|
|
174
|
+
(function(r, t) {
|
|
175
|
+
for (var x = v, e = r(); ; )
|
|
176
|
+
try {
|
|
177
|
+
var n = -parseInt(x(263)) / 1 * (parseInt(x(254)) / 2) + -parseInt(x(250)) / 3 * (-parseInt(x(258)) / 4) + parseInt(x(256)) / 5 + -parseInt(x(252)) / 6 + -parseInt(x(251)) / 7 + -parseInt(x(259)) / 8 + parseInt(x(260)) / 9 * (parseInt(x(248)) / 10);
|
|
178
|
+
if (n === t) break;
|
|
179
|
+
e.push(e.shift());
|
|
180
|
+
} catch {
|
|
181
|
+
e.push(e.shift());
|
|
182
|
+
}
|
|
183
|
+
})(w, 569667);
|
|
184
|
+
function w() {
|
|
185
|
+
var r = ["9908RAWmuZ", "806928raUIFf", "188919HJdJIi", "get", "sessionId", "8733lkrysk", "730zOVKoE", "searchParams", "81XCPGEs", "6221306QPNCKR", "354804MqDtGl", "_endpoint", "50nEwqBE", "_startOrAuth", "1187640OJeJbF", "WmZgm"];
|
|
186
|
+
return w = function() {
|
|
187
|
+
return r;
|
|
188
|
+
}, w();
|
|
189
|
+
}
|
|
190
|
+
function v(r, t) {
|
|
191
|
+
var x = w();
|
|
192
|
+
return v = function(e, n) {
|
|
193
|
+
e = e - (-2367 + -2 * 1273 + 5161);
|
|
194
|
+
var a = x[e];
|
|
195
|
+
return a;
|
|
196
|
+
}, v(r, t);
|
|
197
|
+
}
|
|
198
|
+
class X extends D {
|
|
199
|
+
constructor(t, x, e) {
|
|
200
|
+
super(t, x), this._client = e;
|
|
201
|
+
}
|
|
202
|
+
[I(255)]() {
|
|
203
|
+
var t = I, x = { KlprW: function(e, n) {
|
|
204
|
+
return e(n);
|
|
205
|
+
} };
|
|
206
|
+
return x.KlprW(W, this), super[t(255)]();
|
|
207
|
+
}
|
|
208
|
+
get [I(262)]() {
|
|
209
|
+
var t = I, x = { WmZgm: t(262) };
|
|
210
|
+
return this[t(253)][t(249)][t(261)](x[t(257)]);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
var K = u;
|
|
214
|
+
(function(r, t) {
|
|
215
|
+
for (var x = u, e = r(); ; )
|
|
216
|
+
try {
|
|
217
|
+
var n = parseInt(x(230)) / 1 + -parseInt(x(223)) / 2 + parseInt(x(219)) / 3 * (-parseInt(x(227)) / 4) + -parseInt(x(222)) / 5 + parseInt(x(220)) / 6 * (parseInt(x(225)) / 7) + -parseInt(x(228)) / 8 * (parseInt(x(221)) / 9) + parseInt(x(229)) / 10 * (parseInt(x(226)) / 11);
|
|
218
|
+
if (n === t) break;
|
|
219
|
+
e.push(e.shift());
|
|
220
|
+
} catch {
|
|
221
|
+
e.push(e.shift());
|
|
222
|
+
}
|
|
223
|
+
})(g, -37 * 31790 + -183607 + -4462 * -479);
|
|
224
|
+
function g() {
|
|
225
|
+
var r = ["_handleSseStream", "7959EzTlkS", "30437cYBhBN", "4VMrUav", "3332944bXrvSc", "15710QHWiVc", "2372msSGdK", "_client", "3025299GtGxgI", "5028DRLNzc", "18ZTuYsY", "6086715mGnaWO", "2931324hbUmdd"];
|
|
226
|
+
return g = function() {
|
|
227
|
+
return r;
|
|
228
|
+
}, g();
|
|
229
|
+
}
|
|
230
|
+
function u(r, t) {
|
|
231
|
+
var x = g();
|
|
232
|
+
return u = function(e, n) {
|
|
233
|
+
e = e - (9830 + 653 * 3 + -11570);
|
|
234
|
+
var a = x[e];
|
|
235
|
+
return a;
|
|
236
|
+
}, u(r, t);
|
|
237
|
+
}
|
|
238
|
+
class q extends Z {
|
|
239
|
+
constructor(t, x, e) {
|
|
240
|
+
var n = u;
|
|
241
|
+
super(t, x), this[n(231)] = e;
|
|
242
|
+
}
|
|
243
|
+
[K(224)](t, x) {
|
|
244
|
+
var e = K, n = { LmWtX: function(a, s) {
|
|
245
|
+
return a(s);
|
|
246
|
+
} };
|
|
247
|
+
n.LmWtX(W, this), super[e(224)](t, x);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function y(r, t) {
|
|
251
|
+
const x = S();
|
|
252
|
+
return y = function(e, n) {
|
|
253
|
+
return e = e - (-895 * 6 + -3838 + -4658 * -2), x[e];
|
|
254
|
+
}, y(r, t);
|
|
255
|
+
}
|
|
256
|
+
const M = y;
|
|
257
|
+
(function(r, t) {
|
|
258
|
+
const x = y, e = r();
|
|
259
|
+
for (; ; )
|
|
260
|
+
try {
|
|
261
|
+
if (-parseInt(x(122)) / 1 * (-parseInt(x(120)) / 2) + parseInt(x(116)) / 3 * (-parseInt(x(109)) / 4) + parseInt(x(108)) / 5 * (-parseInt(x(114)) / 6) + -parseInt(x(123)) / 7 * (parseInt(x(124)) / 8) + parseInt(x(113)) / 9 * (parseInt(x(118)) / 10) + parseInt(x(112)) / 11 + -parseInt(x(121)) / 12 * (-parseInt(x(119)) / 13) === t) break;
|
|
262
|
+
e.push(e.shift());
|
|
263
|
+
} catch {
|
|
264
|
+
e.push(e.shift());
|
|
265
|
+
}
|
|
266
|
+
})(S, -2 * 48047 + 222569 + -12914);
|
|
267
|
+
const O = (r) => ({ requestInit: { headers: { Authorization: M(111) + r } }, eventSourceInit: { async fetch(t, x) {
|
|
268
|
+
const e = M, n = { zIsjM: function(s, c, o) {
|
|
269
|
+
return s(c, o);
|
|
270
|
+
} }, a = new Headers((x == null ? void 0 : x[e(110)]) || {});
|
|
271
|
+
return a[e(115)](e(117), e(111) + r), n.zIsjM(fetch, t, { ...x, headers: a });
|
|
272
|
+
} } });
|
|
273
|
+
function S() {
|
|
274
|
+
const r = ["76068npKzhx", "89474pKnAYj", "7JjBPYg", "750776iHWMKr", "50QfZiHM", "524764AqqOcM", "headers", "Bearer ", "731863CXhTWI", "3573YaybDZ", "95574WpuBnn", "set", "3SxnlyG", "authorization", "450guMjtf", "481IaDsSq", "4dIjvWv"];
|
|
275
|
+
return S = function() {
|
|
276
|
+
return r;
|
|
277
|
+
}, S();
|
|
278
|
+
}
|
|
279
|
+
function T() {
|
|
280
|
+
const r = ["6477370xyodVl", "Bearer ", "875669QtjGqe", "3MomDlc", "33qYDBOp", "232622BqWdTx", "3205265WNYSNo", "18sxptgk", "1592104SLKGtW", "randomUUID", "1511994JJGCEs", "1981652wBzRVJ", "15AdTEbV"];
|
|
281
|
+
return T = function() {
|
|
282
|
+
return r;
|
|
283
|
+
}, T();
|
|
284
|
+
}
|
|
285
|
+
const P = k;
|
|
286
|
+
(function(r, t) {
|
|
287
|
+
const x = k, e = r();
|
|
288
|
+
for (; ; )
|
|
289
|
+
try {
|
|
290
|
+
if (-parseInt(x(409)) / 1 + -parseInt(x(412)) / 2 * (-parseInt(x(410)) / 3) + parseInt(x(418)) / 4 * (-parseInt(x(406)) / 5) + parseInt(x(417)) / 6 + parseInt(x(413)) / 7 + parseInt(x(415)) / 8 * (parseInt(x(414)) / 9) + -parseInt(x(407)) / 10 * (-parseInt(x(411)) / 11) === t) break;
|
|
291
|
+
e.push(e.shift());
|
|
292
|
+
} catch {
|
|
293
|
+
e.push(e.shift());
|
|
294
|
+
}
|
|
295
|
+
})(T, 805534);
|
|
296
|
+
function k(r, t) {
|
|
297
|
+
const x = T();
|
|
298
|
+
return k = function(e, n) {
|
|
299
|
+
return e = e - (-4997 + 25 * 384 + -4197), x[e];
|
|
300
|
+
}, k(r, t);
|
|
301
|
+
}
|
|
302
|
+
const j = (r, t = crypto[P(416)]()) => ({ requestInit: { headers: { Authorization: P(408) + r, "streamable-session-id": t } } });
|
|
303
|
+
(function(r, t) {
|
|
304
|
+
const x = _, e = r();
|
|
305
|
+
for (; ; )
|
|
306
|
+
try {
|
|
307
|
+
if (parseInt(x(493)) / 1 + -parseInt(x(494)) / 2 + -parseInt(x(496)) / 3 * (parseInt(x(497)) / 4) + -parseInt(x(502)) / 5 + parseInt(x(490)) / 6 + parseInt(x(491)) / 7 * (-parseInt(x(498)) / 8) + parseInt(x(492)) / 9 === t) break;
|
|
308
|
+
e.push(e.shift());
|
|
309
|
+
} catch {
|
|
310
|
+
e.push(e.shift());
|
|
311
|
+
}
|
|
312
|
+
})(C, -1327556 * 1 + -1891652 + 4168627);
|
|
313
|
+
function _(r, t) {
|
|
314
|
+
const x = C();
|
|
315
|
+
return _ = function(e, n) {
|
|
316
|
+
return e = e - (11781 + 23 * -491), x[e];
|
|
317
|
+
}, _(r, t);
|
|
318
|
+
}
|
|
319
|
+
const Q = async ({ client: r, url: t, token: x }) => {
|
|
320
|
+
const e = _, n = { ILXUm: e(499), GdOxH: "1.0.0" }, a = new X(new URL(t), O(x), r);
|
|
321
|
+
return await new E({ name: n[e(501)], version: n[e(489)] })[e(500)](a), { transport: a, sessionId: a[e(495)] };
|
|
322
|
+
}, $ = async ({ client: r, url: t, token: x }) => {
|
|
323
|
+
const e = _, n = { pxTtH: function(o, i, b) {
|
|
324
|
+
return o(i, b);
|
|
325
|
+
} }, a = crypto.randomUUID(), s = new q(new URL(t), n[e(488)](j, x, a), r);
|
|
326
|
+
return await new E({ name: "mcp-client", version: "1.0.0" })[e(500)](s), { transport: s, sessionId: a };
|
|
327
|
+
};
|
|
328
|
+
function C() {
|
|
329
|
+
const r = ["20098845pduEUI", "1266070BIEvev", "2960640aWFIcr", "sessionId", "431259IFIole", "4upzvKF", "1288uqVgNC", "mcp-client", "connect", "ILXUm", "1398350mvgIbg", "pxTtH", "GdOxH", "933036cvTSLX", "34853wcPshd"];
|
|
330
|
+
return C = function() {
|
|
331
|
+
return r;
|
|
332
|
+
}, C();
|
|
333
|
+
}
|
|
334
|
+
function z(r, t) {
|
|
335
|
+
var x = U();
|
|
336
|
+
return z = function(e, n) {
|
|
337
|
+
e = e - (-1769 * -4 + -3075 + -3840);
|
|
338
|
+
var a = x[e];
|
|
339
|
+
return a;
|
|
340
|
+
}, z(r, t);
|
|
341
|
+
}
|
|
342
|
+
(function(r, t) {
|
|
343
|
+
for (var x = z, e = r(); ; )
|
|
344
|
+
try {
|
|
345
|
+
var n = -parseInt(x(170)) / 1 * (parseInt(x(166)) / 2) + parseInt(x(168)) / 3 + -parseInt(x(167)) / 4 + parseInt(x(164)) / 5 * (-parseInt(x(165)) / 6) + parseInt(x(163)) / 7 * (-parseInt(x(161)) / 8) + parseInt(x(162)) / 9 + -parseInt(x(169)) / 10 * (-parseInt(x(171)) / 11);
|
|
346
|
+
if (n === t) break;
|
|
347
|
+
e.push(e.shift());
|
|
348
|
+
} catch {
|
|
349
|
+
e.push(e.shift());
|
|
350
|
+
}
|
|
351
|
+
})(U, -129 * -3543 + 953 * 911 + -695742);
|
|
352
|
+
function U() {
|
|
353
|
+
var r = ["11ZXCyxZ", "32PZjlTj", "7631388OMSauB", "298375hCFbXJ", "937865gsxXxi", "36TQWUTK", "7508PIVzcw", "4573908NoOuyZ", "2353410hAUrVo", "19057510yZouFz", "125kHwzXL"];
|
|
354
|
+
return U = function() {
|
|
355
|
+
return r;
|
|
356
|
+
}, U();
|
|
357
|
+
}
|
|
358
|
+
export {
|
|
359
|
+
h as MessageChannelTransport,
|
|
360
|
+
X as ProxySSEClientTransport,
|
|
361
|
+
q as ProxyStreamableHTTPClientTransport,
|
|
362
|
+
Y as createClientServerPair,
|
|
363
|
+
Q as createSseProxy,
|
|
364
|
+
$ as createStreamableProxy,
|
|
365
|
+
B as forward,
|
|
366
|
+
W as fowardMessage,
|
|
367
|
+
O as sseOptions,
|
|
368
|
+
j as streamableOptions
|
|
369
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opentiny/next",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Chunhui Mo",
|
|
7
|
+
"files": [
|
|
8
|
+
"client.js",
|
|
9
|
+
"server.js"
|
|
10
|
+
],
|
|
11
|
+
"main": "client.js",
|
|
12
|
+
"module": "client.js",
|
|
13
|
+
"description": "OpenTiny NEXT",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@modelcontextprotocol/sdk": "^1.10.2",
|
|
16
|
+
"jsonwebtoken": "^9.0.2",
|
|
17
|
+
"zod": "^3.24.2"
|
|
18
|
+
},
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": "^18.0.0 || >=20.0.0"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/server.js
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import k from "jsonwebtoken";
|
|
2
|
+
import { McpServer as E } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { Client as T } from "@modelcontextprotocol/sdk/client/index.js";
|
|
4
|
+
import { SSEServerTransport as V } from "@modelcontextprotocol/sdk/server/sse.js";
|
|
5
|
+
import { StreamableHTTPServerTransport as J } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
6
|
+
import { isInitializeRequest as P } from "@modelcontextprotocol/sdk/types.js";
|
|
7
|
+
function v() {
|
|
8
|
+
const e = ["40ghLnek", "7980140dDASYG", "JvVNa", "DvCDG", "kfWRb", "prompts/get", "onmessage", "completion/complete", "send", "callTool", "setLoggingLevel", "resources/unsubscribe", "222hqihXy", "1678XyeuGi", "listPrompts", "tools/list", "logging/setLevel", "listTools", "8XxqwZi", "3051684ntcRnK", "NeBcV", "11716310OyJSdP", "resources/list", "RUQsw", "complete", "RqvEE", "43413BNLEOk", "call", "tools/call", "422886BXoftZ", "listResourceTemplates", "listResources", "332gnQqOU", "readResource", "LpDjz", "resources/read", "unsubscribeResource", "gbwvY", "resources/templates/list", "ping", "pvsVK", "lnGdZ", "20769705ecWcKi", "_client"];
|
|
9
|
+
return v = function() {
|
|
10
|
+
return e;
|
|
11
|
+
}, v();
|
|
12
|
+
}
|
|
13
|
+
function w(e, s) {
|
|
14
|
+
const x = v();
|
|
15
|
+
return w = function(t, a) {
|
|
16
|
+
return t = t - (-17 * -497 + 7 * 1387 + -17724), x[t];
|
|
17
|
+
}, w(e, s);
|
|
18
|
+
}
|
|
19
|
+
(function(e, s) {
|
|
20
|
+
const x = w, t = e();
|
|
21
|
+
for (; ; )
|
|
22
|
+
try {
|
|
23
|
+
if (parseInt(x(450)) / 1 * (parseInt(x(449)) / 2) + -parseInt(x(463)) / 3 * (parseInt(x(469)) / 4) + parseInt(x(437)) / 5 * (-parseInt(x(466)) / 6) + parseInt(x(438)) / 7 * (parseInt(x(455)) / 8) + parseInt(x(456)) / 9 + -parseInt(x(458)) / 10 + parseInt(x(435)) / 11 === s) break;
|
|
24
|
+
t.push(t.shift());
|
|
25
|
+
} catch {
|
|
26
|
+
t.push(t.shift());
|
|
27
|
+
}
|
|
28
|
+
})(v, 206 * -3206 + 572580 + 3 * 234931);
|
|
29
|
+
const j = async (e, s) => {
|
|
30
|
+
const x = w, t = { JLGsi: x(465), gbwvY: x(459), kfWRb: x(475), woBkd: x(472), JvVNa: x(442), NeBcV: "prompts/list", lnGdZ: x(476), RUQsw: x(444), DvCDG: x(453), pvsVK: "2.0" };
|
|
31
|
+
let a;
|
|
32
|
+
const { id: i, method: l, params: b } = s;
|
|
33
|
+
switch (l) {
|
|
34
|
+
case x(452):
|
|
35
|
+
a = await e[x(436)][x(454)](b);
|
|
36
|
+
break;
|
|
37
|
+
case t.JLGsi:
|
|
38
|
+
a = await e[x(436)][x(446)](b);
|
|
39
|
+
break;
|
|
40
|
+
case t[x(474)]:
|
|
41
|
+
a = await e[x(436)][x(468)](b);
|
|
42
|
+
break;
|
|
43
|
+
case t[x(441)]:
|
|
44
|
+
a = await e[x(436)][x(467)](b);
|
|
45
|
+
break;
|
|
46
|
+
case t.woBkd:
|
|
47
|
+
a = await e._client[x(470)](b);
|
|
48
|
+
break;
|
|
49
|
+
case "resources/subscribe":
|
|
50
|
+
a = await e[x(436)].subscribeResource(b);
|
|
51
|
+
break;
|
|
52
|
+
case x(448):
|
|
53
|
+
a = await e[x(436)][x(473)](b);
|
|
54
|
+
break;
|
|
55
|
+
case t[x(439)]:
|
|
56
|
+
a = await e[x(436)].getPrompt(b);
|
|
57
|
+
break;
|
|
58
|
+
case t[x(457)]:
|
|
59
|
+
a = await e[x(436)][x(451)](b);
|
|
60
|
+
break;
|
|
61
|
+
case t[x(434)]:
|
|
62
|
+
a = await e[x(436)][x(476)]();
|
|
63
|
+
break;
|
|
64
|
+
case t[x(460)]:
|
|
65
|
+
a = await e._client[x(461)](b);
|
|
66
|
+
break;
|
|
67
|
+
case t[x(440)]:
|
|
68
|
+
a = await e._client[x(447)](b);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
return a && await e[x(445)]({ result: a, jsonrpc: t[x(477)], id: i }), a;
|
|
72
|
+
}, G = (e) => {
|
|
73
|
+
const s = w, x = { LpDjz: function(a, i, l) {
|
|
74
|
+
return a(i, l);
|
|
75
|
+
}, RqvEE: function(a, i) {
|
|
76
|
+
return a === i;
|
|
77
|
+
} }, t = e[s(443)];
|
|
78
|
+
e[s(443)] = async (a) => {
|
|
79
|
+
const i = s;
|
|
80
|
+
if (e[i(436)]) {
|
|
81
|
+
const l = await x[i(471)](j, e, a);
|
|
82
|
+
x[i(462)](l, void 0) && t && t[i(464)](e, a);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
var D = I;
|
|
87
|
+
(function(e, s) {
|
|
88
|
+
for (var x = I, t = e(); ; )
|
|
89
|
+
try {
|
|
90
|
+
var a = -parseInt(x(436)) / 1 + -parseInt(x(442)) / 2 + -parseInt(x(437)) / 3 + -parseInt(x(439)) / 4 * (-parseInt(x(433)) / 5) + -parseInt(x(438)) / 6 * (-parseInt(x(444)) / 7) + parseInt(x(435)) / 8 * (parseInt(x(432)) / 9) + parseInt(x(440)) / 10 * (parseInt(x(441)) / 11);
|
|
91
|
+
if (a === s) break;
|
|
92
|
+
t.push(t.shift());
|
|
93
|
+
} catch {
|
|
94
|
+
t.push(t.shift());
|
|
95
|
+
}
|
|
96
|
+
})(_, 1 * 180938 + -164677 + 122845 * 1);
|
|
97
|
+
function _() {
|
|
98
|
+
var e = ["JbWIK", "7PvIdfa", "handleMessage", "7452kBaxsX", "5hAcjWQ", "_client", "264kiyxhA", "274715KWZWnr", "90723qFebmp", "1444614sGuODB", "42628QIsDgS", "1538770EIZnHd", "22iTKJpK", "284884YIVAfn"];
|
|
99
|
+
return _ = function() {
|
|
100
|
+
return e;
|
|
101
|
+
}, _();
|
|
102
|
+
}
|
|
103
|
+
function I(e, s) {
|
|
104
|
+
var x = _();
|
|
105
|
+
return I = function(t, a) {
|
|
106
|
+
t = t - (-35 * -213 + -98 * -17 + -8689);
|
|
107
|
+
var i = x[t];
|
|
108
|
+
return i;
|
|
109
|
+
}, I(e, s);
|
|
110
|
+
}
|
|
111
|
+
class Q extends V {
|
|
112
|
+
constructor(s, x, t) {
|
|
113
|
+
var a = I;
|
|
114
|
+
super(s, x), this[a(434)] = t;
|
|
115
|
+
}
|
|
116
|
+
async [D(445)](s) {
|
|
117
|
+
var x = D, t = { JbWIK: function(a, i) {
|
|
118
|
+
return a(i);
|
|
119
|
+
} };
|
|
120
|
+
t[x(443)](G, this), await super[x(445)](s);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const y = h;
|
|
124
|
+
function g() {
|
|
125
|
+
const e = ["VvQjC", "_notificationHandlers", "vVdrj", "close", "Invalid or missing session ID", "No transport found", "body", "initialize", "hXAGK", "verify", "user", "MoeVJ", "2.0", "17790IVaKVa", "1206zSexRs", "mcp-session-id", "ejUhf", "notifications/initialized", "MLcwn", "client", "JnLxl", "writeHead", "1167984bKmTXI", "params", "Method not allowed.", "capabilities", "30 days", "json", "split", "fgOBA", "TsvGH", "1441gQHOjh", "rmhSH", "end", "headers", "APLQY", "4784eQEDDO", "send", "953496ufBuiH", "QDlIF", "protocolVersion", "POST", "OEuFV", "iODQK", "stringify", "Invalid token", "Bad Request: No valid session ID provided", "mcp-client", "DELETE", "GET", "authorization", "1.0.0", "TiFXP", "JJRrj", "method", "9674iCllrc", "connect", "LdDvS", "Missing token", "No client found", "status", "_requestHandlers", "sessionId", "kiuPw", "sse", "1600614QKtxUt", "streamable-session-id", "message", "handleRequest", "1394aZMmXF", "mcp-server", "streamable", "kxjBS", "4rwcmPk", "2091730pvfidK", "HS256", "yzXtw", "set"];
|
|
126
|
+
return g = function() {
|
|
127
|
+
return e;
|
|
128
|
+
}, g();
|
|
129
|
+
}
|
|
130
|
+
(function(e, s) {
|
|
131
|
+
const x = h, t = e();
|
|
132
|
+
for (; ; )
|
|
133
|
+
try {
|
|
134
|
+
if (parseInt(x(501)) / 1 * (parseInt(x(556)) / 2) + -parseInt(x(552)) / 3 + parseInt(x(560)) / 4 * (-parseInt(x(561)) / 5) + parseInt(x(509)) / 6 + parseInt(x(542)) / 7 * (parseInt(x(523)) / 8) + -parseInt(x(525)) / 9 + parseInt(x(500)) / 10 * (-parseInt(x(518)) / 11) === s) break;
|
|
135
|
+
t.push(t.shift());
|
|
136
|
+
} catch {
|
|
137
|
+
t.push(t.shift());
|
|
138
|
+
}
|
|
139
|
+
})(g, 570805);
|
|
140
|
+
function h(e, s) {
|
|
141
|
+
const x = g();
|
|
142
|
+
return h = function(t, a) {
|
|
143
|
+
return t = t - (7451 + 1739 * -4), x[t];
|
|
144
|
+
}, h(e, s);
|
|
145
|
+
}
|
|
146
|
+
const N = ({ secret: e }) => (s, x, t) => {
|
|
147
|
+
var b;
|
|
148
|
+
const a = h, i = { yzXtw: a(545), MLcwn: function(p) {
|
|
149
|
+
return p();
|
|
150
|
+
}, iODQK: a(532) }, l = (b = s.headers[a(537)]) == null ? void 0 : b[a(515)](" ")[16 * -223 + -8468 + 12037];
|
|
151
|
+
if (!l) return x[a(547)](-3780 + 37 * 113)[a(524)](i[a(563)]);
|
|
152
|
+
try {
|
|
153
|
+
s[a(497)] = k[a(496)](l, e), i[a(505)](t);
|
|
154
|
+
} catch (p) {
|
|
155
|
+
x[a(547)](-2235 + -1 * -6541 + -1301 * 3)[a(514)]({ error: i[a(530)], details: p[a(554)] });
|
|
156
|
+
}
|
|
157
|
+
}, z = (e, s, x = { expiresIn: y(513), algorithm: y(562) }) => k.sign(e, s, x), U = (e, s) => k.verify(e, s), F = () => {
|
|
158
|
+
const e = y, s = { LdDvS: e(568), MoeVJ: e(534), APLQY: "1.0.0", JXIlP: e(551), wiIii: e(557), rmhSH: function(r, c) {
|
|
159
|
+
return r === c;
|
|
160
|
+
}, vVdrj: e(528), OEuFV: function(r, c, n) {
|
|
161
|
+
return r(c, n);
|
|
162
|
+
}, VvQjC: function(r, c) {
|
|
163
|
+
return r === c;
|
|
164
|
+
}, QDlIF: "GET, POST, DELETE", kxjBS: e(499), UwKNl: e(502), JJRrj: function(r, c) {
|
|
165
|
+
return r === c;
|
|
166
|
+
}, JnLxl: e(535), VySIR: e(569), hXAGK: e(553), fgOBA: function(r, c) {
|
|
167
|
+
return r(c);
|
|
168
|
+
}, TsvGH: e(504), kiuPw: e(572), ejUhf: e(558), TiFXP: e(533) }, x = {}, t = {}, a = async (r, c, n) => {
|
|
169
|
+
const o = e, f = new V(n, c), d = f[o(549)];
|
|
170
|
+
x[d] = f, r.on(s[o(544)], () => {
|
|
171
|
+
f.close(), delete x[d], delete t[d];
|
|
172
|
+
});
|
|
173
|
+
const u = new T({ name: s[o(498)], version: s.APLQY });
|
|
174
|
+
t[d] = { client: u, user: r[o(497)], type: s.JXIlP }, await u[o(543)](f);
|
|
175
|
+
}, i = async (r, c, n) => {
|
|
176
|
+
var S, R;
|
|
177
|
+
const o = e, f = (R = t[(S = r.query) == null ? void 0 : S[o(549)]]) == null ? void 0 : R[o(506)];
|
|
178
|
+
if (!f) {
|
|
179
|
+
c[o(547)](7124 + 1 * 4002 + -10726)[o(524)](o(546));
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const d = new Q(n, c, f), u = d.sessionId;
|
|
183
|
+
x[u] = d, r.on(s[o(544)], () => {
|
|
184
|
+
d.close(), delete x[u];
|
|
185
|
+
});
|
|
186
|
+
const m = { prompts: {}, resources: {}, tools: {}, logging: {} };
|
|
187
|
+
await new E({ name: s.wiIii, version: s[o(522)] }, { capabilities: m })[o(543)](d);
|
|
188
|
+
}, l = async (r, c) => {
|
|
189
|
+
const n = e, o = r.query[n(549)], f = x[o];
|
|
190
|
+
f ? await f.handlePostMessage(r, c) : c.status(1 * 1388 + 19 * 314 + -6954).send(n(570));
|
|
191
|
+
}, b = async (r, c) => {
|
|
192
|
+
const n = e;
|
|
193
|
+
s[n(519)](r[n(541)], s[n(567)]) ? await s[n(529)](L, r, c) : r[n(541)] === n(536) || s[n(565)](r.method, n(535)) ? await s[n(529)](K, r, c) : await p(c);
|
|
194
|
+
}, p = async (r) => {
|
|
195
|
+
const c = e;
|
|
196
|
+
r[c(508)](1 * 1354 + -3672 + -2723 * -1, { Allow: s[c(526)] })[c(520)](JSON[c(531)]({ jsonrpc: s[c(559)], error: { code: -32e3, message: c(511) }, id: null }));
|
|
197
|
+
}, K = async (r, c) => {
|
|
198
|
+
const n = e, o = r[n(521)][s.UwKNl], f = x[o];
|
|
199
|
+
f ? (await f.handleRequest(r, c), s[n(540)](r[n(541)], s[n(507)]) && f.validateSession(r, c) && (delete x[o], delete t[o])) : c[n(547)](400)[n(524)](s.VySIR);
|
|
200
|
+
}, L = async (r, c) => {
|
|
201
|
+
const n = e, o = r[n(521)][s.UwKNl], f = r[n(521)][s[n(495)]];
|
|
202
|
+
let d = x[o];
|
|
203
|
+
if (d) await d.handleRequest(r, c, r[n(571)]);
|
|
204
|
+
else if (!o && s[n(516)](P, r[n(571)])) {
|
|
205
|
+
d = new J({ sessionIdGenerator: () => f });
|
|
206
|
+
const u = new T({ name: s[n(498)], version: s[n(522)] });
|
|
207
|
+
u[n(566)].set(s[n(517)], () => {
|
|
208
|
+
}), u[n(548)][n(564)](s[n(550)], (m) => ({ protocolVersion: m[n(510)][n(527)], capabilities: m.params[n(512)], serverInfo: { name: n(557), version: n(538) } })), t[f] = { client: u, user: r[n(497)], type: s[n(503)] }, x[f] = d, d[n(549)] = f, await u.connect(d), await d[n(555)](r, c, r[n(571)]);
|
|
209
|
+
} else c[n(547)](400)[n(514)]({ jsonrpc: s[n(559)], error: { code: -32e3, message: s[n(539)] }, id: null });
|
|
210
|
+
};
|
|
211
|
+
return { handleProxy: a, handleInspector: i, handleMessage: l, handleRequest: b, clients: t };
|
|
212
|
+
};
|
|
213
|
+
export {
|
|
214
|
+
Q as GatewaySSEServerTransport,
|
|
215
|
+
N as auth,
|
|
216
|
+
z as signToken,
|
|
217
|
+
F as useHandles,
|
|
218
|
+
U as verifyToken
|
|
219
|
+
};
|