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 Workspace 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 Typed decode/encode helpers for analysis MCP handlers (find_dead_code, find_suspect_fallback_edges, find_large_functions).
@index MCP context handlers that summarize graph state for downstream tool selection.
@index MCP handlers for documentation RAG index build and retrieval over generated docs.
@index MCP handlers for graph summaries: stored flows, communities, and architecture overviews.
@index MCP handlers for source parsing, full/incremental graph builds, and postprocess orchestration.
@index MCP handlers for inspecting and resetting automatic postprocess policy state.
@index MCP handlers for node lookup, search, predefined graph queries, and graph statistics.
@index MCP handlers for namespace workspace uploads, listing, and deletion.
@index Shared handler helpers and response utilities for MCP tools.
@index HTTP safety helpers for MCP server endpoints.
@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 documentation and RAG index operations.
@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 automatic postprocess policy control.
@index MCP tool registration for node lookup and graph query primitives.
@index Top-level MCP tool registration orchestration.
@index MCP tool registration for namespace workspace file management.
Index ¶
- func LimitHTTPBody(next http.Handler) http.Handler
- func NewServer(deps *Deps) *server.MCPServer
- type BoundedFlowTracer
- type BoundedImpactAnalyzer
- type Cache
- type CommunityBuilder
- type CouplingAnalyzer
- type CoverageAnalyzer
- type DeadcodeAnalyzer
- type Deps
- type FallbackAnalyzer
- type FlowBuilder
- type FlowTracer
- type ImpactAnalyzer
- type IncrementalSyncer
- type LargefuncAnalyzer
- type Parser
- type PostprocessPolicy
- type QueryService
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 BoundedFlowTracer ¶
type BoundedFlowTracer interface {
TraceFlowBounded(ctx context.Context, startNodeID uint, opts flowspkg.TraceOptions) (*flowspkg.TraceResult, error)
}
BoundedFlowTracer extends FlowTracer with a node cap to prevent runaway traversal on deeply nested call chains. @intent let MCP handlers trace deep call chains without letting one request expand into an unbounded traversal.
type BoundedImpactAnalyzer ¶
type BoundedImpactAnalyzer interface {
ImpactRadiusBounded(ctx context.Context, nodeID uint, depth int, opts impactpkg.RadiusOptions) (*impactpkg.RadiusResult, error)
}
BoundedImpactAnalyzer extends ImpactAnalyzer with node and depth caps to prevent runaway traversal on large graphs. @intent expose bounded blast-radius analysis for handlers that must protect shared MCP requests from unbounded graph walks.
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 CommunityBuilder ¶
type CommunityBuilder interface {
Rebuild(ctx context.Context, cfg community.Config) ([]community.Stats, error)
}
CommunityBuilder defines the community rebuild contract. @intent Injects an implementation to recalculate module communities during graph post-processing. @see mcp.handlers.runPostprocess
type CouplingAnalyzer ¶
type CouplingAnalyzer interface {
Analyze(ctx context.Context) ([]coupling.CouplingPair, error)
AnalyzePage(ctx context.Context, req paging.Request) (coupling.Result, error)
}
CouplingAnalyzer defines the inter-community coupling analysis contract. @intent Connects an analyzer to the server that calculates coupling between architectural boundaries. @see mcp.handlers.getArchitectureOverview
type CoverageAnalyzer ¶
type CoverageAnalyzer interface {
ByFile(ctx context.Context, filePath string) (*coverage.FileCoverage, error)
ByCommunity(ctx context.Context, communityID uint) (*coverage.CommunityCoverage, error)
}
CoverageAnalyzer defines file and community coverage lookup operations. @intent Provides test coverage information for risk summaries and community detail responses. @see mcp.handlers.getCommunity @see mcp.promptHandlers.reviewChanges
type DeadcodeAnalyzer ¶
type DeadcodeAnalyzer interface {
Find(ctx context.Context, opts deadcode.Options) ([]model.Node, error)
FindPage(ctx context.Context, opts deadcode.Options) (deadcode.Result, error)
}
DeadcodeAnalyzer defines the unused-code detection contract. @intent Injects an analyzer to find unreferenced nodes as candidates for cleanup. @see mcp.handlers.findDeadCode
type Deps ¶
type Deps struct {
Store store.GraphStore
DB *gorm.DB
Parser Parser
Walkers map[string]Parser
SearchBackend storesearch.Backend
ImpactAnalyzer ImpactAnalyzer
FlowTracer FlowTracer
ChangesGitClient changes.GitClient
Logger *slog.Logger
// Added in Phase 11
QueryService QueryService
LargefuncAnalyzer LargefuncAnalyzer
DeadcodeAnalyzer DeadcodeAnalyzer
FallbackAnalyzer FallbackAnalyzer
CouplingAnalyzer CouplingAnalyzer
CoverageAnalyzer CoverageAnalyzer
CommunityBuilder CommunityBuilder
FlowBuilder FlowBuilder
Incremental IncrementalSyncer
PostprocessPolicy PostprocessPolicy
// Cache — nil disables caching
Cache *Cache
// RagIndexDir — Directory where doc-index.json is stored (default: ".ccg")
RagIndexDir string
// RagProjectDesc — Project description used in root node summary
RagProjectDesc string
NamespaceRoot string
WorkspaceRoot string
RepoRoot string
MaxFileBytes int64
MaxTotalParsedBytes int64
}
Deps collects the services and stores required by MCP handlers. @intent Assembles tool and prompt handlers by injecting all MCP server components at once.
type FallbackAnalyzer ¶
type FallbackAnalyzer interface {
FindSuspects(ctx context.Context, opts fallbackanalysis.Options) ([]fallbackanalysis.SuspectEdge, error)
FindSuspectsPage(ctx context.Context, opts fallbackanalysis.Options) (fallbackanalysis.Result, error)
}
FallbackAnalyzer defines the suspect fallback-edge analysis contract. @intent Detects untrustworthy fallback call edges based on annotation overlap. @see mcp.handlers.findSuspectFallbackEdges
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 ¶
FlowTracer defines the call-flow tracing contract for graph nodes. @intent Connects an analyzer to the server that reconstructs call flows starting from a given node. @see mcp.handlers.traceFlow
type ImpactAnalyzer ¶
type ImpactAnalyzer interface {
ImpactRadius(ctx context.Context, nodeID uint, depth int) ([]model.Node, error)
}
ImpactAnalyzer defines the blast-radius analysis contract for graph nodes. @intent Injects an analyzer that calculates the impact radius of node changes into the server handler. @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 LargefuncAnalyzer ¶
type LargefuncAnalyzer interface {
Find(ctx context.Context, threshold int) ([]model.Node, error)
FindPage(ctx context.Context, opts largefunc.Options) (largefunc.Result, error)
}
LargefuncAnalyzer defines the oversized-function detection contract. @intent Injects an analyzer to detect large functions with high maintenance costs. @see mcp.handlers.findLargeFunctions
type Parser ¶
type Parser interface {
Parse(filePath string, content []byte) ([]model.Node, []model.Edge, error)
ParseWithContext(ctx context.Context, filePath string, content []byte) ([]model.Node, []model.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 PostprocessPolicy ¶
type PostprocessPolicy interface {
Resolve(ctx context.Context, input postprocesspolicy.DecisionInput) (string, string, error)
RecordRun(ctx context.Context, record postprocesspolicy.RunRecord) error
Status(ctx context.Context, opts postprocesspolicy.StatusOptions) (*postprocesspolicy.StatusSummary, error)
Reset(ctx context.Context, tool string) error
}
PostprocessPolicy gates and records automatic postprocess runs so repeated failures can be detected and suppressed. @intent centralize automatic postprocess decisions so repeated failures can degrade execution before handlers retry expensive work.
type QueryService ¶
type QueryService interface {
CallersOf(ctx context.Context, nodeID uint) ([]model.Node, error)
CalleesOf(ctx context.Context, nodeID uint) ([]model.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) ([]model.Node, error)
CalleesOfWithOptions(ctx context.Context, nodeID uint, opts query.QueryOptions) ([]model.Node, error)
ImportsOf(ctx context.Context, nodeID uint) ([]model.Node, error)
ImportersOf(ctx context.Context, nodeID uint) ([]model.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) ([]model.Node, error)
ChildrenOfPage(ctx context.Context, nodeID uint, opts query.QueryOptions) (query.PagedNodes, error)
TestsFor(ctx context.Context, nodeID uint) ([]model.Node, error)
TestsForPage(ctx context.Context, nodeID uint, opts query.QueryOptions) (query.PagedNodes, error)
InheritorsOf(ctx context.Context, nodeID uint) ([]model.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
Source Files
¶
- cache.go
- deps.go
- evidence.go
- handler_analysis.go
- handler_analysis_io.go
- handler_context.go
- handler_docs.go
- handler_graph.go
- handler_parse.go
- handler_postprocess.go
- handler_query.go
- handler_workspace.go
- handlers.go
- http.go
- prompts.go
- prompts_register.go
- server.go
- tools_analysis.go
- tools_context.go
- tools_docs.go
- tools_graph.go
- tools_parse.go
- tools_postprocess.go
- tools_query.go
- tools_register.go
- tools_workspace.go