mcp

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package mcp adapts Model Context Protocol servers into agentcore tools. It owns the MCP client SDK and its types and exposes only []ac.Tool plus a closer; no SDK type crosses this boundary.

Trust is the caller's allowlist: Tools only connects to the servers it is handed. Every adapted tool is non-safe (it does not implement gate.SafeTool), so a jess gate confirm-gates and ledgers each call unless the host opted into AllowAll.

Index

Constants

This section is empty.

Variables

View Source
var ErrServerGone = errors.New("mcp: server connection closed")

ErrServerGone is the sentinel a callTool error wraps when the underlying MCP server's connection has closed (the subprocess exited or the transport dropped). It is jess's own error value; no MCP SDK type crosses this boundary. Check it with errors.Is.

Functions

func Tools

func Tools(ctx context.Context, servers []Server, logf func(string, ...any)) ([]ac.Tool, io.Closer, error)

Tools dials every allowlisted server, lists its tools and adapts each into an ac.Tool the agent understands. A server that fails to dial or list is logged via logf and SKIPPED, unless every server requested fails: then Tools returns an error naming each server and its failure, with no tools and a closer that is already safe to close. Partial failure (at least one server dials and lists successfully) still returns a nil error with the working servers' tools.

ctx bounds only the dial, initialize and tools/list handshake for each server; the server subprocess and its session outlive ctx and keep running after Tools returns. The returned io.Closer is the only teardown: it shuts down every started client, and callers must call it when done with the tools.

Types

type Server

type Server struct {
	Name    string
	Command string
	Args    []string
	Env     []string
	// Bare exposes the server's tool names as-is (sanitized) instead of
	// prefixed with "<Name>__"; use it when the host runs a single server and
	// wants the model to see the tools' own names. Bare names are NOT
	// deduplicated against the host's own tools: Tools cannot see them, so a
	// bare "read" or "bash" can silently shadow a host tool of the same name.
	// Avoiding that collision is the host's responsibility.
	Bare bool
}

Server describes one stdio MCP server to launch. Command and Args are the launch line. The subprocess inherits the daemon's own environment plus Env ("K=V" pairs appended after it).

Jump to

Keyboard shortcuts

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