mcp

package
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Package mcp hosts the Seamless MCP tool surface over streamable HTTP with a single static bearer key. It adds what v1 lacked: a per-connection session binding, so an agent calls session_start once and later memory/recall/notes calls inherit the session's project scope without repeating it. Every stored identity is a ULID; names and slugs are only ergonomic handles.

Index

Constants

View Source
const (
	// ServerName is the server name advertised in the MCP initialize handshake.
	// Exported for docsgen, which mirrors the handshake identity into the
	// published server card's serverInfo (docs/.well-known/mcp/server-card.json).
	ServerName = "Seamless"

	// ToolCount is the number of MCP tools registered. doctor asserts the actual
	// registered count (Server.NumTools) equals it. P2 minimal loop = 15; P3 adds
	// tasks (4) + trials (3) = 22; P4 adds gardener (2) + capture_url +
	// usage_summary = 26; plans-as-composition adds tasks_claim + tasks_release = 28;
	// gardener_request = 29; gardener_split = 30; favorite_set = 31;
	// memory_edit + notes_edit = 33.
	ToolCount = 33
)

Variables

This section is empty.

Functions

func Catalog

func Catalog() []mcp.Tool

Catalog returns every registered tool's definition, in registration order.

It exists so documentation tooling (cmd/docsgen) can render the tool surface without constructing a Server: the constructors are plain data -- name, description, and input schema -- and need no DB, config, or listening port. The definitions here are the same values registerTools hands to addTool, so the docs describe exactly what the server serves.

The order below MUST mirror registerTools. catalog_test enforces both halves of that contract (length against ToolCount, names against a live server's registration order), so a tool added to one and not the other fails the build rather than silently vanishing from the docs.

Types

type Config

type Config struct {
	DB       *sql.DB
	Files    *files.Manager
	Retrieve *retrieve.Service
	Events   *events.Recorder
	Gardener *gardener.Service // may be nil (gardener_apply is then unavailable)
	Embedder llm.Embedder      // may be nil (memory_write dedup hint is then skipped)
	APIKey   string
	Version  string // build version advertised in the MCP handshake; defaults to serverVersion
	// ToolEventMaxChars caps each captured field (tool.call args value/result,
	// session findings) of a logged Interactions event at this many runes. 0 =
	// unlimited (the default): content is logged in full.
	ToolEventMaxChars int
	// CaptureAllowedPorts are the destination ports capture_url may dial
	// (config.Capture.AllowedPorts). Empty means the capture package's 80/443
	// default, never "any port".
	CaptureAllowedPorts []int
	// Features is the file/env optional-features config (config.Config.Features).
	// It is only the BASE: the stored override row layers over it per request in
	// effectiveFeatures, so a console toggle needs no restart. The zero value is
	// every optional feature off, which is also config.Defaults().
	Features config.Features
	Logger   *slog.Logger
}

Config wires the MCP server's dependencies.

type Server

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

Server hosts the MCP tools and their per-connection session bindings.

func New

func New(cfg Config) *Server

New constructs a Server and registers the tool surface.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the streamable-HTTP handler for /api/mcp. Authentication is enforced outside mcp-go so every protocol method -- initialize, discovery, SSE, termination, and tool calls -- is rejected before the dependency reads a body or creates a session. Authorized POST bodies are capped before mcp-go buffers them. The tool middleware remains as defense in depth for any future non-HTTP transport or direct in-process dispatch.

func (*Server) NumTools

func (s *Server) NumTools() int

NumTools returns the number of registered MCP tools. doctor asserts it equals ToolCount, catching a tool that was written but never wired into registerTools.

Jump to

Keyboard shortcuts

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