Skip to main content
Glama
cvandesande

project-code-intelligence

by cvandesande

related_code_intel

Retrieve code intelligence graph edges for a record ID or symbol, revealing references, definitions, and dependencies.

Instructions

Return code intelligence graph edges related to a record id or symbol.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
record_idNo
symbolNo
collectionNo
repoNo
limitNo
snapshot_idNo
include_historicalNo

Implementation Reference

  • The handler function for the related_code_intel tool. It builds SQL queries to find code intelligence graph edges (edges from project_code_intel_edges) that match a record_id and/or symbol, filtered by collection, repo, and snapshot scope, ordered by id DESC, limited to 1-100 results.
    def tool_related_code_intel(args: Json) -> Json:
        record_id = optional_text(args, "record_id")
        symbol = optional_text(args, "symbol")
        if not record_id and not symbol:
            raise McpProtocolError("record_id or symbol is required")
        limit = require_int(args, "limit", 20, 1, 100)
        collection = scoped_collection(args)
        repo = optional_text(args, "repo")
    
        clauses = ["TRUE"]
        params: QueryParams = []
        if record_id:
            clauses.append("(e.source_record_id = %s OR e.target_record_id = %s)")
            params.extend([record_id, record_id])
        if symbol:
            clauses.append("(e.source_symbol = %s OR e.target_symbol = %s)")
            params.extend([symbol, symbol])
        if repo:
            clauses.append("e.repo = %s")
            params.append(repo)
        if collection:
            clauses.append("e.collection = %s")
            params.append(collection)
        snapshot_clauses, snapshot_params = scoped_snapshot_clauses(args, "e")
        clauses.extend(snapshot_clauses)
        params.extend(snapshot_params)
        params.append(limit)
    
        with db.connect() as conn:
            if not code_intel_tables_exist(conn):
                return ok({"error": "code intelligence schema is not initialized"})
            edges = conn.execute(
                db.query_sql(
                    query_with_where(
                        """
                SELECT e.id, e.snapshot_id, e.collection, e.repo, e.commit_sha,
                       e.source_record_id, e.target_record_id, e.edge_type,
                       e.source_symbol, e.target_symbol, e.source_path, e.target_path,
                       e.confidence_kind, e.metadata
                FROM project_code_intel_edges e
                """,
                        clauses,
                        """
                ORDER BY e.id DESC
                LIMIT %s
                """,
                    )
                ),
                params,
            ).fetchall()
        return ok({**snapshot_scope_response(args), "edges": edges})
  • The ToolDefinition (metadata + JSON input schema) for related_code_intel. The schema accepts optional fields: record_id, symbol, collection, repo, limit (1-100), snapshot_id, include_historical.
    "related_code_intel": ToolDefinition(
        "Return code intelligence graph edges related to a record id or symbol.",
        {
            "type": "object",
            "properties": {
                "record_id": {"type": "string"},
                "symbol": {"type": "string"},
                "collection": {"type": "string"},
                "repo": {"type": "string"},
                "limit": {"type": "integer", "minimum": 1, "maximum": 100},
                "snapshot_id": {"type": "integer", "minimum": 1},
                "include_historical": {"type": "boolean"},
            },
            "additionalProperties": False,
        },
    ),
  • The TOOLS registry dict that maps the string 'related_code_intel' to its ToolDefinition and handler function (tool_related_code_intel).
    TOOLS: ToolRegistry = {
        "code_intel_status": (TOOL_DEFINITIONS["code_intel_status"], tool_code_intel_status),
        "search_code_intel_text": (TOOL_DEFINITIONS["search_code_intel_text"], tool_search_code_intel_text),
        "search_code_intel_semantic": (TOOL_DEFINITIONS["search_code_intel_semantic"], tool_search_code_intel_semantic),
        "get_code_intel_record": (TOOL_DEFINITIONS["get_code_intel_record"], tool_get_code_intel_record),
        "related_code_intel": (TOOL_DEFINITIONS["related_code_intel"], tool_related_code_intel),
        "search_static_findings": (TOOL_DEFINITIONS["search_static_findings"], tool_search_static_findings),
        "get_static_finding": (TOOL_DEFINITIONS["get_static_finding"], tool_get_static_finding),
        "get_static_code_flow": (TOOL_DEFINITIONS["get_static_code_flow"], tool_get_static_code_flow),
    }
  • The scoped_collection helper function used by the handler to determine the effective collection scope, checking configured vs requested collection with override permissions.
    def scoped_collection(args: Json) -> str | None:
        requested = optional_text(args, "collection")
        configured = config.configured_collection()
        if configured and requested and requested != configured and not config.collection_override_allowed():
            raise McpWritePermissionError(
                "collection override is disabled by PROJECT_CODE_INTELLIGENCE_COLLECTION; "
                "set PROJECT_CODE_INTELLIGENCE_ALLOW_COLLECTION_OVERRIDE=1 for trusted multi-collection access"
            )
        return requested or configured
  • The scoped_snapshot_clauses helper used by the handler to build snapshot-related SQL WHERE clauses based on snapshot_id or include_historical flags.
    def scoped_snapshot_clauses(args: Json, alias: str) -> tuple[list[str], QueryParams]:
        scope, snapshot_id = snapshot_scope(args)
        if snapshot_id is not None:
            return [f"{column(alias, 'snapshot_id')} = %s"], [snapshot_id]
        if scope == "historical":
            return [], []
        return [latest_record_snapshot_clause(alias)], []
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so the description carries full burden. It only states the tool returns graph edges, but fails to disclose any side effects, read-only nature, permissions needed, or ordering/pagination behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, but lacks front-loading of key details. It mentions record_id and symbol but not other parameters. Language is somewhat vague ('related to'), but length is appropriate.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 7 undocumented parameters, no output schema, and no annotations, the description is grossly insufficient for correct tool invocation. The AI lacks guidance on required inputs and expected output structure.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, yet the description only hints at record_id and symbol. It does not explain collection, repo, limit, snapshot_id, or include_historical, leaving the AI without necessary parameter context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool returns code intelligence graph edges, specifying it is related to a record id or symbol. This distinguishes it from siblings like get_code_intel_record which retrieves a single record.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when or when not to use this tool. It does not mention alternatives or prerequisites, leaving the AI to infer usage context from the name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cvandesande/project-code-intelligence'

If you have feedback or need assistance with the MCP directory API, please join our Discord server