mcp

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package mcp provides integration with the Model Context Protocol (MCP). It allows Bucephalus to use tools from MCP servers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToolsFromMCP

func ToolsFromMCP(ctx context.Context, command string, args []string, opts ...Option) ([]llm.Tool, func() error, error)

ToolsFromMCP is a convenience function to get tools from an MCP server.

Example:

tools, cleanup, err := mcp.ToolsFromMCP(ctx, "./my-mcp-server", nil)
if err != nil {
    return err
}
defer cleanup()

resp, err := llm.Call(ctx, "Help me", llm.WithTools(tools...))

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps an MCP client for use with Bucephalus.

func NewStdioClient

func NewStdioClient(ctx context.Context, command string, args []string, opts ...Option) (*Client, error)

NewStdioClient creates an MCP client that communicates via stdio with a subprocess.

Example:

client, err := mcp.NewStdioClient(ctx, "./my-mcp-server", nil)
if err != nil {
    return err
}
defer client.Close()

tools, err := client.Tools(ctx)

func (*Client) Close

func (c *Client) Close() error

Close closes the MCP client connection.

func (*Client) Tools

func (c *Client) Tools(ctx context.Context) ([]llm.Tool, error)

Tools returns all tools from the MCP server as Bucephalus Tools.

Example:

tools, err := client.Tools(ctx)
if err != nil {
    return err
}

resp, err := llm.Call(ctx, "Use the tools to help",
    llm.WithProvider("openai"),
    llm.WithModel("o4-mini"),
    llm.WithTools(tools...),
)

type Option

type Option func(*clientConfig)

Option configures the MCP client.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets the timeout for tool execution.

Jump to

Keyboard shortcuts

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