bridge

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bridge

type Bridge struct {
	Server *mcp.Server
	// contains filtered or unexported fields
}

Bridge connects an mcp.Server to a FullBackend. It registers proxy handlers that forward MCP requests to the SDK process.

func New

func New(backend FullBackend, logger *slog.Logger, version string) *Bridge

New creates a Bridge with an mcp.Server that proxies to the given backend.

func (*Bridge) SetToolListMutationHandler

func (b *Bridge) SetToolListMutationHandler(fn ToolListMutationHandler)

SetToolListMutationHandler registers a callback for enable_tools/disable_tools in tool call responses.

func (*Bridge) SyncAll added in v0.3.0

func (b *Bridge) SyncAll()

SyncAll atomically syncs tools, resources, and prompts under a single lock.

func (*Bridge) SyncPrompts

func (b *Bridge) SyncPrompts()

SyncPrompts reads prompt definitions from the backend and registers them with the mcp.Server.

func (*Bridge) SyncResources

func (b *Bridge) SyncResources()

SyncResources reads resource and resource template definitions from the backend and registers them with the mcp.Server.

func (*Bridge) SyncTools

func (b *Bridge) SyncTools()

SyncTools reads tool definitions from the backend and registers them with the mcp.Server. Called on startup and after hot reload.

type CompletionBackend

type CompletionBackend interface {
	Complete(ctx context.Context, refType, refName, argName, argValue string) (*pb.CompletionResponse, error)
}

CompletionBackend is the interface for completion operations.

type FullBackend

FullBackend combines all backend interfaces.

type ProcessBackend

type ProcessBackend interface {
	ActiveTools() []*pb.ToolDefinition
	CallTool(ctx context.Context, name, argsJSON string) (*pb.CallToolResponse, error)
}

ProcessBackend is the interface for communicating with an SDK tool process. Implemented by process.Manager.

type PromptBackend

type PromptBackend interface {
	ListPrompts(ctx context.Context) ([]*pb.PromptDefinition, error)
	GetPrompt(ctx context.Context, name, argsJSON string) (*pb.GetPromptResponse, error)
}

PromptBackend is the interface for prompt operations.

type ResourceBackend

type ResourceBackend interface {
	ListResources(ctx context.Context) ([]*pb.ResourceDefinition, error)
	ListResourceTemplates(ctx context.Context) ([]*pb.ResourceTemplateDefinition, error)
	ReadResource(ctx context.Context, uri string) (*pb.ReadResourceResponse, error)
}

ResourceBackend is the interface for resource operations.

type SamplingBackend

type SamplingBackend interface {
	SendSamplingResponse(reqID string, resp *pb.SamplingResponse) error
	OnSampling(fn func(*pb.SamplingRequest, string))
	SendListRootsResponse(reqID string, resp *pb.ListRootsResponse) error
	OnListRoots(fn func(string))
}

SamplingBackend lets the bridge send sampling responses back to the SDK process.

type ToolListMutationHandler

type ToolListMutationHandler func(enable, disable []string)

ToolListMutationHandler is called when a tool call response contains enable_tools or disable_tools.

Jump to

Keyboard shortcuts

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