mcp

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mcp speaks the Model Context Protocol, letting Antares borrow tools from external servers over stdio or streamable HTTP.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallResult

type CallResult struct {
	Text    string
	IsError bool
}

CallResult is the outcome of calling an MCP tool.

type Client

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

Client is a connection to one MCP server.

func Connect

func Connect(ctx context.Context, name string, cfg ServerConfig) (*Client, error)

Connect starts a server and performs the initialise handshake.

func (*Client) Call

func (c *Client) Call(ctx context.Context, tool string, args map[string]any) (*CallResult, error)

Call invokes one tool and flattens its content into text.

func (*Client) Close

func (c *Client) Close() error

Close shuts down the connection.

func (*Client) ListResources

func (c *Client) ListResources(ctx context.Context) ([]ResourceDef, error)

ListResources returns the resources a server offers. A server that does not implement resources answers with an error, which is reported as none.

func (*Client) Name

func (c *Client) Name() string

Name returns the configured server name.

func (*Client) ReadResource

func (c *Client) ReadResource(ctx context.Context, uri string) (string, error)

ReadResource fetches one resource's contents by URI and flattens them to text.

func (*Client) ToolState added in v0.4.0

func (c *Client) ToolState() (bool, string)

ToolState returns whether tool discovery reached the backing application and the last discovery error. A proxy can initialize successfully while its backing application (for example IDA Pro) is still offline.

func (*Client) Tools

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

Tools returns the cached tool list.

type Manager

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

Manager owns the configured MCP servers and exposes their tools to the agent.

func NewManager

func NewManager() *Manager

NewManager returns an empty manager.

func (*Manager) Close

func (m *Manager) Close()

Close shuts every server down and removes its tools from the registry.

func (*Manager) Connect

func (m *Manager) Connect(ctx context.Context, cfg *config.Config)

Connect brings up every enabled server, recording rather than propagating individual failures so one bad server cannot block startup.

func (*Manager) ListResources

func (m *Manager) ListResources(ctx context.Context) []ResourceView

ListResources aggregates resources from every connected server, prefixing each with its server so the same-named resource on two servers stays distinct.

func (*Manager) ReadResource

func (m *Manager) ReadResource(ctx context.Context, uri string) (string, error)

ReadResource reads a resource by URI from whichever server exposes it.

func (*Manager) Refresh added in v0.4.0

func (m *Manager) Refresh(ctx context.Context, cfg *config.Config) []ServerStatus

Refresh reconnects every configured server, atomically replaces the MCP tools visible to agents, and then closes the old transports.

func (*Manager) Register

func (m *Manager) Register(reg *tools.Registry) []string

Register publishes every connected server's tools into the registry and keeps the registry binding for later refreshes.

func (*Manager) Status

func (m *Manager) Status(cfg *config.Config) []ServerStatus

Status lists every configured server and its tools.

type ResourceDef

type ResourceDef struct {
	URI         string `json:"uri"`
	Name        string `json:"name"`
	Description string `json:"description"`
	MimeType    string `json:"mimeType"`
}

ResourceDef describes an MCP resource a server exposes.

type ResourceView

type ResourceView struct {
	Server      string
	URI         string
	Name        string
	Description string
	MimeType    string
}

ResourceView is one resource with the server that hosts it.

type ServerConfig

type ServerConfig struct {
	Transport string
	Command   string
	Args      []string
	Env       map[string]string
	URL       string
	Headers   map[string]string
}

ServerConfig describes how to reach one MCP server.

type ServerStatus

type ServerStatus struct {
	Name      string    `json:"name"`
	Started   bool      `json:"started"`
	Connected bool      `json:"connected"`
	Error     string    `json:"error,omitempty"`
	Tools     []ToolDef `json:"tools"`
}

ServerStatus reports one server for the dashboard.

type ToolDef

type ToolDef struct {
	Name        string         `json:"name"`
	Description string         `json:"description"`
	InputSchema map[string]any `json:"inputSchema"`
}

ToolDef is a tool advertised by an MCP server.

Jump to

Keyboard shortcuts

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