Code Outline
Code Outline
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:
- Declare every symbol (functions, methods, types, variables, constants).
- Record forward relations — which other symbols each symbol references.
- 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:
| Kind | Direction | Meaning |
|---|---|---|
calls | forward | Functions called by this function |
calledBy | reverse | Functions that call this function |
accesses | forward | Package-level variables/constants read by this function |
accessedBy | reverse | Functions that read this variable/constant |
assigns | forward | Package-level variables written by this function |
assignedBy | reverse | Functions that write this variable |
uses | forward | Types referenced in this function's signature or body |
usedBy | reverse | Functions that reference this type |
extends | forward | Types embedded by this struct |
extendedBy | reverse | Structs that embed this type |
implements | forward | Interfaces implemented by this type |
implementedBy | reverse | Types that implement this interface |
declares | — | Symbols declared inside this scope |
imports | — | Packages 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 asobj.Method(using the variable name, not the type). Type inference is not performed, so thecalledByreverse relation is matched by method name suffix rather than the exact qualified name. In practice this means acalledByresult may list callers of any method namedMethodacross 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). assignsrelation — Only records writes using=to package-level variables. Short variable declarations (:=) are intentionally excluded because they declare local variables.accessesrelation — 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.implementsrelation — Not yet extracted; interface-to-concrete mapping is not currently emitted.omit_nativeflag — 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 directories —
vendor,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.
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"
}