Help us shape the future of Go! Take the 2026 Go Developer Survey

mcp

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package mcp serves graphmaster's query tools over the Model Context Protocol (stdio in production, any transport in tests).

Every tool of internal/query is registered with a typed input (mcp.AddTool[In, any]) so the client sees a JSON schema with field descriptions. A call routes absolute path arguments to the repository that contains them, opens (once) and freshens that repository's index through query.Engine, and returns the tool's plain text as a single TextContent block. Failures become tool errors ("isError") with a banner-style text; the server never crashes on a tool call.

Index

Constants

View Source
const ServerName = "graphmaster"

ServerName is the MCP implementation name agents register.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Dir is the start directory; its repository answers calls that do not
	// name a path elsewhere. Default: the process working directory.
	Dir string
	// NewResolver creates the name resolver for each opened index.
	// Default: internal/resolve.
	NewResolver func() index.Resolver
	// FreshenBudget bounds the wait for the write lock before a tool
	// answers from the current graph (default query.DefaultFreshenBudget).
	FreshenBudget time.Duration
	// Logf receives indexer diagnostics; default discards. It must not
	// write to stdout, which carries the protocol.
	Logf func(format string, args ...any)
}

Options configure a Server.

type Server

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

Server is graphmaster's MCP server. It keeps one index per repository it has answered for; Close releases them.

func New

func New(opts Options) (*Server, error)

New builds a server with every query tool registered. It does not open any index yet: the first tool call does, so a server started outside a repository still lists its tools and explains the problem per call.

func (*Server) Close

func (s *Server) Close() error

Close closes every open index. Calls after Close fail.

func (*Server) MCP

func (s *Server) MCP() *gomcp.Server

MCP returns the underlying SDK server (tests connect it in-process).

func (*Server) Run

func (s *Server) Run(ctx context.Context, t gomcp.Transport) error

Run serves one session over t until the client disconnects or ctx ends.

Jump to

Keyboard shortcuts

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