MCPcopy Index your code
hub / github.com/apache/answer / convertMCPToolToOpenAI

Method convertMCPToolToOpenAI

internal/controller/ai_controller.go:684–709  ·  view source on GitHub ↗

convertMCPToolToOpenAI

(mcpTool mcp.Tool)

Source from the content-addressed store, hash-verified

682
683// convertMCPToolToOpenAI
684func (c *AIController) convertMCPToolToOpenAI(mcpTool mcp.Tool) openai.Tool {
685 properties := make(map[string]any)
686 required := make([]string, 0)
687
688 maps.Copy(properties, mcpTool.InputSchema.Properties)
689
690 required = append(required, mcpTool.InputSchema.Required...)
691
692 parameters := map[string]any{
693 "type": "object",
694 "properties": properties,
695 }
696
697 if len(required) > 0 {
698 parameters["required"] = required
699 }
700
701 return openai.Tool{
702 Type: openai.ToolTypeFunction,
703 Function: &openai.FunctionDefinition{
704 Name: mcpTool.Name,
705 Description: mcpTool.Description,
706 Parameters: parameters,
707 },
708 }
709}
710
711// callMCPTool
712func (c *AIController) callMCPTool(ctx context.Context, toolName string, arguments map[string]any) (string, error) {

Callers 1

getMCPToolsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected