mcp

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseMessage

type BaseMessage struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      *int64          `json:"id,omitempty"`
	Method  string          `json:"method,omitempty"`
	Result  json.RawMessage `json:"result,omitempty"`
	Error   *struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
	} `json:"error,omitempty"`
}

type Client

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

Client implements an MCP client for interacting with MCP servers

func NewRemoteClient

func NewRemoteClient(url, transportType string, headers map[string]string) (*Client, error)

NewRemoteClient creates a new MCP client that can connect to a remote MCP server

func NewStdioClient

func NewStdioClient(command string, args, env []string) *Client

NewStdioClient creates a new MCP client that can start an stdio MCP server

func (*Client) CallTool

func (c *Client) CallTool(ctx context.Context, toolCall tools.ToolCall) (*tools.ToolCallResult, error)

CallTool calls a tool on the MCP server

func (*Client) CallToolWithArgs

func (c *Client) CallToolWithArgs(ctx context.Context, toolName string, args any) (*tools.ToolCallResult, error)

CallToolWithArgs is a convenience method to call a tool with arguments

func (*Client) GetToolByName

func (c *Client) GetToolByName(name string) (tools.Tool, error)

GetToolByName returns a tool by name

func (*Client) ListTools

func (c *Client) ListTools(ctx context.Context, toolFilter []string) ([]tools.Tool, error)

ListTools fetches available tools from the MCP server

func (*Client) Start

func (c *Client) Start(ctx context.Context) error

Start initializes and starts the MCP server connection

func (*Client) Stop

func (c *Client) Stop() error

Stop stops the MCP server

type RPCResponse

type RPCResponse struct {
	Error    *string
	Response *json.RawMessage
}

type Toolset

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

Toolset represents a set of MCP tools

func NewToolsetCommand

func NewToolsetCommand(command string, args, env, toolFilter []string) *Toolset

NewToolsetCommand creates a new MCP toolset from a command.

func NewToolsetRemote

func NewToolsetRemote(url, transport string, headers map[string]string, toolFilter []string) (*Toolset, error)

NewToolsetRemote creates a new MCP toolset from a remote MCP Server.

func (*Toolset) Instructions

func (t *Toolset) Instructions() string

Instructions returns the toolset instructions

func (*Toolset) Start

func (t *Toolset) Start(ctx context.Context) error

Start starts the toolset

func (*Toolset) Stop

func (t *Toolset) Stop() error

Stop stops the toolset

func (*Toolset) Tools

func (t *Toolset) Tools(ctx context.Context) ([]tools.Tool, error)

Tools returns the available tools

Jump to

Keyboard shortcuts

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