mcptools

package
v1.3.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertMCPListToolsResultToOpenAITools

func ConvertMCPListToolsResultToOpenAITools(tools *mcp.ListToolsResult) []openai.ChatCompletionToolUnionParam

ConvertMCPListToolsResultToOpenAITools transforms MCP tool definitions into OpenAI tool format

func ConvertMCPListToolsResultToOpenAIToolsWithFilter

func ConvertMCPListToolsResultToOpenAIToolsWithFilter(tools *mcp.ListToolsResult, toolsFilter []string) []openai.ChatCompletionToolUnionParam

ConvertMCPListToolsResultToOpenAIToolsWithFilter transforms filtered MCP tool definitions into OpenAI tool format

func ConvertMCPToolsToOpenAITools

func ConvertMCPToolsToOpenAITools(tools []mcp.Tool) []openai.ChatCompletionToolUnionParam

func ConvertMCPToolsToOpenAIToolsWithFilter

func ConvertMCPToolsToOpenAIToolsWithFilter(tools []mcp.Tool, toolsFilter []string) []openai.ChatCompletionToolUnionParam

func Exec

func Exec[I, O any](mcpClient *MCPClient, functionName string, input I) (O, error)

Types

type MCPClient

type MCPClient struct {
	ToolsResult *mcp.ListToolsResult
	// contains filtered or unexported fields
}

MCPClient wraps an MCP client connection with available tools

func NewStdioMCPClient

func NewStdioMCPClient(ctx context.Context, command string, env []string, args ...string) (*MCPClient, error)

func NewStreamableHttpMCPClient

func NewStreamableHttpMCPClient(ctx context.Context, mcpHostURL string) (*MCPClient, error)

NewStreamableHttpMCPClient creates and initializes a new MCP client over HTTP

func (*MCPClient) Close

func (c *MCPClient) Close() error

Close safely closes the MCP client connection

func (*MCPClient) ExecToolWithAny

func (c *MCPClient) ExecToolWithAny(functionName string, input any) (string, error)

func (*MCPClient) ExecToolWithMap

func (c *MCPClient) ExecToolWithMap(functionName string, input map[string]any) (string, error)

func (*MCPClient) ExecToolWithString

func (c *MCPClient) ExecToolWithString(functionName string, input string) (string, error)

func (*MCPClient) GetTools

func (c *MCPClient) GetTools() []mcp.Tool

func (*MCPClient) GetToolsWithFilter

func (c *MCPClient) GetToolsWithFilter(toolsFilter []string) []mcp.Tool

GetToolsWithFilter returns only the tools that match the provided filter names

func (*MCPClient) OpenAITools

func (c *MCPClient) OpenAITools() []openai.ChatCompletionToolUnionParam

OpenAITools converts the MCP client's tools to OpenAI-compatible format

func (*MCPClient) OpenAIToolsWithFilter

func (c *MCPClient) OpenAIToolsWithFilter(toolsFilter []string) []openai.ChatCompletionToolUnionParam

OpenAIToolsWithFilter converts only the filtered MCP tools to OpenAI-compatible format

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL