claude-flow-novice 1.5.12 → 1.5.14

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.
Files changed (53) hide show
  1. package/.claude/agents/analysis/code-review/analyze-code-quality.md +160 -177
  2. package/.claude/agents/architecture/system-design/arch-system-design.md +118 -153
  3. package/.claude-flow-novice/dist/mcp/auth.js +347 -0
  4. package/.claude-flow-novice/dist/mcp/claude-code-wrapper.js +717 -0
  5. package/.claude-flow-novice/dist/mcp/claude-flow-tools.js +1365 -0
  6. package/.claude-flow-novice/dist/mcp/client.js +201 -0
  7. package/.claude-flow-novice/dist/mcp/index.js +192 -0
  8. package/.claude-flow-novice/dist/mcp/integrate-wrapper.js +85 -0
  9. package/.claude-flow-novice/dist/mcp/lifecycle-manager.js +348 -0
  10. package/.claude-flow-novice/dist/mcp/load-balancer.js +386 -0
  11. package/.claude-flow-novice/dist/mcp/mcp-config-manager.js +1362 -0
  12. package/.claude-flow-novice/dist/mcp/mcp-server-novice-simplified.js +583 -0
  13. package/.claude-flow-novice/dist/mcp/mcp-server-novice.js +723 -0
  14. package/.claude-flow-novice/dist/mcp/mcp-server-sdk.js +649 -0
  15. package/.claude-flow-novice/dist/mcp/mcp-server.js +2256 -0
  16. package/.claude-flow-novice/dist/mcp/orchestration-integration.js +800 -0
  17. package/.claude-flow-novice/dist/mcp/performance-monitor.js +489 -0
  18. package/.claude-flow-novice/dist/mcp/protocol-manager.js +376 -0
  19. package/.claude-flow-novice/dist/mcp/router.js +220 -0
  20. package/.claude-flow-novice/dist/mcp/ruv-swarm-tools.js +671 -0
  21. package/.claude-flow-novice/dist/mcp/ruv-swarm-wrapper.js +254 -0
  22. package/.claude-flow-novice/dist/mcp/server-with-wrapper.js +32 -0
  23. package/.claude-flow-novice/dist/mcp/server-wrapper-mode.js +26 -0
  24. package/.claude-flow-novice/dist/mcp/server.js +539 -0
  25. package/.claude-flow-novice/dist/mcp/session-manager.js +338 -0
  26. package/.claude-flow-novice/dist/mcp/sparc-modes.js +455 -0
  27. package/.claude-flow-novice/dist/mcp/swarm-tools.js +903 -0
  28. package/.claude-flow-novice/dist/mcp/tools.js +426 -0
  29. package/.claude-flow-novice/dist/src/cli/commands/swarm.js +23 -1
  30. package/.claude-flow-novice/dist/src/cli/commands/swarm.js.map +1 -1
  31. package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/CLAUDE.md +42 -102
  32. package/.claude-flow-novice/dist/src/config/web-portal-config.js +2 -1
  33. package/.claude-flow-novice/dist/src/config/web-portal-config.js.map +1 -1
  34. package/.claude-flow-novice/dist/src/coordination/swarm-coordinator-factory.js +36 -0
  35. package/.claude-flow-novice/dist/src/coordination/swarm-coordinator-factory.js.map +1 -0
  36. package/.claude-flow-novice/dist/src/preferences/user-preference-manager.js +371 -0
  37. package/.claude-flow-novice/dist/src/preferences/user-preference-manager.js.map +1 -0
  38. package/.claude-flow-novice/dist/src/validators/index.js +12 -0
  39. package/.claude-flow-novice/dist/src/validators/index.js.map +1 -0
  40. package/.claude-flow-novice/dist/src/validators/swarm-init-validator.js +261 -0
  41. package/.claude-flow-novice/dist/src/validators/swarm-init-validator.js.map +1 -0
  42. package/.claude-flow-novice/dist/src/validators/todowrite-batching-validator.js +204 -0
  43. package/.claude-flow-novice/dist/src/validators/todowrite-batching-validator.js.map +1 -0
  44. package/.claude-flow-novice/dist/src/validators/todowrite-integration.js +189 -0
  45. package/.claude-flow-novice/dist/src/validators/todowrite-integration.js.map +1 -0
  46. package/.claude-flow-novice/dist/src/web/portal-server.js +12 -5
  47. package/.claude-flow-novice/dist/src/web/portal-server.js.map +1 -1
  48. package/config/hooks/post-edit-pipeline.js +231 -10
  49. package/package.json +4 -2
  50. package/scripts/src/web/frontend/.claude-flow/metrics/agent-metrics.json +1 -0
  51. package/scripts/src/web/frontend/.claude-flow/metrics/performance.json +9 -0
  52. package/scripts/src/web/frontend/.claude-flow/metrics/task-metrics.json +10 -0
  53. package/src/cli/simple-commands/init/templates/CLAUDE.md +4 -1
@@ -0,0 +1,376 @@
1
+ /**
2
+ * MCP Protocol Version Management and Compatibility Checking
3
+ */ import { MCPError } from '../utils/errors.js';
4
+ /**
5
+ * MCP Protocol Manager
6
+ * Handles protocol version negotiation, compatibility checking, and feature management
7
+ */ export class MCPProtocolManager {
8
+ logger;
9
+ supportedVersions = new Map();
10
+ currentVersion;
11
+ serverCapabilities;
12
+ knownVersions = [
13
+ {
14
+ version: {
15
+ major: 2024,
16
+ minor: 11,
17
+ patch: 5
18
+ },
19
+ name: 'MCP 2024.11.5',
20
+ releaseDate: new Date('2024-11-01'),
21
+ supportedFeatures: [
22
+ 'tools',
23
+ 'prompts',
24
+ 'resources',
25
+ 'logging',
26
+ 'sampling',
27
+ 'notifications',
28
+ 'tool_list_changed',
29
+ 'resource_list_changed',
30
+ 'prompt_list_changed'
31
+ ]
32
+ },
33
+ {
34
+ version: {
35
+ major: 2024,
36
+ minor: 11,
37
+ patch: 4
38
+ },
39
+ name: 'MCP 2024.11.4',
40
+ releaseDate: new Date('2024-10-15'),
41
+ supportedFeatures: [
42
+ 'tools',
43
+ 'prompts',
44
+ 'resources',
45
+ 'logging',
46
+ 'notifications',
47
+ 'tool_list_changed',
48
+ 'resource_list_changed'
49
+ ]
50
+ },
51
+ {
52
+ version: {
53
+ major: 2024,
54
+ minor: 11,
55
+ patch: 3
56
+ },
57
+ name: 'MCP 2024.11.3',
58
+ releaseDate: new Date('2024-10-01'),
59
+ supportedFeatures: [
60
+ 'tools',
61
+ 'prompts',
62
+ 'resources',
63
+ 'logging',
64
+ 'notifications'
65
+ ]
66
+ },
67
+ {
68
+ version: {
69
+ major: 2024,
70
+ minor: 10,
71
+ patch: 0
72
+ },
73
+ name: 'MCP 2024.10.0',
74
+ releaseDate: new Date('2024-09-01'),
75
+ deprecated: true,
76
+ deprecationDate: new Date('2024-11-01'),
77
+ supportedFeatures: [
78
+ 'tools',
79
+ 'prompts',
80
+ 'resources',
81
+ 'logging'
82
+ ],
83
+ breakingChanges: [
84
+ 'Changed tool response format',
85
+ 'Modified error codes'
86
+ ],
87
+ migrationGuide: 'https://docs.mcp.io/migration/2024.10-to-2024.11'
88
+ }
89
+ ];
90
+ constructor(logger, preferredVersion, serverCapabilities){
91
+ this.logger = logger;
92
+ // Initialize supported versions
93
+ for (const versionInfo of this.knownVersions){
94
+ const key = this.versionToString(versionInfo.version);
95
+ this.supportedVersions.set(key, versionInfo);
96
+ }
97
+ // Set current version (latest supported or preferred)
98
+ this.currentVersion = preferredVersion || this.getLatestSupportedVersion();
99
+ // Set server capabilities
100
+ this.serverCapabilities = serverCapabilities || this.getDefaultCapabilities();
101
+ this.logger.info('Protocol manager initialized', {
102
+ currentVersion: this.versionToString(this.currentVersion),
103
+ supportedVersions: this.getSupportedVersionStrings()
104
+ });
105
+ }
106
+ /**
107
+ * Negotiate protocol version and capabilities with client
108
+ */ async negotiateProtocol(clientParams) {
109
+ this.logger.debug('Starting protocol negotiation', {
110
+ clientVersion: this.versionToString(clientParams.protocolVersion),
111
+ clientCapabilities: clientParams.capabilities,
112
+ clientInfo: clientParams.clientInfo
113
+ });
114
+ const result = {
115
+ agreedVersion: this.currentVersion,
116
+ agreedCapabilities: {
117
+ ...this.serverCapabilities
118
+ },
119
+ clientCapabilities: clientParams.capabilities,
120
+ serverCapabilities: this.serverCapabilities,
121
+ warnings: [],
122
+ limitations: []
123
+ };
124
+ try {
125
+ // Check version compatibility
126
+ const compatibility = this.checkCompatibility(clientParams.protocolVersion);
127
+ if (!compatibility.compatible) {
128
+ throw new MCPError(`Protocol version ${this.versionToString(clientParams.protocolVersion)} is not compatible. ${compatibility.errors.join(', ')}`);
129
+ }
130
+ // Use client's version if it's supported and newer
131
+ if (this.isVersionSupported(clientParams.protocolVersion)) {
132
+ const clientVersionInfo = this.getVersionInfo(clientParams.protocolVersion);
133
+ const currentVersionInfo = this.getVersionInfo(this.currentVersion);
134
+ if (clientVersionInfo && currentVersionInfo) {
135
+ if (this.compareVersions(clientParams.protocolVersion, this.currentVersion) <= 0) {
136
+ result.agreedVersion = clientParams.protocolVersion;
137
+ }
138
+ }
139
+ }
140
+ // Negotiate capabilities
141
+ result.agreedCapabilities = this.negotiateCapabilities(clientParams.capabilities, this.serverCapabilities, result.agreedVersion);
142
+ // Add warnings from compatibility check
143
+ result.warnings.push(...compatibility.warnings);
144
+ // Check for deprecated features
145
+ const versionInfo = this.getVersionInfo(result.agreedVersion);
146
+ if (versionInfo?.deprecated) {
147
+ result.warnings.push(`Protocol version ${this.versionToString(result.agreedVersion)} is deprecated. ` + `Please upgrade to a newer version.`);
148
+ }
149
+ // Check for missing features
150
+ const missingFeatures = this.getMissingFeatures(result.agreedVersion, result.agreedCapabilities);
151
+ if (missingFeatures.length > 0) {
152
+ result.limitations.push(`Some features may not be available: ${missingFeatures.join(', ')}`);
153
+ }
154
+ this.logger.info('Protocol negotiation completed', {
155
+ agreedVersion: this.versionToString(result.agreedVersion),
156
+ warnings: result.warnings.length,
157
+ limitations: result.limitations.length
158
+ });
159
+ return result;
160
+ } catch (error) {
161
+ this.logger.error('Protocol negotiation failed', {
162
+ clientVersion: this.versionToString(clientParams.protocolVersion),
163
+ error
164
+ });
165
+ throw error;
166
+ }
167
+ }
168
+ /**
169
+ * Check compatibility between client and server versions
170
+ */ checkCompatibility(clientVersion) {
171
+ const result = {
172
+ compatible: false,
173
+ warnings: [],
174
+ errors: []
175
+ };
176
+ const clientVersionInfo = this.getVersionInfo(clientVersion);
177
+ const serverVersionInfo = this.getVersionInfo(this.currentVersion);
178
+ // Check if version is known
179
+ if (!clientVersionInfo) {
180
+ result.errors.push(`Unknown protocol version: ${this.versionToString(clientVersion)}`);
181
+ result.recommendedVersion = this.getLatestSupportedVersion();
182
+ return result;
183
+ }
184
+ // Check major version compatibility
185
+ if (clientVersion.major !== this.currentVersion.major) {
186
+ result.errors.push(`Major version mismatch: client ${clientVersion.major}, server ${this.currentVersion.major}`);
187
+ return result;
188
+ }
189
+ // Check if client version is too new
190
+ if (this.compareVersions(clientVersion, this.currentVersion) > 0) {
191
+ result.errors.push(`Client version ${this.versionToString(clientVersion)} is newer than supported server version ${this.versionToString(this.currentVersion)}`);
192
+ result.recommendedVersion = this.currentVersion;
193
+ return result;
194
+ }
195
+ // Check for deprecated versions
196
+ if (clientVersionInfo.deprecated) {
197
+ result.warnings.push(`Client is using deprecated version ${this.versionToString(clientVersion)}. ` + `Support will be removed after ${clientVersionInfo.deprecationDate?.toISOString().split('T')[0]}`);
198
+ result.recommendedVersion = this.getLatestSupportedVersion();
199
+ }
200
+ // Check for missing features
201
+ const serverFeatures = serverVersionInfo?.supportedFeatures || [];
202
+ const clientFeatures = clientVersionInfo.supportedFeatures;
203
+ const missingFeatures = serverFeatures.filter((feature)=>!clientFeatures.includes(feature));
204
+ if (missingFeatures.length > 0) {
205
+ result.missingFeatures = missingFeatures;
206
+ result.warnings.push(`Client version lacks some server features: ${missingFeatures.join(', ')}`);
207
+ }
208
+ // Check for deprecated features being used
209
+ const deprecatedFeatures = this.getDeprecatedFeatures(clientVersion);
210
+ if (deprecatedFeatures.length > 0) {
211
+ result.deprecatedFeatures = deprecatedFeatures;
212
+ result.warnings.push(`Client version uses deprecated features: ${deprecatedFeatures.join(', ')}`);
213
+ }
214
+ result.compatible = true;
215
+ return result;
216
+ }
217
+ /**
218
+ * Get information about a specific protocol version
219
+ */ getVersionInfo(version) {
220
+ return this.supportedVersions.get(this.versionToString(version));
221
+ }
222
+ /**
223
+ * Check if a version is supported
224
+ */ isVersionSupported(version) {
225
+ return this.supportedVersions.has(this.versionToString(version));
226
+ }
227
+ /**
228
+ * Get the latest supported version
229
+ */ getLatestSupportedVersion() {
230
+ const versions = Array.from(this.supportedVersions.values()).filter((v)=>!v.deprecated).sort((a, b)=>this.compareVersions(b.version, a.version));
231
+ return versions[0]?.version || {
232
+ major: 2024,
233
+ minor: 11,
234
+ patch: 5
235
+ };
236
+ }
237
+ /**
238
+ * Get all supported version strings
239
+ */ getSupportedVersionStrings() {
240
+ return Array.from(this.supportedVersions.keys());
241
+ }
242
+ /**
243
+ * Get current server capabilities
244
+ */ getServerCapabilities() {
245
+ return {
246
+ ...this.serverCapabilities
247
+ };
248
+ }
249
+ /**
250
+ * Update server capabilities
251
+ */ updateServerCapabilities(capabilities) {
252
+ this.serverCapabilities = {
253
+ ...this.serverCapabilities,
254
+ ...capabilities
255
+ };
256
+ this.logger.info('Server capabilities updated', {
257
+ capabilities: this.serverCapabilities
258
+ });
259
+ }
260
+ /**
261
+ * Check if a feature is supported in a specific version
262
+ */ isFeatureSupported(version, feature) {
263
+ const versionInfo = this.getVersionInfo(version);
264
+ return versionInfo?.supportedFeatures.includes(feature) || false;
265
+ }
266
+ versionToString(version) {
267
+ return `${version.major}.${version.minor}.${version.patch}`;
268
+ }
269
+ compareVersions(a, b) {
270
+ if (a.major !== b.major) return a.major - b.major;
271
+ if (a.minor !== b.minor) return a.minor - b.minor;
272
+ return a.patch - b.patch;
273
+ }
274
+ getDefaultCapabilities() {
275
+ return {
276
+ logging: {
277
+ level: 'info'
278
+ },
279
+ tools: {
280
+ listChanged: true
281
+ },
282
+ resources: {
283
+ listChanged: true,
284
+ subscribe: false
285
+ },
286
+ prompts: {
287
+ listChanged: true
288
+ }
289
+ };
290
+ }
291
+ negotiateCapabilities(clientCapabilities, serverCapabilities, agreedVersion) {
292
+ const result = {};
293
+ // Negotiate logging capabilities
294
+ if (clientCapabilities.logging && serverCapabilities.logging) {
295
+ result.logging = {
296
+ level: this.negotiateLogLevel(clientCapabilities.logging.level, serverCapabilities.logging.level)
297
+ };
298
+ }
299
+ // Negotiate tools capabilities
300
+ if (clientCapabilities.tools && serverCapabilities.tools) {
301
+ result.tools = {
302
+ listChanged: clientCapabilities.tools.listChanged && serverCapabilities.tools.listChanged
303
+ };
304
+ }
305
+ // Negotiate resources capabilities
306
+ if (clientCapabilities.resources && serverCapabilities.resources) {
307
+ result.resources = {
308
+ listChanged: clientCapabilities.resources.listChanged && serverCapabilities.resources.listChanged,
309
+ subscribe: clientCapabilities.resources.subscribe && serverCapabilities.resources.subscribe
310
+ };
311
+ }
312
+ // Negotiate prompts capabilities
313
+ if (clientCapabilities.prompts && serverCapabilities.prompts) {
314
+ result.prompts = {
315
+ listChanged: clientCapabilities.prompts.listChanged && serverCapabilities.prompts.listChanged
316
+ };
317
+ }
318
+ // Only include capabilities supported by the agreed version
319
+ return this.filterCapabilitiesByVersion(result, agreedVersion);
320
+ }
321
+ negotiateLogLevel(clientLevel, serverLevel) {
322
+ const levels = [
323
+ 'debug',
324
+ 'info',
325
+ 'warn',
326
+ 'error'
327
+ ];
328
+ const clientIndex = clientLevel ? levels.indexOf(clientLevel) : 1;
329
+ const serverIndex = serverLevel ? levels.indexOf(serverLevel) : 1;
330
+ // Use the more restrictive (higher) level
331
+ const chosenIndex = Math.max(clientIndex, serverIndex);
332
+ return levels[chosenIndex];
333
+ }
334
+ filterCapabilitiesByVersion(capabilities, version) {
335
+ const versionInfo = this.getVersionInfo(version);
336
+ if (!versionInfo) return capabilities;
337
+ const result = {};
338
+ // Only include capabilities supported by this version
339
+ if (versionInfo.supportedFeatures.includes('logging') && capabilities.logging) {
340
+ result.logging = capabilities.logging;
341
+ }
342
+ if (versionInfo.supportedFeatures.includes('tools') && capabilities.tools) {
343
+ result.tools = capabilities.tools;
344
+ }
345
+ if (versionInfo.supportedFeatures.includes('resources') && capabilities.resources) {
346
+ result.resources = capabilities.resources;
347
+ }
348
+ if (versionInfo.supportedFeatures.includes('prompts') && capabilities.prompts) {
349
+ result.prompts = capabilities.prompts;
350
+ }
351
+ return result;
352
+ }
353
+ getMissingFeatures(version, capabilities) {
354
+ const versionInfo = this.getVersionInfo(version);
355
+ if (!versionInfo) return [];
356
+ const missing = [];
357
+ const availableFeatures = versionInfo.supportedFeatures;
358
+ // Check what's missing compared to latest version
359
+ const latestVersion = this.getLatestSupportedVersion();
360
+ const latestVersionInfo = this.getVersionInfo(latestVersion);
361
+ if (latestVersionInfo) {
362
+ for (const feature of latestVersionInfo.supportedFeatures){
363
+ if (!availableFeatures.includes(feature)) {
364
+ missing.push(feature);
365
+ }
366
+ }
367
+ }
368
+ return missing;
369
+ }
370
+ getDeprecatedFeatures(version) {
371
+ const versionInfo = this.getVersionInfo(version);
372
+ return versionInfo?.breakingChanges || [];
373
+ }
374
+ }
375
+
376
+ //# sourceMappingURL=protocol-manager.js.map
@@ -0,0 +1,220 @@
1
+ /**
2
+ * Request router for MCP
3
+ */ import { MCPMethodNotFoundError } from '../utils/errors.js';
4
+ /**
5
+ * Request router implementation
6
+ */ export class RequestRouter {
7
+ toolRegistry;
8
+ logger;
9
+ totalRequests = 0;
10
+ successfulRequests = 0;
11
+ failedRequests = 0;
12
+ constructor(toolRegistry, logger){
13
+ this.toolRegistry = toolRegistry;
14
+ this.logger = logger;
15
+ }
16
+ /**
17
+ * Routes a request to the appropriate handler
18
+ */ async route(request) {
19
+ this.totalRequests++;
20
+ try {
21
+ // Parse method to determine handler
22
+ const { method, params } = request;
23
+ // Handle built-in methods
24
+ if (method.startsWith('rpc.')) {
25
+ return await this.handleRPCMethod(method, params);
26
+ }
27
+ // Handle tool invocations
28
+ if (method.startsWith('tools.')) {
29
+ return await this.handleToolMethod(method, params);
30
+ }
31
+ // Try to execute as a tool directly
32
+ const tool = this.toolRegistry.getTool(method);
33
+ if (tool) {
34
+ const result = await this.toolRegistry.executeTool(method, params);
35
+ this.successfulRequests++;
36
+ return result;
37
+ }
38
+ // Method not found
39
+ throw new MCPMethodNotFoundError(method);
40
+ } catch (error) {
41
+ this.failedRequests++;
42
+ throw error;
43
+ }
44
+ }
45
+ /**
46
+ * Gets router metrics
47
+ */ getMetrics() {
48
+ return {
49
+ totalRequests: this.totalRequests,
50
+ successfulRequests: this.successfulRequests,
51
+ failedRequests: this.failedRequests
52
+ };
53
+ }
54
+ /**
55
+ * Handles built-in RPC methods
56
+ */ async handleRPCMethod(method, params) {
57
+ switch(method){
58
+ case 'rpc.discover':
59
+ return this.discoverMethods();
60
+ case 'rpc.ping':
61
+ return {
62
+ pong: true
63
+ };
64
+ case 'rpc.describe':
65
+ return this.describeMethod(params);
66
+ default:
67
+ throw new MCPMethodNotFoundError(method);
68
+ }
69
+ }
70
+ /**
71
+ * Handles tool-related methods
72
+ */ async handleToolMethod(method, params) {
73
+ switch(method){
74
+ case 'tools.list':
75
+ return this.toolRegistry.listTools();
76
+ case 'tools.invoke':
77
+ return await this.invokeTool(params);
78
+ case 'tools.describe':
79
+ return this.describeTool(params);
80
+ default:
81
+ throw new MCPMethodNotFoundError(method);
82
+ }
83
+ }
84
+ /**
85
+ * Discovers all available methods
86
+ */ discoverMethods() {
87
+ const methods = {
88
+ 'rpc.discover': 'Discover all available methods',
89
+ 'rpc.ping': 'Ping the server',
90
+ 'rpc.describe': 'Describe a specific method',
91
+ 'tools.list': 'List all available tools',
92
+ 'tools.invoke': 'Invoke a specific tool',
93
+ 'tools.describe': 'Describe a specific tool'
94
+ };
95
+ // Add all registered tools
96
+ for (const tool of this.toolRegistry.listTools()){
97
+ methods[tool.name] = tool.description;
98
+ }
99
+ return methods;
100
+ }
101
+ /**
102
+ * Describes a specific method
103
+ */ describeMethod(params) {
104
+ if (!params || typeof params !== 'object' || !('method' in params)) {
105
+ throw new Error('Invalid params: method required');
106
+ }
107
+ const { method } = params;
108
+ // Check if it's a tool
109
+ const tool = this.toolRegistry.getTool(method);
110
+ if (tool) {
111
+ return {
112
+ name: tool.name,
113
+ description: tool.description,
114
+ inputSchema: tool.inputSchema
115
+ };
116
+ }
117
+ // Check built-in methods
118
+ const builtInMethods = {
119
+ 'rpc.discover': {
120
+ description: 'Discover all available methods',
121
+ inputSchema: {
122
+ type: 'object',
123
+ properties: {}
124
+ }
125
+ },
126
+ 'rpc.ping': {
127
+ description: 'Ping the server',
128
+ inputSchema: {
129
+ type: 'object',
130
+ properties: {}
131
+ }
132
+ },
133
+ 'rpc.describe': {
134
+ description: 'Describe a specific method',
135
+ inputSchema: {
136
+ type: 'object',
137
+ properties: {
138
+ method: {
139
+ type: 'string'
140
+ }
141
+ },
142
+ required: [
143
+ 'method'
144
+ ]
145
+ }
146
+ },
147
+ 'tools.list': {
148
+ description: 'List all available tools',
149
+ inputSchema: {
150
+ type: 'object',
151
+ properties: {}
152
+ }
153
+ },
154
+ 'tools.invoke': {
155
+ description: 'Invoke a specific tool',
156
+ inputSchema: {
157
+ type: 'object',
158
+ properties: {
159
+ tool: {
160
+ type: 'string'
161
+ },
162
+ input: {
163
+ type: 'object'
164
+ }
165
+ },
166
+ required: [
167
+ 'tool',
168
+ 'input'
169
+ ]
170
+ }
171
+ },
172
+ 'tools.describe': {
173
+ description: 'Describe a specific tool',
174
+ inputSchema: {
175
+ type: 'object',
176
+ properties: {
177
+ tool: {
178
+ type: 'string'
179
+ }
180
+ },
181
+ required: [
182
+ 'tool'
183
+ ]
184
+ }
185
+ }
186
+ };
187
+ if (method in builtInMethods) {
188
+ return builtInMethods[method];
189
+ }
190
+ throw new MCPMethodNotFoundError(method);
191
+ }
192
+ /**
193
+ * Invokes a tool
194
+ */ async invokeTool(params) {
195
+ if (!params || typeof params !== 'object' || !('tool' in params)) {
196
+ throw new Error('Invalid params: tool required');
197
+ }
198
+ const { tool, input } = params;
199
+ return await this.toolRegistry.executeTool(tool, input || {});
200
+ }
201
+ /**
202
+ * Describes a specific tool
203
+ */ describeTool(params) {
204
+ if (!params || typeof params !== 'object' || !('tool' in params)) {
205
+ throw new Error('Invalid params: tool required');
206
+ }
207
+ const { tool: toolName } = params;
208
+ const tool = this.toolRegistry.getTool(toolName);
209
+ if (!tool) {
210
+ throw new Error(`Tool not found: ${toolName}`);
211
+ }
212
+ return {
213
+ name: tool.name,
214
+ description: tool.description,
215
+ inputSchema: tool.inputSchema
216
+ };
217
+ }
218
+ }
219
+
220
+ //# sourceMappingURL=router.js.map