MCPcopy Create free account
hub / github.com/ephraimduncan/opencode-cursor / buildMcpToolDefinitions

Function buildMcpToolDefinitions

src/proxy.ts:578–594  ·  view source on GitHub ↗

Convert OpenAI tool definitions to Cursor's MCP tool protobuf format.

(tools: OpenAIToolDef[])

Source from the content-addressed store, hash-verified

576
577/** Convert OpenAI tool definitions to Cursor's MCP tool protobuf format. */
578function 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. */
597function decodeMcpArgValue(value: Uint8Array): unknown {

Callers 1

handleChatCompletionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected