MCPcopy Create free account
hub / github.com/echoVic/blade-code / generateTestParams

Function generateTestParams

src/commands/tools.ts:450–480  ·  view source on GitHub ↗

* 生成测试参数

(tool: ToolDefinition)

Source from the content-addressed store, hash-verified

448 * 生成测试参数
449 */
450function generateTestParams(tool: ToolDefinition): Record<string, any> {
451 const testParams: Record<string, any> = {};
452
453 for (const [paramName, paramSchema] of Object.entries(tool.parameters)) {
454 if (paramSchema.default !== undefined) {
455 testParams[paramName] = paramSchema.default;
456 } else if (paramSchema.enum && paramSchema.enum.length > 0) {
457 testParams[paramName] = paramSchema.enum[0];
458 } else {
459 switch (paramSchema.type) {
460 case 'string':
461 testParams[paramName] = 'test';
462 break;
463 case 'number':
464 testParams[paramName] = 42;
465 break;
466 case 'boolean':
467 testParams[paramName] = true;
468 break;
469 case 'array':
470 testParams[paramName] = [];
471 break;
472 case 'object':
473 testParams[paramName] = {};
474 break;
475 }
476 }
477 }
478
479 return testParams;
480}

Callers 1

toolsCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected