tool

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager manages MCP tool server connections and tool execution.

func NewManager

func NewManager(logger *slog.Logger) *Manager

NewManager creates a manager with no servers registered.

func (*Manager) AdoptFrom

func (m *Manager) AdoptFrom(source *Manager)

AdoptFrom copies all registered tool connections from source into m. Both managers then share the same underlying *mcp.ClientSession pointers, which is safe for concurrent use. Use this to give per-agent managers access to shared external MCP servers without re-spawning subprocesses.

func (*Manager) Close

func (m *Manager) Close() error

Close shuts down all MCP server connections.

func (*Manager) Execute

func (m *Manager) Execute(ctx context.Context, call llm.ToolCall) (string, error)

Execute runs a single tool call and returns the text result.

func (*Manager) RegisterServer

func (m *Manager) RegisterServer(ctx context.Context, name, command string, args []string, env map[string]string) error

RegisterServer spawns an MCP server subprocess, connects to it over stdio, and discovers its available tools.

func (*Manager) RegisterSession

func (m *Manager) RegisterSession(ctx context.Context, name string, session *mcp.ClientSession) error

RegisterSession registers an already-connected MCP client session without spawning a subprocess. Use this for in-process servers (e.g. configmcp).

func (*Manager) ToolDefs

func (m *Manager) ToolDefs() []llm.ToolDef

ToolDefs returns OpenAI-format tool definitions for all registered tools.

func (*Manager) ToolNames

func (m *Manager) ToolNames() []string

ToolNames returns the names of all registered MCP tools.

Jump to

Keyboard shortcuts

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