MCP Tool Definitions Dependencies in codebase-memory-mcp: A Zero-Runtime-Dependency Architecture
MCP tool definitions in codebase-memory-mcp compile into a single binary with zero external runtime dependencies, relying solely on internal C libraries and the operating system's C runtime.
The codebase-memory-mcp project implements a Model Context Protocol (MCP) server entirely in C, packaging all 14 tool definitions into a static binary. Unlike typical MCP implementations that rely on external interpreters or package managers, these MCP tool definitions are self-contained and require no additional runtime installations beyond the compiled executable.
Internal Dependency Architecture
The MCP tool definitions depend on a layered architecture of internal C libraries that are statically linked during compilation. Each layer provides specific functionality required by the tools.
Foundation Layer (src/foundation/)
The foundation layer provides cross-platform abstractions including logging, threading, memory management, platform detection, diagnostics, YAML parsing, and LZ4 compression. All 14 MCP tools rely on these primitives for basic operations. This layer resides in src/foundation/*.[c|h] and serves as the base dependency for every other module in the system.
Storage Layer (src/store/store.c)
Persistent graph storage is handled by the SQLite Store module, which wraps SQLite with WAL (Write-Ahead Logging) and FTS5 for full-text search. The storage layer also implements custom indexes for nodes and edges. Tools like search_graph and query_graph depend directly on this module to persist and retrieve data.
Discovery and Pipeline (src/discover/ and src/pipeline/)
The Discovery layer (src/discover/*.[c|h]) handles repository scanning, including .gitignore and .cbmignore parsing, language detection, and file-type mapping. The Pipeline layer (src/pipeline/*.[c|h]) implements multi-pass indexing including definitions, imports, calls, LSP-cross references, route nodes, package mapping, Git diff analysis, environment scanning, enrichment, and similarity calculations. The index_repository tool relies on these layers to build the knowledge graph.
Cypher Query Engine (src/cypher/cypher.c)
Read-only OpenCypher-style query parsing, planning, and execution are provided by the Cypher Engine in src/cypher/cypher.c. This module powers the query_graph tool, allowing agents to execute graph queries without external database dependencies.
Optional Components
The UI layer (src/ui/*.[c|h]) provides an embedded HTTP server and 3-D visualization, but only in the UI-variant binary. The Tracing module (src/traces/traces.c) handles runtime trace ingestion for HTTP-CALL edge validation. The Graph Buffer (src/graph_buffer/graph_buffer.c) manages in-memory graph building before dumping to SQLite. These are conditionally compiled based on the build target.
Tool Registration in the Core MCP Server
All 14 MCP tool definitions are registered in src/mcp/mcp.c, which also implements the JSON-RPC 2.0 transport layer, session handling, and auto-indexing capabilities. The registration happens statically during initialization, binding tool names like index_repository, search_graph, trace_path, and query_graph to their respective implementations in the internal library layers.
The CLI layer (src/cli/*.[c|h]) provides the command-line interface, progress reporting, and pre-tool-use hooks for agents, forwarding commands to the MCP server.
Runtime Dependency Profile
The only runtime dependency for the MCP tool definitions is the operating system's C runtime library. On Linux this means glibc, on macOS libSystem, and on Windows the Windows C runtime. There are no third-party dynamic libraries, Python wheels, Node modules, or external services required.
All dependencies—including SQLite, YAML parsing, and LZ4 compression—are compiled statically into the final binary. This zero-dependency design ensures that the MCP server runs identically across environments without version conflicts or package management issues.
Practical Usage Examples
You can invoke MCP tools directly through the built-in CLI or via JSON-RPC 2.0 requests from MCP-compatible agents.
CLI Invocation
# List all indexed projects
codebase-memory-mcp cli list_projects
# Search the graph for functions whose name contains "Handler"
codebase-memory-mcp cli search_graph '{"label":"Function","name_pattern":".*Handler.*"}'
# Run a Cypher-like query
codebase-memory-mcp cli query_graph '{"query":"MATCH (f:Function)-[:CALLS]->(g) WHERE f.name = \"processOrder\" RETURN g.name"}'
JSON-RPC 2.0 Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "search_graph",
"params": {
"label": "Function",
"name_pattern": ".*Handler.*"
}
}
Summary
- MCP tool definitions in codebase-memory-mcp are compiled directly into the binary with no external runtime dependencies.
- All 14 tools rely on internal C libraries including Foundation (
src/foundation/), SQLite Store (src/store/store.c), Discovery (src/discover/), Pipeline (src/pipeline/), and Cypher Engine (src/cypher/cypher.c). - Tool registration occurs in
src/mcp/mcp.c, which implements the JSON-RPC 2.0 server and static linking of implementations. - The only runtime requirement is the OS C runtime (glibc, libSystem, or Windows CRT).
- Static compilation includes SQLite with WAL/FTS5, YAML parsing, and LZ4 compression, eliminating package management overhead.
Frequently Asked Questions
Does codebase-memory-mcp require Python or Node.js to run MCP tool definitions?
No. The MCP tool definitions are implemented in C and compiled into a native binary. Unlike many MCP servers that require external runtimes, codebase-memory-mcp has zero dependencies on Python, Node.js, or other language ecosystems. The only requirement is the operating system's C runtime library.
Can I use the MCP tools without installing SQLite separately?
Yes. SQLite is embedded statically into the codebase-memory-mcp binary via the storage layer in src/store/store.c. The implementation includes WAL mode and FTS5 full-text search capabilities compiled directly into the executable, so no separate SQLite installation or shared library is needed.
Why are there 14 specific MCP tools, and where are they defined?
The 14 tools provide complete knowledge graph operations including repository indexing, graph searching, path tracing, and Cypher queries. They are defined and registered in src/mcp/mcp.c, where each tool name is bound to its implementation function. This registration happens at compile time, ensuring all tools are available immediately when the binary starts.
Is the UI component required for the MCP server to function?
No. The UI components in src/ui/*.[c|h] are optional and only included in the UI-variant binary. The core MCP server and all 14 tool definitions function without the embedded HTTP server or 3-D visualization. You can run the standard binary purely as a JSON-RPC 2.0 server for MCP tool operations.
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 →