MCPcopy
hub / github.com/7836246/cursor2api / convertTools

Function convertTools

test/unit-openai-compat.mjs:460–475  ·  view source on GitHub ↗
(tools)

Source from the content-addressed store, hash-verified

458console.log('\n📦 [3] Cursor 扁平格式工具兼容\n');
459
460function convertTools(tools) {
461 return tools.map(t => {
462 if ('function' in t && t.function) {
463 return {
464 name: t.function.name,
465 description: t.function.description,
466 input_schema: t.function.parameters || { type: 'object', properties: {} },
467 };
468 }
469 return {
470 name: t.name || '',
471 description: t.description,
472 input_schema: t.input_schema || { type: 'object', properties: {} },
473 };
474 });
475}
476
477test('标准 OpenAI 格式工具', () => {
478 const tools = convertTools([{

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected