Data Sources for MCP Tool Definitions in Codebase Memory MCP

MCP tool definitions are hard-coded as a static C array in src/mcp/mcp.c, containing 14 tools with their JSON schemas compiled directly into the binary.

In the DeusData/codebase-memory-mcp repository, understanding where tool metadata originates is critical for developers extending the Memory-Code-Project (MCP) server. Unlike configuration-driven architectures, the data sources for MCP tool definitions are embedded directly in the source code, eliminating external dependencies and ensuring consistent RPC responses.

The Static TOOLS Array

The primary data source for all MCP tool definitions is the TOOLS array declared in src/mcp/mcp.c (lines 311-395).

This static TOOL_DEF_T structure contains complete metadata for 14 distinct tools, including:

  • name: The tool identifier used in RPC calls
  • title: Human-readable label for the tool
  • description: Detailed explanation of functionality
  • input_schema: Raw JSON string defining parameters

Structure of TOOL_DEF_T

Each entry in the TOOLS array follows this pattern:

typedef struct {
    const char *name;
    const char *title;
    const char *description;
    const char *input_schema;  /* JSON string literal */
} TOOL_DEF_T;

The array is initialized with string literals at compile time, meaning the input_schema fields contain embedded JSON like {"type":"object","properties":{...}} directly in the C source.

JSON Schemas and Output Definitions

The codebase separates input validation schemas from output specifications.

Input Schemas

Each tool's input validation rules are stored as raw JSON strings within the TOOLS array entries. These schemas define required parameters, property types, and constraints. For example, the search_graph tool includes an input schema requiring a project parameter.

Generic Output Schema

All 14 tools share a uniform output definition via the constant MCP_TOOL_OUTPUT_SCHEMA located at lines 500-502 in src/mcp/mcp.c:

#define MCP_TOOL_OUTPUT_SCHEMA "{\"type\":\"object\",\"additionalProperties\":true}"

This generic schema is attached to every tool definition at runtime, allowing flexible return objects while maintaining MCP protocol compliance.

How Tool Definitions Are Exposed

Static data becomes dynamic through helper functions that transform the compiled array into JSON-RPC responses.

RPC Interface (tools/list)

When clients call the tools/list method, the server invokes cbm_mcp_tools_list(), which internally uses cbm_mcp_tools_list_range() (lines 514-560) to iterate the TOOLS array. The function mcp_add_tool_def serializes each struct into JSON format, injecting the constant output schema alongside the hard-coded input schemas.

CLI Helper Functions

For command-line interfaces, cbm_mcp_tool_input_schema() (lines 668-680) provides direct lookup capabilities:

const char *cbm_mcp_tool_input_schema(const char *name);

This function searches the static TOOLS array by name and returns the raw input_schema JSON string, enabling per-tool help generation without RPC overhead.

Code Examples

Listing All Tools Programmatically

Retrieve the complete tool catalog as a JSON string:

#include "mcp.h"

char *json = cbm_mcp_tools_list();
/* Returns:
{
  "tools": [
    {
      "name": "index_repository",
      "title": "Index repository",
      "description": "...",
      "inputSchema": {...},
      "outputSchema": {"type":"object","additionalProperties":true}
    },
    ...
  ]
}
*/
free(json);

Retrieving a Specific Input Schema

Access the raw JSON schema for individual tool validation:

const char *schema = cbm_mcp_tool_input_schema("search_graph");
/* Returns: {"type":"object","properties":{...},"required":["project"]} */

RPC Client Usage

Query the tool list via JSON-RPC:

POST /jsonrpc
{
  "jsonrpc": "2.0",
  "method": "tools/list",
  "id": 1,
  "params": {}
}

The server processes this through cbm_mcp_tools_list() and returns the compiled tool definitions.

Summary

  • Data sources for MCP tool definitions are compiled directly into the binary via the static TOOLS array in src/mcp/mcp.c
  • 14 tools are defined with hard-coded metadata and JSON input schemas at lines 311-395
  • Output schemas are generic and defined by the MCP_TOOL_OUTPUT_SCHEMA constant (lines 500-502)
  • No external configuration files, databases, or runtime data sources are consulted
  • Helper functions cbm_mcp_tools_list() and cbm_mcp_tool_input_schema() expose the static data to RPC and CLI interfaces

Frequently Asked Questions

Are MCP tool definitions configurable via external files?

No. According to the DeusData/codebase-memory-mcp source code, there are no external JSON files, databases, or configuration files feeding the tool definitions. All metadata is embedded as string literals in the TOOLS array within src/mcp/mcp.c and requires recompilation to modify.

How many tools are defined in the hard-coded array?

The static TOOLS array contains 14 distinct MCP tools, each with complete name, title, description, and input schema definitions located between lines 311 and 395 in src/mcp/mcp.c.

Where is the output schema defined for MCP tools?

The output schema is defined by the MCP_TOOL_OUTPUT_SCHEMA macro at lines 500-502 in src/mcp/mcp.c. This constant contains a generic JSON schema ({"type":"object","additionalProperties":true}) that is attached to every tool definition in the tools/list RPC response.

Can I modify tool definitions without recompiling?

No. Because the data sources for MCP tool definitions are static C arrays compiled into the binary, any changes to tool metadata, descriptions, or input schemas require editing src/mcp/mcp.c and recompiling the project. There is no runtime configuration mechanism provided.

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:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →