client

package
v0.6.16 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package client owns protocol-native Model Context Protocol connections, transports, tool discovery, and tool calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expand

func Expand(value, workspace string) (string, error)

Expand resolves workspace and environment references used by MCP transport configuration.

func ExpandHome

func ExpandHome(path string) (string, error)

ExpandHome resolves a leading tilde in an MCP path.

Types

type Config

type Config struct {
	Command        string
	Args           []string
	Env            map[string]string
	Cwd            string
	URL            string
	Headers        map[string]string
	TimeoutSeconds int
}

Config contains only the transport fields needed to connect one MCP server. Product concerns such as enablement and workspace visibility stay above the protocol client.

func (Config) Validate

func (config Config) Validate() error

Validate checks the transport fields that do not require interpolation or opening a connection.

type Connection

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

Connection owns one initialized MCP client session and its discovered tools. Product-level managers can share it without depending on protocol internals.

func Connect

func Connect(ctx context.Context, name string, config Config, workspace string) (*Connection, error)

Connect initializes one server and discovers its complete tools/list result. Workspace scoping is a product concern and must be checked by the caller.

func (*Connection) Close

func (connection *Connection) Close()

Close gracefully terminates the protocol session. It is idempotent.

func (*Connection) Diagnostic

func (connection *Connection) Diagnostic() string

Diagnostic reports non-fatal tool definition problems found at startup.

func (*Connection) Name

func (connection *Connection) Name() string

Name returns the configured server name used for tool names and diagnostics.

func (*Connection) Tools

func (connection *Connection) Tools() []Tool

Tools returns an independent slice of the tools discovered at initialization.

func (*Connection) Transport

func (connection *Connection) Transport() string

Transport returns stdio or streamable_http.

type Tool

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

Tool is one tool discovered from an MCP server. It retains the protocol definition and connection needed to call the original server without depending on Or's agent, provider, or permission types.

func (Tool) Call

func (tool Tool) Call(ctx context.Context, arguments any) (*protocol.CallToolResult, error)

Call invokes the tool with protocol-native arguments and returns the protocol-native result.

func (Tool) Definition

func (tool Tool) Definition() *protocol.Tool

Definition returns the MCP protocol definition advertised by the server. Callers must treat the returned definition as read-only.

func (Tool) ServerName

func (tool Tool) ServerName() string

ServerName returns the configured name of the server that owns the tool.

func (Tool) Transport

func (tool Tool) Transport() string

Transport returns the MCP transport used by the owning server.

Jump to

Keyboard shortcuts

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