mcp

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package mcp exposes the knowing knowledge graph as MCP (Model Context Protocol) tools over stdio and HTTP transports.

The server registers 27 tools organized into seven planes:

Execution plane (write operations):

  • index_repo: trigger indexing of a repository
  • cross_repo_callers: find transitive callers across all repos
  • graph_query: search nodes by qualified name prefix
  • repo_graph: list all files in a repository

Intelligence plane (read-only analytics):

  • blast_radius: compute all transitive callers of a symbol, grouped by repo
  • trace_dataflow: follow all transitive callees from a symbol
  • stale_edges: find edges invalidated by file changes
  • snapshot_diff: raw structural diff between two snapshots
  • semantic_diff: enriched diff with summary statistics
  • pr_impact: blast radius analysis of all symbols changed between snapshots
  • ownership: list files and their symbols for code ownership analysis
  • ownership_query: query ownership by file path pattern

Runtime plane (runtime trace queries, requires SQLiteStore):

  • runtime_traffic: query runtime-observed edges by service and route
  • dead_routes: find route symbols with no recent observations
  • trace_stats: aggregate statistics about runtime-derived edges

Context plane (graph-aware context packing):

  • context_for_task: generate token-budgeted context for a task description
  • context_for_files: generate blast-radius context for changed files
  • context_for_pr: generate context for a pull request (changed files between refs)
  • explain_symbol: explain why a symbol ranked where it did for a task

Feedback plane (agent learning loop):

  • feedback: record/query symbol usefulness for ranking improvement

Discovery plane (exploration and planning):

  • test_scope: find affected tests for changed files
  • flow_between: find all paths between two symbols via BFS
  • plan_turn: suggest relevant knowing tools for a task description
  • communities: Louvain modularity-based graph clustering

Audit plane (integrity and proofs):

  • prove: generate a Merkle proof that a relationship exists
  • prove_absent: prove a relationship does NOT exist (absence proof)
  • fsck: verify graph integrity (hashes, references, snapshot chain)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Examples

func Examples(values ...string) mcp.PropertyOption

Examples returns a PropertyOption that sets JSON Schema "examples" on the property. This satisfies mcp-assert W103 which requires enum, pattern, example, or default.

func SetIndexFunc

func SetIndexFunc(fn func(ctx context.Context, repoURL, repoPath, commitHash string) error)

SetIndexFunc sets the package-level indexing function used by the index_repo handler.

Types

type Server

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

Server wraps an MCP server that exposes graph queries as tools. It holds a reference to the GraphStore for executing queries and delegates transport handling to the mcp-go library.

func NewServer

func NewServer(store types.GraphStore) *Server

NewServer creates a new MCP server backed by the given GraphStore. It registers all tools, prompts, and resources.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(ctx context.Context, addr string) error

ServeHTTP runs the MCP server over HTTP at the given address until ctx is cancelled.

func (*Server) ServeStdio

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

ServeStdio runs the MCP server over stdin/stdout until ctx is cancelled.

func (*Server) SetResultCache added in v0.3.0

func (s *Server) SetResultCache(c *cache.SubgraphCache)

SetResultCache attaches a SubgraphCache for memoizing blast_radius and test_scope results. When set, handlers check the cache before computing and store results after a miss. Pass nil to disable caching.

func (*Server) SetSnapshotManager added in v0.3.0

func (s *Server) SetSnapshotManager(sm *snapshot.SnapshotManager)

SetSnapshotManager attaches a SnapshotManager so MCP handlers can access the most recently computed HierarchicalTree for subgraph cache keying. Call this before Start if you want cache-aware blast_radius and test_scope.

func (*Server) ToolNames

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

ToolNames returns the names of all registered tools, useful for testing.

Jump to

Keyboard shortcuts

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