How to Import MCP Tool Definitions from codebase-memory-mcp
You can import MCP tool definitions by querying the JSON-RPC tools/list endpoint, adding a static server entry to your agent's configuration file, or running the built-in CLI helper to inspect schemas locally.
The codebase-memory-mcp repository implements a Model Context Protocol (MCP) server that exposes 14 codebase analysis tools—including search_graph, trace_path, and get_architecture—through a zero-dependency binary. Rather than manually defining tool contracts, you can import MCP tool definitions dynamically using the standard discovery protocol or static configuration methods provided by the server.
Run the JSON-RPC Discovery Call
The canonical way to import MCP tool definitions is through the tools/list method defined in the MCP specification. When an agent connects to the server, it sends a JSON-RPC request to discover available tools and their schemas.
The server implementation lives in src/mcp/, where the tool registry advertises all 14 available methods. The protocol schema is declared in server.json, which validates the JSON-RPC 2.0 structure.
To retrieve definitions programmatically:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list",
"params": {}
}
The response includes each tool's name, description, parameter schema, and result schema. This dynamic discovery ensures your agent always uses the latest tool definitions without configuration updates.
Configure via Static JSON Entry
For agents that require manual setup, you can import MCP tool definitions by registering the server in your agent's configuration file. This static approach lets the agent fetch tool definitions on first use.
Create or edit ~/.claude/.mcp.json (or the equivalent path for your specific agent):
{
"mcpServers": {
"codebase-memory-mcp": {
"command": "/path/to/codebase-memory-mcp",
"args": []
}
}
}
The codebase-memory-mcp install command automates this process. Located in pkg/pypi/src/codebase_memory_mcp/_cli.py, the install logic detects installed agents on your system and writes the appropriate *.mcp.json files to each agent's configuration directory, eliminating manual path configuration.
Inspect Definitions with the CLI Helper
If you need to import MCP tool definitions for inspection or debugging without running a full agent session, use the CLI helper bundled in _cli.py. This Python shim downloads the static binary (containing 158 Tree-Sitter grammars and the Hybrid LSP type-resolution layer) and forwards arguments directly to the server.
Run the following to print tool definitions locally:
codebase-memory-mcp cli tools/list
This outputs the same JSON-RPC response you would receive over the wire, allowing you to verify tool schemas before integration:
codebase-memory-mcp cli tools/list | jq '.tools[] | {name, description}'
The command returns structured metadata for all 14 tools, including search_graph for structured codebase queries and trace_path for BFS traversal analysis.
Why Automatic Discovery Works
Zero-dependency binary. The server compiles all Tree-Sitter grammars and the Hybrid LSP type-resolution layer into a single executable, requiring no external language-server processes.
Standard MCP protocol. The server follows the Model Context Protocol JSON-RPC 2.0 specification as defined in server.json. The tools/list method is the canonical discovery mechanism, ensuring compatibility with Claude Code, Codex CLI, Gemini CLI, and VS Code extensions.
Auto-configuration. The installation script in _cli.py validates checksums, caches the binary, and automatically registers the server with detected agents, streamlining the import process.
Summary
- Dynamic discovery: Send a JSON-RPC
tools/listrequest tosrc/mcp/to retrieve live tool definitions. - Static configuration: Add the server entry to
~/.claude/.mcp.jsonor letcodebase-memory-mcp installauto-detect your agent. - Local inspection: Use
codebase-memory-mcp cli tools/listto view schemas without starting an agent session. - Self-contained: The binary includes 158 Tree-Sitter grammars and requires no external dependencies.
Frequently Asked Questions
Where are the tool definitions stored in the codebase?
The tool registry is implemented in the C source under src/mcp/, while the JSON-RPC protocol schema is declared in server.json. The _cli.py file in pkg/pypi/src/codebase_memory_mcp/ handles binary distribution and CLI argument forwarding.
Do I need to manually write JSON schemas for each tool?
No. codebase-memory-mcp automatically advertises tool schemas through the MCP tools/list endpoint. When you import MCP tool definitions via discovery or the CLI helper, you receive complete parameter and result schemas without manual configuration.
What agents are compatible with the tool definitions?
Any MCP-compatible client can import these definitions, including Claude Code, Codex CLI, Gemini CLI, and VS Code with MCP extensions. The server speaks standard JSON-RPC 2.0 over stdio, making it transport-agnostic.
How do I verify the tool definitions before connecting an agent?
Run codebase-memory-mcp cli tools/list to print the JSON-RPC response locally. This validates that the binary downloaded correctly and shows the exact schemas—for tools like search_graph and trace_path—that your agent will receive during discovery.
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 →