@shin1ohno/sage 0.8.4 → 0.8.6
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/dist/cli/mcp-handler.d.ts.map +1 -1
- package/dist/cli/mcp-handler.js +141 -987
- package/dist/cli/mcp-handler.js.map +1 -1
- package/dist/config/update-validation.d.ts +52 -0
- package/dist/config/update-validation.d.ts.map +1 -0
- package/dist/config/update-validation.js +133 -0
- package/dist/config/update-validation.js.map +1 -0
- package/dist/index.js +163 -1815
- package/dist/index.js.map +1 -1
- package/dist/integrations/calendar-event-creator.d.ts +2 -3
- package/dist/integrations/calendar-event-creator.d.ts.map +1 -1
- package/dist/integrations/calendar-event-creator.js +3 -4
- package/dist/integrations/calendar-event-creator.js.map +1 -1
- package/dist/integrations/calendar-event-deleter.d.ts +2 -3
- package/dist/integrations/calendar-event-deleter.d.ts.map +1 -1
- package/dist/integrations/calendar-event-deleter.js +3 -4
- package/dist/integrations/calendar-event-deleter.js.map +1 -1
- package/dist/integrations/calendar-event-response.d.ts +4 -17
- package/dist/integrations/calendar-event-response.d.ts.map +1 -1
- package/dist/integrations/calendar-event-response.js +3 -4
- package/dist/integrations/calendar-event-response.js.map +1 -1
- package/dist/integrations/notion-mcp.d.ts +28 -3
- package/dist/integrations/notion-mcp.d.ts.map +1 -1
- package/dist/integrations/notion-mcp.js +21 -5
- package/dist/integrations/notion-mcp.js.map +1 -1
- package/dist/integrations/reminder-manager.d.ts.map +1 -1
- package/dist/integrations/reminder-manager.js +2 -0
- package/dist/integrations/reminder-manager.js.map +1 -1
- package/dist/services/container.d.ts +56 -0
- package/dist/services/container.d.ts.map +1 -0
- package/dist/services/container.js +76 -0
- package/dist/services/container.js.map +1 -0
- package/dist/tools/calendar/handlers.d.ts +186 -0
- package/dist/tools/calendar/handlers.d.ts.map +1 -0
- package/dist/tools/calendar/handlers.js +525 -0
- package/dist/tools/calendar/handlers.js.map +1 -0
- package/dist/tools/calendar/index.d.ts +11 -0
- package/dist/tools/calendar/index.d.ts.map +1 -0
- package/dist/tools/calendar/index.js +10 -0
- package/dist/tools/calendar/index.js.map +1 -0
- package/dist/tools/index.d.ts +23 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +24 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/integrations/handlers.d.ts +57 -0
- package/dist/tools/integrations/handlers.d.ts.map +1 -0
- package/dist/tools/integrations/handlers.js +159 -0
- package/dist/tools/integrations/handlers.js.map +1 -0
- package/dist/tools/integrations/index.d.ts +11 -0
- package/dist/tools/integrations/index.d.ts.map +1 -0
- package/dist/tools/integrations/index.js +10 -0
- package/dist/tools/integrations/index.js.map +1 -0
- package/dist/tools/registry.d.ts +8 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +10 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/reminders/handlers.d.ts +61 -0
- package/dist/tools/reminders/handlers.d.ts.map +1 -0
- package/dist/tools/reminders/handlers.js +148 -0
- package/dist/tools/reminders/handlers.js.map +1 -0
- package/dist/tools/reminders/index.d.ts +11 -0
- package/dist/tools/reminders/index.d.ts.map +1 -0
- package/dist/tools/reminders/index.js +10 -0
- package/dist/tools/reminders/index.js.map +1 -0
- package/dist/tools/setup/handlers.d.ts +81 -0
- package/dist/tools/setup/handlers.d.ts.map +1 -0
- package/dist/tools/setup/handlers.js +172 -0
- package/dist/tools/setup/handlers.js.map +1 -0
- package/dist/tools/setup/index.d.ts +11 -0
- package/dist/tools/setup/index.d.ts.map +1 -0
- package/dist/tools/setup/index.js +10 -0
- package/dist/tools/setup/index.js.map +1 -0
- package/dist/tools/tasks/handlers.d.ts +95 -0
- package/dist/tools/tasks/handlers.d.ts.map +1 -0
- package/dist/tools/tasks/handlers.js +197 -0
- package/dist/tools/tasks/handlers.js.map +1 -0
- package/dist/tools/tasks/index.d.ts +11 -0
- package/dist/tools/tasks/index.d.ts.map +1 -0
- package/dist/tools/tasks/index.js +10 -0
- package/dist/tools/tasks/index.js.map +1 -0
- package/dist/tools/types.d.ts +54 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +9 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/types/calendar.d.ts +41 -0
- package/dist/types/calendar.d.ts.map +1 -0
- package/dist/types/calendar.js +18 -0
- package/dist/types/calendar.js.map +1 -0
- package/dist/utils/estimation.d.ts +34 -0
- package/dist/utils/estimation.d.ts.map +1 -1
- package/dist/utils/estimation.js +38 -1
- package/dist/utils/estimation.js.map +1 -1
- package/dist/utils/mcp-response.d.ts +89 -0
- package/dist/utils/mcp-response.d.ts.map +1 -0
- package/dist/utils/mcp-response.js +103 -0
- package/dist/utils/mcp-response.js.map +1 -0
- package/dist/utils/task-splitter.d.ts +65 -4
- package/dist/utils/task-splitter.d.ts.map +1 -1
- package/dist/utils/task-splitter.js +69 -5
- package/dist/utils/task-splitter.js.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/cli/http-server.d.ts +0 -74
- package/dist/cli/http-server.d.ts.map +0 -1
- package/dist/cli/http-server.js +0 -407
- package/dist/cli/http-server.js.map +0 -1
- package/dist/remote/remote-mcp-server.d.ts +0 -244
- package/dist/remote/remote-mcp-server.d.ts.map +0 -1
- package/dist/remote/remote-mcp-server.js +0 -507
- package/dist/remote/remote-mcp-server.js.map +0 -1
|
@@ -1,507 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Remote MCP Server
|
|
3
|
-
* HTTP/WebSocket based MCP server for remote access
|
|
4
|
-
* Requirements: 13.1-13.5
|
|
5
|
-
*/
|
|
6
|
-
import { createServer } from 'http';
|
|
7
|
-
import { createServer as createHttpsServer } from 'https';
|
|
8
|
-
import { randomUUID } from 'crypto';
|
|
9
|
-
/**
|
|
10
|
-
* Session Manager
|
|
11
|
-
* Handles session creation, validation, and cleanup
|
|
12
|
-
*/
|
|
13
|
-
export class SessionManager {
|
|
14
|
-
sessions = new Map();
|
|
15
|
-
config;
|
|
16
|
-
constructor(config) {
|
|
17
|
-
this.config = config;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Create a new session
|
|
21
|
-
*/
|
|
22
|
-
createSession(userId) {
|
|
23
|
-
// Check if we're at max sessions and remove oldest if needed
|
|
24
|
-
while (this.sessions.size >= this.config.maxSessions) {
|
|
25
|
-
// Remove oldest session
|
|
26
|
-
this.removeOldestSession();
|
|
27
|
-
}
|
|
28
|
-
const session = {
|
|
29
|
-
id: randomUUID(),
|
|
30
|
-
userId,
|
|
31
|
-
createdAt: new Date(),
|
|
32
|
-
lastAccessedAt: new Date(),
|
|
33
|
-
data: {},
|
|
34
|
-
};
|
|
35
|
-
this.sessions.set(session.id, session);
|
|
36
|
-
return session;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Check if a session is valid
|
|
40
|
-
*/
|
|
41
|
-
isValidSession(sessionId) {
|
|
42
|
-
const session = this.sessions.get(sessionId);
|
|
43
|
-
if (!session) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
const now = Date.now();
|
|
47
|
-
const lastAccess = session.lastAccessedAt.getTime();
|
|
48
|
-
if (now - lastAccess > this.config.sessionTimeout) {
|
|
49
|
-
this.sessions.delete(sessionId);
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
// Update last accessed time
|
|
53
|
-
session.lastAccessedAt = new Date();
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Terminate a session
|
|
58
|
-
*/
|
|
59
|
-
terminateSession(sessionId) {
|
|
60
|
-
this.sessions.delete(sessionId);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Get a session by ID
|
|
64
|
-
*/
|
|
65
|
-
getSession(sessionId) {
|
|
66
|
-
if (this.isValidSession(sessionId)) {
|
|
67
|
-
return this.sessions.get(sessionId);
|
|
68
|
-
}
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Clean up expired sessions
|
|
73
|
-
*/
|
|
74
|
-
cleanExpiredSessions() {
|
|
75
|
-
const now = Date.now();
|
|
76
|
-
for (const [id, session] of this.sessions.entries()) {
|
|
77
|
-
if (now - session.lastAccessedAt.getTime() > this.config.sessionTimeout) {
|
|
78
|
-
this.sessions.delete(id);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Get active session count
|
|
84
|
-
*/
|
|
85
|
-
getActiveSessionCount() {
|
|
86
|
-
return this.sessions.size;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Remove oldest session
|
|
90
|
-
*/
|
|
91
|
-
removeOldestSession() {
|
|
92
|
-
let oldestId = null;
|
|
93
|
-
let oldestTime = Date.now();
|
|
94
|
-
for (const [id, session] of this.sessions.entries()) {
|
|
95
|
-
if (session.createdAt.getTime() < oldestTime) {
|
|
96
|
-
oldestTime = session.createdAt.getTime();
|
|
97
|
-
oldestId = id;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (oldestId) {
|
|
101
|
-
this.sessions.delete(oldestId);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Authentication Configuration
|
|
107
|
-
* Handles JWT, API keys, and IP whitelist authentication
|
|
108
|
-
*/
|
|
109
|
-
export class AuthConfig {
|
|
110
|
-
config;
|
|
111
|
-
tokens = new Map();
|
|
112
|
-
constructor(config) {
|
|
113
|
-
this.config = config;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Generate a token for a user
|
|
117
|
-
*/
|
|
118
|
-
generateToken(userId) {
|
|
119
|
-
const token = randomUUID();
|
|
120
|
-
const expiry = this.config.tokenExpiry || 3600000; // 1 hour default
|
|
121
|
-
const expiresAt = Date.now() + expiry;
|
|
122
|
-
this.tokens.set(token, { userId, expiresAt });
|
|
123
|
-
return token;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Validate a token
|
|
127
|
-
*/
|
|
128
|
-
validateToken(token) {
|
|
129
|
-
const tokenData = this.tokens.get(token);
|
|
130
|
-
if (!tokenData) {
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
if (Date.now() > tokenData.expiresAt) {
|
|
134
|
-
this.tokens.delete(token);
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Validate an API key
|
|
141
|
-
*/
|
|
142
|
-
validateApiKey(apiKey) {
|
|
143
|
-
if (!this.config.apiKeys || this.config.apiKeys.length === 0) {
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
return this.config.apiKeys.includes(apiKey);
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Check if an IP is allowed
|
|
150
|
-
*/
|
|
151
|
-
isIPAllowed(ip) {
|
|
152
|
-
if (!this.config.ipWhitelist || this.config.ipWhitelist.length === 0) {
|
|
153
|
-
return true; // No whitelist means all IPs allowed
|
|
154
|
-
}
|
|
155
|
-
// Simple IP matching (supports exact match and CIDR notation)
|
|
156
|
-
for (const allowed of this.config.ipWhitelist) {
|
|
157
|
-
if (this.matchIP(ip, allowed)) {
|
|
158
|
-
return true;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Match IP against pattern (exact or CIDR)
|
|
165
|
-
*/
|
|
166
|
-
matchIP(ip, pattern) {
|
|
167
|
-
if (ip === pattern) {
|
|
168
|
-
return true;
|
|
169
|
-
}
|
|
170
|
-
// Simple CIDR matching for IPv4
|
|
171
|
-
if (pattern.includes('/')) {
|
|
172
|
-
const [network, bits] = pattern.split('/');
|
|
173
|
-
const mask = parseInt(bits, 10);
|
|
174
|
-
if (mask >= 0 && mask <= 32) {
|
|
175
|
-
const ipParts = ip.split('.').map(Number);
|
|
176
|
-
const networkParts = network.split('.').map(Number);
|
|
177
|
-
if (ipParts.length === 4 && networkParts.length === 4) {
|
|
178
|
-
const ipNum = (ipParts[0] << 24) | (ipParts[1] << 16) | (ipParts[2] << 8) | ipParts[3];
|
|
179
|
-
const networkNum = (networkParts[0] << 24) |
|
|
180
|
-
(networkParts[1] << 16) |
|
|
181
|
-
(networkParts[2] << 8) |
|
|
182
|
-
networkParts[3];
|
|
183
|
-
const maskNum = ~((1 << (32 - mask)) - 1);
|
|
184
|
-
return (ipNum & maskNum) === (networkNum & maskNum);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Extract token from Authorization header
|
|
192
|
-
*/
|
|
193
|
-
extractToken(authHeader) {
|
|
194
|
-
if (!authHeader) {
|
|
195
|
-
return null;
|
|
196
|
-
}
|
|
197
|
-
if (authHeader.startsWith('Bearer ')) {
|
|
198
|
-
return authHeader.slice(7);
|
|
199
|
-
}
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Check if authentication is enabled
|
|
204
|
-
*/
|
|
205
|
-
isEnabled() {
|
|
206
|
-
return this.config.enabled;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* MCP Over HTTP Handler
|
|
211
|
-
* Handles JSON-RPC over HTTP protocol
|
|
212
|
-
*/
|
|
213
|
-
export class MCPOverHTTPHandler {
|
|
214
|
-
config;
|
|
215
|
-
constructor(config) {
|
|
216
|
-
this.config = config || {};
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Parse a JSON-RPC request
|
|
220
|
-
*/
|
|
221
|
-
parseRequest(body) {
|
|
222
|
-
let parsed;
|
|
223
|
-
try {
|
|
224
|
-
parsed = JSON.parse(body);
|
|
225
|
-
}
|
|
226
|
-
catch {
|
|
227
|
-
throw new Error('Invalid JSON');
|
|
228
|
-
}
|
|
229
|
-
const request = parsed;
|
|
230
|
-
if (!request.jsonrpc || request.jsonrpc !== '2.0') {
|
|
231
|
-
throw new Error('Invalid JSON-RPC request');
|
|
232
|
-
}
|
|
233
|
-
if (request.method === undefined) {
|
|
234
|
-
throw new Error('Invalid JSON-RPC request: missing method');
|
|
235
|
-
}
|
|
236
|
-
return {
|
|
237
|
-
jsonrpc: '2.0',
|
|
238
|
-
id: request.id ?? null,
|
|
239
|
-
method: request.method,
|
|
240
|
-
params: request.params,
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Build a success response
|
|
245
|
-
*/
|
|
246
|
-
buildResponse(id, result) {
|
|
247
|
-
return {
|
|
248
|
-
jsonrpc: '2.0',
|
|
249
|
-
id,
|
|
250
|
-
result,
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Build an error response
|
|
255
|
-
*/
|
|
256
|
-
buildErrorResponse(id, code, message, data) {
|
|
257
|
-
return {
|
|
258
|
-
jsonrpc: '2.0',
|
|
259
|
-
id,
|
|
260
|
-
error: {
|
|
261
|
-
code,
|
|
262
|
-
message,
|
|
263
|
-
data,
|
|
264
|
-
},
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Get CORS headers for a request
|
|
269
|
-
*/
|
|
270
|
-
getCORSHeaders(origin) {
|
|
271
|
-
const allowedOrigins = this.config.allowedOrigins || ['*'];
|
|
272
|
-
let allowOrigin = '*';
|
|
273
|
-
if (origin && allowedOrigins.includes(origin)) {
|
|
274
|
-
allowOrigin = origin;
|
|
275
|
-
}
|
|
276
|
-
else if (allowedOrigins.length === 1 && allowedOrigins[0] !== '*') {
|
|
277
|
-
allowOrigin = allowedOrigins[0];
|
|
278
|
-
}
|
|
279
|
-
return {
|
|
280
|
-
'Access-Control-Allow-Origin': allowOrigin,
|
|
281
|
-
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
|
|
282
|
-
'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-API-Key',
|
|
283
|
-
'Access-Control-Max-Age': '86400',
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Remote MCP Server
|
|
289
|
-
* HTTP/HTTPS server that exposes MCP protocol over HTTP
|
|
290
|
-
*/
|
|
291
|
-
export class RemoteMCPServer {
|
|
292
|
-
config;
|
|
293
|
-
server = null;
|
|
294
|
-
running = false;
|
|
295
|
-
startTime = null;
|
|
296
|
-
_sessionManager;
|
|
297
|
-
auth;
|
|
298
|
-
httpHandler;
|
|
299
|
-
constructor(config) {
|
|
300
|
-
this.config = {
|
|
301
|
-
port: 3000,
|
|
302
|
-
host: 'localhost',
|
|
303
|
-
...config,
|
|
304
|
-
};
|
|
305
|
-
this._sessionManager = new SessionManager({
|
|
306
|
-
sessionTimeout: 3600000, // 1 hour
|
|
307
|
-
maxSessions: 1000,
|
|
308
|
-
});
|
|
309
|
-
this.auth = config.auth ? new AuthConfig(config.auth) : null;
|
|
310
|
-
this.httpHandler = new MCPOverHTTPHandler({
|
|
311
|
-
allowedOrigins: config.cors?.allowedOrigins,
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* Start the server
|
|
316
|
-
*/
|
|
317
|
-
async start() {
|
|
318
|
-
if (this.running) {
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
return new Promise((resolve, reject) => {
|
|
322
|
-
try {
|
|
323
|
-
const requestHandler = this.handleRequest.bind(this);
|
|
324
|
-
if (this.config.ssl) {
|
|
325
|
-
this.server = createHttpsServer({
|
|
326
|
-
cert: this.config.ssl.cert,
|
|
327
|
-
key: this.config.ssl.key,
|
|
328
|
-
ca: this.config.ssl.ca,
|
|
329
|
-
}, requestHandler);
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
this.server = createServer(requestHandler);
|
|
333
|
-
}
|
|
334
|
-
this.server.listen(this.config.port, this.config.host, () => {
|
|
335
|
-
this.running = true;
|
|
336
|
-
this.startTime = new Date();
|
|
337
|
-
resolve();
|
|
338
|
-
});
|
|
339
|
-
this.server.on('error', (error) => {
|
|
340
|
-
reject(error);
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
catch (error) {
|
|
344
|
-
reject(error);
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Stop the server
|
|
350
|
-
*/
|
|
351
|
-
async stop() {
|
|
352
|
-
if (!this.running || !this.server) {
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
return new Promise((resolve) => {
|
|
356
|
-
this.server.close(() => {
|
|
357
|
-
this.running = false;
|
|
358
|
-
this.startTime = null;
|
|
359
|
-
resolve();
|
|
360
|
-
});
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
* Check if server is running
|
|
365
|
-
*/
|
|
366
|
-
isRunning() {
|
|
367
|
-
return this.running;
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Get configured port
|
|
371
|
-
*/
|
|
372
|
-
getPort() {
|
|
373
|
-
return this.config.port;
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Check if HTTPS is enabled
|
|
377
|
-
*/
|
|
378
|
-
isHTTPS() {
|
|
379
|
-
return !!this.config.ssl;
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Health check
|
|
383
|
-
*/
|
|
384
|
-
async healthCheck() {
|
|
385
|
-
const uptime = this.startTime ? Date.now() - this.startTime.getTime() : 0;
|
|
386
|
-
return {
|
|
387
|
-
status: this.running ? 'ok' : 'error',
|
|
388
|
-
uptime,
|
|
389
|
-
version: '1.0.0',
|
|
390
|
-
timestamp: new Date().toISOString(),
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
/**
|
|
394
|
-
* Get session manager for external access
|
|
395
|
-
*/
|
|
396
|
-
getSessionManager() {
|
|
397
|
-
return this._sessionManager;
|
|
398
|
-
}
|
|
399
|
-
/**
|
|
400
|
-
* Get active session count
|
|
401
|
-
*/
|
|
402
|
-
getActiveSessionCount() {
|
|
403
|
-
return this._sessionManager.getActiveSessionCount();
|
|
404
|
-
}
|
|
405
|
-
/**
|
|
406
|
-
* Handle incoming HTTP request
|
|
407
|
-
*/
|
|
408
|
-
handleRequest(req, res) {
|
|
409
|
-
const url = req.url || '/';
|
|
410
|
-
const method = req.method || 'GET';
|
|
411
|
-
const origin = req.headers.origin;
|
|
412
|
-
// Add CORS headers
|
|
413
|
-
const corsHeaders = this.httpHandler.getCORSHeaders(origin);
|
|
414
|
-
for (const [key, value] of Object.entries(corsHeaders)) {
|
|
415
|
-
res.setHeader(key, value);
|
|
416
|
-
}
|
|
417
|
-
// Handle preflight
|
|
418
|
-
if (method === 'OPTIONS') {
|
|
419
|
-
res.writeHead(204);
|
|
420
|
-
res.end();
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
// Health check endpoint
|
|
424
|
-
if (url === '/health' && method === 'GET') {
|
|
425
|
-
this.handleHealthCheck(res);
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
// MCP endpoint
|
|
429
|
-
if (url === '/mcp' && method === 'POST') {
|
|
430
|
-
this.handleMCPRequest(req, res);
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
// 404 for unknown routes
|
|
434
|
-
res.writeHead(404, { 'Content-Type': 'application/json' });
|
|
435
|
-
res.end(JSON.stringify({ error: 'Not found' }));
|
|
436
|
-
}
|
|
437
|
-
/**
|
|
438
|
-
* Handle health check request
|
|
439
|
-
*/
|
|
440
|
-
async handleHealthCheck(res) {
|
|
441
|
-
const health = await this.healthCheck();
|
|
442
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
443
|
-
res.end(JSON.stringify(health));
|
|
444
|
-
}
|
|
445
|
-
/**
|
|
446
|
-
* Handle MCP request
|
|
447
|
-
*/
|
|
448
|
-
handleMCPRequest(req, res) {
|
|
449
|
-
// Check authentication if enabled
|
|
450
|
-
if (this.auth?.isEnabled()) {
|
|
451
|
-
const authHeader = req.headers.authorization;
|
|
452
|
-
const apiKey = req.headers['x-api-key'];
|
|
453
|
-
const clientIP = req.headers['x-forwarded-for']?.split(',')[0] ||
|
|
454
|
-
req.socket.remoteAddress ||
|
|
455
|
-
'';
|
|
456
|
-
// Check IP whitelist
|
|
457
|
-
if (!this.auth.isIPAllowed(clientIP)) {
|
|
458
|
-
res.writeHead(403, { 'Content-Type': 'application/json' });
|
|
459
|
-
res.end(JSON.stringify(this.httpHandler.buildErrorResponse(null, -32001, 'IP not allowed')));
|
|
460
|
-
return;
|
|
461
|
-
}
|
|
462
|
-
// Check API key or token
|
|
463
|
-
const token = this.auth.extractToken(authHeader);
|
|
464
|
-
if (!token && !apiKey) {
|
|
465
|
-
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
466
|
-
res.end(JSON.stringify(this.httpHandler.buildErrorResponse(null, -32002, 'Authentication required')));
|
|
467
|
-
return;
|
|
468
|
-
}
|
|
469
|
-
if (token && !this.auth.validateToken(token)) {
|
|
470
|
-
if (!apiKey || !this.auth.validateApiKey(apiKey)) {
|
|
471
|
-
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
472
|
-
res.end(JSON.stringify(this.httpHandler.buildErrorResponse(null, -32003, 'Invalid credentials')));
|
|
473
|
-
return;
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
// Read request body
|
|
478
|
-
let body = '';
|
|
479
|
-
req.on('data', (chunk) => {
|
|
480
|
-
body += chunk.toString();
|
|
481
|
-
});
|
|
482
|
-
req.on('end', () => {
|
|
483
|
-
try {
|
|
484
|
-
const request = this.httpHandler.parseRequest(body);
|
|
485
|
-
// TODO: Route to appropriate MCP tool handler
|
|
486
|
-
// For now, return a placeholder response
|
|
487
|
-
const response = this.httpHandler.buildResponse(request.id, {
|
|
488
|
-
message: 'MCP request received',
|
|
489
|
-
method: request.method,
|
|
490
|
-
params: request.params,
|
|
491
|
-
});
|
|
492
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
493
|
-
res.end(JSON.stringify(response));
|
|
494
|
-
}
|
|
495
|
-
catch (error) {
|
|
496
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
497
|
-
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
498
|
-
res.end(JSON.stringify(this.httpHandler.buildErrorResponse(null, -32700, errorMessage)));
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
req.on('error', (error) => {
|
|
502
|
-
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
503
|
-
res.end(JSON.stringify(this.httpHandler.buildErrorResponse(null, -32603, error.message)));
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
//# sourceMappingURL=remote-mcp-server.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remote-mcp-server.js","sourceRoot":"","sources":["../../src/remote/remote-mcp-server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAA2C,MAAM,MAAM,CAAC;AAC7E,OAAO,EAAE,YAAY,IAAI,iBAAiB,EAAyB,MAAM,OAAO,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AA4FpC;;;GAGG;AACH,MAAM,OAAO,cAAc;IACjB,QAAQ,GAAyB,IAAI,GAAG,EAAE,CAAC;IAC3C,MAAM,CAAuB;IAErC,YAAY,MAA4B;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,MAAc;QAC1B,6DAA6D;QAC7D,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YACrD,wBAAwB;YACxB,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC7B,CAAC;QAED,MAAM,OAAO,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