Module github.com/bide-ai/bide/mcptools
Go module github.com/bide-ai/bide/mcptools; all modules.
mcptools
github.com/bide-ai/bide/mcptools · pkg.go.dev · Stability: core
Package mcptools adapts a Model Context Protocol server's tools into agent.Tool.
Constants
const DefaultMaxDescriptionBytes = 8 << 10: DefaultMaxDescriptionBytes is the longest tool description, in bytes, that Tools accepts unless WithMaxDescriptionBytes says otherwise: 8 KiB.const DefaultMaxResultBytes = 1 << 20: DefaultMaxResultBytes is the largest tool result, in bytes of JSON, that Call accepts unless WithMaxResultBytes says otherwise: 1 MiB.
Variables
var ErrResultTooLarge: ErrResultTooLarge is a tool call whose result was larger than the limit (see WithMaxResultBytes).
Functions
func Connect(ctx context.Context, transport mcp.Transport, opts ...Option) (*mcp.ClientSession, error): Connect is a convenience over the SDK's client + transport: it builds a client and opens a session on the given transport (stdio, in-memory, streamable HTTP, ...).func DeclineElicitation(context.Context, *mcp.ElicitRequest) (*mcp.ElicitResult, error): DeclineElicitation is a safe default resolver that declines every elicitation.func Tools(ctx context.Context, session *mcp.ClientSession, opts ...ToolsOption) ([]agent.Tool, error): Tools lists the tools exposed by a connected MCP client session and returns each one wrapped as an agent.Tool.
type ElicitFunc
go
type ElicitFunc func(context.Context, *mcp.ElicitRequest) (*mcp.ElicitResult, error)ElicitFunc answers an MCP server's elicitation/create request: the server asks the host for structured input (a message plus a JSON schema), either as a standalone request or embedded in a tool's multi-round-trip input requests.
type Option
go
type Option func(*config)Option configures the MCP client that Connect builds.
Constructors and functions
func WithClientInfo(name, version string) Option: WithClientInfo overrides the client name and version reported to the server (default "bide"/"0.1.0").func WithElicitation(f ElicitFunc) Option: WithElicitation registers a resolver for the server's elicitation/create requests.func WithToolListChanged(f func(context.Context)) Option: WithToolListChanged registers a callback fired when the server notifies that its tool list changed.
type ToolsOption
go
type ToolsOption func(*toolsConfig)ToolsOption configures Tools.
Constructors and functions
func TrustAnnotations() ToolsOption: TrustAnnotations maps the server's tool annotations onto agent.Safety: readOnlyHint becomes ReadOnly and idempotentHint becomes Idempotent.func WithApproval(name string, p *agent.ApprovalPolicy) ToolsOption: WithApproval gates every call to the server's tool named name on human approval before the server sees it: p is agent.SingleApproval() for one decision (agent.Approve), or an m-of-n policy (agent.SubmitDecision, with the agent's WithApproverVerifiers).func WithCallTimeout(d time.Duration) ToolsOption: WithCallTimeout bounds each call to a tool from Tools by d, on top of the caller's context.func WithMaxDescriptionBytes(n int) ToolsOption: WithMaxDescriptionBytes sets the longest tool description, in bytes, that Tools accepts (DefaultMaxDescriptionBytes by default).func WithMaxResultBytes(n int) ToolsOption: WithMaxResultBytes sets the largest result, in bytes of JSON, that a tool's Call accepts (DefaultMaxResultBytes by default).func WithSafety(name string, s agent.Safety) ToolsOption: WithSafety sets the agent.Safety of the server's tool named name, in place of the default (a side effect) and of anything its annotations say, trusted or not.