sub-agents-mcp 0.1.2
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 +21 -0
- package/README.md +265 -0
- package/dist/agents/AgentManager.d.ts +58 -0
- package/dist/agents/AgentManager.d.ts.map +1 -0
- package/dist/agents/AgentManager.js +182 -0
- package/dist/agents/AgentManager.js.map +1 -0
- package/dist/config/ServerConfig.d.ts +34 -0
- package/dist/config/ServerConfig.d.ts.map +1 -0
- package/dist/config/ServerConfig.js +54 -0
- package/dist/config/ServerConfig.js.map +1 -0
- package/dist/execution/AgentExecutor.d.ts +114 -0
- package/dist/execution/AgentExecutor.d.ts.map +1 -0
- package/dist/execution/AgentExecutor.js +234 -0
- package/dist/execution/AgentExecutor.js.map +1 -0
- package/dist/execution/ExecutionLimits.d.ts +141 -0
- package/dist/execution/ExecutionLimits.d.ts.map +1 -0
- package/dist/execution/ExecutionLimits.js +231 -0
- package/dist/execution/ExecutionLimits.js.map +1 -0
- package/dist/execution/McpRequestTimeout.d.ts +166 -0
- package/dist/execution/McpRequestTimeout.d.ts.map +1 -0
- package/dist/execution/McpRequestTimeout.js +278 -0
- package/dist/execution/McpRequestTimeout.js.map +1 -0
- package/dist/execution/PromptController.d.ts +92 -0
- package/dist/execution/PromptController.d.ts.map +1 -0
- package/dist/execution/PromptController.js +130 -0
- package/dist/execution/PromptController.js.map +1 -0
- package/dist/execution/StreamProcessor.d.ts +23 -0
- package/dist/execution/StreamProcessor.d.ts.map +1 -0
- package/dist/execution/StreamProcessor.js +51 -0
- package/dist/execution/StreamProcessor.js.map +1 -0
- package/dist/execution/TimeoutManager.d.ts +159 -0
- package/dist/execution/TimeoutManager.d.ts.map +1 -0
- package/dist/execution/TimeoutManager.js +283 -0
- package/dist/execution/TimeoutManager.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/AgentResources.d.ts +104 -0
- package/dist/resources/AgentResources.d.ts.map +1 -0
- package/dist/resources/AgentResources.js +315 -0
- package/dist/resources/AgentResources.js.map +1 -0
- package/dist/server/McpServer.d.ts +138 -0
- package/dist/server/McpServer.d.ts.map +1 -0
- package/dist/server/McpServer.js +373 -0
- package/dist/server/McpServer.js.map +1 -0
- package/dist/tools/RunAgentTool.d.ts +140 -0
- package/dist/tools/RunAgentTool.d.ts.map +1 -0
- package/dist/tools/RunAgentTool.js +371 -0
- package/dist/tools/RunAgentTool.js.map +1 -0
- package/dist/types/AgentDefinition.d.ts +33 -0
- package/dist/types/AgentDefinition.d.ts.map +1 -0
- package/dist/types/AgentDefinition.js +3 -0
- package/dist/types/AgentDefinition.js.map +1 -0
- package/dist/types/ExecutionParams.d.ts +48 -0
- package/dist/types/ExecutionParams.d.ts.map +1 -0
- package/dist/types/ExecutionParams.js +3 -0
- package/dist/types/ExecutionParams.js.map +1 -0
- package/dist/types/ServerConfig.d.ts +39 -0
- package/dist/types/ServerConfig.d.ts.map +1 -0
- package/dist/types/ServerConfig.js +3 -0
- package/dist/types/ServerConfig.js.map +1 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/ErrorHandler.d.ts +86 -0
- package/dist/utils/ErrorHandler.d.ts.map +1 -0
- package/dist/utils/ErrorHandler.js +99 -0
- package/dist/utils/ErrorHandler.js.map +1 -0
- package/dist/utils/Logger.d.ts +99 -0
- package/dist/utils/Logger.d.ts.map +1 -0
- package/dist/utils/Logger.js +151 -0
- package/dist/utils/Logger.js.map +1 -0
- package/package.json +92 -0
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MCP Server implementation using @modelcontextprotocol/sdk
|
|
4
|
+
*
|
|
5
|
+
* Provides the foundational MCP server functionality with StdioServerTransport
|
|
6
|
+
* for stdin/stdout communication. This class serves as the entry point for
|
|
7
|
+
* the MCP server and handles basic server lifecycle operations.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const config = await ServerConfig.fromEnvironment()
|
|
12
|
+
* const server = new McpServer(config)
|
|
13
|
+
* await server.start()
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.McpServer = void 0;
|
|
18
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
19
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
20
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
21
|
+
const AgentManager_1 = require("../agents/AgentManager");
|
|
22
|
+
const AgentExecutor_1 = require("../execution/AgentExecutor");
|
|
23
|
+
const AgentResources_1 = require("../resources/AgentResources");
|
|
24
|
+
const RunAgentTool_1 = require("../tools/RunAgentTool");
|
|
25
|
+
const ErrorHandler_1 = require("../utils/ErrorHandler");
|
|
26
|
+
const Logger_1 = require("../utils/Logger");
|
|
27
|
+
/**
|
|
28
|
+
* MCP Server class providing foundational server functionality
|
|
29
|
+
*/
|
|
30
|
+
class McpServer {
|
|
31
|
+
/**
|
|
32
|
+
* Create a new MCP server instance
|
|
33
|
+
* @param config Server configuration object
|
|
34
|
+
* @throws {Error} When server name is empty
|
|
35
|
+
*/
|
|
36
|
+
constructor(config) {
|
|
37
|
+
this.transport = null;
|
|
38
|
+
this.validateConfig(config);
|
|
39
|
+
this.config = config;
|
|
40
|
+
this.log('info', 'Initializing MCP server', {
|
|
41
|
+
name: config.serverName,
|
|
42
|
+
version: config.serverVersion,
|
|
43
|
+
});
|
|
44
|
+
// Initialize agent management components
|
|
45
|
+
this.agentManager = new AgentManager_1.AgentManager(config);
|
|
46
|
+
// Create ExecutionConfig with the agent type from server config
|
|
47
|
+
const executionConfig = (0, AgentExecutor_1.createExecutionConfig)(config.agentType, {
|
|
48
|
+
executionTimeout: config.executionTimeoutMs, // Use timeout from config (env var or 90s default)
|
|
49
|
+
});
|
|
50
|
+
// Create logger with log level from config
|
|
51
|
+
const executorLogger = new Logger_1.Logger(config.logLevel);
|
|
52
|
+
this.agentExecutor = new AgentExecutor_1.AgentExecutor(executionConfig, executorLogger);
|
|
53
|
+
this.runAgentTool = new RunAgentTool_1.RunAgentTool(this.agentExecutor, this.agentManager);
|
|
54
|
+
this.agentResources = new AgentResources_1.AgentResources(this.agentManager);
|
|
55
|
+
// Initialize MCP server with capabilities
|
|
56
|
+
this.server = new index_js_1.Server({
|
|
57
|
+
name: config.serverName,
|
|
58
|
+
version: config.serverVersion,
|
|
59
|
+
}, {
|
|
60
|
+
capabilities: {
|
|
61
|
+
tools: {},
|
|
62
|
+
resources: {},
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
// Setup StdioServerTransport for stdin/stdout communication
|
|
66
|
+
this.setupTransport();
|
|
67
|
+
// Setup MCP handlers
|
|
68
|
+
this.setupHandlers();
|
|
69
|
+
this.log('info', 'MCP server initialized successfully');
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Validate server configuration
|
|
73
|
+
* @param config Configuration to validate
|
|
74
|
+
* @throws {Error} When configuration is invalid
|
|
75
|
+
*/
|
|
76
|
+
validateConfig(config) {
|
|
77
|
+
if (!config.serverName || config.serverName.trim() === '') {
|
|
78
|
+
throw new Error('Server name cannot be empty');
|
|
79
|
+
}
|
|
80
|
+
if (!config.serverVersion || config.serverVersion.trim() === '') {
|
|
81
|
+
throw new Error('Server version cannot be empty');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Log message with structured format
|
|
86
|
+
* @param level Log level
|
|
87
|
+
* @param message Log message
|
|
88
|
+
* @param metadata Additional metadata
|
|
89
|
+
*/
|
|
90
|
+
log(level, message, metadata) {
|
|
91
|
+
const logLevels = {
|
|
92
|
+
debug: 0,
|
|
93
|
+
info: 1,
|
|
94
|
+
warn: 2,
|
|
95
|
+
error: 3,
|
|
96
|
+
};
|
|
97
|
+
if (logLevels[level] >= logLevels[this.config.logLevel]) {
|
|
98
|
+
const timestamp = new Date().toISOString();
|
|
99
|
+
const logEntry = {
|
|
100
|
+
timestamp,
|
|
101
|
+
level,
|
|
102
|
+
message,
|
|
103
|
+
service: 'mcp-server',
|
|
104
|
+
...metadata,
|
|
105
|
+
};
|
|
106
|
+
console.log(JSON.stringify(logEntry));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Setup StdioServerTransport for MCP communication
|
|
111
|
+
*/
|
|
112
|
+
setupTransport() {
|
|
113
|
+
try {
|
|
114
|
+
this.transport = new stdio_js_1.StdioServerTransport();
|
|
115
|
+
this.log('debug', 'StdioServerTransport configured successfully');
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
this.log('error', 'Failed to setup transport', { error: String(error) });
|
|
119
|
+
throw new ErrorHandler_1.AppError('Failed to setup MCP transport', 'TRANSPORT_SETUP_FAILED');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Setup MCP protocol handlers with performance monitoring
|
|
124
|
+
*/
|
|
125
|
+
setupHandlers() {
|
|
126
|
+
try {
|
|
127
|
+
// List tools handler
|
|
128
|
+
this.server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
|
|
129
|
+
const startTime = Date.now();
|
|
130
|
+
this.log('debug', 'Received list_tools request');
|
|
131
|
+
try {
|
|
132
|
+
const result = {
|
|
133
|
+
tools: [
|
|
134
|
+
{
|
|
135
|
+
name: this.runAgentTool.name,
|
|
136
|
+
description: this.runAgentTool.description,
|
|
137
|
+
inputSchema: this.runAgentTool.inputSchema,
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
};
|
|
141
|
+
this.log('debug', 'List tools request completed', {
|
|
142
|
+
responseTime: Date.now() - startTime,
|
|
143
|
+
toolCount: result.tools.length,
|
|
144
|
+
});
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
this.log('error', 'List tools request failed', {
|
|
149
|
+
responseTime: Date.now() - startTime,
|
|
150
|
+
error: error instanceof Error ? error.message : String(error),
|
|
151
|
+
});
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
// Call tool handler
|
|
156
|
+
this.server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
157
|
+
const startTime = Date.now();
|
|
158
|
+
const { params } = request;
|
|
159
|
+
this.log('debug', 'Received call_tool request', { tool: params.name });
|
|
160
|
+
try {
|
|
161
|
+
if (params.name === 'run_agent') {
|
|
162
|
+
const result = await this.runAgentTool.execute(params.arguments);
|
|
163
|
+
this.log('info', 'Tool execution completed', {
|
|
164
|
+
tool: params.name,
|
|
165
|
+
responseTime: Date.now() - startTime,
|
|
166
|
+
success: true,
|
|
167
|
+
});
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
throw new ErrorHandler_1.ValidationError(`Unknown tool: ${params.name}`, 'UNKNOWN_TOOL');
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
this.log('error', 'Tool execution failed', {
|
|
174
|
+
tool: params.name,
|
|
175
|
+
responseTime: Date.now() - startTime,
|
|
176
|
+
error: error instanceof Error ? error.message : String(error),
|
|
177
|
+
});
|
|
178
|
+
throw error;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
// List resources handler
|
|
182
|
+
this.server.setRequestHandler(types_js_1.ListResourcesRequestSchema, async () => {
|
|
183
|
+
const startTime = Date.now();
|
|
184
|
+
this.log('debug', 'Received list_resources request');
|
|
185
|
+
try {
|
|
186
|
+
const resources = await this.agentResources.listResources();
|
|
187
|
+
this.log('debug', 'List resources request completed', {
|
|
188
|
+
responseTime: Date.now() - startTime,
|
|
189
|
+
resourceCount: resources.length,
|
|
190
|
+
});
|
|
191
|
+
return { resources };
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
this.log('error', 'List resources request failed', {
|
|
195
|
+
responseTime: Date.now() - startTime,
|
|
196
|
+
error: error instanceof Error ? error.message : String(error),
|
|
197
|
+
});
|
|
198
|
+
throw error;
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
// Read resource handler
|
|
202
|
+
this.server.setRequestHandler(types_js_1.ReadResourceRequestSchema, async (request) => {
|
|
203
|
+
const startTime = Date.now();
|
|
204
|
+
const { params } = request;
|
|
205
|
+
this.log('debug', 'Received read_resource request', { uri: params.uri });
|
|
206
|
+
try {
|
|
207
|
+
if (!this.agentResources.isValidResourceUri(params.uri)) {
|
|
208
|
+
throw new ErrorHandler_1.ValidationError(`Invalid resource URI: ${params.uri}`, 'INVALID_RESOURCE_URI');
|
|
209
|
+
}
|
|
210
|
+
const result = await this.agentResources.readResource(params.uri);
|
|
211
|
+
this.log('debug', 'Read resource request completed', {
|
|
212
|
+
uri: params.uri,
|
|
213
|
+
responseTime: Date.now() - startTime,
|
|
214
|
+
contentLength: result.contents[0]?.text?.length || 0,
|
|
215
|
+
});
|
|
216
|
+
return result;
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
this.log('error', 'Read resource request failed', {
|
|
220
|
+
uri: params.uri,
|
|
221
|
+
responseTime: Date.now() - startTime,
|
|
222
|
+
error: error instanceof Error ? error.message : String(error),
|
|
223
|
+
});
|
|
224
|
+
throw error;
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
this.log('debug', 'MCP handlers configured successfully');
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
this.log('error', 'Failed to setup MCP handlers', { error: String(error) });
|
|
231
|
+
throw new ErrorHandler_1.AppError('Failed to setup MCP handlers', 'HANDLERS_SETUP_FAILED');
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Get server information
|
|
236
|
+
* @returns Server name and version
|
|
237
|
+
*/
|
|
238
|
+
getServerInfo() {
|
|
239
|
+
return {
|
|
240
|
+
name: this.config.serverName,
|
|
241
|
+
version: this.config.serverVersion,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Check if transport is configured
|
|
246
|
+
* @returns True if transport is available
|
|
247
|
+
*/
|
|
248
|
+
hasTransport() {
|
|
249
|
+
return this.transport !== null;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Check if server is ready to start
|
|
253
|
+
* @returns True if server is ready
|
|
254
|
+
*/
|
|
255
|
+
isReady() {
|
|
256
|
+
return this.hasTransport() && this.server !== null;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Start the MCP server
|
|
260
|
+
* @throws {Error} When server is not ready or transport setup fails
|
|
261
|
+
*/
|
|
262
|
+
async start() {
|
|
263
|
+
try {
|
|
264
|
+
if (!this.isReady()) {
|
|
265
|
+
throw new ErrorHandler_1.AppError('Server is not ready to start', 'SERVER_NOT_READY');
|
|
266
|
+
}
|
|
267
|
+
if (!this.transport) {
|
|
268
|
+
throw new ErrorHandler_1.AppError('Transport not configured', 'TRANSPORT_NOT_CONFIGURED');
|
|
269
|
+
}
|
|
270
|
+
this.log('info', 'Starting MCP server...');
|
|
271
|
+
// Connect server to transport
|
|
272
|
+
await this.server.connect(this.transport);
|
|
273
|
+
this.log('info', 'MCP server started successfully', {
|
|
274
|
+
serverName: this.config.serverName,
|
|
275
|
+
serverVersion: this.config.serverVersion,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
this.log('error', 'Failed to start MCP server', { error: String(error) });
|
|
280
|
+
throw error instanceof ErrorHandler_1.AppError
|
|
281
|
+
? error
|
|
282
|
+
: new ErrorHandler_1.AppError('Failed to start MCP server', 'SERVER_START_FAILED');
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* List available tools (for testing)
|
|
287
|
+
* @returns Promise resolving to array of tool definitions
|
|
288
|
+
*/
|
|
289
|
+
async listTools() {
|
|
290
|
+
return [
|
|
291
|
+
{
|
|
292
|
+
name: this.runAgentTool.name,
|
|
293
|
+
description: this.runAgentTool.description,
|
|
294
|
+
inputSchema: this.runAgentTool.inputSchema,
|
|
295
|
+
},
|
|
296
|
+
];
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* List available resources (for testing)
|
|
300
|
+
* @returns Promise resolving to array of resource definitions
|
|
301
|
+
*/
|
|
302
|
+
async listResources() {
|
|
303
|
+
const resources = await this.agentResources.listResources();
|
|
304
|
+
return resources.map((resource) => ({
|
|
305
|
+
uri: resource.uri,
|
|
306
|
+
name: resource.name,
|
|
307
|
+
description: resource.description,
|
|
308
|
+
}));
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Call a tool (for testing)
|
|
312
|
+
* @param toolName - Name of the tool to call
|
|
313
|
+
* @param params - Tool parameters
|
|
314
|
+
* @returns Promise resolving to tool response
|
|
315
|
+
*/
|
|
316
|
+
async callTool(toolName, params) {
|
|
317
|
+
if (toolName === 'run_agent') {
|
|
318
|
+
return await this.runAgentTool.execute(params);
|
|
319
|
+
}
|
|
320
|
+
throw new ErrorHandler_1.ValidationError(`Unknown tool: ${toolName}`, 'UNKNOWN_TOOL');
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Read a resource (for testing)
|
|
324
|
+
* @param uri - Resource URI to read
|
|
325
|
+
* @returns Promise resolving to resource content
|
|
326
|
+
*/
|
|
327
|
+
async readResource(uri) {
|
|
328
|
+
if (!this.agentResources.isValidResourceUri(uri)) {
|
|
329
|
+
throw new ErrorHandler_1.ValidationError(`Invalid resource URI: ${uri}`, 'INVALID_RESOURCE_URI');
|
|
330
|
+
}
|
|
331
|
+
return await this.agentResources.readResource(uri);
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Get server performance statistics
|
|
335
|
+
*
|
|
336
|
+
* @returns Performance and usage statistics
|
|
337
|
+
*/
|
|
338
|
+
getServerStats() {
|
|
339
|
+
return {
|
|
340
|
+
serverInfo: this.getServerInfo(),
|
|
341
|
+
executionStats: this.runAgentTool.getExecutionStats(),
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Reset statistics
|
|
346
|
+
*/
|
|
347
|
+
resetStats() {
|
|
348
|
+
this.log('info', 'Server statistics reset');
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Close the server and cleanup resources
|
|
352
|
+
*/
|
|
353
|
+
async close() {
|
|
354
|
+
try {
|
|
355
|
+
this.log('info', 'Shutting down MCP server...');
|
|
356
|
+
// Log final statistics before shutdown
|
|
357
|
+
const stats = this.getServerStats();
|
|
358
|
+
this.log('info', 'Final server statistics', {
|
|
359
|
+
executionCount: Array.from(stats.executionStats.values()).reduce((sum, stat) => sum + stat.count, 0),
|
|
360
|
+
});
|
|
361
|
+
if (this.server) {
|
|
362
|
+
await this.server.close();
|
|
363
|
+
}
|
|
364
|
+
this.log('info', 'MCP server shutdown completed');
|
|
365
|
+
}
|
|
366
|
+
catch (error) {
|
|
367
|
+
this.log('error', 'Error during server shutdown', { error: String(error) });
|
|
368
|
+
throw new ErrorHandler_1.AppError('Failed to shutdown MCP server gracefully', 'SERVER_SHUTDOWN_FAILED');
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
exports.McpServer = McpServer;
|
|
373
|
+
//# sourceMappingURL=McpServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpServer.js","sourceRoot":"","sources":["../../src/server/McpServer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAEH,wEAAkE;AAClE,wEAAgF;AAChF,iEAS2C;AAC3C,0DAAsD;AAEtD,+DAAkF;AAClF,iEAA6D;AAC7D,yDAAqD;AACrD,yDAAkE;AAClE,6CAAyC;AAezC;;GAEG;AACH,MAAa,SAAS;IASpB;;;;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
|
2
|
+
* RunAgentTool implementation for executing Claude Code sub-agents via MCP
|
|
3
|
+
*
|
|
4
|
+
* Provides the run_agent tool that allows MCP clients to execute specific
|
|
5
|
+
* agents with parameters, integrating with AgentExecutor and AgentManager
|
|
6
|
+
* for complete agent execution workflow.
|
|
7
|
+
*/
|
|
8
|
+
import type { AgentManager } from '../agents/AgentManager';
|
|
9
|
+
import type { AgentExecutor } from '../execution/AgentExecutor';
|
|
10
|
+
/**
|
|
11
|
+
* MCP tool content type for text responses
|
|
12
|
+
*/
|
|
13
|
+
interface McpTextContent {
|
|
14
|
+
type: 'text';
|
|
15
|
+
text: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* MCP tool response format
|
|
19
|
+
*/
|
|
20
|
+
interface McpToolResponse {
|
|
21
|
+
content: McpTextContent[];
|
|
22
|
+
isError?: boolean;
|
|
23
|
+
structuredContent?: unknown;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Input schema for run_agent tool parameters
|
|
27
|
+
*/
|
|
28
|
+
interface RunAgentInputSchema {
|
|
29
|
+
[x: string]: unknown;
|
|
30
|
+
type: 'object';
|
|
31
|
+
properties: {
|
|
32
|
+
[x: string]: unknown;
|
|
33
|
+
agent: {
|
|
34
|
+
type: 'string';
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
|
37
|
+
prompt: {
|
|
38
|
+
type: 'string';
|
|
39
|
+
description: string;
|
|
40
|
+
};
|
|
41
|
+
cwd: {
|
|
42
|
+
type: 'string';
|
|
43
|
+
description: string;
|
|
44
|
+
};
|
|
45
|
+
extra_args: {
|
|
46
|
+
type: 'array';
|
|
47
|
+
items: {
|
|
48
|
+
type: 'string';
|
|
49
|
+
};
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
required: string[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* RunAgentTool class implementing the run_agent MCP tool
|
|
57
|
+
*
|
|
58
|
+
* Provides execution of Claude Code sub-agents with parameter validation,
|
|
59
|
+
* error handling, and proper MCP response formatting.
|
|
60
|
+
*/
|
|
61
|
+
export declare class RunAgentTool {
|
|
62
|
+
private agentExecutor?;
|
|
63
|
+
private agentManager?;
|
|
64
|
+
readonly name = "run_agent";
|
|
65
|
+
readonly description = "Execute a Claude Code sub-agent with specified parameters";
|
|
66
|
+
private logger;
|
|
67
|
+
private executionStats;
|
|
68
|
+
readonly inputSchema: RunAgentInputSchema;
|
|
69
|
+
constructor(agentExecutor?: AgentExecutor | undefined, agentManager?: AgentManager | undefined);
|
|
70
|
+
/**
|
|
71
|
+
* Execute the run_agent tool with the provided parameters
|
|
72
|
+
*
|
|
73
|
+
* @param params - Tool execution parameters
|
|
74
|
+
* @returns Promise resolving to MCP tool response
|
|
75
|
+
* @throws {Error} When parameters are invalid or execution fails
|
|
76
|
+
*/
|
|
77
|
+
execute(params: unknown): Promise<McpToolResponse>;
|
|
78
|
+
/**
|
|
79
|
+
* Validate and type-check the input parameters with comprehensive validation
|
|
80
|
+
*
|
|
81
|
+
* @private
|
|
82
|
+
* @param params - Raw parameters to validate
|
|
83
|
+
* @returns Validated parameters
|
|
84
|
+
* @throws {Error} When parameters are invalid
|
|
85
|
+
*/
|
|
86
|
+
private validateParams;
|
|
87
|
+
/**
|
|
88
|
+
* Format agent execution response
|
|
89
|
+
*
|
|
90
|
+
* @private
|
|
91
|
+
* @param result - Agent execution result
|
|
92
|
+
* @param agentName - Name of the executed agent
|
|
93
|
+
* @param requestId - Request tracking ID
|
|
94
|
+
* @returns Formatted MCP response
|
|
95
|
+
*/
|
|
96
|
+
private formatExecutionResponse;
|
|
97
|
+
/**
|
|
98
|
+
* Create error response with optional available agents list
|
|
99
|
+
*
|
|
100
|
+
* @private
|
|
101
|
+
* @param errorMessage - Error message to display
|
|
102
|
+
* @param availableAgents - Optional list of available agents
|
|
103
|
+
* @returns Error response in MCP format
|
|
104
|
+
*/
|
|
105
|
+
private createErrorResponse;
|
|
106
|
+
/**
|
|
107
|
+
* Generate unique request ID for tracking
|
|
108
|
+
*
|
|
109
|
+
* @private
|
|
110
|
+
* @returns Unique request identifier
|
|
111
|
+
*/
|
|
112
|
+
private generateRequestId;
|
|
113
|
+
/**
|
|
114
|
+
* Update execution statistics
|
|
115
|
+
*
|
|
116
|
+
* @private
|
|
117
|
+
* @param agentName - Name of the executed agent
|
|
118
|
+
* @param executionTime - Time taken for execution
|
|
119
|
+
*/
|
|
120
|
+
private updateExecutionStats;
|
|
121
|
+
/**
|
|
122
|
+
* Get execution statistics for monitoring
|
|
123
|
+
*
|
|
124
|
+
* @returns Map of agent execution statistics
|
|
125
|
+
*/
|
|
126
|
+
getExecutionStats(): Map<string, {
|
|
127
|
+
count: number;
|
|
128
|
+
totalTime: number;
|
|
129
|
+
lastUsed: Date;
|
|
130
|
+
}>;
|
|
131
|
+
/**
|
|
132
|
+
* Get list of available agent names
|
|
133
|
+
*
|
|
134
|
+
* @private
|
|
135
|
+
* @returns Promise resolving to array of agent names
|
|
136
|
+
*/
|
|
137
|
+
private getAvailableAgentsList;
|
|
138
|
+
}
|
|
139
|
+
export {};
|
|
140
|
+
//# sourceMappingURL=RunAgentTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunAgentTool.d.ts","sourceRoot":"","sources":["../../src/tools/RunAgentTool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAwB,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAItF;;GAEG;AACH,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,UAAU,eAAe;IACvB,OAAO,EAAE,cAAc,EAAE,CAAA;IACzB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B;AA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