Convert OpenAI tool definitions to Cursor's MCP tool protobuf format.
(tools: OpenAIToolDef[])
| 576 | |
| 577 | /** Convert OpenAI tool definitions to Cursor's MCP tool protobuf format. */ |
| 578 | function buildMcpToolDefinitions(tools: OpenAIToolDef[]): McpToolDefinition[] { |
| 579 | return tools.map((t) => { |
| 580 | const fn = t.function; |
| 581 | const jsonSchema: JsonValue = |
| 582 | fn.parameters && typeof fn.parameters === "object" |
| 583 | ? (fn.parameters as JsonValue) |
| 584 | : { type: "object", properties: {}, required: [] }; |
| 585 | const inputSchema = toBinary(ValueSchema, fromJson(ValueSchema, jsonSchema)); |
| 586 | return create(McpToolDefinitionSchema, { |
| 587 | name: fn.name, |
| 588 | description: fn.description || "", |
| 589 | providerIdentifier: "opencode", |
| 590 | toolName: fn.name, |
| 591 | inputSchema, |
| 592 | }); |
| 593 | }); |
| 594 | } |
| 595 | |
| 596 | /** Decode a Cursor MCP arg value (protobuf Value bytes) to a JS value. */ |
| 597 | function decodeMcpArgValue(value: Uint8Array): unknown { |
no outgoing calls
no test coverage detected