proofscan 0.9.2 → 0.10.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/dist/cli.js +4 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +2 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/proxy.d.ts +11 -0
- package/dist/commands/proxy.d.ts.map +1 -0
- package/dist/commands/proxy.js +119 -0
- package/dist/commands/proxy.js.map +1 -0
- package/dist/proxy/index.d.ts +9 -0
- package/dist/proxy/index.d.ts.map +1 -0
- package/dist/proxy/index.js +9 -0
- package/dist/proxy/index.js.map +1 -0
- package/dist/proxy/logger.d.ts +36 -0
- package/dist/proxy/logger.d.ts.map +1 -0
- package/dist/proxy/logger.js +72 -0
- package/dist/proxy/logger.js.map +1 -0
- package/dist/proxy/mcp-server.d.ts +93 -0
- package/dist/proxy/mcp-server.d.ts.map +1 -0
- package/dist/proxy/mcp-server.js +311 -0
- package/dist/proxy/mcp-server.js.map +1 -0
- package/dist/proxy/request-router.d.ts +26 -0
- package/dist/proxy/request-router.d.ts.map +1 -0
- package/dist/proxy/request-router.js +90 -0
- package/dist/proxy/request-router.js.map +1 -0
- package/dist/proxy/tool-aggregator.d.ts +46 -0
- package/dist/proxy/tool-aggregator.d.ts.map +1 -0
- package/dist/proxy/tool-aggregator.js +112 -0
- package/dist/proxy/tool-aggregator.js.map +1 -0
- package/dist/proxy/types.d.ts +117 -0
- package/dist/proxy/types.d.ts.map +1 -0
- package/dist/proxy/types.js +21 -0
- package/dist/proxy/types.js.map +1 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -25,7 +25,7 @@ import { setOutputOptions } from './utils/output.js';
|
|
|
25
25
|
const require = createRequire(import.meta.url);
|
|
26
26
|
const packageJson = require('../package.json');
|
|
27
27
|
const VERSION = packageJson.version;
|
|
28
|
-
import { createConfigCommand, createConnectorsCommand, createScanCommand, createMonitorCommand, createSessionsCommand, createArchiveCommand, createViewCommand, createTreeCommand, createExploreCommand, createStatusCommand, createEventsCommand, createRpcCommand, createSummaryCommand, createPermissionsCommand, createRecordCommand, createDoctorCommand, createShellCommand, createSecretsCommand, createToolCommand, } from './commands/index.js';
|
|
28
|
+
import { createConfigCommand, createConnectorsCommand, createScanCommand, createMonitorCommand, createSessionsCommand, createArchiveCommand, createViewCommand, createTreeCommand, createExploreCommand, createStatusCommand, createEventsCommand, createRpcCommand, createSummaryCommand, createPermissionsCommand, createRecordCommand, createDoctorCommand, createShellCommand, createSecretsCommand, createToolCommand, createProxyCommand, } from './commands/index.js';
|
|
29
29
|
const program = new Command();
|
|
30
30
|
// Global state for config path
|
|
31
31
|
let globalConfigPath;
|
|
@@ -172,6 +172,8 @@ secretCmd.name('secret').description('Alias for secrets');
|
|
|
172
172
|
program.addCommand(secretCmd);
|
|
173
173
|
// tool (Phase 4.4: CLI tool commands - ls, show, call)
|
|
174
174
|
program.addCommand(createToolCommand(getConfigPath));
|
|
175
|
+
// proxy (Phase 5.0: MCP Proxy server)
|
|
176
|
+
program.addCommand(createProxyCommand(getConfigPath));
|
|
175
177
|
// ============================================================
|
|
176
178
|
// Default action: pfscan → pfscan view
|
|
177
179
|
// ============================================================
|
|
@@ -183,7 +185,7 @@ function hasHelpFlag() {
|
|
|
183
185
|
const KNOWN_COMMANDS = new Set([
|
|
184
186
|
'view', 'v', 'tree', 't', 'explore', 'e', 'status', 'st',
|
|
185
187
|
'scan', 's', 'archive', 'a', 'config', 'c',
|
|
186
|
-
'connectors', 'connector', 'sessions', 'monitor', 'events', 'rpc', 'summary', 'permissions', 'record', 'doctor', 'shell', 'secrets', 'secret', 'tool', 'help'
|
|
188
|
+
'connectors', 'connector', 'sessions', 'monitor', 'events', 'rpc', 'summary', 'permissions', 'record', 'doctor', 'shell', 'secrets', 'secret', 'tool', 'proxy', 'help'
|
|
187
189
|
]);
|
|
188
190
|
// Shell-only commands (not available as CLI commands)
|
|
189
191
|
const SHELL_ONLY_COMMANDS = new Set(['send']);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,iCAAiC;AACjC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAC/C,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;AACpC,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,iCAAiC;AACjC,MAAM,OA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CAAC,CAAC;AACpC,CAAC;AAED,gBAAgB;AAChB,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/commands/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAG7B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAG5B,cAAc,UAAU,CAAC;AAGzB,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAG5B,cAAc,YAAY,CAAC;AAG3B,cAAc,cAAc,CAAC;AAG7B,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAG7B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAG5B,cAAc,UAAU,CAAC;AAGzB,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAG5B,cAAc,YAAY,CAAC;AAG3B,cAAc,cAAc,CAAC;AAG7B,cAAc,WAAW,CAAC;AAG1B,cAAc,YAAY,CAAC"}
|
package/dist/commands/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAE7B,yBAAyB;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAE5B,yBAAyB;AACzB,cAAc,UAAU,CAAC;AAEzB,uBAAuB;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAE5B,sBAAsB;AACtB,cAAc,YAAY,CAAC;AAE3B,gCAAgC;AAChC,cAAc,cAAc,CAAC;AAE7B,+BAA+B;AAC/B,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAE7B,yBAAyB;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAE5B,yBAAyB;AACzB,cAAc,UAAU,CAAC;AAEzB,uBAAuB;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAE5B,sBAAsB;AACtB,cAAc,YAAY,CAAC;AAE3B,gCAAgC;AAChC,cAAc,cAAc,CAAC;AAE7B,+BAA+B;AAC/B,cAAc,WAAW,CAAC;AAE1B,uBAAuB;AACvB,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy Command (Phase 5.0)
|
|
3
|
+
*
|
|
4
|
+
* pfscan proxy start [options]
|
|
5
|
+
*
|
|
6
|
+
* Starts an MCP proxy server that aggregates tools from multiple
|
|
7
|
+
* backend connectors.
|
|
8
|
+
*/
|
|
9
|
+
import { Command } from 'commander';
|
|
10
|
+
export declare function createProxyCommand(getConfigPath: () => string): Command;
|
|
11
|
+
//# sourceMappingURL=proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/commands/proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,MAAM,GAAG,OAAO,CAgIvE"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy Command (Phase 5.0)
|
|
3
|
+
*
|
|
4
|
+
* pfscan proxy start [options]
|
|
5
|
+
*
|
|
6
|
+
* Starts an MCP proxy server that aggregates tools from multiple
|
|
7
|
+
* backend connectors.
|
|
8
|
+
*/
|
|
9
|
+
import { Command } from 'commander';
|
|
10
|
+
import { ConfigManager } from '../config/index.js';
|
|
11
|
+
import { McpProxyServer, setVerbose, logger } from '../proxy/index.js';
|
|
12
|
+
import { getOutputOptions } from '../utils/output.js';
|
|
13
|
+
export function createProxyCommand(getConfigPath) {
|
|
14
|
+
const cmd = new Command('proxy')
|
|
15
|
+
.description('MCP proxy server operations');
|
|
16
|
+
cmd
|
|
17
|
+
.command('start')
|
|
18
|
+
.description('Start MCP proxy server (stdio)')
|
|
19
|
+
.option('--connectors <ids>', 'Connector IDs to expose (comma-separated)')
|
|
20
|
+
.option('--all', 'Expose all enabled connectors')
|
|
21
|
+
.option('--timeout <seconds>', 'Timeout for backend calls in seconds (default: 30)', '30')
|
|
22
|
+
.action(async (options) => {
|
|
23
|
+
// Set up logging - use global verbose option from CLI
|
|
24
|
+
const globalOpts = getOutputOptions();
|
|
25
|
+
if (globalOpts.verbose) {
|
|
26
|
+
setVerbose(true);
|
|
27
|
+
}
|
|
28
|
+
// Validate mutually exclusive options
|
|
29
|
+
if (options.connectors && options.all) {
|
|
30
|
+
logger.error('Cannot use --connectors and --all together');
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
if (!options.connectors && !options.all) {
|
|
34
|
+
logger.error('Must specify --connectors <ids> or --all');
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
// Load config
|
|
38
|
+
const configPath = getConfigPath();
|
|
39
|
+
const manager = new ConfigManager(configPath);
|
|
40
|
+
const configDir = manager.getConfigDir();
|
|
41
|
+
let config;
|
|
42
|
+
try {
|
|
43
|
+
config = await manager.load();
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
47
|
+
logger.error(`Failed to load config: ${msg}`);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
// Resolve connectors
|
|
51
|
+
let connectors;
|
|
52
|
+
if (options.all) {
|
|
53
|
+
// All enabled connectors
|
|
54
|
+
connectors = config.connectors.filter((c) => c.enabled);
|
|
55
|
+
if (connectors.length === 0) {
|
|
56
|
+
logger.error('No enabled connectors found');
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
logger.info(`Using ${connectors.length} enabled connector(s)`);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// Specific connectors
|
|
63
|
+
const ids = options.connectors.split(',').map((id) => id.trim());
|
|
64
|
+
connectors = [];
|
|
65
|
+
for (const id of ids) {
|
|
66
|
+
const connector = config.connectors.find((c) => c.id === id);
|
|
67
|
+
if (!connector) {
|
|
68
|
+
logger.error(`Connector not found: ${id}`);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
if (!connector.enabled) {
|
|
72
|
+
logger.warn(`Connector disabled, skipping: ${id}`);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
connectors.push(connector);
|
|
76
|
+
}
|
|
77
|
+
if (connectors.length === 0) {
|
|
78
|
+
logger.error('No valid connectors to expose');
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
logger.info(`Using ${connectors.length} connector(s): ${connectors.map(c => c.id).join(', ')}`);
|
|
82
|
+
}
|
|
83
|
+
// Parse timeout
|
|
84
|
+
const timeout = parseInt(options.timeout, 10);
|
|
85
|
+
if (isNaN(timeout) || timeout < 1 || timeout > 300) {
|
|
86
|
+
logger.error('Invalid timeout: must be 1-300 seconds');
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
// Create and start server
|
|
90
|
+
const server = new McpProxyServer({
|
|
91
|
+
connectors,
|
|
92
|
+
configDir,
|
|
93
|
+
verbose: globalOpts.verbose,
|
|
94
|
+
timeout,
|
|
95
|
+
});
|
|
96
|
+
// Handle signals for graceful shutdown
|
|
97
|
+
const shutdown = () => {
|
|
98
|
+
logger.info('Received shutdown signal');
|
|
99
|
+
server.stop();
|
|
100
|
+
process.exit(0);
|
|
101
|
+
};
|
|
102
|
+
process.on('SIGINT', shutdown);
|
|
103
|
+
process.on('SIGTERM', shutdown);
|
|
104
|
+
// Handle server stop
|
|
105
|
+
server.on('stopped', () => {
|
|
106
|
+
process.exit(0);
|
|
107
|
+
});
|
|
108
|
+
try {
|
|
109
|
+
await server.start();
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
113
|
+
logger.error(`Failed to start server: ${msg}`);
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
return cmd;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/commands/proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,UAAU,kBAAkB,CAAC,aAA2B;IAC5D,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;SAC7B,WAAW,CAAC,6BAA6B,CAAC,CAAC;IAE9C,GAAG;SACA,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,gCAAgC,CAAC;SAC7C,MAAM,CAAC,oBAAoB,EAAE,2CAA2C,CAAC;SACzE,MAAM,CAAC,OAAO,EAAE,+BAA+B,CAAC;SAChD,MAAM,CAAC,qBAAqB,EAAE,oDAAoD,EAAE,IAAI,CAAC;SACzF,MAAM,CAAC,KAAK,EAAE,OAId,EAAE,EAAE;QACH,sDAAsD;QACtD,MAAM,UAAU,GAAG,gBAAgB,EAAE,CAAC;QACtC,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;YACvB,UAAU,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;QAED,sCAAsC;QACtC,IAAI,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YACtC,MAAM,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;YAC3D,OAAO,CAAC,IA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
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy Module Exports (Phase 5.0)
|
|
3
|
+
*/
|
|
4
|
+
export { logger, setVerbose, isVerbose } from './logger.js';
|
|
5
|
+
export { ToolAggregator } from './tool-aggregator.js';
|
|
6
|
+
export { RequestRouter } from './request-router.js';
|
|
7
|
+
export { McpProxyServer } from './mcp-server.js';
|
|
8
|
+
export { NAMESPACE_SEPARATOR, MCP_ERROR, type ProxyOptions, type NamespacedTool, type ParsedNamespace, type RouteResult, type JsonRpcRequest, type JsonRpcResponse, type McpErrorCode, } from './types.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/proxy/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,mBAAmB,EACnB,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy Module Exports (Phase 5.0)
|
|
3
|
+
*/
|
|
4
|
+
export { logger, setVerbose, isVerbose } from './logger.js';
|
|
5
|
+
export { ToolAggregator } from './tool-aggregator.js';
|
|
6
|
+
export { RequestRouter } from './request-router.js';
|
|
7
|
+
export { McpProxyServer } from './mcp-server.js';
|
|
8
|
+
export { NAMESPACE_SEPARATOR, MCP_ERROR, } from './types.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/proxy/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,mBAAmB,EACnB,SAAS,GAQV,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy Logger Module (Phase 5.0)
|
|
3
|
+
*
|
|
4
|
+
* Structured logging to stderr only (stdout reserved for JSON-RPC).
|
|
5
|
+
*
|
|
6
|
+
* Log levels:
|
|
7
|
+
* - ERROR: Always output (red)
|
|
8
|
+
* - WARN: Always output (yellow)
|
|
9
|
+
* - INFO: Only when verbose mode enabled (no color)
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Set verbose mode (enables INFO logs)
|
|
13
|
+
*/
|
|
14
|
+
export declare function setVerbose(enabled: boolean): void;
|
|
15
|
+
/**
|
|
16
|
+
* Check if verbose mode is enabled
|
|
17
|
+
*/
|
|
18
|
+
export declare function isVerbose(): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Logger instance
|
|
21
|
+
*/
|
|
22
|
+
export declare const logger: {
|
|
23
|
+
/**
|
|
24
|
+
* Info level - only shown when verbose mode is enabled
|
|
25
|
+
*/
|
|
26
|
+
info: (msg: string) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Warning level - always shown (yellow)
|
|
29
|
+
*/
|
|
30
|
+
warn: (msg: string) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Error level - always shown (red)
|
|
33
|
+
*/
|
|
34
|
+
error: (msg: string) => void;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/proxy/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAyCH;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAEjD;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED;;GAEG;AACH,eAAO,MAAM,MAAM;IACjB;;OAEG;gBACS,MAAM,KAAG,IAAI;IAEzB;;OAEG;gBACS,MAAM,KAAG,IAAI;IAEzB;;OAEG;iBACU,MAAM,KAAG,IAAI;CAC3B,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy Logger Module (Phase 5.0)
|
|
3
|
+
*
|
|
4
|
+
* Structured logging to stderr only (stdout reserved for JSON-RPC).
|
|
5
|
+
*
|
|
6
|
+
* Log levels:
|
|
7
|
+
* - ERROR: Always output (red)
|
|
8
|
+
* - WARN: Always output (yellow)
|
|
9
|
+
* - INFO: Only when verbose mode enabled (no color)
|
|
10
|
+
*/
|
|
11
|
+
const COLORS = {
|
|
12
|
+
WARN: '\x1b[33m',
|
|
13
|
+
ERROR: '\x1b[31m',
|
|
14
|
+
RESET: '\x1b[0m',
|
|
15
|
+
};
|
|
16
|
+
/** Global verbose flag - set by proxy command */
|
|
17
|
+
let verboseMode = false;
|
|
18
|
+
/**
|
|
19
|
+
* Get current time in HH:MM:SS format
|
|
20
|
+
*/
|
|
21
|
+
function now() {
|
|
22
|
+
return new Date().toISOString().slice(11, 19);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Internal log function
|
|
26
|
+
*/
|
|
27
|
+
function log(level, msg) {
|
|
28
|
+
// INFO is only shown in verbose mode
|
|
29
|
+
if (level === 'INFO' && !verboseMode) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const prefix = `[${now()}] [${level}] `;
|
|
33
|
+
if (level === 'INFO') {
|
|
34
|
+
// INFO: no color
|
|
35
|
+
process.stderr.write(prefix + msg + '\n');
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
// WARN/ERROR: with color
|
|
39
|
+
const color = COLORS[level];
|
|
40
|
+
process.stderr.write(color + prefix + msg + COLORS.RESET + '\n');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Set verbose mode (enables INFO logs)
|
|
45
|
+
*/
|
|
46
|
+
export function setVerbose(enabled) {
|
|
47
|
+
verboseMode = enabled;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Check if verbose mode is enabled
|
|
51
|
+
*/
|
|
52
|
+
export function isVerbose() {
|
|
53
|
+
return verboseMode;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Logger instance
|
|
57
|
+
*/
|
|
58
|
+
export const logger = {
|
|
59
|
+
/**
|
|
60
|
+
* Info level - only shown when verbose mode is enabled
|
|
61
|
+
*/
|
|
62
|
+
info: (msg) => log('INFO', msg),
|
|
63
|
+
/**
|
|
64
|
+
* Warning level - always shown (yellow)
|
|
65
|
+
*/
|
|
66
|
+
warn: (msg) => log('WARN', msg),
|
|
67
|
+
/**
|
|
68
|
+
* Error level - always shown (red)
|
|
69
|
+
*/
|
|
70
|
+
error: (msg) => log('ERROR', msg),
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/proxy/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,MAAM,MAAM,GAAG;IACb,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;IACjB,KAAK,EAAE,SAAS;CACR,CAAC;AAEX,iDAAiD;AACjD,IAA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AC,OAAO,EAAE,GAAG,CAAC;CAChD,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Proxy Server (Phase 5.0)
|
|
3
|
+
*
|
|
4
|
+
* A stdio-based MCP server that aggregates tools from multiple backend
|
|
5
|
+
* connectors and routes requests accordingly.
|
|
6
|
+
*
|
|
7
|
+
* Supported methods:
|
|
8
|
+
* - initialize
|
|
9
|
+
* - notifications/initialized
|
|
10
|
+
* - tools/list
|
|
11
|
+
* - tools/call
|
|
12
|
+
*/
|
|
13
|
+
import { EventEmitter } from 'events';
|
|
14
|
+
import { type ProxyOptions } from './types.js';
|
|
15
|
+
/**
|
|
16
|
+
* MCP Proxy Server
|
|
17
|
+
*
|
|
18
|
+
* Reads JSON-RPC from stdin, writes responses to stdout.
|
|
19
|
+
* All logging goes to stderr.
|
|
20
|
+
*/
|
|
21
|
+
export declare class McpProxyServer extends EventEmitter {
|
|
22
|
+
private readonly aggregator;
|
|
23
|
+
private readonly router;
|
|
24
|
+
private buffer;
|
|
25
|
+
private initialized;
|
|
26
|
+
private running;
|
|
27
|
+
constructor(options: ProxyOptions);
|
|
28
|
+
/**
|
|
29
|
+
* Start the proxy server
|
|
30
|
+
*
|
|
31
|
+
* Begins reading from stdin and processing JSON-RPC messages.
|
|
32
|
+
*/
|
|
33
|
+
start(): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Stop the proxy server
|
|
36
|
+
*/
|
|
37
|
+
stop(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Handle incoming data from stdin
|
|
40
|
+
*/
|
|
41
|
+
private handleData;
|
|
42
|
+
/**
|
|
43
|
+
* Handle stdin end
|
|
44
|
+
*/
|
|
45
|
+
private handleEnd;
|
|
46
|
+
/**
|
|
47
|
+
* Handle stdin error
|
|
48
|
+
*/
|
|
49
|
+
private handleError;
|
|
50
|
+
/**
|
|
51
|
+
* Process buffered data and extract complete JSON-RPC messages
|
|
52
|
+
*
|
|
53
|
+
* Messages are newline-delimited JSON.
|
|
54
|
+
*/
|
|
55
|
+
private processBuffer;
|
|
56
|
+
/**
|
|
57
|
+
* Process a single JSON-RPC message
|
|
58
|
+
*/
|
|
59
|
+
private processMessage;
|
|
60
|
+
/**
|
|
61
|
+
* Handle a JSON-RPC request (requires response)
|
|
62
|
+
*/
|
|
63
|
+
private handleRequest;
|
|
64
|
+
/**
|
|
65
|
+
* Handle a JSON-RPC notification (no response)
|
|
66
|
+
*/
|
|
67
|
+
private handleNotification;
|
|
68
|
+
/**
|
|
69
|
+
* Handle initialize request
|
|
70
|
+
*/
|
|
71
|
+
private handleInitialize;
|
|
72
|
+
/**
|
|
73
|
+
* Handle tools/list request
|
|
74
|
+
*/
|
|
75
|
+
private handleToolsList;
|
|
76
|
+
/**
|
|
77
|
+
* Handle tools/call request
|
|
78
|
+
*/
|
|
79
|
+
private handleToolsCall;
|
|
80
|
+
/**
|
|
81
|
+
* Send a JSON-RPC response with result
|
|
82
|
+
*/
|
|
83
|
+
private sendResult;
|
|
84
|
+
/**
|
|
85
|
+
* Send a JSON-RPC error response
|
|
86
|
+
*/
|
|
87
|
+
private sendError;
|
|
88
|
+
/**
|
|
89
|
+
* Send a message to stdout
|
|
90
|
+
*/
|
|
91
|
+
private send;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=mcp-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../../src/proxy/mcp-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAItC,OAAO,EAEL,KAAK,YAAY,EASlB,MAAM,YAAY,CAAC;AASpB;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,YAAY;IAC9C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiB;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,YAAY;IAMjC;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAkB5B;;OAEG;IACH,IAAI,IAAI,IAAI;IAeZ;;OAEG;IACH,OAAO,CAAC,UAAU;IAclB;;OAEG;IACH,OAAO,CAAC,SAAS;IAKjB;;OAEG;IACH,OAAO,CAAC,WAAW;IAKnB;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAerB;;OAEG;YACW,cAAc;IA+C5B;;OAEG;YACW,aAAa;IA6B3B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAiB1B;;OAEG;YACW,gBAAgB;IA4B9B;;OAEG;YACW,eAAe;IAyB7B;;OAEG;YACW,eAAe;IAiC7B;;OAEG;IACH,OAAO,CAAC,UAAU;IAUlB;;OAEG;IACH,OAAO,CAAC,SAAS;IAmBjB;;OAEG;IACH,OAAO,CAAC,IAAI;CAIb"}
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Proxy Server (Phase 5.0)
|
|
3
|
+
*
|
|
4
|
+
* A stdio-based MCP server that aggregates tools from multiple backend
|
|
5
|
+
* connectors and routes requests accordingly.
|
|
6
|
+
*
|
|
7
|
+
* Supported methods:
|
|
8
|
+
* - initialize
|
|
9
|
+
* - notifications/initialized
|
|
10
|
+
* - tools/list
|
|
11
|
+
* - tools/call
|
|
12
|
+
*/
|
|
13
|
+
import { EventEmitter } from 'events';
|
|
14
|
+
import { logger } from './logger.js';
|
|
15
|
+
import { ToolAggregator } from './tool-aggregator.js';
|
|
16
|
+
import { RequestRouter } from './request-router.js';
|
|
17
|
+
import { MCP_ERROR, } from './types.js';
|
|
18
|
+
const PROTOCOL_VERSION = '2024-11-05';
|
|
19
|
+
const SERVER_NAME = 'proofscan-proxy';
|
|
20
|
+
const SERVER_VERSION = '0.7.0';
|
|
21
|
+
/** Maximum buffer size in bytes (1MB) - prevents memory exhaustion attacks */
|
|
22
|
+
const MAX_BUFFER_SIZE = 1024 * 1024;
|
|
23
|
+
/**
|
|
24
|
+
* MCP Proxy Server
|
|
25
|
+
*
|
|
26
|
+
* Reads JSON-RPC from stdin, writes responses to stdout.
|
|
27
|
+
* All logging goes to stderr.
|
|
28
|
+
*/
|
|
29
|
+
export class McpProxyServer extends EventEmitter {
|
|
30
|
+
aggregator;
|
|
31
|
+
router;
|
|
32
|
+
buffer = '';
|
|
33
|
+
initialized = false;
|
|
34
|
+
running = false;
|
|
35
|
+
constructor(options) {
|
|
36
|
+
super();
|
|
37
|
+
this.aggregator = new ToolAggregator(options);
|
|
38
|
+
this.router = new RequestRouter(options, this.aggregator);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Start the proxy server
|
|
42
|
+
*
|
|
43
|
+
* Begins reading from stdin and processing JSON-RPC messages.
|
|
44
|
+
*/
|
|
45
|
+
async start() {
|
|
46
|
+
if (this.running) {
|
|
47
|
+
throw new Error('Server is already running');
|
|
48
|
+
}
|
|
49
|
+
this.running = true;
|
|
50
|
+
logger.info('MCP proxy server starting...');
|
|
51
|
+
// Set up stdin
|
|
52
|
+
process.stdin.setEncoding('utf-8');
|
|
53
|
+
process.stdin.on('data', (chunk) => this.handleData(chunk));
|
|
54
|
+
process.stdin.on('end', () => this.handleEnd());
|
|
55
|
+
process.stdin.on('error', (err) => this.handleError(err));
|
|
56
|
+
// Resume stdin
|
|
57
|
+
process.stdin.resume();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Stop the proxy server
|
|
61
|
+
*/
|
|
62
|
+
stop() {
|
|
63
|
+
if (!this.running) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
this.running = false;
|
|
67
|
+
logger.info('MCP proxy server stopping...');
|
|
68
|
+
// Clean up stdin
|
|
69
|
+
process.stdin.pause();
|
|
70
|
+
process.stdin.removeAllListeners();
|
|
71
|
+
this.emit('stopped');
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Handle incoming data from stdin
|
|
75
|
+
*/
|
|
76
|
+
handleData(chunk) {
|
|
77
|
+
this.buffer += chunk;
|
|
78
|
+
// Prevent memory exhaustion from large messages without newlines
|
|
79
|
+
if (this.buffer.length > MAX_BUFFER_SIZE) {
|
|
80
|
+
logger.error(`Buffer overflow: ${this.buffer.length} bytes exceeds ${MAX_BUFFER_SIZE}`);
|
|
81
|
+
this.sendError(null, MCP_ERROR.INVALID_REQUEST, 'Message too large');
|
|
82
|
+
this.buffer = '';
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this.processBuffer();
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Handle stdin end
|
|
89
|
+
*/
|
|
90
|
+
handleEnd() {
|
|
91
|
+
logger.info('stdin closed');
|
|
92
|
+
this.stop();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Handle stdin error
|
|
96
|
+
*/
|
|
97
|
+
handleError(err) {
|
|
98
|
+
logger.error(`stdin error: ${err.message}`);
|
|
99
|
+
this.stop();
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Process buffered data and extract complete JSON-RPC messages
|
|
103
|
+
*
|
|
104
|
+
* Messages are newline-delimited JSON.
|
|
105
|
+
*/
|
|
106
|
+
processBuffer() {
|
|
107
|
+
let newlineIndex;
|
|
108
|
+
while ((newlineIndex = this.buffer.indexOf('\n')) !== -1) {
|
|
109
|
+
const line = this.buffer.slice(0, newlineIndex).trim();
|
|
110
|
+
this.buffer = this.buffer.slice(newlineIndex + 1);
|
|
111
|
+
if (line) {
|
|
112
|
+
this.processMessage(line).catch((err) => {
|
|
113
|
+
logger.error(`Message processing error: ${err instanceof Error ? err.message : err}`);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Process a single JSON-RPC message
|
|
120
|
+
*/
|
|
121
|
+
async processMessage(line) {
|
|
122
|
+
let parsed;
|
|
123
|
+
try {
|
|
124
|
+
parsed = JSON.parse(line);
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
logger.error('JSON parse error');
|
|
128
|
+
this.sendError(null, MCP_ERROR.PARSE_ERROR, 'Parse error');
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
// Validate JSON-RPC structure
|
|
132
|
+
if (typeof parsed !== 'object' || parsed === null) {
|
|
133
|
+
logger.error('Invalid request: not an object');
|
|
134
|
+
this.sendError(null, MCP_ERROR.INVALID_REQUEST, 'Invalid Request');
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const msg = parsed;
|
|
138
|
+
if (msg.jsonrpc !== '2.0') {
|
|
139
|
+
logger.error('Invalid request: not JSON-RPC 2.0');
|
|
140
|
+
this.sendError(null, MCP_ERROR.INVALID_REQUEST, 'Invalid Request');
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
// Check if it's a request (has id) or notification (no id)
|
|
144
|
+
const hasId = 'id' in msg && msg.id !== undefined;
|
|
145
|
+
const method = msg.method;
|
|
146
|
+
if (!method || typeof method !== 'string') {
|
|
147
|
+
logger.error('Invalid request: missing method');
|
|
148
|
+
if (hasId) {
|
|
149
|
+
this.sendError(msg.id, MCP_ERROR.INVALID_REQUEST, 'Invalid Request');
|
|
150
|
+
}
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (hasId) {
|
|
154
|
+
// It's a request - needs response
|
|
155
|
+
await this.handleRequest(msg);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
// It's a notification - no response needed
|
|
159
|
+
this.handleNotification(msg);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Handle a JSON-RPC request (requires response)
|
|
164
|
+
*/
|
|
165
|
+
async handleRequest(request) {
|
|
166
|
+
// Check if server is still running (prevents race condition on shutdown)
|
|
167
|
+
if (!this.running) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const { id, method, params } = request;
|
|
171
|
+
logger.info(`Request: ${method}`);
|
|
172
|
+
switch (method) {
|
|
173
|
+
case 'initialize':
|
|
174
|
+
await this.handleInitialize(id, params);
|
|
175
|
+
break;
|
|
176
|
+
case 'tools/list':
|
|
177
|
+
await this.handleToolsList(id);
|
|
178
|
+
break;
|
|
179
|
+
case 'tools/call':
|
|
180
|
+
await this.handleToolsCall(id, params);
|
|
181
|
+
break;
|
|
182
|
+
default:
|
|
183
|
+
logger.warn(`Unknown method: ${method}`);
|
|
184
|
+
this.sendError(id, MCP_ERROR.METHOD_NOT_FOUND, `Method not found: ${method}`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Handle a JSON-RPC notification (no response)
|
|
189
|
+
*/
|
|
190
|
+
handleNotification(notification) {
|
|
191
|
+
const { method } = notification;
|
|
192
|
+
logger.info(`Notification: ${method}`);
|
|
193
|
+
switch (method) {
|
|
194
|
+
case 'notifications/initialized':
|
|
195
|
+
// Client acknowledged initialization
|
|
196
|
+
logger.info('Client initialized');
|
|
197
|
+
break;
|
|
198
|
+
default:
|
|
199
|
+
// Unknown notifications are silently ignored per MCP spec
|
|
200
|
+
logger.info(`Ignoring notification: ${method}`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Handle initialize request
|
|
205
|
+
*/
|
|
206
|
+
async handleInitialize(id, params) {
|
|
207
|
+
if (this.initialized) {
|
|
208
|
+
logger.warn('Already initialized');
|
|
209
|
+
}
|
|
210
|
+
const clientVersion = params?.protocolVersion || 'unknown';
|
|
211
|
+
const clientName = params?.clientInfo?.name || 'unknown';
|
|
212
|
+
logger.info(`Client: ${clientName} (protocol=${clientVersion})`);
|
|
213
|
+
this.initialized = true;
|
|
214
|
+
const result = {
|
|
215
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
216
|
+
capabilities: {
|
|
217
|
+
tools: {},
|
|
218
|
+
},
|
|
219
|
+
serverInfo: {
|
|
220
|
+
name: SERVER_NAME,
|
|
221
|
+
version: SERVER_VERSION,
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
this.sendResult(id, result);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Handle tools/list request
|
|
228
|
+
*/
|
|
229
|
+
async handleToolsList(id) {
|
|
230
|
+
if (!this.initialized) {
|
|
231
|
+
logger.warn('tools/list before initialize');
|
|
232
|
+
}
|
|
233
|
+
try {
|
|
234
|
+
const tools = await this.aggregator.getAggregatedTools();
|
|
235
|
+
const result = {
|
|
236
|
+
tools: tools.map((t) => ({
|
|
237
|
+
name: t.namespacedName,
|
|
238
|
+
description: t.description,
|
|
239
|
+
inputSchema: t.inputSchema,
|
|
240
|
+
})),
|
|
241
|
+
};
|
|
242
|
+
logger.info(`Returning ${tools.length} tool(s)`);
|
|
243
|
+
this.sendResult(id, result);
|
|
244
|
+
}
|
|
245
|
+
catch (error) {
|
|
246
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
247
|
+
logger.error(`tools/list failed: ${errorMessage}`);
|
|
248
|
+
this.sendError(id, MCP_ERROR.INTERNAL_ERROR, errorMessage);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Handle tools/call request
|
|
253
|
+
*/
|
|
254
|
+
async handleToolsCall(id, params) {
|
|
255
|
+
if (!this.initialized) {
|
|
256
|
+
logger.warn('tools/call before initialize');
|
|
257
|
+
}
|
|
258
|
+
if (!params || typeof params.name !== 'string') {
|
|
259
|
+
logger.error('tools/call: missing or invalid name');
|
|
260
|
+
this.sendError(id, MCP_ERROR.INVALID_PARAMS, 'Missing required parameter: name');
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const { name, arguments: args = {} } = params;
|
|
264
|
+
logger.info(`tools/call name=${name}`);
|
|
265
|
+
const result = await this.router.routeToolCall(name, args);
|
|
266
|
+
if (!result.success) {
|
|
267
|
+
// Routing or backend error
|
|
268
|
+
this.sendError(id, MCP_ERROR.INTERNAL_ERROR, result.error || 'Unknown error');
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const callResult = {
|
|
272
|
+
content: result.content,
|
|
273
|
+
isError: result.isError,
|
|
274
|
+
};
|
|
275
|
+
this.sendResult(id, callResult);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Send a JSON-RPC response with result
|
|
279
|
+
*/
|
|
280
|
+
sendResult(id, result) {
|
|
281
|
+
const response = {
|
|
282
|
+
jsonrpc: '2.0',
|
|
283
|
+
id,
|
|
284
|
+
result,
|
|
285
|
+
};
|
|
286
|
+
this.send(response);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Send a JSON-RPC error response
|
|
290
|
+
*/
|
|
291
|
+
sendError(id, code, message, data) {
|
|
292
|
+
const response = {
|
|
293
|
+
jsonrpc: '2.0',
|
|
294
|
+
id,
|
|
295
|
+
error: {
|
|
296
|
+
code,
|
|
297
|
+
message,
|
|
298
|
+
...(data !== undefined ? { data } : {}),
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
this.send(response);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Send a message to stdout
|
|
305
|
+
*/
|
|
306
|
+
send(message) {
|
|
307
|
+
const json = JSON.stringify(message);
|
|
308
|
+
process.stdout.write(json + '\n');
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
//# sourceMappingURL=mcp-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../../src/proxy/mcp-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB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;YAChC,OAAO,EAAE,KAAK;YACd,EAAE;YACF,MAAM;SACP,CAAC;QAEF,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtB,CAAC;IAED;;OAEG;IACK,SAAS,CACf,EAA0B,EAC1B,IAAY,EACZ,OAAe,EACf,IAAc;QAEd,MAAM,QAAQ,GAAoB;YAChC,OAAO,EAAE,KAAK;YACd,EAAE;YACF,KAAK,EAAE;gBACL,IAAI;gBACJ,OAAO;gBACP,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACxC;SACF,CAAC;QAEF,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtB,CAAC;IAED;;OAEG;IACK,IAAI,CAAC,OAAwB;QACnC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACrC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request Router (Phase 5.0)
|
|
3
|
+
*
|
|
4
|
+
* Routes tools/call requests to the appropriate backend connector
|
|
5
|
+
* based on the namespace prefix.
|
|
6
|
+
*/
|
|
7
|
+
import { type ProxyOptions, type RouteResult } from './types.js';
|
|
8
|
+
import { ToolAggregator } from './tool-aggregator.js';
|
|
9
|
+
/**
|
|
10
|
+
* Routes tool call requests to backend connectors
|
|
11
|
+
*/
|
|
12
|
+
export declare class RequestRouter {
|
|
13
|
+
private readonly aggregator;
|
|
14
|
+
private readonly configDir;
|
|
15
|
+
private readonly timeout;
|
|
16
|
+
constructor(options: ProxyOptions, aggregator: ToolAggregator);
|
|
17
|
+
/**
|
|
18
|
+
* Route a tools/call request to the appropriate backend
|
|
19
|
+
*
|
|
20
|
+
* @param namespacedName - Tool name with namespace prefix (e.g., "time__get_current_time")
|
|
21
|
+
* @param args - Tool arguments
|
|
22
|
+
* @returns Route result with content or error
|
|
23
|
+
*/
|
|
24
|
+
routeToolCall(namespacedName: string, args: Record<string, unknown>): Promise<RouteResult>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=request-router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-router.d.ts","sourceRoot":"","sources":["../../src/proxy/request-router.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAmB,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiB;IAC5C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc;IAM7D;;;;;;OAMG;IACG,aAAa,CACjB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,WAAW,CAAC;CAmExB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request Router (Phase 5.0)
|
|
3
|
+
*
|
|
4
|
+
* Routes tools/call requests to the appropriate backend connector
|
|
5
|
+
* based on the namespace prefix.
|
|
6
|
+
*/
|
|
7
|
+
import { callTool } from '../tools/adapter.js';
|
|
8
|
+
import { logger } from './logger.js';
|
|
9
|
+
import { DEFAULT_TIMEOUT } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Routes tool call requests to backend connectors
|
|
12
|
+
*/
|
|
13
|
+
export class RequestRouter {
|
|
14
|
+
aggregator;
|
|
15
|
+
configDir;
|
|
16
|
+
timeout;
|
|
17
|
+
constructor(options, aggregator) {
|
|
18
|
+
this.aggregator = aggregator;
|
|
19
|
+
this.configDir = options.configDir;
|
|
20
|
+
this.timeout = options.timeout ?? DEFAULT_TIMEOUT;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Route a tools/call request to the appropriate backend
|
|
24
|
+
*
|
|
25
|
+
* @param namespacedName - Tool name with namespace prefix (e.g., "time__get_current_time")
|
|
26
|
+
* @param args - Tool arguments
|
|
27
|
+
* @returns Route result with content or error
|
|
28
|
+
*/
|
|
29
|
+
async routeToolCall(namespacedName, args) {
|
|
30
|
+
// Parse namespace
|
|
31
|
+
const parsed = this.aggregator.parseNamespace(namespacedName);
|
|
32
|
+
if (!parsed) {
|
|
33
|
+
logger.error(`Invalid namespace format: ${namespacedName}`);
|
|
34
|
+
return {
|
|
35
|
+
success: false,
|
|
36
|
+
error: `Invalid tool name format. Expected: <connector>__<tool>, got: ${namespacedName}`,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const { connectorId, toolName } = parsed;
|
|
40
|
+
logger.info(`Routing → connector=${connectorId} tool=${toolName}`);
|
|
41
|
+
// Find connector
|
|
42
|
+
const connector = this.aggregator.findConnector(connectorId);
|
|
43
|
+
if (!connector) {
|
|
44
|
+
logger.error(`Connector not found: ${connectorId}`);
|
|
45
|
+
return {
|
|
46
|
+
success: false,
|
|
47
|
+
error: `Connector not found: ${connectorId}`,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (!connector.enabled) {
|
|
51
|
+
logger.error(`Connector disabled: ${connectorId}`);
|
|
52
|
+
return {
|
|
53
|
+
success: false,
|
|
54
|
+
error: `Connector is disabled: ${connectorId}`,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
// Call the backend tool
|
|
58
|
+
const ctx = {
|
|
59
|
+
connectorId,
|
|
60
|
+
configDir: this.configDir,
|
|
61
|
+
};
|
|
62
|
+
try {
|
|
63
|
+
const result = await callTool(ctx, connector, toolName, args, {
|
|
64
|
+
timeout: this.timeout,
|
|
65
|
+
});
|
|
66
|
+
if (result.success) {
|
|
67
|
+
logger.info(`Result: success sessionId=${result.sessionId.slice(0, 8)}`);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
logger.error(`Result: failed sessionId=${result.sessionId.slice(0, 8)} error=${result.error}`);
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
success: result.success,
|
|
74
|
+
content: result.content,
|
|
75
|
+
isError: result.isError,
|
|
76
|
+
error: result.error,
|
|
77
|
+
sessionId: result.sessionId,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
82
|
+
logger.error(`Backend call failed: ${errorMessage}`);
|
|
83
|
+
return {
|
|
84
|
+
success: false,
|
|
85
|
+
error: errorMessage,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=request-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-router.js","sourceRoot":"","sources":["../../src/proxy/request-router.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,eAAe,EAAuC,MAAM,YAAY,CAAC;AAGlF;;GAEG;AACH,MAAM,OAAO,aAAa;IACP,UAAU,CAAiB;IAC3B,SAAS,CAAS;IAClB,OAAO,CAAS;IAEjC,YAAY,OAAqB,EAAE,UAA0B;QAC3D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,eAAe,CAAC;IACpD,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,aAAa,CAC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AM,CAAC,OAAO,EAAE,CAAC;gBACnB,MAAM,CAAC,IAAI,CAAC,6BAA6B,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;YAC3E,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,KAAK,CAAC,4BAA4B,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,UAAU,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;YACjG,CAAC;YAED,OAAO;gBACL,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5E,MAAM,CAAC,KAAK,CAAC,wBAAwB,YAAY,EAAE,CAAC,CAAC;YACrD,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,YAAY;aACpB,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Aggregator (Phase 5.0)
|
|
3
|
+
*
|
|
4
|
+
* Aggregates tools from multiple backend connectors and provides
|
|
5
|
+
* namespace-prefixed tool names for the proxy.
|
|
6
|
+
*/
|
|
7
|
+
import type { Connector } from '../types/index.js';
|
|
8
|
+
import { type ProxyOptions, type NamespacedTool, type ParsedNamespace } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Aggregates tools from multiple MCP connectors
|
|
11
|
+
*/
|
|
12
|
+
export declare class ToolAggregator {
|
|
13
|
+
private readonly connectors;
|
|
14
|
+
private readonly configDir;
|
|
15
|
+
private readonly timeout;
|
|
16
|
+
constructor(options: ProxyOptions);
|
|
17
|
+
/**
|
|
18
|
+
* Get all tools from all connectors with namespace prefixes
|
|
19
|
+
*
|
|
20
|
+
* Each connector is queried in parallel. Failed connectors are logged
|
|
21
|
+
* as warnings and skipped (partial success behavior).
|
|
22
|
+
*/
|
|
23
|
+
getAggregatedTools(): Promise<NamespacedTool[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Add namespace prefix to a tool
|
|
26
|
+
*
|
|
27
|
+
* Warns if connector ID or tool name contains the namespace separator,
|
|
28
|
+
* as this can cause ambiguous parsing.
|
|
29
|
+
*/
|
|
30
|
+
private addNamespace;
|
|
31
|
+
/**
|
|
32
|
+
* Parse a namespaced tool name into connector ID and tool name
|
|
33
|
+
*
|
|
34
|
+
* Returns null if the format is invalid.
|
|
35
|
+
*
|
|
36
|
+
* Valid format: <connectorId>__<toolName>
|
|
37
|
+
* - connectorId and toolName must not be empty
|
|
38
|
+
* - Uses __ (double underscore) as separator
|
|
39
|
+
*/
|
|
40
|
+
parseNamespace(namespacedName: string): ParsedNamespace | null;
|
|
41
|
+
/**
|
|
42
|
+
* Find a connector by ID
|
|
43
|
+
*/
|
|
44
|
+
findConnector(connectorId: string): Connector | undefined;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=tool-aggregator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-aggregator.d.ts","sourceRoot":"","sources":["../../src/proxy/tool-aggregator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGnD,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAc;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,OAAO,EAAE,YAAY;IAMjC;;;;;OAKG;IACG,kBAAkB,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IA+CrD;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAgBpB;;;;;;;;OAQG;IACH,cAAc,CAAC,cAAc,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI;IAkB9D;;OAEG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;CAG1D"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Aggregator (Phase 5.0)
|
|
3
|
+
*
|
|
4
|
+
* Aggregates tools from multiple backend connectors and provides
|
|
5
|
+
* namespace-prefixed tool names for the proxy.
|
|
6
|
+
*/
|
|
7
|
+
import { listTools } from '../tools/adapter.js';
|
|
8
|
+
import { logger } from './logger.js';
|
|
9
|
+
import { NAMESPACE_SEPARATOR, DEFAULT_TIMEOUT, } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Aggregates tools from multiple MCP connectors
|
|
12
|
+
*/
|
|
13
|
+
export class ToolAggregator {
|
|
14
|
+
connectors;
|
|
15
|
+
configDir;
|
|
16
|
+
timeout;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.connectors = options.connectors;
|
|
19
|
+
this.configDir = options.configDir;
|
|
20
|
+
this.timeout = options.timeout ?? DEFAULT_TIMEOUT;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get all tools from all connectors with namespace prefixes
|
|
24
|
+
*
|
|
25
|
+
* Each connector is queried in parallel. Failed connectors are logged
|
|
26
|
+
* as warnings and skipped (partial success behavior).
|
|
27
|
+
*/
|
|
28
|
+
async getAggregatedTools() {
|
|
29
|
+
const allTools = [];
|
|
30
|
+
// Query all connectors in parallel
|
|
31
|
+
const results = await Promise.allSettled(this.connectors.map(async (connector) => {
|
|
32
|
+
const ctx = {
|
|
33
|
+
connectorId: connector.id,
|
|
34
|
+
configDir: this.configDir,
|
|
35
|
+
};
|
|
36
|
+
const result = await listTools(ctx, connector, { timeout: this.timeout });
|
|
37
|
+
if (result.error) {
|
|
38
|
+
throw new Error(result.error);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
connectorId: connector.id,
|
|
42
|
+
tools: result.tools,
|
|
43
|
+
sessionId: result.sessionId,
|
|
44
|
+
};
|
|
45
|
+
}));
|
|
46
|
+
// Process results
|
|
47
|
+
for (let i = 0; i < results.length; i++) {
|
|
48
|
+
const result = results[i];
|
|
49
|
+
const connector = this.connectors[i];
|
|
50
|
+
if (result.status === 'rejected') {
|
|
51
|
+
logger.warn(`Failed to list tools from ${connector.id}: ${result.reason}`);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const { connectorId, tools, sessionId } = result.value;
|
|
55
|
+
logger.info(`Listed ${tools.length} tool(s) from ${connectorId} (session=${sessionId.slice(0, 8)})`);
|
|
56
|
+
// Add namespace prefix to each tool
|
|
57
|
+
for (const tool of tools) {
|
|
58
|
+
allTools.push(this.addNamespace(connectorId, tool));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return allTools;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Add namespace prefix to a tool
|
|
65
|
+
*
|
|
66
|
+
* Warns if connector ID or tool name contains the namespace separator,
|
|
67
|
+
* as this can cause ambiguous parsing.
|
|
68
|
+
*/
|
|
69
|
+
addNamespace(connectorId, tool) {
|
|
70
|
+
// Warn about potential namespace collisions
|
|
71
|
+
if (connectorId.includes(NAMESPACE_SEPARATOR)) {
|
|
72
|
+
logger.warn(`Connector ID contains separator '${NAMESPACE_SEPARATOR}': ${connectorId}`);
|
|
73
|
+
}
|
|
74
|
+
if (tool.name.includes(NAMESPACE_SEPARATOR)) {
|
|
75
|
+
logger.warn(`Tool name contains separator '${NAMESPACE_SEPARATOR}': ${tool.name} in ${connectorId}`);
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
...tool,
|
|
79
|
+
connectorId,
|
|
80
|
+
namespacedName: `${connectorId}${NAMESPACE_SEPARATOR}${tool.name}`,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Parse a namespaced tool name into connector ID and tool name
|
|
85
|
+
*
|
|
86
|
+
* Returns null if the format is invalid.
|
|
87
|
+
*
|
|
88
|
+
* Valid format: <connectorId>__<toolName>
|
|
89
|
+
* - connectorId and toolName must not be empty
|
|
90
|
+
* - Uses __ (double underscore) as separator
|
|
91
|
+
*/
|
|
92
|
+
parseNamespace(namespacedName) {
|
|
93
|
+
const separatorIndex = namespacedName.indexOf(NAMESPACE_SEPARATOR);
|
|
94
|
+
if (separatorIndex === -1) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
const connectorId = namespacedName.slice(0, separatorIndex);
|
|
98
|
+
const toolName = namespacedName.slice(separatorIndex + NAMESPACE_SEPARATOR.length);
|
|
99
|
+
// Both parts must be non-empty
|
|
100
|
+
if (!connectorId || !toolName) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
return { connectorId, toolName };
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Find a connector by ID
|
|
107
|
+
*/
|
|
108
|
+
findConnector(connectorId) {
|
|
109
|
+
return this.connectors.find((c) => c.id === connectorId);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=tool-aggregator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-aggregator.js","sourceRoot":"","sources":["../../src/proxy/tool-aggregator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAA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AAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACH,cAAc,CAAC,cAAsB;QACnC,MAAM,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAEnE,IAAI,cAAc,KAAK,CAAC,CAAC,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,WAAW,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC5D,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,CAAC,cAAc,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAEnF,+BAA+B;QAC/B,IAAI,CAAC,WAAW,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,WAAmB;QAC/B,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,WAAW,CAAC,CAAC;IAC3D,CAAC;CACF"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy Type Definitions (Phase 5.0)
|
|
3
|
+
*/
|
|
4
|
+
import type { Connector } from '../types/index.js';
|
|
5
|
+
import type { ToolInfo } from '../tools/adapter.js';
|
|
6
|
+
/** Namespace separator for tool names */
|
|
7
|
+
export declare const NAMESPACE_SEPARATOR = "__";
|
|
8
|
+
/** Default timeout in seconds for backend calls */
|
|
9
|
+
export declare const DEFAULT_TIMEOUT = 30;
|
|
10
|
+
/** Proxy startup options */
|
|
11
|
+
export interface ProxyOptions {
|
|
12
|
+
/** Connectors to expose through the proxy */
|
|
13
|
+
connectors: Connector[];
|
|
14
|
+
/** Config directory path */
|
|
15
|
+
configDir: string;
|
|
16
|
+
/** Enable verbose logging */
|
|
17
|
+
verbose?: boolean;
|
|
18
|
+
/** Timeout in seconds for backend calls (default: 30) */
|
|
19
|
+
timeout?: number;
|
|
20
|
+
}
|
|
21
|
+
/** MCP JSON-RPC error codes */
|
|
22
|
+
export declare const MCP_ERROR: {
|
|
23
|
+
/** Invalid JSON was received */
|
|
24
|
+
readonly PARSE_ERROR: -32700;
|
|
25
|
+
/** The JSON sent is not a valid Request object */
|
|
26
|
+
readonly INVALID_REQUEST: -32600;
|
|
27
|
+
/** The method does not exist or is not available */
|
|
28
|
+
readonly METHOD_NOT_FOUND: -32601;
|
|
29
|
+
/** Invalid method parameters */
|
|
30
|
+
readonly INVALID_PARAMS: -32602;
|
|
31
|
+
/** Internal JSON-RPC error */
|
|
32
|
+
readonly INTERNAL_ERROR: -32603;
|
|
33
|
+
};
|
|
34
|
+
export type McpErrorCode = typeof MCP_ERROR[keyof typeof MCP_ERROR];
|
|
35
|
+
/** Tool with namespace prefix */
|
|
36
|
+
export interface NamespacedTool extends ToolInfo {
|
|
37
|
+
/** Original connector ID */
|
|
38
|
+
connectorId: string;
|
|
39
|
+
/** Namespaced name (connectorId__toolName) */
|
|
40
|
+
namespacedName: string;
|
|
41
|
+
}
|
|
42
|
+
/** Parsed namespace result */
|
|
43
|
+
export interface ParsedNamespace {
|
|
44
|
+
connectorId: string;
|
|
45
|
+
toolName: string;
|
|
46
|
+
}
|
|
47
|
+
/** Result of routing a tool call */
|
|
48
|
+
export interface RouteResult {
|
|
49
|
+
success: boolean;
|
|
50
|
+
content?: unknown[];
|
|
51
|
+
isError?: boolean;
|
|
52
|
+
error?: string;
|
|
53
|
+
sessionId?: string;
|
|
54
|
+
}
|
|
55
|
+
/** JSON-RPC 2.0 request */
|
|
56
|
+
export interface JsonRpcRequest {
|
|
57
|
+
jsonrpc: '2.0';
|
|
58
|
+
id: string | number | null;
|
|
59
|
+
method: string;
|
|
60
|
+
params?: unknown;
|
|
61
|
+
}
|
|
62
|
+
/** JSON-RPC 2.0 response */
|
|
63
|
+
export interface JsonRpcResponse {
|
|
64
|
+
jsonrpc: '2.0';
|
|
65
|
+
id: string | number | null;
|
|
66
|
+
result?: unknown;
|
|
67
|
+
error?: {
|
|
68
|
+
code: number;
|
|
69
|
+
message: string;
|
|
70
|
+
data?: unknown;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** JSON-RPC 2.0 notification (no id) */
|
|
74
|
+
export interface JsonRpcNotification {
|
|
75
|
+
jsonrpc: '2.0';
|
|
76
|
+
method: string;
|
|
77
|
+
params?: unknown;
|
|
78
|
+
}
|
|
79
|
+
/** MCP initialize params */
|
|
80
|
+
export interface InitializeParams {
|
|
81
|
+
protocolVersion: string;
|
|
82
|
+
capabilities?: Record<string, unknown>;
|
|
83
|
+
clientInfo?: {
|
|
84
|
+
name: string;
|
|
85
|
+
version?: string;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/** MCP initialize result */
|
|
89
|
+
export interface InitializeResult {
|
|
90
|
+
protocolVersion: string;
|
|
91
|
+
capabilities: {
|
|
92
|
+
tools?: Record<string, unknown>;
|
|
93
|
+
};
|
|
94
|
+
serverInfo: {
|
|
95
|
+
name: string;
|
|
96
|
+
version: string;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** MCP tools/list result */
|
|
100
|
+
export interface ToolsListResult {
|
|
101
|
+
tools: Array<{
|
|
102
|
+
name: string;
|
|
103
|
+
description?: string;
|
|
104
|
+
inputSchema?: unknown;
|
|
105
|
+
}>;
|
|
106
|
+
}
|
|
107
|
+
/** MCP tools/call params */
|
|
108
|
+
export interface ToolsCallParams {
|
|
109
|
+
name: string;
|
|
110
|
+
arguments?: Record<string, unknown>;
|
|
111
|
+
}
|
|
112
|
+
/** MCP tools/call result */
|
|
113
|
+
export interface ToolsCallResult {
|
|
114
|
+
content?: unknown[];
|
|
115
|
+
isError?: boolean;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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AM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,OAAO,CAAC;KACvB,CAAC,CAAC;CACJ;AAED,4BAA4B;AAC5B,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED,4BAA4B;AAC5B,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy Type Definitions (Phase 5.0)
|
|
3
|
+
*/
|
|
4
|
+
/** Namespace separator for tool names */
|
|
5
|
+
export const NAMESPACE_SEPARATOR = '__';
|
|
6
|
+
/** Default timeout in seconds for backend calls */
|
|
7
|
+
export const DEFAULT_TIMEOUT = 30;
|
|
8
|
+
/** MCP JSON-RPC error codes */
|
|
9
|
+
export const MCP_ERROR = {
|
|
10
|
+
/** Invalid JSON was received */
|
|
11
|
+
PARSE_ERROR: -32700,
|
|
12
|
+
/** The JSON sent is not a valid Request object */
|
|
13
|
+
INVALID_REQUEST: -32600,
|
|
14
|
+
/** The method does not exist or is not available */
|
|
15
|
+
METHOD_NOT_FOUND: -32601,
|
|
16
|
+
/** Invalid method parameters */
|
|
17
|
+
INVALID_PARAMS: -32602,
|
|
18
|
+
/** Internal JSON-RPC error */
|
|
19
|
+
INTERNAL_ERROR: -32603,
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/proxy/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,yCAAyC;AACzC,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAExC,mDAAmD;AACnD,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAclC,+BAA+B;AAC/B,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,gCAAgC;IAChC,WAAW,EAAE,CAAC,KAAK;IACnB,kDAAkD;IAClD,eAAe,EAAE,CAAC,KAAK;IACvB,oDAAoD;IACpD,gBAAgB,EAAE,CAAC,KAAK;IACxB,gCAAgC;IAChC,cAAc,EAAE,CAAC,KAAK;IACtB,8BAA8B;IAC9B,cAAc,EAAE,CAAC,KAAK;CACd,CAAC"}
|