@opentiny/next 0.0.1 → 0.1.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.
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "@opentiny/next",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Chunhui Mo",
7
7
  "files": [
8
8
  "client.js",
9
- "server.js"
9
+ "client.d.ts",
10
+ "server.js",
11
+ "server.d.ts"
10
12
  ],
11
13
  "main": "client.js",
12
14
  "module": "client.js",
@@ -16,6 +18,13 @@
16
18
  "jsonwebtoken": "^9.0.2",
17
19
  "zod": "^3.24.2"
18
20
  },
21
+ "peerDependencies": {
22
+ "express": "^4.21.2"
23
+ },
24
+ "devDependencies": {
25
+ "@types/express": "^5.0.1",
26
+ "@types/jsonwebtoken": "^9.0.9"
27
+ },
19
28
  "engines": {
20
29
  "node": "^18.0.0 || >=20.0.0"
21
30
  },
package/server.d.ts ADDED
@@ -0,0 +1,95 @@
1
+ import jwt, { JwtPayload } from 'jsonwebtoken';
2
+ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
3
+ import { Request, Response, NextFunction } from 'express';
4
+
5
+ /**
6
+ * 客户端连接的 Transport 类型,比如:StreamableHTTP、SSE
7
+ */
8
+ type TransportType = 'SSE' | 'StreamableHTTP';
9
+ /**
10
+ * 客户端连接的信息,包括客户端实例、用户信息和 Transport 类型
11
+ */
12
+ interface ClientInfo {
13
+ /**
14
+ * MCP 客户端实例
15
+ */
16
+ client: Client;
17
+ /**
18
+ * 连接的用户信息
19
+ */
20
+ user?: JwtPayload | string;
21
+ /**
22
+ * 用于识别不同连接的信息
23
+ */
24
+ device: {
25
+ /**
26
+ * 连接的来源 IP 地址,可能是 IPv4 或 IPv6 地址
27
+ */
28
+ ip: string | string[];
29
+ /**
30
+ * 识别浏览器类型和版本 User-Agent 字符串
31
+ */
32
+ userAgent: string;
33
+ /**
34
+ * 连接的语言设置,通常是浏览器的 Accept-Language 字段
35
+ */
36
+ acceptLanguage: string;
37
+ /**
38
+ * 连接的来源 URL,通常是 HTTP Referer 字段
39
+ */
40
+ referer: string;
41
+ };
42
+ /**
43
+ * 客户端连接的 Transport 类型
44
+ */
45
+ type: TransportType;
46
+ }
47
+ /**
48
+ * Express 请求对象的扩展,添加了可选的用户信息属性
49
+ */
50
+ declare module 'express' {
51
+ interface Request {
52
+ user?: JwtPayload | string;
53
+ }
54
+ }
55
+ /**
56
+ * 认证中间件,用于校验 JWT Token。
57
+ *
58
+ * 检查请求头中的 Authorization 字段,提取并校验 Bearer Token。
59
+ * 校验通过后,将解码后的用户信息挂载到 req.user。
60
+ * 校验失败或缺失 token 时,返回 401 或 403 错误。
61
+ */
62
+ declare const auth: ({ secret }: {
63
+ secret: string;
64
+ }) => (req: Request, res: Response, next: NextFunction) => void;
65
+ /**
66
+ * 根据签名的密钥生成 JWT Token
67
+ *
68
+ * @param payload - JWT Token 的载荷,包含用户信息等
69
+ * @param secret - 用于签名的密钥
70
+ * @param signOption - 签名选项,默认过期时间 30 天,默认算法 HS256
71
+ * @returns - 生成的 JWT Token
72
+ */
73
+ declare const signToken: (payload: object, secret: string, signOption?: jwt.SignOptions) => string;
74
+ /**
75
+ * 验证 JWT Token,如果验证失败,比如 Token 过期、签名不匹配等,将抛出错误异常。
76
+ *
77
+ * @param token - 要验证的 JWT Token
78
+ * @param secret - 用于验证的密钥
79
+ * @returns - 解码后的 JWT Token 载荷,包含用户信息等
80
+ */
81
+ declare const verifyToken: (token: string, secret: string) => any;
82
+ /**
83
+ * SSE 与 Streamable HTTP 连接的处理函数,同时返回所有客户端代理实例
84
+ */
85
+ declare const useProxyHandles: () => {
86
+ handleSseProxy: (req: Request, res: Response, endpoint: string) => Promise<void>;
87
+ handleSseInspector: (req: Request, res: Response, endpoint: string) => Promise<void>;
88
+ handleSseMessage: (req: Request, res: Response) => Promise<void>;
89
+ handleStreamRequest: (req: Request, res: Response) => Promise<void>;
90
+ handleStreamInspector: (req: Request, res: Response) => Promise<void>;
91
+ clients: Record<string, ClientInfo>;
92
+ };
93
+
94
+ export { auth, signToken, useProxyHandles, verifyToken };
95
+ export type { ClientInfo, TransportType };
package/server.js CHANGED
@@ -1,219 +1,269 @@
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);
1
+ import M from "jsonwebtoken";
2
+ import { McpServer as D } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { Client as V } from "@modelcontextprotocol/sdk/client/index.js";
4
+ import { SSEServerTransport as N } from "@modelcontextprotocol/sdk/server/sse.js";
5
+ import { StreamableHTTPServerTransport as P } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
6
+ import { isInitializeRequest as L } from "@modelcontextprotocol/sdk/types.js";
7
+ function _(e, a) {
8
+ const x = g();
9
+ return _ = function(s, n) {
10
+ return s = s - (9141 + -6 * 63 + 33 * -253), x[s];
11
+ }, _(e, a);
18
12
  }
19
- (function(e, s) {
20
- const x = w, t = e();
13
+ (function(e, a) {
14
+ const x = _, s = e();
21
15
  for (; ; )
22
16
  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());
17
+ if (-parseInt(x(441)) / 1 * (parseInt(x(456)) / 2) + -parseInt(x(416)) / 3 * (-parseInt(x(415)) / 4) + -parseInt(x(425)) / 5 * (-parseInt(x(426)) / 6) + -parseInt(x(438)) / 7 * (parseInt(x(440)) / 8) + parseInt(x(455)) / 9 * (-parseInt(x(448)) / 10) + -parseInt(x(423)) / 11 * (parseInt(x(447)) / 12) + parseInt(x(446)) / 13 * (parseInt(x(429)) / 14) === a) break;
18
+ s.push(s.shift());
25
19
  } catch {
26
- t.push(t.shift());
20
+ s.push(s.shift());
21
+ }
22
+ })(g, -276384 * -4 + 1354678 + -1774470);
23
+ function g() {
24
+ const e = ["resources/unsubscribe", "subscribeResource", "tools/call", "readResource", "3661ghODPp", "logging/setLevel", "19064NSEcAs", "127MjtXKH", "getPrompt", "send", "tools/list", "prompts/list", "169rCWZyY", "12ruWgpk", "4471280evukDT", "ApqQw", "sExur", "ping", "complete", "resources/read", "resources/subscribe", "18FYdDVz", "11054ciDAzC", "ivBSM", "onmessage", "OtdbO", "40TggALB", "346350eWjLOm", "resources/list", "callTool", "LVIkQ", "listTools", "2.0", "listResourceTemplates", "1715835DOrzVE", "listPrompts", "1013195MxsBkk", "30CEeAEg", "_client", "listResources", "1633184sotXfk", "unsubscribeResource", "RZrry", "resources/templates/list", "completion/complete"];
25
+ return g = function() {
26
+ return e;
27
+ }, g();
28
+ }
29
+ const A = async (e, a) => {
30
+ const x = _, s = { OtdbO: x(436), OLpMt: x(417), RZrry: x(434), LVIkQ: "prompts/get", sExur: x(445), ApqQw: x(451), xpeDk: x(433), ivBSM: x(439), RRNXj: x(421) };
31
+ let n;
32
+ const { id: i, method: l, params: b } = a;
33
+ if (l) {
34
+ switch (l) {
35
+ case x(444):
36
+ n = await e[x(427)][x(420)](b);
37
+ break;
38
+ case s[x(414)]:
39
+ n = await e[x(427)][x(418)](b);
40
+ break;
41
+ case s.OLpMt:
42
+ n = await e[x(427)][x(428)](b);
43
+ break;
44
+ case x(432):
45
+ n = await e[x(427)][x(422)](b);
46
+ break;
47
+ case x(453):
48
+ n = await e._client[x(437)](b);
49
+ break;
50
+ case x(454):
51
+ n = await e[x(427)][x(435)](b);
52
+ break;
53
+ case s[x(431)]:
54
+ n = await e[x(427)][x(430)](b);
55
+ break;
56
+ case s[x(419)]:
57
+ n = await e[x(427)][x(442)](b);
58
+ break;
59
+ case s[x(450)]:
60
+ n = await e._client[x(424)](b);
61
+ break;
62
+ case s[x(449)]:
63
+ n = await e._client[x(451)]();
64
+ break;
65
+ case s.xpeDk:
66
+ n = await e[x(427)][x(452)](b);
67
+ break;
68
+ case s[x(457)]:
69
+ n = await e._client.setLoggingLevel(b);
70
+ break;
27
71
  }
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;
72
+ return n && await e[x(443)]({ result: n, jsonrpc: s.RRNXj, id: i }), n;
70
73
  }
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);
74
+ }, B = (e) => {
75
+ const a = _, x = { UVsDk: function(n, i) {
76
+ return n === i;
77
+ } }, s = e.onmessage;
78
+ e[a(458)] = async (n) => {
79
+ if (e._client) {
80
+ const i = await A(e, n);
81
+ x.UVsDk(i, void 0) && s && s.call(e, n);
83
82
  }
84
83
  };
85
84
  };
86
- var D = I;
87
- (function(e, s) {
88
- for (var x = I, t = e(); ; )
85
+ function v(e, a) {
86
+ var x = y();
87
+ return v = function(s, n) {
88
+ s = s - (8692 + 1 * -112 + -8331);
89
+ var i = x[s];
90
+ return i;
91
+ }, v(e, a);
92
+ }
93
+ var j = v;
94
+ (function(e, a) {
95
+ for (var x = v, s = e(); ; )
89
96
  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());
97
+ var n = parseInt(x(250)) / 1 + -parseInt(x(258)) / 2 + parseInt(x(259)) / 3 * (-parseInt(x(251)) / 4) + -parseInt(x(249)) / 5 + -parseInt(x(256)) / 6 + -parseInt(x(254)) / 7 * (parseInt(x(253)) / 8) + -parseInt(x(257)) / 9 * (-parseInt(x(255)) / 10);
98
+ if (n === a) break;
99
+ s.push(s.shift());
93
100
  } catch {
94
- t.push(t.shift());
101
+ s.push(s.shift());
95
102
  }
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() {
103
+ })(y, -1 * -564824 + 25687 * -8 + -1 * -396581);
104
+ class G extends N {
105
+ constructor(a, x, s) {
106
+ super(a, x), this._client = s;
107
+ }
108
+ async [j(252)](a) {
109
+ var x = j;
110
+ B(this), await super[x(252)](a);
111
+ }
112
+ }
113
+ function y() {
114
+ var e = ["5783748DPOUZj", "2331sMYHuu", "491280RBsbgA", "456gjwhrP", "4609585wzBuIC", "966778XgDNrC", "2452GYmdvV", "handleMessage", "32gBlYmI", "1016470ePDinz", "100180lbWCCD"];
115
+ return y = function() {
116
+ return e;
117
+ }, y();
118
+ }
119
+ function k() {
120
+ var e = ["145130mmOiYO", "86OecNVy", "1504503mktzfw", "4607100ojCaUM", "5927450EwZzAq", "141QuWaeP", "72kuFQfD", "1769jYRFYU", "40220uZYWhy", "22806124hJenCS", "_client", "handlePostRequest", "8hfYmWV"];
121
+ return k = function() {
100
122
  return e;
101
- }, _();
123
+ }, k();
102
124
  }
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];
125
+ function h(e, a) {
126
+ var x = k();
127
+ return h = function(s, n) {
128
+ s = s - (-493 * 11 + 1 * 5 + 5633);
129
+ var i = x[s];
108
130
  return i;
109
- }, I(e, s);
131
+ }, h(e, a);
110
132
  }
111
- class Q extends V {
112
- constructor(s, x, t) {
113
- var a = I;
114
- super(s, x), this[a(434)] = t;
133
+ var Q = h;
134
+ (function(e, a) {
135
+ for (var x = h, s = e(); ; )
136
+ try {
137
+ var n = -parseInt(x(227)) / 1 * (-parseInt(x(221)) / 2) + -parseInt(x(225)) / 3 * (parseInt(x(215)) / 4) + -parseInt(x(220)) / 5 * (parseInt(x(226)) / 6) + -parseInt(x(222)) / 7 * (-parseInt(x(219)) / 8) + -parseInt(x(223)) / 9 + -parseInt(x(224)) / 10 + parseInt(x(216)) / 11;
138
+ if (n === a) break;
139
+ s.push(s.shift());
140
+ } catch {
141
+ s.push(s.shift());
142
+ }
143
+ })(k, 762 * -382 + 10567 * -61 + 1374409);
144
+ class Z extends P {
145
+ constructor(a, x) {
146
+ var s = h;
147
+ super(a), this[s(217)] = x;
115
148
  }
116
- async [D(445)](s) {
117
- var x = D, t = { JbWIK: function(a, i) {
118
- return a(i);
149
+ async [Q(218)](a, x, s) {
150
+ var n = Q, i = { IOEYc: function(l, b) {
151
+ return l(b);
119
152
  } };
120
- t[x(443)](G, this), await super[x(445)](s);
153
+ i.IOEYc(B, this), await super[n(218)](a, x, s);
121
154
  }
122
155
  }
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();
156
+ const I = w;
157
+ (function(e, a) {
158
+ const x = w, s = e();
132
159
  for (; ; )
133
160
  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());
161
+ if (-parseInt(x(334)) / 1 * (-parseInt(x(322)) / 2) + parseInt(x(384)) / 3 + parseInt(x(326)) / 4 * (parseInt(x(387)) / 5) + -parseInt(x(342)) / 6 + -parseInt(x(381)) / 7 * (parseInt(x(390)) / 8) + -parseInt(x(383)) / 9 + -parseInt(x(367)) / 10 * (-parseInt(x(347)) / 11) === a) break;
162
+ s.push(s.shift());
136
163
  } catch {
137
- t.push(t.shift());
164
+ s.push(s.shift());
138
165
  }
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);
166
+ })(E, 507367);
167
+ function E() {
168
+ const e = ["275265DeMorS", "handleRequest", "protocolVersion", "664QUBQZi", "NZyuD", "message", "SGkVu", "Bad Request: No valid session ID provided", "2.0", "NKfhY", "sign", "user", "aTTmj", "writeHead", "referer", "mcp-proxy-client", "2YQCpBv", "mcp-session-id", "_requestHandlers", "GET", "8YeSGoI", "mcp-server", "query", "client", "headers", "IRQUp", "close", "end", "579527YvVojK", "cxhYJ", "stream-session-id", "rHMQM", "stringify", "JKnQL", "StreamableHTTP", "method", "5083710dEWIWB", "bmbQY", "ehpra", "Method not allowed.", "MbjmQ", "11VPeucu", "KqVMP", "connect", "send", "POST", "NTflE", "handlePostMessage", "status", "SZoau", "SSE", "EomGT", "user-agent", "json", "set", "initialize", "GET, POST, DELETE", "No transport found", "notifications/initialized", "sessionId", "PBzet", "11187480dNiAUD", "daZeK", "Xarej", "LnLIi", "JGjws", "EoEBV", "BGWyo", "MumfE", "Invalid bearer token", "verify", "1.0.0", "accept-language", "_notificationHandlers", "No client found", "21308EanUnc", "params", "3374991mZhigd", "521766FifKNn", "DlBYP", "body"];
169
+ return E = function() {
170
+ return e;
171
+ }, E();
172
+ }
173
+ function w(e, a) {
174
+ const x = E();
175
+ return w = function(s, n) {
176
+ return s = s - (8016 + 2 * -3903 + 101 * 1), x[s];
177
+ }, w(e, a);
145
178
  }
146
- const N = ({ secret: e }) => (s, x, t) => {
179
+ const F = ({ secret: e }) => (a, x, s) => {
147
180
  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)]);
181
+ const n = w, i = { SGkVu: "Missing bearer token", DlBYP: n(375) }, l = (b = a[n(330)].authorization) == null ? void 0 : b.split(" ")[29 * 163 + 494 * -2 + -1869 * 2];
182
+ if (!l) {
183
+ x[n(354)](3171 + -2 * 1385).send(i[n(312)]);
184
+ return;
185
+ }
152
186
  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)] });
187
+ a[n(317)] = M.verify(l, e), s();
188
+ } catch (S) {
189
+ x[n(354)](1 * 821 + -660 + -1 * -242)[n(359)]({ error: i[n(385)], details: S[n(311)] });
156
190
  }
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) {
191
+ }, $ = (e, a, x = { expiresIn: "30 days", algorithm: "HS256" }) => M[I(316)](e, a, x), x0 = (e, a) => M[I(376)](e, a), Y = (e) => ({ ip: e.headers["x-forwarded-for"] || e.ip || "", userAgent: e.headers[I(358)] || "", acceptLanguage: e[I(330)][I(378)] || "", referer: e[I(330)][I(320)] || "" }), e0 = () => {
192
+ const e = I, a = { MumfE: "close", MbjmQ: e(321), LnLIi: e(377), aTTmj: function(r, c) {
193
+ return r(c);
194
+ }, DcJAO: e(356), EoEBV: e(380), daZeK: "mcp-proxy-server", ehpra: e(363), JGjws: function(r, c) {
159
195
  return r === c;
160
- }, vVdrj: e(528), OEuFV: function(r, c, n) {
161
- return r(c, n);
162
- }, VvQjC: function(r, c) {
196
+ }, PBzet: e(351), AQrVD: function(r, c, t) {
197
+ return r(c, t);
198
+ }, cxhYJ: function(r, c) {
163
199
  return r === c;
164
- }, QDlIF: "GET, POST, DELETE", kxjBS: e(499), UwKNl: e(502), JJRrj: function(r, c) {
200
+ }, EomGT: e(325), SZoau: function(r, c) {
165
201
  return r === c;
166
- }, JnLxl: e(535), VySIR: e(569), hXAGK: e(553), fgOBA: function(r, c) {
202
+ }, NTflE: "DELETE", VstVe: function(r, c, t) {
203
+ return r(c, t);
204
+ }, IRQUp: e(362), rHMQM: e(314), VzFAj: e(345), BGWyo: e(323), mnfxr: "Invalid or missing session ID", Xarej: e(336), NKfhY: function(r, c) {
167
205
  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];
206
+ }, JKnQL: e(364), NZyuD: e(361), ZinNN: function(r, c) {
207
+ return r(c);
208
+ }, bmbQY: e(340), KqVMP: e(313) }, x = {}, s = {}, n = async (r, c, t) => {
209
+ const o = e, d = new N(t, c), f = d[o(365)];
210
+ x[f] = d, r.on(a.MumfE, () => {
211
+ d[o(332)](), delete x[f], delete s[f];
172
212
  });
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)];
213
+ const p = { prompts: {}, resources: {}, tools: {}, logging: {} }, u = new V({ name: a[o(346)], version: a[o(370)] }, { capabilities: p });
214
+ s[f] = { client: u, user: r[o(317)], device: a[o(318)](Y, r), type: a.DcJAO }, await u[o(349)](d);
215
+ }, i = async (r, c, t) => {
216
+ var T;
217
+ const o = e, d = r[o(328)][o(365)], f = (T = s[d]) == null ? void 0 : T.client;
178
218
  if (!f) {
179
- c[o(547)](7124 + 1 * 4002 + -10726)[o(524)](o(546));
219
+ c[o(354)](-543 * -17 + 1 * 3587 + -2 * 6209).send(a[o(372)]);
180
220
  return;
181
221
  }
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];
222
+ const p = new G(t, c, f), u = p[o(365)];
223
+ x[u] = p, r.on(a[o(374)], () => {
224
+ p[o(332)](), delete x[u];
185
225
  });
186
226
  const m = { prompts: {}, resources: {}, tools: {}, logging: {} };
187
- await new E({ name: s.wiIii, version: s[o(522)] }, { capabilities: m })[o(543)](d);
227
+ await new D({ name: a[o(368)], version: "1.0.0" }, { capabilities: m })[o(349)](p);
188
228
  }, 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));
229
+ const t = e, o = r[t(328)][t(365)], d = x[o];
230
+ d ? await d[t(353)](r, c) : c[t(354)](1 * -6898 + 1 * 2494 + 4804)[t(350)](a[t(344)]);
191
231
  }, 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) => {
232
+ const t = e;
233
+ a[t(371)](r[t(341)], a[t(366)]) ? await a.AQrVD(R, r, c) : a[t(335)](r.method, a[t(357)]) || a[t(355)](r[t(341)], a[t(352)]) ? await a.VstVe(O, r, c) : await S(c);
234
+ }, S = async (r) => {
195
235
  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 });
236
+ r[c(319)](906 * -7 + -5628 + 2475 * 5, { Allow: a[c(331)] })[c(333)](JSON[c(338)]({ jsonrpc: a.rHMQM, error: { code: -32e3, message: a.VzFAj }, id: null }));
237
+ }, O = async (r, c) => {
238
+ const t = e, o = r[t(330)][a[t(373)]], d = x[o];
239
+ d ? (await d[t(388)](r, c), r[t(341)] === a.NTflE && (delete x[o], delete s[o])) : c[t(354)](1765 * 3 + -8 * 29 + -4663)[t(350)](a.mnfxr);
240
+ }, R = async (r, c) => {
241
+ const t = e, o = r[t(330)][a.BGWyo], d = r[t(330)][a[t(369)]];
242
+ let f = x[o];
243
+ if (f) await f[t(388)](r, c, r[t(386)]);
244
+ else if (!o && a[t(315)](L, r.body)) {
245
+ f = new P({ sessionIdGenerator: () => d });
246
+ const p = { prompts: {}, resources: {}, tools: {}, logging: {} }, u = new V({ name: a.MbjmQ, version: a[t(370)] }, { capabilities: p });
247
+ u[t(379)][t(360)](a[t(339)], () => {
248
+ }), u[t(324)][t(360)](a[t(391)], (m) => ({ protocolVersion: m[t(382)][t(389)], capabilities: m[t(382)].capabilities, serverInfo: { name: t(327), version: t(377) } })), s[d] = { client: u, user: r[t(317)], device: a.ZinNN(Y, r), type: a[t(343)] }, x[d] = f, f[t(365)] = d, await u.connect(f), await f[t(388)](r, c, r[t(386)]);
249
+ } else c[t(354)](10343 + 1 * -9943)[t(359)]({ jsonrpc: a[t(337)], error: { code: -32e3, message: a[t(348)] }, id: null });
210
250
  };
211
- return { handleProxy: a, handleInspector: i, handleMessage: l, handleRequest: b, clients: t };
251
+ return { handleSseProxy: n, handleSseInspector: i, handleSseMessage: l, handleStreamRequest: b, handleStreamInspector: async (r, c) => {
252
+ var m;
253
+ const t = e, o = r[t(328)][t(365)], d = (m = s[o]) == null ? void 0 : m[t(329)];
254
+ if (!d) {
255
+ c[t(354)](3059 + -137 * 39 + -22 * -122).send(a[t(372)]);
256
+ return;
257
+ }
258
+ const f = new Z({ sessionIdGenerator: void 0 }, d), p = { prompts: {}, resources: {}, tools: {}, logging: {} }, u = new D({ name: a[t(368)], version: a[t(370)] }, { capabilities: p });
259
+ await u.connect(f), await f[t(388)](r, c, r.body), c.on(a[t(374)], () => {
260
+ f.close(), u.close();
261
+ });
262
+ }, clients: s };
212
263
  };
213
264
  export {
214
- Q as GatewaySSEServerTransport,
215
- N as auth,
216
- z as signToken,
217
- F as useHandles,
218
- U as verifyToken
265
+ F as auth,
266
+ $ as signToken,
267
+ e0 as useProxyHandles,
268
+ x0 as verifyToken
219
269
  };