Code Outline

Code Outline

warning
Experimental feature

Code-outline tools are experimental and must be enabled with the --experimental server flag.

The code-outline feature builds a symbol relation graph from your project's source code. It lets AI agents navigate a codebase by following the connections between symbols — who calls what, which types are used where, how interfaces are implemented — without reading every file manually.

How It Works

When an outline tool is called, Einstein MCP walks the project directory and runs a language-specific extractor on every matching source file. The extractor uses the language's AST (or a regex fallback) to:

  1. Declare every symbol (functions, methods, types, variables, constants).
  2. Record forward relations — which other symbols each symbol references.
  3. Derive reverse relations automatically — calledBy, accessedBy, usedBy, etc.

The resulting graph is then trimmed to the requested depth and rendered as text or JSON.

Relation Kinds

Each symbol can carry up to 14 relation kinds:

KindDirectionMeaning
callsforwardFunctions called by this function
calledByreverseFunctions that call this function
accessesforwardPackage-level variables/constants read by this function
accessedByreverseFunctions that read this variable/constant
assignsforwardPackage-level variables written by this function
assignedByreverseFunctions that write this variable
usesforwardTypes referenced in this function's signature or body
usedByreverseFunctions that reference this type
extendsforwardTypes embedded by this struct
extendedByreverseStructs that embed this type
implementsforwardInterfaces implemented by this type
implementedByreverseTypes that implement this interface
declaresSymbols declared inside this scope
importsPackages imported by this file

Use the relations parameter on any outline tool to filter to only the kinds you care about. For example, passing ["implementedBy"] on a type shows every concrete implementation of an interface.

Supported Languages

Go

Extractor type: AST (full fidelity via go/ast)

Symbol naming: package.Name for top-level declarations, package.(*ReceiverType).Method for pointer-receiver methods, package.ReceiverType.Method for value-receiver methods.

Special cases and limitations:

  • Receiver method calls — When code calls obj.Method(), the extractor records the callee as obj.Method (using the variable name, not the type). Type inference is not performed, so the calledBy reverse relation is matched by method name suffix rather than the exact qualified name. In practice this means a calledBy result may list callers of any method named Method across all types.
  • Calls relation — Only plain-identifier calls to package-level functions are qualified with the package name. Calls through receivers or imported packages keep their original form (obj.Method, fmt.Println).
  • assigns relation — Only records writes using = to package-level variables. Short variable declarations (:=) are intentionally excluded because they declare local variables.
  • accesses relation — Records reads of package-level variables and constants. Excludes identifiers that appear as a call target or on the left-hand side of an assignment.
  • implements relation — Not yet extracted; interface-to-concrete mapping is not currently emitted.
  • omit_native flag — Filters symbols whose package prefix matches an imported package name (e.g. fmt, os, strings) as well as Go built-in identifiers (append, len, make, etc.).
  • Ignored directoriesvendor, node_modules, dist, and any directory beginning with . are skipped during project walks.

Untested, supported languages

The following languages are supported by the outliner, but mostly untested. Results yielded for these languages may be partially incorrect or incomplete!

  • javascript
  • laravel
  • nextjs
  • php
  • react
  • symfony
  • typescript
  • twig (mostly tested, but not fully stable yet)
  • shopware-twig (superset for twig with Shopware 6 features)

Generic (fallback)

Extractor type: Regex

The generic extractor is available under the language name Generic. It uses simple regular expressions to detect common declaration patterns and does not perform deep relation analysis. It is intended as a starting point for languages that do not yet have a dedicated extractor.

info
Adding a new language

Implement the SymbolExtractor interface in internal/tools/outline/languages/ and register the extractor in cmd/mcp/main.go. The extractor receives raw file content and returns []Symbol and []Relation slices — no other integration is required.

Usage Examples

Get all callers of a function:

{
  "symbol": "RegisterExtractor",
  "language": "go",
  "relations": ["calledBy"],
  "depth": 1,
  "omit_native": true
}

List every type that implements an interface (once implements is supported):

{
  "symbol": "SymbolExtractor",
  "language": "go",
  "relations": ["implementedBy"],
  "depth": 1
}

Outline an entire file without traversing into dependencies:

{
  "file": "internal/tools/outline/manager.go",
  "language": "go",
  "depth": 0
}

Full project outline in JSON:

{
  "language": "go",
  "depth": 1,
  "omit_native": true,
  "format": "json"
}