mcp

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultRemoteCreator

func DefaultRemoteCreator(ctx context.Context, url string, headers map[string]string) (client.MCPClient, error)

DefaultRemoteCreator is the standard creator for remote (SSE or Streamable HTTP) clients.

func DefaultStdioCreator

func DefaultStdioCreator(command string, env []string, args ...string) (client.MCPClient, error)

DefaultStdioCreator is the standard creator for Stdio clients.

func ResolveConfigPath

func ResolveConfigPath() (string, error)

ResolveConfigPath returns the default path to the mcp.json file.

Types

type Config

type Config struct {
	McpServers map[string]ServerConfig `json:"mcpServers"`
}

Config represents the mcp.json format.

func LoadConfigPath

func LoadConfigPath(path string) (*Config, error)

LoadConfigPath loads the config from the given file path.

func ParseConfig

func ParseConfig(data []byte) (*Config, error)

ParseConfig parses the mcp.json contents.

type Manager

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

Manager manages MCP server clients and lifecycles.

func NewManager

func NewManager(cfg *Config, stdioCreator StdioCreator, remoteCreator RemoteCreator) *Manager

NewManager creates a new Manager.

func (*Manager) Close

func (m *Manager) Close() error

Close terminates all active client connections.

func (*Manager) Start

func (m *Manager) Start(ctx context.Context) ([]einotool.BaseTool, error)

Start spawns all configured MCP servers in parallel, initializes them, and returns Eino tools.

type RemoteCreator

type RemoteCreator func(ctx context.Context, url string, headers map[string]string) (client.MCPClient, error)

RemoteCreator defines a function type for creating remote (SSE or HTTP) MCPClient.

type ServerConfig

type ServerConfig struct {
	Command string            `json:"command,omitempty"`
	Args    []string          `json:"args,omitempty"`
	Env     []string          `json:"env,omitempty"`
	URL     string            `json:"url,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
}

ServerConfig defines how to run an MCP server.

type StdioCreator

type StdioCreator func(command string, env []string, args ...string) (client.MCPClient, error)

StdioCreator defines a function type for creating stdio MCPClient.

Jump to

Keyboard shortcuts

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