Documentation
¶
Overview ¶
@index In-memory TTL cache for repeat MCP read-tool responses with background eviction.
@index Dependency contracts and injected services for MCP handlers.
@index Namespace and git provenance evidence builders for namespace-scoped MCP responses.
@index MCP handlers for impact, flow, change-risk, dead-code, and suspect-edge analyses over the stored graph.
@index MCP context handlers that summarize graph state for downstream tool selection.
@index MCP handler exposing materialized cross-namespace references as a repository dependency map.
@index MCP handlers for DB-backed documentation search and safe generated-document reads.
@index MCP handlers for graph summaries: stored flows, communities, and architecture overviews.
@index MCP handler that enumerates graph namespaces for cross-namespace discovery.
@index MCP handlers for source parsing, full/incremental graph builds, and postprocess orchestration.
@index MCP handlers for node lookup, search, predefined graph queries, and graph statistics.
@index Shared handler helpers and response utilities for MCP tools.
@index HTTP safety helpers for MCP server endpoints.
@index Namespace filesystem path resolution shared by namespace-scoped doc handlers.
@index MCP prompt handlers that compose graph queries into review, debug, onboarding, and pre-merge workflows.
@index Prompt registration for curated MCP workflows.
@index MCP server. Exposes code analysis capabilities to AI through multiple tools and 5 prompt templates.
@index MCP tool registration for analysis-oriented graph operations.
@index MCP tool registration for lightweight context discovery.
@index MCP tool registration for DB-backed documentation search and generated document reads.
@index MCP tool registration for graph summaries and architecture views.
@index MCP tool registration for parsing, graph build, and postprocess execution.
@index MCP tool registration for node lookup and graph query primitives.
@index Top-level MCP tool registration orchestration.
Index ¶
- func LimitHTTPBody(next http.Handler) http.Handler
- func NewServer(deps *Deps) *server.MCPServer
- type AnalysisToolsDeps
- type BuildToolsDeps
- type Cache
- type ChangeAnalyzer
- type CrossRefLister
- type Deps
- type DocsToolsDeps
- type FlowBuilder
- type FlowTracer
- type GraphToolsDeps
- type ImpactAnalyzer
- type IncrementalSyncer
- type Parser
- type QueryService
- type RuntimeToolsDeps
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LimitHTTPBody ¶
@intent cap request memory usage before MCP handlers allocate or parse large request bodies. @ensures requests larger than the configured limit are rejected with 413. @sideEffect wraps the request body with a MaxBytesReader.
func NewServer ¶
NewServer creates and configures the MCP server with all tools and prompts. @intent Configures a server instance that exposes code graph features as MCP tools and prompts. @requires deps != nil @ensures The returned server is registered with MCP tools and prompts. @sideEffect Logs server metadata to the logger. @see mcp.Deps
Types ¶
type AnalysisToolsDeps ¶
type AnalysisToolsDeps struct {
Impact ImpactAnalyzer
Flow FlowTracer
Changes ChangeAnalyzer
Reader analyze.GraphReadRepository
CrossImpact ImpactAnalyzer
CrossFlow FlowTracer
CrossRefs CrossRefLister
}
AnalysisToolsDeps owns bounded impact, flow, and git-change analysis dependencies. @intent group only configured application analyzers and their read-model port. @domainRule CrossImpact/CrossFlow/CrossRefs are optional; when nil the cross-namespace analysis surface reports itself unconfigured.
type BuildToolsDeps ¶
type BuildToolsDeps struct {
Store ingest.GraphStore
Walkers map[string]Parser
UnitOfWork ingest.UnitOfWork
Search ingest.SearchWriter
Maintenance document.Maintenance
FlowBuilder FlowBuilder
Incremental IncrementalSyncer
}
BuildToolsDeps owns graph mutation and postprocess dependencies. @intent group only the dependencies required by parse, build, update, and postprocess tools.
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a simple in-memory TTL cache safe for concurrent use. @intent Reuses MCP read-tool responses in memory for frequently repeated queries.
func NewCache ¶
NewCache creates a Cache with the given TTL and starts a background cleanup goroutine. Call Close() when the cache is no longer needed to stop the goroutine. @intent Creates a TTL-based memory cache and starts the expired entry cleanup loop. @param ttl The maximum duration each entry remains valid. @ensures The returned Cache has an empty entry map and an active cleanup goroutine. @sideEffect Starts a background cleanup goroutine.
func (*Cache) Close ¶
func (c *Cache) Close()
Close stops the background cleanup goroutine. @intent Safely stops the cleanup goroutine when the cache is no longer used. @sideEffect Closes stopCh to terminate the cleanup loop. @mutates c.stopCh
func (*Cache) Flush ¶
func (c *Cache) Flush()
Flush removes all entries from the cache. @intent Invalidates all cached read results after a graph or index update. @mutates c.entries
type ChangeAnalyzer ¶
type ChangeAnalyzer interface {
AnalyzePage(ctx context.Context, repoDir, baseRef string, limit, offset int) (changes.Result, error)
ChangedNodeIDs(ctx context.Context, repoDir, baseRef string) ([]uint, error)
}
ChangeAnalyzer is the application change-risk surface consumed by tools and prompts. @intent inject a configured application change service without exposing Git or persistence implementations.
type CrossRefLister ¶
type CrossRefLister interface {
ListOutboundCrossRefs(ctx context.Context, fromNamespace string) ([]graph.CrossRef, error)
ListInboundCrossRefs(ctx context.Context, toNamespace string) ([]graph.CrossRef, error)
}
CrossRefLister exposes materialized cross-namespace references for listing tools. @intent let handlers enumerate repository-level dependencies without a store implementation dependency.
type Deps ¶
type Deps struct {
Build BuildToolsDeps
Graph GraphToolsDeps
Analysis AnalysisToolsDeps
Docs DocsToolsDeps
Runtime RuntimeToolsDeps
}
Deps groups MCP dependencies by registered tool surface. @intent make each MCP capability's required application contracts explicit at composition time.
type DocsToolsDeps ¶
DocsToolsDeps owns DB-primary documentation retrieval. @intent group the configured application retrieval service used by documentation tools.
type FlowBuilder ¶
type FlowBuilder interface {
Rebuild(ctx context.Context, cfg flowspkg.Config) ([]flowspkg.Stats, error)
}
FlowBuilder defines the persisted flow rebuild contract. @intent Injects a builder into the MCP handler that regenerates stored flow post-processing results. @see mcp.handlers.runPostprocess
type FlowTracer ¶
type FlowTracer interface {
TraceFlowBounded(ctx context.Context, startNodeID uint, opts flowspkg.TraceOptions) (*flowspkg.TraceResult, error)
}
FlowTracer defines the bounded call-flow tracing contract for graph nodes. @intent inject a node-capped call-flow tracer so a deep call chain cannot expand into an unbounded traversal. @see mcp.handlers.traceFlow
type GraphToolsDeps ¶
type GraphToolsDeps struct {
Store analyze.GraphLookup
Query QueryService
Search retrieval.CandidateSearcher
Statistics analyze.StatisticsReader
Reader analyze.GraphReadRepository
}
GraphToolsDeps owns graph lookup, query, search, and aggregate dependencies. @intent group only the dependencies required by graph and search read tools.
type ImpactAnalyzer ¶
type ImpactAnalyzer interface {
ImpactRadiusBounded(ctx context.Context, nodeID uint, depth int, opts impactpkg.RadiusOptions) (*impactpkg.RadiusResult, error)
}
ImpactAnalyzer defines the bounded blast-radius analysis contract for graph nodes. @intent inject a node/depth-capped blast-radius analyzer so a single MCP request cannot expand into an unbounded graph walk. @see mcp.handlers.getImpactRadius
type IncrementalSyncer ¶
type IncrementalSyncer interface {
Sync(ctx context.Context, files map[string]incremental.FileInfo) (*incremental.SyncStats, error)
SyncWithExisting(ctx context.Context, files map[string]incremental.FileInfo, existingFiles []string) (*incremental.SyncStats, error)
}
IncrementalSyncer defines the incremental graph synchronization contract. @intent Injects a syncer that reflects only changed files into the graph without full re-parsing. @see mcp.handlers.buildOrUpdateGraph
type Parser ¶
type Parser interface {
Parse(filePath string, content []byte) ([]graph.Node, []graph.Edge, error)
ParseWithContext(ctx context.Context, filePath string, content []byte) ([]graph.Node, []graph.Edge, error)
}
Parser defines the source parser contract used by MCP graph builds. @intent Injects an abstract parser to combine language-specific parsing implementations on the server. @see mcp.Deps
type QueryService ¶
type QueryService interface {
CallersOf(ctx context.Context, nodeID uint) ([]graph.Node, error)
CalleesOf(ctx context.Context, nodeID uint) ([]graph.Node, error)
CallersOfPage(ctx context.Context, nodeID uint, opts query.QueryOptions) (query.PagedNodes, error)
CalleesOfPage(ctx context.Context, nodeID uint, opts query.QueryOptions) (query.PagedNodes, error)
CallersOfWithOptions(ctx context.Context, nodeID uint, opts query.QueryOptions) ([]graph.Node, error)
CalleesOfWithOptions(ctx context.Context, nodeID uint, opts query.QueryOptions) ([]graph.Node, error)
ImportsOf(ctx context.Context, nodeID uint) ([]graph.Node, error)
ImportersOf(ctx context.Context, nodeID uint) ([]graph.Node, error)
ImportsOfPage(ctx context.Context, nodeID uint, opts query.QueryOptions) (query.PagedNodes, error)
ImportersOfPage(ctx context.Context, nodeID uint, opts query.QueryOptions) (query.PagedNodes, error)
ChildrenOf(ctx context.Context, nodeID uint) ([]graph.Node, error)
ChildrenOfPage(ctx context.Context, nodeID uint, opts query.QueryOptions) (query.PagedNodes, error)
TestsFor(ctx context.Context, nodeID uint) ([]graph.Node, error)
TestsForPage(ctx context.Context, nodeID uint, opts query.QueryOptions) (query.PagedNodes, error)
InheritorsOf(ctx context.Context, nodeID uint) ([]graph.Node, error)
InheritorsOfPage(ctx context.Context, nodeID uint, opts query.QueryOptions) (query.PagedNodes, error)
FileSummaryOf(ctx context.Context, filePath string) (*query.FileSummary, error)
FindExactNameMatches(ctx context.Context, target string, limit int) ([]query.CandidateMatch, error)
}
QueryService defines predefined graph query operations exposed over MCP. @intent Simplifies handlers by abstracting standard graph queries into a single service interface. @see mcp.handlers.queryGraph
type RuntimeToolsDeps ¶
type RuntimeToolsDeps struct {
Logger *slog.Logger
Cache *Cache
RagIndexDir string
RagProjectDesc string
NamespaceRoot string
RepoRoot string
MaxFileBytes int64
MaxTotalParsedBytes int64
}
RuntimeToolsDeps owns cross-cutting cache, logging, paths, and request limits. @intent group transport runtime configuration separately from capability dependencies.
Source Files
¶
- cache.go
- deps.go
- evidence.go
- handler_analysis.go
- handler_context.go
- handler_crossref.go
- handler_docs.go
- handler_graph.go
- handler_namespace.go
- handler_parse.go
- handler_query.go
- handlers.go
- http.go
- namespace_paths.go
- prompts.go
- prompts_register.go
- server.go
- tools_analysis.go
- tools_context.go
- tools_docs.go
- tools_graph.go
- tools_parse.go
- tools_query.go
- tools_register.go