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 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 ¶
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 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 Deps ¶
type Deps struct {
Store store.GraphStore
DB *gorm.DB
Walkers map[string]Parser
SearchBackend storesearch.Backend
ImpactAnalyzer ImpactAnalyzer
FlowTracer FlowTracer
ChangesGitClient changes.GitClient
Logger *slog.Logger
// Added in Phase 11
QueryService QueryService
FlowBuilder FlowBuilder
Incremental IncrementalSyncer
// Cache — nil disables caching
Cache *Cache
// RagIndexDir — Directory where Wiki index artifacts are stored (default: ".ccg")
RagIndexDir string
// RagProjectDesc — Project description used in root node summary
RagProjectDesc string
NamespaceRoot string
RepoRoot string
MaxFileBytes int64
MaxTotalParsedBytes int64
// RefreshSearchDocuments overrides the search-document refresh used after a build; nil uses
// service.RefreshSearchDocuments. Kept as an injectable field so tests need no package globals.
RefreshSearchDocuments func(ctx context.Context, db *gorm.DB) (int, error)
}
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 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 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) ([]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 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_context.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