@whook/mcp 26.0.5
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 +20 -0
- package/README.md +93 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +550 -0
- package/dist/index.test.js.map +1 -0
- package/dist/services/httpRouter.d.ts +20 -0
- package/dist/services/httpRouter.js +5 -0
- package/dist/services/httpRouter.js.map +1 -0
- package/dist/services/mcpHandler.d.ts +60 -0
- package/dist/services/mcpHandler.js +334 -0
- package/dist/services/mcpHandler.js.map +1 -0
- package/dist/wrappers/wrapHTTPRouterWithMCPServer.d.ts +17 -0
- package/dist/wrappers/wrapHTTPRouterWithMCPServer.js +72 -0
- package/dist/wrappers/wrapHTTPRouterWithMCPServer.js.map +1 -0
- package/package.json +162 -0
- package/src/index.test.ts +598 -0
- package/src/index.ts +9 -0
- package/src/services/httpRouter.ts +8 -0
- package/src/services/mcpHandler.ts +551 -0
- package/src/types.d.ts +7 -0
- package/src/wrappers/wrapHTTPRouterWithMCPServer.ts +137 -0
|
@@ -0,0 +1,598 @@
|
|
|
1
|
+
import { describe, test, beforeEach, jest, expect } from '@jest/globals';
|
|
2
|
+
import { constant, initializer, type Knifecycle } from 'knifecycle';
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
import {
|
|
5
|
+
prepareProcess,
|
|
6
|
+
prepareEnvironment,
|
|
7
|
+
getPingDefinition,
|
|
8
|
+
initHTTPRouter,
|
|
9
|
+
type WhookDefinitions,
|
|
10
|
+
} from '@whook/whook';
|
|
11
|
+
import { YError } from 'yerror';
|
|
12
|
+
import {
|
|
13
|
+
wrapHTTPRouterWithMCPServer,
|
|
14
|
+
initMCPHandler,
|
|
15
|
+
type BearerPayload,
|
|
16
|
+
} from './index.js';
|
|
17
|
+
import { type WhookMCPOptions } from './index.js';
|
|
18
|
+
import { type OpenAPI } from 'ya-open-api-types';
|
|
19
|
+
import { type Logger } from 'common-services';
|
|
20
|
+
import { type WhookAuthenticationService } from '@whook/authorization';
|
|
21
|
+
|
|
22
|
+
describe('wrapHTTPRouterWithMCPServer', () => {
|
|
23
|
+
const HOST = 'localhost';
|
|
24
|
+
const BASE_PATH = '/v1';
|
|
25
|
+
const API: OpenAPI = {
|
|
26
|
+
openapi: '3.1.0',
|
|
27
|
+
info: {
|
|
28
|
+
version: '1.0.0',
|
|
29
|
+
title: 'Sample OpenAPI',
|
|
30
|
+
description: 'A sample OpenAPI file for testing purpose.',
|
|
31
|
+
},
|
|
32
|
+
paths: {
|
|
33
|
+
[`${BASE_PATH}${getPingDefinition.path}`]: {
|
|
34
|
+
[getPingDefinition.method]: getPingDefinition.operation,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
const logger = {
|
|
39
|
+
output: jest.fn(),
|
|
40
|
+
error: jest.fn(),
|
|
41
|
+
debug: jest.fn(),
|
|
42
|
+
};
|
|
43
|
+
const time = jest.fn();
|
|
44
|
+
const authentication = {
|
|
45
|
+
check: jest.fn<WhookAuthenticationService<BearerPayload>['check']>(),
|
|
46
|
+
};
|
|
47
|
+
const $autoload = jest.fn(async (serviceName) => {
|
|
48
|
+
throw new YError('E_UNMATCHED_DEPENDENCY', [serviceName as string]);
|
|
49
|
+
});
|
|
50
|
+
const MCP_OPTIONS: WhookMCPOptions = {
|
|
51
|
+
metadata: {
|
|
52
|
+
name: 'MCP Server',
|
|
53
|
+
version: '1.0.0',
|
|
54
|
+
},
|
|
55
|
+
path: '/mcp',
|
|
56
|
+
prebuildTools: true,
|
|
57
|
+
securityKeys: ['bearerAuth'],
|
|
58
|
+
};
|
|
59
|
+
const DEFINITIONS: WhookDefinitions = {
|
|
60
|
+
components: {},
|
|
61
|
+
paths: {
|
|
62
|
+
'/ping': {
|
|
63
|
+
get: getPingDefinition.operation,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
security: [],
|
|
67
|
+
configs: {
|
|
68
|
+
getPing: {
|
|
69
|
+
type: 'route',
|
|
70
|
+
path: '/ping',
|
|
71
|
+
method: 'get',
|
|
72
|
+
config: {},
|
|
73
|
+
operation: getPingDefinition.operation,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
let $: Knifecycle;
|
|
78
|
+
|
|
79
|
+
beforeEach(() => {
|
|
80
|
+
logger.output.mockReset();
|
|
81
|
+
logger.error.mockReset();
|
|
82
|
+
logger.debug.mockReset();
|
|
83
|
+
time.mockReset();
|
|
84
|
+
authentication.check.mockReset();
|
|
85
|
+
$autoload.mockClear();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
beforeEach(async () => {
|
|
89
|
+
$ = await prepareEnvironment();
|
|
90
|
+
|
|
91
|
+
$.register(
|
|
92
|
+
initializer(
|
|
93
|
+
{
|
|
94
|
+
name: '$autoload',
|
|
95
|
+
type: 'service',
|
|
96
|
+
singleton: true,
|
|
97
|
+
},
|
|
98
|
+
async () => $autoload,
|
|
99
|
+
),
|
|
100
|
+
);
|
|
101
|
+
$.register(constant('DEV_ACCESS_TOKEN', 'oudelali'));
|
|
102
|
+
$.register(constant('BASE_PATH', BASE_PATH));
|
|
103
|
+
$.register(constant('HOST', HOST));
|
|
104
|
+
$.register(constant('APP_ENV', 'local'));
|
|
105
|
+
$.register(constant('API', API));
|
|
106
|
+
$.register(constant('DEFINITIONS', DEFINITIONS));
|
|
107
|
+
$.register(constant('ROUTES_WRAPPERS_NAMES', []));
|
|
108
|
+
$.register(constant('authentication', authentication));
|
|
109
|
+
$.register(
|
|
110
|
+
constant('ROUTES_HANDLERS', {
|
|
111
|
+
getPing: jest.fn(async () => ({
|
|
112
|
+
status: 200,
|
|
113
|
+
headers: { 'content-type': 'application/json' },
|
|
114
|
+
body: { ping: 'pong' },
|
|
115
|
+
})),
|
|
116
|
+
}),
|
|
117
|
+
);
|
|
118
|
+
$.register(constant('logger', logger as Logger));
|
|
119
|
+
$.register(constant('time', time));
|
|
120
|
+
$.register(constant('MCP_OPTIONS', MCP_OPTIONS));
|
|
121
|
+
$.register(initMCPHandler);
|
|
122
|
+
$.register(wrapHTTPRouterWithMCPServer(initHTTPRouter));
|
|
123
|
+
$.register(constant('CONFIG', {}));
|
|
124
|
+
$.register(constant('DEBUG_NODE_ENVS', ['test']));
|
|
125
|
+
$.register(
|
|
126
|
+
constant('ENV', {
|
|
127
|
+
NODE_ENV: 'test',
|
|
128
|
+
DEV_MODE: '1',
|
|
129
|
+
}),
|
|
130
|
+
);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('should list tools', async () => {
|
|
134
|
+
const PORT = 11111;
|
|
135
|
+
$.register(constant('PORT', PORT));
|
|
136
|
+
|
|
137
|
+
time.mockReturnValue(new Date('2010-03-06T00:00:00Z').getTime());
|
|
138
|
+
|
|
139
|
+
const { $instance } = await prepareProcess(
|
|
140
|
+
['$instance', 'httpServer', 'process'],
|
|
141
|
+
$,
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
authentication.check.mockResolvedValueOnce({
|
|
145
|
+
scopes: ['user'],
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const { status, headers, data } = await axios({
|
|
149
|
+
method: 'post',
|
|
150
|
+
url: `http://${HOST}:${PORT}${MCP_OPTIONS.path}`,
|
|
151
|
+
headers: {
|
|
152
|
+
'user-agent': '__avoid_axios_version__',
|
|
153
|
+
Authorization: 'bearer a_valid_token',
|
|
154
|
+
Accept: 'application/json; text/event-stream',
|
|
155
|
+
'Content-Type': 'application/json',
|
|
156
|
+
},
|
|
157
|
+
data: { jsonrpc: '2.0', id: 2, method: 'tools/list', params: {} },
|
|
158
|
+
validateStatus: () => true,
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
await $instance.destroy();
|
|
162
|
+
|
|
163
|
+
expect({
|
|
164
|
+
status,
|
|
165
|
+
headers: {
|
|
166
|
+
...headers,
|
|
167
|
+
// Erasing the Date header that may be added by Axios :/
|
|
168
|
+
date: undefined,
|
|
169
|
+
etag: undefined,
|
|
170
|
+
'last-modified': undefined,
|
|
171
|
+
server: undefined,
|
|
172
|
+
connection: undefined,
|
|
173
|
+
'keep-alive': undefined,
|
|
174
|
+
},
|
|
175
|
+
data,
|
|
176
|
+
}).toMatchInlineSnapshot(`
|
|
177
|
+
{
|
|
178
|
+
"data": "event: message
|
|
179
|
+
data: {"result":{"tools":[{"name":"getPing","description":"Checks API's availability.","annotations":{"readOnlyHint":true,"idempotentHint":true,"destructiveHint":false,"openWorldHint":true},"inputSchema":{"type":"object","required":[],"properties":{}},"outputSchema":{"type":"object","required":["status","body"],"properties":{"status":{"const":200},"body":{"type":"object","additionalProperties":false,"properties":{"pong":{"type":"string","enum":["pong"]}}}}}}]},"jsonrpc":"2.0","id":2}
|
|
180
|
+
|
|
181
|
+
",
|
|
182
|
+
"headers": {
|
|
183
|
+
"cache-control": "no-cache, no-transform",
|
|
184
|
+
"connection": undefined,
|
|
185
|
+
"content-type": "text/event-stream",
|
|
186
|
+
"date": undefined,
|
|
187
|
+
"etag": undefined,
|
|
188
|
+
"keep-alive": undefined,
|
|
189
|
+
"last-modified": undefined,
|
|
190
|
+
"server": undefined,
|
|
191
|
+
"transfer-encoding": "chunked",
|
|
192
|
+
"x-accel-buffering": "no",
|
|
193
|
+
},
|
|
194
|
+
"status": 200,
|
|
195
|
+
}
|
|
196
|
+
`);
|
|
197
|
+
expect({
|
|
198
|
+
debugCalls: logger.debug.mock.calls.sort(sortLogs),
|
|
199
|
+
logErrorCalls: logger.error.mock.calls,
|
|
200
|
+
autoloaderCalls: $autoload.mock.calls,
|
|
201
|
+
authenticationCheckCalls: authentication.check.mock.calls,
|
|
202
|
+
}).toMatchInlineSnapshot(`
|
|
203
|
+
{
|
|
204
|
+
"authenticationCheckCalls": [
|
|
205
|
+
[
|
|
206
|
+
"bearer",
|
|
207
|
+
{
|
|
208
|
+
"hash": "a_valid_token",
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
],
|
|
212
|
+
"autoloaderCalls": [
|
|
213
|
+
[
|
|
214
|
+
"BUFFER_LIMIT",
|
|
215
|
+
],
|
|
216
|
+
[
|
|
217
|
+
"PARSERS",
|
|
218
|
+
],
|
|
219
|
+
[
|
|
220
|
+
"STRINGIFIERS",
|
|
221
|
+
],
|
|
222
|
+
[
|
|
223
|
+
"DECODERS",
|
|
224
|
+
],
|
|
225
|
+
[
|
|
226
|
+
"ENCODERS",
|
|
227
|
+
],
|
|
228
|
+
[
|
|
229
|
+
"COERCION_OPTIONS",
|
|
230
|
+
],
|
|
231
|
+
[
|
|
232
|
+
"SCHEMA_VALIDATORS_OPTIONS",
|
|
233
|
+
],
|
|
234
|
+
[
|
|
235
|
+
"TIMEOUT",
|
|
236
|
+
],
|
|
237
|
+
[
|
|
238
|
+
"TRANSACTIONS",
|
|
239
|
+
],
|
|
240
|
+
[
|
|
241
|
+
"SHIELD_CHAR",
|
|
242
|
+
],
|
|
243
|
+
[
|
|
244
|
+
"MAX_CLEAR_CHARS",
|
|
245
|
+
],
|
|
246
|
+
[
|
|
247
|
+
"MAX_CLEAR_RATIO",
|
|
248
|
+
],
|
|
249
|
+
[
|
|
250
|
+
"SENSIBLE_PROPS",
|
|
251
|
+
],
|
|
252
|
+
[
|
|
253
|
+
"SENSIBLE_HEADERS",
|
|
254
|
+
],
|
|
255
|
+
[
|
|
256
|
+
"uniqueId",
|
|
257
|
+
],
|
|
258
|
+
[
|
|
259
|
+
"ERRORS_DESCRIPTORS",
|
|
260
|
+
],
|
|
261
|
+
[
|
|
262
|
+
"DEFAULT_ERROR_CODE",
|
|
263
|
+
],
|
|
264
|
+
[
|
|
265
|
+
"QUERY_PARSER_OPTIONS",
|
|
266
|
+
],
|
|
267
|
+
[
|
|
268
|
+
"PROCESS_NAME",
|
|
269
|
+
],
|
|
270
|
+
[
|
|
271
|
+
"SIGNALS",
|
|
272
|
+
],
|
|
273
|
+
[
|
|
274
|
+
"HTTP_SERVER_OPTIONS",
|
|
275
|
+
],
|
|
276
|
+
],
|
|
277
|
+
"debugCalls": [
|
|
278
|
+
[
|
|
279
|
+
"⌛ - Delay service initialized.",
|
|
280
|
+
],
|
|
281
|
+
[
|
|
282
|
+
"⏳ - Cancelling pending timeouts:",
|
|
283
|
+
0,
|
|
284
|
+
],
|
|
285
|
+
[
|
|
286
|
+
"✅ - Closing HTTP server.",
|
|
287
|
+
],
|
|
288
|
+
[
|
|
289
|
+
"✔️ - HTTP server closed!",
|
|
290
|
+
],
|
|
291
|
+
[
|
|
292
|
+
"❤️ - Initializing the APM service.",
|
|
293
|
+
],
|
|
294
|
+
[
|
|
295
|
+
"➕ - Found 1 tools!",
|
|
296
|
+
],
|
|
297
|
+
[
|
|
298
|
+
"➕ - Listing tools!",
|
|
299
|
+
],
|
|
300
|
+
[
|
|
301
|
+
"➕ - MCP request authenticated",
|
|
302
|
+
],
|
|
303
|
+
[
|
|
304
|
+
"👣 - Logging service initialized.",
|
|
305
|
+
],
|
|
306
|
+
[
|
|
307
|
+
"💱 - HTTP Transaction initialized.",
|
|
308
|
+
],
|
|
309
|
+
[
|
|
310
|
+
"📇 - Process service initialized.",
|
|
311
|
+
],
|
|
312
|
+
[
|
|
313
|
+
"🔧 - Building tool for getPing!",
|
|
314
|
+
],
|
|
315
|
+
[
|
|
316
|
+
"🔧 - Pre-building tools!",
|
|
317
|
+
],
|
|
318
|
+
[
|
|
319
|
+
"🕶️ - Initializing the obfuscator service.",
|
|
320
|
+
],
|
|
321
|
+
[
|
|
322
|
+
"🙋 - MCP authentication: ",
|
|
323
|
+
"{"scopes":["user"]}",
|
|
324
|
+
],
|
|
325
|
+
[
|
|
326
|
+
"🚦 - HTTP Router initialized.",
|
|
327
|
+
],
|
|
328
|
+
],
|
|
329
|
+
"logErrorCalls": [
|
|
330
|
+
[
|
|
331
|
+
"🖃 - Initializing the validators service.",
|
|
332
|
+
],
|
|
333
|
+
[
|
|
334
|
+
"⌨️ - Initializing the basic query parser.",
|
|
335
|
+
],
|
|
336
|
+
[
|
|
337
|
+
"💻 - Starting the MCPServer service.",
|
|
338
|
+
],
|
|
339
|
+
[
|
|
340
|
+
"💁 - Serving API through MCP (path: /mcp)",
|
|
341
|
+
],
|
|
342
|
+
[
|
|
343
|
+
"🎙️ - HTTP Server listening at "http://localhost:11111".",
|
|
344
|
+
],
|
|
345
|
+
[
|
|
346
|
+
"On air 🚀🌕",
|
|
347
|
+
],
|
|
348
|
+
],
|
|
349
|
+
}
|
|
350
|
+
`);
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
test('should run a tool', async () => {
|
|
354
|
+
const PORT = 11112;
|
|
355
|
+
|
|
356
|
+
$.register(constant('PORT', PORT));
|
|
357
|
+
|
|
358
|
+
time.mockReturnValue(new Date('2010-03-06T00:00:00Z').getTime());
|
|
359
|
+
|
|
360
|
+
const { $instance } = await prepareProcess(
|
|
361
|
+
['$instance', 'httpServer', 'process'],
|
|
362
|
+
$,
|
|
363
|
+
);
|
|
364
|
+
|
|
365
|
+
authentication.check.mockResolvedValueOnce({
|
|
366
|
+
scopes: ['user'],
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
const { status, headers, data } = await axios({
|
|
370
|
+
method: 'post',
|
|
371
|
+
url: `http://${HOST}:${PORT}${MCP_OPTIONS.path}`,
|
|
372
|
+
headers: {
|
|
373
|
+
'user-agent': '__avoid_axios_version__',
|
|
374
|
+
Authorization: 'bearer a_valid_token',
|
|
375
|
+
Accept: 'application/json; text/event-stream',
|
|
376
|
+
'Content-Type': 'application/json',
|
|
377
|
+
},
|
|
378
|
+
data: {
|
|
379
|
+
jsonrpc: '2.0',
|
|
380
|
+
id: 2,
|
|
381
|
+
method: 'tools/call',
|
|
382
|
+
params: {
|
|
383
|
+
name: 'getPing',
|
|
384
|
+
arguments: {},
|
|
385
|
+
},
|
|
386
|
+
},
|
|
387
|
+
validateStatus: () => true,
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
await $instance.destroy();
|
|
391
|
+
|
|
392
|
+
expect({
|
|
393
|
+
status,
|
|
394
|
+
headers: {
|
|
395
|
+
...headers,
|
|
396
|
+
// Erasing the Date header that may be added by Axios :/
|
|
397
|
+
date: undefined,
|
|
398
|
+
etag: undefined,
|
|
399
|
+
'last-modified': undefined,
|
|
400
|
+
server: undefined,
|
|
401
|
+
connection: undefined,
|
|
402
|
+
'keep-alive': undefined,
|
|
403
|
+
},
|
|
404
|
+
data,
|
|
405
|
+
}).toMatchInlineSnapshot(`
|
|
406
|
+
{
|
|
407
|
+
"data": "event: message
|
|
408
|
+
data: {"result":{"content":[{"type":"text","text":"{\\"status\\":200,\\"headers\\":{\\"content-type\\":\\"application/json\\"},\\"body\\":{\\"ping\\":\\"pong\\"}}"}]},"jsonrpc":"2.0","id":2}
|
|
409
|
+
|
|
410
|
+
",
|
|
411
|
+
"headers": {
|
|
412
|
+
"cache-control": "no-cache, no-transform",
|
|
413
|
+
"connection": undefined,
|
|
414
|
+
"content-type": "text/event-stream",
|
|
415
|
+
"date": undefined,
|
|
416
|
+
"etag": undefined,
|
|
417
|
+
"keep-alive": undefined,
|
|
418
|
+
"last-modified": undefined,
|
|
419
|
+
"server": undefined,
|
|
420
|
+
"transfer-encoding": "chunked",
|
|
421
|
+
"x-accel-buffering": "no",
|
|
422
|
+
},
|
|
423
|
+
"status": 200,
|
|
424
|
+
}
|
|
425
|
+
`);
|
|
426
|
+
expect({
|
|
427
|
+
debugCalls: logger.debug.mock.calls.sort(sortLogs),
|
|
428
|
+
logErrorCalls: logger.error.mock.calls,
|
|
429
|
+
autoloaderCalls: $autoload.mock.calls,
|
|
430
|
+
authenticationCheckCalls: authentication.check.mock.calls,
|
|
431
|
+
}).toMatchInlineSnapshot(`
|
|
432
|
+
{
|
|
433
|
+
"authenticationCheckCalls": [
|
|
434
|
+
[
|
|
435
|
+
"bearer",
|
|
436
|
+
{
|
|
437
|
+
"hash": "a_valid_token",
|
|
438
|
+
},
|
|
439
|
+
],
|
|
440
|
+
],
|
|
441
|
+
"autoloaderCalls": [
|
|
442
|
+
[
|
|
443
|
+
"BUFFER_LIMIT",
|
|
444
|
+
],
|
|
445
|
+
[
|
|
446
|
+
"PARSERS",
|
|
447
|
+
],
|
|
448
|
+
[
|
|
449
|
+
"STRINGIFIERS",
|
|
450
|
+
],
|
|
451
|
+
[
|
|
452
|
+
"DECODERS",
|
|
453
|
+
],
|
|
454
|
+
[
|
|
455
|
+
"ENCODERS",
|
|
456
|
+
],
|
|
457
|
+
[
|
|
458
|
+
"COERCION_OPTIONS",
|
|
459
|
+
],
|
|
460
|
+
[
|
|
461
|
+
"SCHEMA_VALIDATORS_OPTIONS",
|
|
462
|
+
],
|
|
463
|
+
[
|
|
464
|
+
"TIMEOUT",
|
|
465
|
+
],
|
|
466
|
+
[
|
|
467
|
+
"TRANSACTIONS",
|
|
468
|
+
],
|
|
469
|
+
[
|
|
470
|
+
"SHIELD_CHAR",
|
|
471
|
+
],
|
|
472
|
+
[
|
|
473
|
+
"MAX_CLEAR_CHARS",
|
|
474
|
+
],
|
|
475
|
+
[
|
|
476
|
+
"MAX_CLEAR_RATIO",
|
|
477
|
+
],
|
|
478
|
+
[
|
|
479
|
+
"SENSIBLE_PROPS",
|
|
480
|
+
],
|
|
481
|
+
[
|
|
482
|
+
"SENSIBLE_HEADERS",
|
|
483
|
+
],
|
|
484
|
+
[
|
|
485
|
+
"uniqueId",
|
|
486
|
+
],
|
|
487
|
+
[
|
|
488
|
+
"ERRORS_DESCRIPTORS",
|
|
489
|
+
],
|
|
490
|
+
[
|
|
491
|
+
"DEFAULT_ERROR_CODE",
|
|
492
|
+
],
|
|
493
|
+
[
|
|
494
|
+
"QUERY_PARSER_OPTIONS",
|
|
495
|
+
],
|
|
496
|
+
[
|
|
497
|
+
"PROCESS_NAME",
|
|
498
|
+
],
|
|
499
|
+
[
|
|
500
|
+
"SIGNALS",
|
|
501
|
+
],
|
|
502
|
+
[
|
|
503
|
+
"HTTP_SERVER_OPTIONS",
|
|
504
|
+
],
|
|
505
|
+
],
|
|
506
|
+
"debugCalls": [
|
|
507
|
+
[
|
|
508
|
+
"{"type":"object","required":[],"properties":{}}",
|
|
509
|
+
],
|
|
510
|
+
[
|
|
511
|
+
"⌛ - Delay service initialized.",
|
|
512
|
+
],
|
|
513
|
+
[
|
|
514
|
+
"⏳ - Cancelling pending timeouts:",
|
|
515
|
+
0,
|
|
516
|
+
],
|
|
517
|
+
[
|
|
518
|
+
"⚠️ - Prefer using $ref to OpenAPI schemas components to build more efficiently!",
|
|
519
|
+
],
|
|
520
|
+
[
|
|
521
|
+
"✅ - Closing HTTP server.",
|
|
522
|
+
],
|
|
523
|
+
[
|
|
524
|
+
"✔️ - HTTP server closed!",
|
|
525
|
+
],
|
|
526
|
+
[
|
|
527
|
+
"❤️ - Initializing the APM service.",
|
|
528
|
+
],
|
|
529
|
+
[
|
|
530
|
+
"➕ - MCP request authenticated",
|
|
531
|
+
],
|
|
532
|
+
[
|
|
533
|
+
"➕ - Parameters "{"path":{},"query":{},"cookies":{},"headers":{}}"",
|
|
534
|
+
],
|
|
535
|
+
[
|
|
536
|
+
"➕ - Response "{"status":200,"headers":{"content-type":"application/json"},"body":{"ping":"pong"}}"!",
|
|
537
|
+
],
|
|
538
|
+
[
|
|
539
|
+
"➕ - Running call getPing!",
|
|
540
|
+
],
|
|
541
|
+
[
|
|
542
|
+
"👣 - Logging service initialized.",
|
|
543
|
+
],
|
|
544
|
+
[
|
|
545
|
+
"💱 - HTTP Transaction initialized.",
|
|
546
|
+
],
|
|
547
|
+
[
|
|
548
|
+
"📇 - Process service initialized.",
|
|
549
|
+
],
|
|
550
|
+
[
|
|
551
|
+
"🔧 - Building tool for getPing!",
|
|
552
|
+
],
|
|
553
|
+
[
|
|
554
|
+
"🔧 - Pre-building tools!",
|
|
555
|
+
],
|
|
556
|
+
[
|
|
557
|
+
"🕶️ - Initializing the obfuscator service.",
|
|
558
|
+
],
|
|
559
|
+
[
|
|
560
|
+
"🙋 - MCP authentication: ",
|
|
561
|
+
"{"scopes":["user"]}",
|
|
562
|
+
],
|
|
563
|
+
[
|
|
564
|
+
"🚦 - HTTP Router initialized.",
|
|
565
|
+
],
|
|
566
|
+
],
|
|
567
|
+
"logErrorCalls": [
|
|
568
|
+
[
|
|
569
|
+
"🖃 - Initializing the validators service.",
|
|
570
|
+
],
|
|
571
|
+
[
|
|
572
|
+
"⌨️ - Initializing the basic query parser.",
|
|
573
|
+
],
|
|
574
|
+
[
|
|
575
|
+
"💻 - Starting the MCPServer service.",
|
|
576
|
+
],
|
|
577
|
+
[
|
|
578
|
+
"💁 - Serving API through MCP (path: /mcp)",
|
|
579
|
+
],
|
|
580
|
+
[
|
|
581
|
+
"🎙️ - HTTP Server listening at "http://localhost:11112".",
|
|
582
|
+
],
|
|
583
|
+
[
|
|
584
|
+
"On air 🚀🌕",
|
|
585
|
+
],
|
|
586
|
+
],
|
|
587
|
+
}
|
|
588
|
+
`);
|
|
589
|
+
});
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
function sortLogs(strs1: unknown[], strs2: unknown[]): number {
|
|
593
|
+
return (strs1 as string[])[0] > (strs2 as string[])[0]
|
|
594
|
+
? 1
|
|
595
|
+
: (strs1 as string[])[0] === (strs2 as string[])[0]
|
|
596
|
+
? 0
|
|
597
|
+
: -1;
|
|
598
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type * from './wrappers/wrapHTTPRouterWithMCPServer.js';
|
|
2
|
+
export type * from './services/httpRouter.js';
|
|
3
|
+
export type * from './services/mcpHandler.js';
|
|
4
|
+
|
|
5
|
+
import wrapHTTPRouterWithMCPServer from './wrappers/wrapHTTPRouterWithMCPServer.js';
|
|
6
|
+
import initHTTPRouter from './services/httpRouter.js';
|
|
7
|
+
import initMCPHandler from './services/mcpHandler.js';
|
|
8
|
+
|
|
9
|
+
export { wrapHTTPRouterWithMCPServer, initHTTPRouter, initMCPHandler };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { initHTTPRouter } from '@whook/whook';
|
|
2
|
+
import { location } from 'knifecycle';
|
|
3
|
+
import wrapHTTPRouterWithMCPServer from '../wrappers/wrapHTTPRouterWithMCPServer.js';
|
|
4
|
+
|
|
5
|
+
export default location(
|
|
6
|
+
wrapHTTPRouterWithMCPServer(initHTTPRouter),
|
|
7
|
+
import.meta.url,
|
|
8
|
+
);
|