mcpbridge

package module
v1.10.4 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package mcpbridge registers the tools of an MCP server as cortex tools.

The host owns the *mcp.ClientSession and its lifetime. The bridge lists the server's tools, maps each to an llm.Tool plus a handler that calls the server, and tells the engine which of them are safe to run again after a crash.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EngineOptions

func EngineOptions(ctx context.Context, cs *mcp.ClientSession, opts Options) ([]engine.Option, error)

EngineOptions returns a WithTool option for every tool, plus a WithToolRetrySafe option naming the read-only ones.

Types

type Options

type Options struct {
	// Prefix is prepended to every tool name, for example "github_".
	Prefix string
	// Include filters the server's tools. Nil includes every tool.
	Include func(t *mcp.Tool) bool
	// MaxResultBytes caps a tool result. A larger result is a tool error.
	// Zero means 1 MiB.
	MaxResultBytes int
}

Options tunes how a server's tools are exposed.

type Tool

type Tool struct {
	// Def is the definition advertised to the model. Name carries the prefix
	// and Parameters is the server's input schema.
	Def llm.Tool
	// Handler calls the server.
	Handler engine.ToolHandler
	// ReadOnly mirrors the readOnlyHint annotation.
	ReadOnly bool
	// Destructive mirrors the destructiveHint annotation. It defaults to
	// true when the annotation is unset and the tool is not read-only.
	Destructive bool
}

Tool is one server tool, ready to register with the engine.

func Tools

func Tools(ctx context.Context, cs *mcp.ClientSession, opts Options) ([]Tool, error)

Tools lists the server's tools, following pagination, and maps each one. It returns an error naming every included tool whose prefixed name does not match ^[a-zA-Z0-9_-]{1,64}$.

Jump to

Keyboard shortcuts

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