Documentation
¶
Overview ¶
Package langchaingo_mcp_adapter provides an adapter between LangChain Go and MCP servers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewToolForTesting ¶
func NewToolForTesting(name, description string, inputSchema map[string]any, client MCPClientInterface) (langchaingoTools.Tool, error)
NewToolForTesting creates an mcpTool instance for testing purposes. This function is for testing only and should not be used in production applications.
Types ¶
type MCPAdapter ¶
type MCPAdapter struct {
// contains filtered or unexported fields
}
MCPAdapter adapts an MCP client to the LangChain Go tools interface.
func New ¶
func New(client MCPClientInterface, opts ...Option) (*MCPAdapter, error)
New creates a new MCPAdapter instance with the given MCP client. It initializes the connection with the MCP server. Optional parameters can be passed using functional options.
func (*MCPAdapter) Tools ¶
func (a *MCPAdapter) Tools() ([]langchaingoTools.Tool, error)
Tools returns a list of all available tools from the MCP server. Each tool is wrapped as a langchaingoTools.Tool.
type MCPClientInterface ¶
type MCPClientInterface interface {
Initialize(ctx context.Context, request mcp.InitializeRequest) (*mcp.InitializeResult, error)
ListTools(ctx context.Context, request mcp.ListToolsRequest) (*mcp.ListToolsResult, error)
CallTool(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error)
}
MCPClientInterface defines the interface for MCP client operations used by this adapter. This interface is a subset of client.MCPClient that includes only the exported methods we need. The client.MCPClient from github.com/mark3labs/mcp-go/client package implements this interface.
type Option ¶
type Option func(*MCPAdapter)
Option defines a functional option type for configuring MCPAdapter.
func WithToolTimeout ¶
WithToolTimeout sets the timeout for tool calls.