mcp

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps an MCP stdio client for communicating with MCP servers like ogden.

func NewClient

func NewClient(ctx context.Context, cfg ServerConfig) (*Client, error)

NewClient spawns an MCP server as a child process and initializes the connection.

func (*Client) CallTool

func (c *Client) CallTool(ctx context.Context, name string, arguments map[string]any) (string, time.Duration, error)

CallTool invokes a tool on the MCP server. Uses the provided context for timeout control — callers should set appropriate deadlines. Returns the text content of the response, duration of the call, or empty string on error.

func (*Client) Close

func (c *Client) Close() error

Close shuts down the MCP client and its child process.

func (*Client) HasTool

func (c *Client) HasTool(name string) bool

HasTool returns true if the server has a tool whose name contains the given substring.

func (*Client) Tools

func (c *Client) Tools() map[string]ToolDef

Tools returns all discovered tool definitions.

type ServerConfig

type ServerConfig struct {
	Command string   // e.g., "ogden"
	Args    []string // e.g., ["mcp"]
	Env     []string // additional env vars
}

ServerConfig defines how to connect to an MCP server.

func ConfigFromEnv

func ConfigFromEnv() ServerConfig

ConfigFromEnv builds ServerConfig from OGCODE_MCP_* environment variables.

type ToolDef

type ToolDef struct {
	Name        string
	Description string
	InputSchema json.RawMessage
}

ToolDef describes a tool discovered from an MCP server.

Jump to

Keyboard shortcuts

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