Skip to main content
Glama

Code Intelligence

code_intel
Read-onlyIdempotent

Analyze code structure to find symbol definitions, callers, dependencies, and refactoring impact before editing. Replaces repeated text searches with graph-backed queries.

Instructions

DECISION RULE: Structure questions → this tool. Text search → Grep.

Before using Grep, ask: Is this a STRUCTURE question (definitions, callers, impact) or a TEXT question (strings, config)?

QUICK START: return await api.searchSymbols({query: "AuthService"}) — simple queries are one-liners. Run api.listMethods() for full API reference with signatures and descriptions. Run api.help("methodName") for inline TypeScript type definitions — no resource reads needed. Compose: const [impact, deps] = await Promise.all([api.impactAnalysis({symbolId}), api.getDependents({filePath})]);

WHY THIS TOOL: Graph-backed intelligence finds indirect relationships, transitive dependencies, and breaking change risks that text search cannot detect.

"What uses X?" disambiguation: getDependents (file imports) vs getCallGraph (call chain) vs traceSymbolUsage (all usages).

USE IMMEDIATELY WHEN: • BEFORE using Edit on a function/class → run impactAnalysis({symbolId}) first • BEFORE exploring an unfamiliar codebase → run getArchitectureOverview() • BEFORE refactoring → trace getDependencies + getDependents for blast radius • Running 3+ Grep calls for structure? STOP → use code_intel instead

TOP 5 QUESTIONS (query is case-insensitive substring match): • "Where is X defined?" / "Find function Y" → searchSymbols({query}) • "What calls X?" / "What imports this?" → getDependents({filePath}) or getCallGraph({symbolId}) • "What does X depend on?" → getDependencies({filePath}) • "Safe to modify X?" / "Blast radius?" → impactAnalysis({symbolId}) • "Find dead code" / "Unused exports?" → findOrphanedCode() • "Complex functions?" / "Refactoring targets?" → searchSymbols results include complexity.cyclomaticComplexity + complexityRisk per function

NOT FOR: literal string search, log messages, config values, or reading source code. Use Grep/Glob/Read for those. Supports TypeScript, JavaScript, Python, and more — run api.getCapabilities() to check your project. File-path-scoped methods (getDependencies, getDependents, getCallGraph, traceSymbolUsage, impactAnalysis) reject calls whose filePath extension is not in the project's configured languages with UNSUPPORTED_LANGUAGE — check api.getCapabilities() first.

WRONG TOOL SIGNAL: If you've run 3+ Grep calls for structure (callers, dependencies, impact), STOP and use code_intel instead. Typical workflow: code_intel to find (results include source snippets) → Edit to modify

Sandbox limits: 50 api.* calls per execution, 128 MB memory, 100 KB max code size, limit max 100 on any method with a limit param. Pure JS only — no require/import/fs/net/process (see constellation://docs/guide for full restrictions).

IMPORTANT: The cwd parameter is required — always set it to the target project directory path.

The optional hook input is for agent-plugin hooks; agents omit it.

Input Schema

NameRequiredDescriptionDefault
cwdYesAbsolute path to the project directory being queried. Used to locate the correct constellation.json by finding the git repository root. Set this to the root of the repository or workspace folder you are working in.
codeYesJavaScript code to execute. Can use top-level await. Available API methods: searchSymbols, getSymbolDetails, getDependencies, getDependents, findCircularDependencies, traceSymbolUsage, getCallGraph, impactAnalysis, findOrphanedCode, getArchitectureOverview
hookNoFor agent-plugin hooks; agents omit it. Runs `code` with a read-only `hook` global and returns an advisory hook output instead of the result envelope.
timeoutNoOptional execution-time override in milliseconds. When omitted, the sandbox derives the timeout from the static complexity of your code (heavier api.* methods raise the budget) and clamps the result to [1000, 60000]. The breakdown is returned in the response so you can see what was applied. Explicit values still win and are clamped to the same range.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed8 schema fields changedv1.3.0
    • removedInput schema / $schema
      Removed value: -"http://json-schema.org/draft-07/schema#"
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedInput schema / properties / hook
      Added value: +{
      +  "description": "For agent-plugin hooks; agents omit it. Runs `code` with a read-only `hook` global and returns an advisory hook output instead of the result envelope.",
      +  "properties": {
      +    "event": {
      +      "description": "Hook event name (string), e.g. PreToolUse or SessionStart."
      +    },
      +    "input": {
      +      "description": "Hook payload (JSON)."
      +    },
      +    "sessionId": {
      +      "description": "Hook session id (string)."
      +    },
      +    "settings": {
      +      "description": "CONSTELLATION_* env names to expose (string[])."
      +    }
      +  },
      +  "required": [
      +    "event"
      +  ],
      +  "type": "object"
      +}
    • removedOutput schema / $schema
      Removed value: -"http://json-schema.org/draft-07/schema#"
    • removedOutput schema / additionalProperties
      Removed value: -false
    • addedOutput schema / anyOf
      Added value: +[
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "asOfCommit": {
      +        "type": "string"
      +      },
      +      "error": {
      +        "type": "string"
      +      },
      +      "lastIndexedAt": {
      +        "type": "string"
      +      },
      +      "logs": {
      +        "items": {
      +          "type": "string"
      +        },
      +        "type": "array"
      +      },
      +      "result": {},
      +      "resultContext": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "branchIndexed": {
      +            "type": "boolean"
      +          },
      +          "indexedFileCount": {
      +            "type": "number"
      +          },
      +          "reason": {
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "reason",
      +          "branchIndexed",
      +          "indexedFileCount"
      +        ],
      +        "type": "object"
      +      },
      +      "success": {
      +        "type": "boolean"
      +      },
      +      "time": {
      +        "type": "number"
      +      },
      +      "timeoutBreakdown": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "appliedMs": {
      +            "type": "number"
      +          },
      +          "baseMs": {
      +            "type": "number"
      +          },
      +          "calls": {
      +            "items": {
      +              "additionalProperties": false,
      +              "properties": {
      +                "computed": {
      +                  "const": true,
      +                  "type": "boolean"
      +                },
      +                "method": {
      +                  "type": "string"
      +                },
      +                "weight": {
      +                  "type": "number"
      +                }
      +              },
      +              "required": [
      +                "method",
      +                "weight"
      +              ],
      +              "type": "object"
      +            },
      +            "type": "array"
      +          },
      +          "coldStartGraceMs": {
      +            "type": "number"
      +          },
      +          "estimatedMs": {
      +            "type": "number"
      +          },
      +          "parallelismFactor": {
      +            "type": "number"
      +          },
      +          "warnings": {
      +            "items": {
      +              "type": "string"
      +            },
      +            "type": "array"
      +          }
      +        },
      +        "required": [
      +          "baseMs",
      +          "calls",
      +          "parallelismFactor",
      +          "estimatedMs",
      +          "coldStartGraceMs",
      +          "appliedMs",
      +          "warnings"
      +        ],
      +        "type": "object"
      +      }
      +    },
      +    "required": [
      +      "success"
      +    ],
      +    "type": "object"
      +  },
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "hookSpecificOutput": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "additionalContext": {
      +            "type": "string"
      +          },
      +          "hookEventName": {
      +            "enum": [
      +              "PreToolUse",
      +              "PostToolUse",
      +              "SessionStart",
      +              "SubagentStart",
      +              "UserPromptSubmit",
      +              "Stop"
      +            ],
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "hookEventName",
      +          "additionalContext"
      +        ],
      +        "type": "object"
      +      },
      +      "systemMessage": {
      +        "type": "string"
      +      }
      +    },
      +    "type": "object"
      +  }
      +]
    • removedOutput schema / properties
      Removed value: -{
      -  "asOfCommit": {
      -    "type": "string"
      -  },
      -  "error": {
      -    "type": "string"
      -  },
      -  "lastIndexedAt": {
      -    "type": "string"
      -  },
      -  "logs": {
      -    "items": {
      -      "type": "string"
      -    },
      -    "type": "array"
      -  },
      -  "result": {},
      -  "resultContext": {
      -    "additionalProperties": false,
      -    "properties": {
      -      "branchIndexed": {
      -        "type": "boolean"
      -      },
      -      "indexedFileCount": {
      -        "type": "number"
      -      },
      -      "reason": {
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "reason",
      -      "branchIndexed",
      -      "indexedFileCount"
      -    ],
      -    "type": "object"
      -  },
      -  "success": {
      -    "type": "boolean"
      -  },
      -  "time": {
      -    "type": "number"
      -  },
      -  "timeoutBreakdown": {
      -    "additionalProperties": false,
      -    "properties": {
      -      "appliedMs": {
      -        "type": "number"
      -      },
      -      "baseMs": {
      -        "type": "number"
      -      },
      -      "calls": {
      -        "items": {
      -          "additionalProperties": false,
      -          "properties": {
      -            "computed": {
      -              "const": true,
      -              "type": "boolean"
      -            },
      -            "method": {
      -              "type": "string"
      -            },
      -            "weight": {
      -              "type": "number"
      -            }
      -          },
      -          "required": [
      -            "method",
      -            "weight"
      -          ],
      -          "type": "object"
      -        },
      -        "type": "array"
      -      },
      -      "coldStartGraceMs": {
      -        "type": "number"
      -      },
      -      "estimatedMs": {
      -        "type": "number"
      -      },
      -      "parallelismFactor": {
      -        "type": "number"
      -      },
      -      "warnings": {
      -        "items": {
      -          "type": "string"
      -        },
      -        "type": "array"
      -      }
      -    },
      -    "required": [
      -      "baseMs",
      -      "calls",
      -      "parallelismFactor",
      -      "estimatedMs",
      -      "coldStartGraceMs",
      -      "appliedMs",
      -      "warnings"
      -    ],
      -    "type": "object"
      -  }
      -}
    • removedOutput schema / required
      Removed value: -[
      -  "success"
      -]
  2. Changed2 schema fields changedv1.2.4
    • addedOutput schema / properties / timeoutBreakdown / properties / coldStartGraceMs
      Added value: +{
      +  "type": "number"
      +}
    • changedOutput schema / properties / timeoutBreakdown / required
      Previous value: -[
      -  "baseMs",
      -  "calls",
      -  "parallelismFactor",
      -  "estimatedMs",
      -  "appliedMs",
      -  "warnings"
      -]New value: +[
      +  "baseMs",
      +  "calls",
      +  "parallelismFactor",
      +  "estimatedMs",
      +  "coldStartGraceMs",
      +  "appliedMs",
      +  "warnings"
      +]
  3. Addedv1.2.1
  4. Removedv1.2.0
  5. First observedv0.1.4

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already declare read-only, idempotent, non-destructive behavior, but the description adds substantial context beyond them: sandbox call/memory/size limits, `limit` max 100, prohibited Node APIs, required `cwd`, and UNSUPPORTED_LANGUAGE rejection for file-path-scoped methods. This is exactly the extra behavioral disclosure an agent needs before running arbitrary code.

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

Conciseness4/5

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

The description is long but well structured with headers, quick-start examples, and front-loaded decision rules. Some points, especially the Grep-vs-structure rule, are repeated in 'NOT FOR' and 'WRONG TOOL SIGNAL', which costs a little conciseness without hurting usability.

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

Completeness5/5

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

Given a complex sandboxed-code tool with nested objects and an output schema, the description covers execution constraints, language support, error behavior, required inputs, and the recommended workflow. Return values need not be explained because an output schema exists, so nothing essential is missing.

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

Parameters3/5

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

Schema description coverage is 100%, so the baseline is 3. The description emphasizes that `cwd` is required and that agents should omit `hook`, but the schema already says both; its `limit` note applies to nested API methods rather than top-level parameters, so added meaning over the schema is marginal.

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 states a specific purpose: graph-backed code intelligence for structure questions, explicitly contrasted with text search via Grep. It names concrete API methods (searchSymbols, impactAnalysis, getDependents) and the questions they answer, so an agent can tell exactly what the tool is for.

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

Usage Guidelines5/5

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

It gives an explicit decision rule (structure → this tool, text → Grep), a 'NOT FOR' list, a 'WRONG TOOL SIGNAL' trigger for repeated Grep calls, and a typical workflow (code_intel → Edit). Alternatives and exclusions are both named, leaving nothing to inference.

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

Deploy Server

Other Tools