mcp

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version is set by ldflags during release builds.

Functions

func RegisterPrompts

func RegisterPrompts(s *Server)

RegisterPrompts registers all MCP prompt templates with the server.

func RegisterResources

func RegisterResources(s *Server, deps ToolDeps)

RegisterResources registers all MCP resources with the server.

func RegisterTools

func RegisterTools(s *Server, deps ToolDeps, indexFn IndexFunc)

RegisterTools registers all 20 tools for CLI mode and profile-gated tools for MCP SDK mode. CLI tools: all 20 available via GetHandler/GetTools (always). SDK tools (MCP protocol): gated by deps.Profile — "minimal" (4), "core" (8), "extended" (15), or "full" (20).

Types

type ActivatedTool

type ActivatedTool struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

ActivatedTool describes a newly activated tool.

type ArchitectureSummaryParams

type ArchitectureSummaryParams struct {
	Limit   int  `json:"limit,omitempty" jsonschema:"description=Maximum number of structurally important nodes to return (default: 5)"`
	Compact bool `` /* 157-byte string literal not displayed */
}

ArchitectureSummaryParams are the parameters for the get_architecture_summary tool

type AssembleContextItem

type AssembleContextItem struct {
	Rank     int     `json:"rank"`
	Name     string  `json:"name"`
	FilePath string  `json:"file_path"`
	ID       string  `json:"id"`
	Score    float64 `json:"score"`
	Content  string  `json:"content"`
	Tokens   int     `json:"tokens"`
	Reason   string  `json:"reason,omitempty"`
	Group    string  `json:"group,omitempty"`
}

AssembleContextItem represents a single item in the assembled context

type AssembleContextParams

type AssembleContextParams struct {
	Query            string   `json:"query" jsonschema:"required,description=Search query to find relevant code"`
	Task             string   `json:"task,omitempty" jsonschema:"description=Deprecated alias for query. Prefer query."`
	BudgetTokens     int      `json:"budget_tokens,omitempty" jsonschema:"description=Maximum token budget for assembled context (default: 4000)"`
	Mode             string   `` /* 130-byte string literal not displayed */
	ActiveFiles      []string `json:"active_files,omitempty" jsonschema:"description=File paths currently being edited for PPR personalization"`
	MaxPerFile       int      `json:"max_per_file,omitempty" jsonschema:"description=Maximum results per file (default: 2)"`
	IncludeNeighbors bool     `json:"include_neighbors,omitempty" jsonschema:"description=Include callers/callees of top results (default: false)"`
	Compact          bool     `` /* 157-byte string literal not displayed */
	Goal             string   `` /* 190-byte string literal not displayed */
	Targets          []string `json:"targets,omitempty" jsonschema:"description=Optional symbol or route references used with goal-aware assembly"`
}

AssembleContextParams are the parameters for the assemble_context tool

type AssembleContextResponse

type AssembleContextResponse struct {
	Query            string                  `json:"query"`
	Mode             string                  `json:"mode"`
	BudgetTokens     int                     `json:"budget_tokens"`
	UsedTokens       int                     `json:"used_tokens"`
	Items            []AssembleContextItem   `json:"items"`
	Excluded         int                     `json:"excluded"`
	Summary          string                  `json:"summary"`
	Strategy         string                  `json:"strategy,omitempty"`
	Phases           map[string][]string     `json:"phases,omitempty"`
	RecommendedSteps []types.RecommendedStep `json:"recommended_steps,omitempty"`
}

AssembleContextResponse is the structured response from assemble_context

type Checkpoint

type Checkpoint struct {
	Name       string    `json:"name"`
	Timestamp  time.Time `json:"timestamp"`
	HeadCommit string    `json:"head_commit"`
	NodeCount  int       `json:"node_count"`
	FileCount  int       `json:"file_count"`
	// contains filtered or unexported fields
}

Checkpoint captures index state at a point in time.

type CheckpointContextParams

type CheckpointContextParams struct {
	Name string `json:"name,omitempty" jsonschema:"description=Checkpoint name (auto-generated if empty)"`
}

CheckpointContextParams are the parameters for the checkpoint_context tool

type CheckpointStore

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

CheckpointStore holds in-memory session checkpoints.

func NewCheckpointStore

func NewCheckpointStore() *CheckpointStore

NewCheckpointStore creates a new in-memory checkpoint store.

func (*CheckpointStore) ComputeDelta

func (cs *CheckpointStore) ComputeDelta(checkpointName, repoRoot string, store *storage.Store, pathFilter string, limit int) (*DeltaResult, error)

ComputeDelta compares the current index state against a named checkpoint.

func (*CheckpointStore) CreateCheckpoint

func (cs *CheckpointStore) CreateCheckpoint(name, repoRoot string, store *storage.Store) (*Checkpoint, error)

CreateCheckpoint snapshots the current index state under the given name. If name is empty, an auto-generated name is used.

func (*CheckpointStore) GetCheckpoint

func (cs *CheckpointStore) GetCheckpoint(name string) (*Checkpoint, bool)

GetCheckpoint retrieves a checkpoint by name.

type CompareRoutesParams

type CompareRoutesParams struct {
	Left    string `json:"left" jsonschema:"required,description=Left route ID or symbol"`
	Right   string `json:"right" jsonschema:"required,description=Right route ID or symbol"`
	Depth   int    `json:"depth,omitempty" jsonschema:"description=Maximum downstream traversal depth from each handler (default: 2, max: 4)"`
	Compact bool   `json:"compact,omitempty" jsonschema:"description=Return compact output by dropping verbose summaries from list items"`
}

type CompareSymbolsParams

type CompareSymbolsParams struct {
	Left    string `json:"left" jsonschema:"required,description=Left symbol name or ID"`
	Right   string `json:"right" jsonschema:"required,description=Right symbol name or ID"`
	Depth   int    `json:"depth,omitempty" jsonschema:"description=Traversal depth for callers/callees comparison (default: 1, max: 3)"`
	Compact bool   `json:"compact,omitempty" jsonschema:"description=Return compact output by dropping verbose summaries from list items"`
}

type ContextParams

type ContextParams struct {
	Query       string   `json:"query" jsonschema:"description=Natural language or keyword query to search for relevant code"`
	Limit       int      `json:"limit,omitempty" jsonschema:"description=Maximum number of results to return (default: 5)"`
	Mode        string   `` /* 138-byte string literal not displayed */
	MaxPerFile  int      `json:"max_per_file,omitempty" jsonschema:"description=Maximum results per unique file path (default: 1)"`
	ActiveFiles []string `json:"active_files,omitempty" jsonschema:"description=File paths the developer is currently editing for PPR personalization"`
	Compact     bool     `` /* 157-byte string literal not displayed */
}

ContextParams are the parameters for the context tool. Tags provide JSON schema metadata for the MCP SDK.

type DeltaItem

type DeltaItem struct {
	NodeID     string `json:"node_id"`
	SymbolName string `json:"symbol_name"`
	FilePath   string `json:"file_path"`
	NodeType   string `json:"node_type"`
	ChangeType string `json:"change_type"` // "added", "modified", "deleted"
}

DeltaItem represents a single changed node in the delta.

type DeltaResult

type DeltaResult struct {
	CheckpointName string      `json:"checkpoint_name"`
	CheckpointTime string      `json:"checkpoint_time"`
	Summary        string      `json:"summary"`
	Added          []DeltaItem `json:"added"`
	Modified       []DeltaItem `json:"modified"`
	Deleted        []DeltaItem `json:"deleted"`
	TotalChanges   int         `json:"total_changes"`
}

DeltaResult holds the diff between a checkpoint and the current index state.

type DetectChangesParams

type DetectChangesParams struct {
	Since   string `json:"since" jsonschema:"required,description=Git ref to compare against (e.g. HEAD~5 or main or a commit hash)"`
	Path    string `json:"path,omitempty" jsonschema:"description=Optional path filter for changed files"`
	Limit   int    `json:"limit,omitempty" jsonschema:"description=Maximum number of ranked changes to return (default: 5)"`
	Compact bool   `` /* 157-byte string literal not displayed */
}

DetectChangesParams are the parameters for the detect_changes tool

type DiscoverToolsParams

type DiscoverToolsParams struct {
	Need     string   `json:"need,omitempty" jsonschema:"description=Describe your task and the most relevant tool bundle will be activated."`
	Activate []string `json:"activate,omitempty" jsonschema:"description=Specific tool names to activate directly (bypasses bundle matching, max 5)"`
}

DiscoverToolsParams are the parameters for the discover_tools tool.

type DiscoverToolsResponse

type DiscoverToolsResponse struct {
	Bundle           string          `json:"bundle"`
	Reason           string          `json:"reason"`
	Activated        []ActivatedTool `json:"activated"`
	ActivatedCount   int             `json:"activated_count"`
	ActivationCapped bool            `json:"activation_capped"`
	AlreadyActive    []string        `json:"already_active,omitempty"`
	Pending          []string        `json:"pending"`
}

DiscoverToolsResponse is the response from discover_tools.

type ExecuteToolParams

type ExecuteToolParams struct {
	Name string         `json:"name" jsonschema:"required,description=Name of the tool to execute"`
	Args map[string]any `json:"args" jsonschema:"required,description=Tool arguments as a JSON object"`
}

ExecuteToolParams are the parameters for the execute_tool fallback proxy.

type ExploreParams

type ExploreParams struct {
	Symbol      string `json:"symbol" jsonschema:"required,description=Symbol name to search for"`
	IncludeDeps bool   `json:"include_deps,omitempty" jsonschema:"description=Whether to include dependency/dependent analysis (default: false)"`
	Depth       int    `json:"depth,omitempty" jsonschema:"description=Depth for dependency traversal (default: 2)"`
	Compact     bool   `` /* 157-byte string literal not displayed */
}

ExploreParams are the parameters for the explore tool

type FindRoutesParams

type FindRoutesParams struct {
	Query           string `json:"query" jsonschema:"required,description=Route path, handler, or concept query"`
	Method          string `json:"method,omitempty" jsonschema:"description=Optional HTTP method filter"`
	Limit           int    `json:"limit,omitempty" jsonschema:"description=Maximum number of routes to return (default: 10)"`
	IncludeHandlers *bool  `json:"include_handlers,omitempty" jsonschema:"description=Include resolved route handlers when available (default: true)"`
	Compact         bool   `json:"compact,omitempty" jsonschema:"description=Return compact output by dropping verbose summaries from list items"`
}

type GetKeySymbolsParams

type GetKeySymbolsParams struct {
	Limit      int    `json:"limit,omitempty" jsonschema:"description=Maximum number of symbols to return (default: 20)"`
	FileFilter string `json:"file_filter,omitempty" jsonschema:"description=Optional file path prefix to scope results to a specific directory"`
}

GetKeySymbolsParams are the parameters for the get_key_symbols tool

type HealthParams

type HealthParams struct{}

HealthParams are the parameters for the health tool (empty — no inputs).

type ImpactParams

type ImpactParams struct {
	SymbolID string `json:"symbol_id" jsonschema:"required,description=The ID or name of the symbol to analyze"`
	Symbol   string `json:"symbol,omitempty"`
	Query    string `json:"query,omitempty"`
	Name     string `json:"name,omitempty"`
	Depth    int    `json:"depth,omitempty" jsonschema:"description=Maximum BFS traversal depth (default: 5)"`
	Compact  bool   `` /* 157-byte string literal not displayed */
}

ImpactParams are the parameters for the impact tool.

type IndexFunc

type IndexFunc func(path string) error

IndexFunc is the callback for triggering a re-index

type IndexParams

type IndexParams struct {
	Path string `json:"path,omitempty" jsonschema:"description=Optional: specific path to re-index"`
}

IndexParams are the parameters for the index tool.

type ListFileSymbolsParams

type ListFileSymbolsParams struct {
	Path    string   `json:"path" jsonschema:"required,description=Repo-relative or absolute-under-repo file path to inspect"`
	Query   string   `` /* 134-byte string literal not displayed */
	Limit   int      `json:"limit,omitempty" jsonschema:"description=Maximum symbols to return (default: 25, hard cap: 100)"`
	Kinds   []string `` /* 132-byte string literal not displayed */
	Compact bool     `json:"compact,omitempty" jsonschema:"description=Return the minimal inventory shape only; omits extra display-only metadata"`
}

ListFileSymbolsParams are the parameters for the list_file_symbols tool.

type OutputStore

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

OutputStore holds large tool responses for paginated retrieval.

func NewOutputStore

func NewOutputStore(maxSize int, ttl time.Duration) *OutputStore

NewOutputStore creates a new output store with the given max entries and TTL.

func (*OutputStore) Retrieve

func (s *OutputStore) Retrieve(handle string, offset, limit int) ([]byte, int, error)

Retrieve returns a slice of the stored data.

func (*OutputStore) Store

func (s *OutputStore) Store(toolName string, data []byte) (string, error)

Store saves data and returns a handle for later retrieval.

type PendingSDKTool

type PendingSDKTool struct {
	Tool    mcp.Tool
	Handler server.ToolHandlerFunc
}

PendingSDKTool holds a pre-built SDK tool ready for dynamic activation.

type QueryParams

type QueryParams struct {
	SQL string `json:"sql" jsonschema:"required,description=SQL SELECT query to execute"`
}

QueryParams are the parameters for the query tool.

type ReadDeltaParams

type ReadDeltaParams struct {
	Since string `json:"since" jsonschema:"description=Checkpoint name to compare against,required"`
	Path  string `json:"path,omitempty" jsonschema:"description=Filter by file path prefix"`
	Limit int    `json:"limit,omitempty" jsonschema:"description=Maximum items per change type (default: 20)"`
}

ReadDeltaParams are the parameters for the read_delta tool

type ReadSymbolParams

type ReadSymbolParams struct {
	SymbolID  string `json:"symbol_id" jsonschema:"required,description=The ID or name of the symbol to read"`
	Mode      string `json:"mode,omitempty" jsonschema:"description=Read mode: bounded (default), signature, section, flow_summary, or full"`
	MaxChars  int    `` /* 138-byte string literal not displayed */
	MaxLines  int    `` /* 129-byte string literal not displayed */
	StartLine int    `json:"start_line,omitempty" jsonschema:"description=Optional 1-based file-relative start line for section reads"`
	EndLine   int    `json:"end_line,omitempty" jsonschema:"description=Optional 1-based file-relative end line for section reads"`
	Section   string `json:"section,omitempty" jsonschema:"description=Section selector for section reads: top, middle, bottom, auto"`
}

ReadSymbolParams are the parameters for the read_symbol tool.

type RetrieveOutputParams

type RetrieveOutputParams struct {
	Handle string `json:"handle" jsonschema:"required,description=Handle from a sandboxed response"`
	Offset int    `json:"offset,omitempty" jsonschema:"description=Byte offset to start reading from (default: 0)"`
	Limit  int    `json:"limit,omitempty" jsonschema:"description=Maximum bytes to return (default: 4000, max: 16000)"`
}

RetrieveOutputParams are the parameters for the retrieve_output tool.

type SearchCodeParams

type SearchCodeParams struct {
	Pattern    string `json:"pattern" jsonschema:"required,description=Regex pattern to search for in file contents"`
	Query      string `json:"query,omitempty"`
	FileFilter string `json:"file_filter,omitempty" jsonschema:"description=Optional glob pattern to filter files"`
	Limit      int    `json:"limit,omitempty" jsonschema:"description=Maximum number of matching lines to return (default: 20)"`
}

SearchCodeParams are the parameters for the search_code tool

type Server

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

Server wraps the mark3labs/mcp-go SDK server while preserving the GetHandler / GetTools interface used by CLI mode.

func NewServer

func NewServer() *Server

NewServer creates a new MCP server backed by the SDK, using stdin/stdout.

func NewServerWithIO

func NewServerWithIO(input io.Reader, output io.Writer) *Server

NewServerWithIO creates a new MCP server with custom I/O (for testing).

func (*Server) ActivateTool

func (s *Server) ActivateTool(name string) bool

ActivateTool moves a tool from pending to active via mcpServer.AddTool(). Returns true if the tool was activated, false if not found or already active.

func (*Server) AddPrompt

func (s *Server) AddPrompt(prompt mcp.Prompt, handler server.PromptHandlerFunc)

AddPrompt registers a prompt with the underlying MCP SDK server.

func (*Server) AddResource

func (s *Server) AddResource(resource mcp.Resource, handler server.ResourceHandlerFunc)

AddResource registers a resource with the underlying MCP SDK server.

func (*Server) AddSDKTool

func (s *Server) AddSDKTool(tool mcp.Tool, handler server.ToolHandlerFunc)

AddSDKTool registers a tool with the underlying MCP SDK server.

func (*Server) GetHandler

func (s *Server) GetHandler(name string) (ToolHandler, bool)

GetHandler returns the handler for a named tool, or false if not found.

func (*Server) GetTools

func (s *Server) GetTools() []ToolDefinition

GetTools returns a copy of all registered tool definitions.

func (*Server) IsActivated

func (s *Server) IsActivated(name string) bool

IsActivated returns true if a tool has been activated (or was initially registered).

func (*Server) ListPending

func (s *Server) ListPending() []string

ListPending returns names of tools that haven't been activated yet.

func (*Server) MCPServer

func (s *Server) MCPServer() *server.MCPServer

MCPServer returns the underlying mark3labs MCPServer for custom transport usage (e.g., streamable HTTP).

func (*Server) RegisterTool

func (s *Server) RegisterTool(def ToolDefinition, handler ToolHandler)

RegisterTool registers a tool definition and a json.RawMessage-based handler for CLI mode only. Call AddSDKTool separately to register the typed handler with the MCP SDK for protocol mode.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context) error

Serve starts the MCP server using the SDK's protocol handler. It blocks until the context is cancelled, the transport is closed (stdin EOF), or an error occurs. Passing a cancellable context allows the caller's signal handler to trigger a clean shutdown without relying on the library's internal signal handling.

func (*Server) StorePendingTool

func (s *Server) StorePendingTool(name string, tool mcp.Tool, handler server.ToolHandlerFunc)

StorePendingTool saves an SDK tool for later activation.

type ToolDefinition

type ToolDefinition struct {
	Name        string      `json:"name"`
	Description string      `json:"description"`
	InputSchema interface{} `json:"inputSchema"`
}

ToolDefinition describes an MCP tool for the tools/list response. Retained for CLI compatibility and tool introspection.

type ToolDeps

type ToolDeps struct {
	Store       *storage.Store
	Graph       *graph.GraphEngine
	Search      *search.HybridSearch
	RepoRoot    string
	Profile     string
	Checkpoints *CheckpointStore // nil-safe, tools skip if nil
	OutputStore *OutputStore     // nil-safe, initialized in RegisterTools if nil
}

ToolDeps holds dependencies needed by MCP tools

type ToolHandler

type ToolHandler func(params json.RawMessage) (interface{}, error)

ToolHandler is the function signature for tool implementations. Retained for CLI compatibility (GetHandler / runCLI).

type TraceCallPathParams

type TraceCallPathParams struct {
	From       string `json:"from" jsonschema:"required,description=Source symbol name or ID"`
	To         string `json:"to" jsonschema:"required,description=Target symbol name or ID"`
	FromSymbol string `json:"from_symbol,omitempty"`
	ToSymbol   string `json:"to_symbol,omitempty"`
	Direction  string `json:"direction,omitempty"`
	Depth      int    `json:"depth,omitempty"`
	MaxDepth   int    `json:"max_depth,omitempty" jsonschema:"description=Maximum path depth to search (default: 10)"`
}

TraceCallPathParams are the parameters for the trace_call_path tool

type TraceRouteParams

type TraceRouteParams struct {
	Route   string `json:"route" jsonschema:"required,description=Route ID, symbol, or path fragment to trace"`
	Depth   int    `json:"depth,omitempty" jsonschema:"description=Maximum downstream traversal depth from the handler (default: 2, max: 4)"`
	Compact bool   `json:"compact,omitempty" jsonschema:"description=Return compact output by dropping verbose summaries from list items"`
}

type UnderstandParams

type UnderstandParams struct {
	Symbol   string `json:"symbol,omitempty" jsonschema:"description=Canonical parameter: symbol name or ID to understand"`
	SymbolID string `json:"symbol_id,omitempty"`
	Query    string `json:"query,omitempty"`
	Name     string `json:"name,omitempty"`
	Compact  bool   `` /* 157-byte string literal not displayed */
}

UnderstandParams are the parameters for the understand tool

Jump to

Keyboard shortcuts

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