Codebase-Memory-MCP Tools and Input Schemas: Complete Reference for 15 Built-in Methods
The codebase-memory-mcp server exposes 15 built-in MCP tools that accept flat JSON payloads via JSON-RPC 2.0, ranging from repository indexing and graph traversal to ADR management and runtime trace ingestion.
The codebase-memory-mcp repository provides a static-binary MCP server that transforms source code into a queryable knowledge graph. Understanding the available MCP tools and their input schemas allows MCP-compatible clients like Claude Code or Cursor to reliably index projects, trace call paths, and manage architecture decisions through structured JSON-RPC requests.
Available MCP Tools and Their Input Schemas
The server registers all methods in src/main.c and validates incoming arguments against flat JSON schemas. Each tool accepts a single JSON object where missing optional fields are ignored, and unrecognized keys are discarded.
Indexing and Project Management
These tools handle repository ingestion and lifecycle operations.
-
index_repository: Indexes a repository into the knowledge graph (creates or updates a project).{ "repo_path": "<absolute-path-to-repo>" } -
list_projects: Returns every indexed project together with node and edge counts.{} -
delete_project: Removes a project and all its graph data from the store.{ "project": "<project-name>" } -
index_status: Queries the current indexing state (queued, running, finished, error).{ "project": "<project-name>" }
Graph Query and Traversal
These tools provide structured and ad-hoc access to the knowledge graph.
-
search_graph: Structured graph search with filtering by label, name pattern, file pattern, degree, and pagination.{ "project": "<project>", "label": "Function|Class|…", "name_pattern": ".*", "file_pattern": ".*", "min_degree": 0, "max_degree": 100, "limit": 100, "offset": 0 } -
trace_path(aliastrace_call_path): Breadth-first traversal of the call graph with configurable depth.{ "project": "<project>", "function_name": "<qualified-name>", "direction": "inbound|outbound|both", "max_depth": 5 } -
query_graph: Executes read-only Cypher-like queries against the knowledge graph.{ "project": "<project>", "query": "<Cypher-query-string>" } -
get_graph_schema: Returns node-label statistics, edge-type definitions, and property schemas.{}
Code Analysis and Retrieval
Use these tools to extract code segments and analyze change impact.
-
get_code_snippet: Retrieves source code for a symbol given its fully-qualified name.{ "project": "<project>", "qualified_name": "<symbol-path>" } -
get_architecture: Generates a high-level summary including languages, packages, entry points, HTTP routes, hot spots, and clusters.{ "project": "<project>" } -
search_code: Performs text search (grep-style) limited to files belonging to the indexed project.{ "project": "<project>", "query": "<regex-or-plain-text>", "file_pattern": ".*", "limit": 100, "offset": 0 } -
detect_changes: Maps agit diffonto affected symbols and classifies blast-radius risk.{ "project": "<project>", "diff": "<git-diff-text>", "include_untracked": true }
Architecture and Runtime Management
These tools manage Architecture Decision Records (ADRs) and runtime telemetry.
-
manage_adr: CRUD operations for ADRs stored in the graph.{ "project": "<project>", "action": "list|create|read|update|delete", "adr_id": "<id-optional>", "title": "<title-optional>", "content": "<markdown-optional>" } -
ingest_traces: Ingests runtime trace data to validate or enrichHTTP_CALLSedges.{ "project": "<project>", "traces": [ { "source": "<function>", "target": "<endpoint>", "method": "GET|POST|…", "status": 200, "latency_ms": 12 } ] }
Input Schema Validation Rules
All input schemas are defined as flat JSON objects. The server implementation in src/main.c validates the presence of required keys and returns a structured error if mandatory fields are missing. Optional parameters may be omitted entirely without affecting execution. This flat structure ensures compatibility with the MCP specification while simplifying payload construction for client agents.
CLI Usage Examples
The codebase-memory-mcp cli wrapper forwards JSON payloads to the server, simplifying JSON-RPC invocation.
Index a repository using an absolute path:
codebase-memory-mcp cli index_repository '{"repo_path":"/home/user/my-project"}'
List all indexed projects:
codebase-memory-mcp cli list_projects '{}'
Search for functions containing "Handler":
codebase-memory-mcp cli search_graph \
'{"project":"my-project","label":"Function","name_pattern":".*Handler.*"}'
Trace call chains in both directions with depth 3:
codebase-memory-mcp cli trace_path \
'{"project":"my-project","function_name":"my_pkg.my_mod.DoWork","direction":"both","max_depth":3}'
Execute a custom Cypher query:
codebase-memory-mcp cli query_graph \
'{"project":"my-project","query":"MATCH (f:Function) WHERE NOT EXISTS { (f)<-[:CALLS]-() } RETURN f.name"}'
Retrieve architecture overview:
codebase-memory-mcp cli get_architecture '{"project":"my-project"}'
Search source code for TODO markers:
codebase-memory-mcp cli search_code \
'{"project":"my-project","query":"TODO","file_pattern":"*.go"}'
Create a new Architecture Decision Record:
codebase-memory-mcp cli manage_adr \
'{"project":"my-project","action":"create","title":"Use CBM for indexing","content":"..."}'
Source Code References
The MCP tools are implemented and documented in the following locations:
src/main.c: Registers the 15 JSON-RPC methods and implements the dispatch logic that validates incoming payloads.README.md(lines 37–78): Contains the complete tool table and schema definitions referenced in this guide.docs/CONFIGURATION.md: Documents server configuration and environment variables affecting tool behavior.internal/cbm/*(e.g.,zstd_store.c): Core indexing pipeline that populates the graph data queried by these tools.tests/test_mcp.c: Unit tests verifying argument handling and schema validation for each tool.
Summary
codebase-memory-mcpexposes 15 MCP tools via JSON-RPC 2.0 for comprehensive codebase analysis.- All tools expect flat JSON input schemas with required fields strictly validated in
src/main.c. - Indexing tools (
index_repository,list_projects,delete_project,index_status) manage the knowledge graph lifecycle. - Traversal tools (
search_graph,trace_path,query_graph) provide both structured filtering and custom Cypher access. - Analysis tools (
detect_changes,get_architecture,search_code) support impact analysis and code retrieval. - Management tools (
manage_adr,ingest_traces) support architectural documentation and runtime correlation.
Frequently Asked Questions
How do I validate the JSON input before sending it to the MCP server?
The server validates all incoming payloads against expected keys in src/main.c. Ensure your JSON object includes all required fields listed in the schema tables above; optional fields may be omitted. If validation fails, the server returns a structured error indicating the missing parameter.
What is the difference between search_graph and query_graph?
search_graph provides a structured interface with specific filter parameters like label, name_pattern, and min_degree, making it ideal for targeted symbol discovery. query_graph accepts raw Cypher-like strings in the query field, offering full flexibility for complex graph traversals but requiring knowledge of the graph schema.
Can I use trace_path to analyze both incoming and outgoing call chains?
Yes. The direction parameter accepts three values: "inbound" for callers, "outbound" for callees, and "both" to traverse the complete call graph bidirectionally up to the specified max_depth.
Where are the MCP tool schemas documented in the repository?
The authoritative schema definitions reside in the MCP Tools section of README.md (lines 37–78). Implementation details, including argument parsing and validation logic, are found in src/main.c, while configuration options are detailed in docs/CONFIGURATION.md.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →