The get_code_element tool retrieves the complete implementation of a specific function, class, method, or type by name. It returns the full source code along with rich metadata including parameters, return types, complexity scores, and documentation.
Stellarion uses tree-sitter AST parsing to accurately identify code elements and extract their complete implementations. It first queries a RocksDB index for instant results (<10ms) and falls back to full AST parsing if needed.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | Yes | - | Name of the element to find (or * for entire file) |
type | string | No | auto | Element type: function, class, method, type, enum, variable, constant, or auto |
file | string | No | - | Specific file path to search in |
includeComments | boolean | No | false | Include associated documentation comments |
includeSignature | boolean | No | false | Include detailed function/method signature |
mcp__stellarion__get_code_element name:"ElementName" type:class file:src/services/user.ts
Natural Language:
Show me the validateEmail function implementation
Direct MCP Call:
mcp__stellarion__get_code_element name:validateEmail type:function
Returns: Complete implementation of validateEmail with file path and line numbers
Natural Language:
Show me the UserService class
Direct MCP Call:
mcp__stellarion__get_code_element name:UserService type:class includeComments:true
Returns: Full class definition including all methods, properties, and JSDoc comments
Natural Language:
Show me the handleSubmit method
Direct MCP Call:
mcp__stellarion__get_code_element name:handleSubmit type:method includeSignature:true
Returns: The handleSubmit method with parameter and return type details
Natural Language:
Get the processData function from src/utils/helpers.ts
Direct MCP Call:
mcp__stellarion__get_code_element name:processData file:src/utils/helpers.ts
Returns: The processData function from that specific file (useful when multiple functions share the same name)
Natural Language:
Show me the UserConfig type
Direct MCP Call:
mcp__stellarion__get_code_element name:UserConfig type:type includeComments:true
Returns: The complete type definition with documentation
Natural Language:
Show me the ApiResponse interface
Direct MCP Call:
mcp__stellarion__get_code_element name:ApiResponse type:type
Returns: Interface definition with all properties
Natural Language:
Show me the entire config.ts file
Direct MCP Call:
mcp__stellarion__get_code_element name:"*" file:src/config.ts
Returns: Complete file content (special * wildcard)
Results include:
| Field | Description |
|---|---|
| Source code | Complete implementation of the element |
| File path | Full path to the file |
| Line range | Start and end line numbers |
| Element type | Function, class, method, etc. |
| Visibility | Public, private, protected, exported |
| Parameters | Parameter names, types, and documentation |
| Return type | Function return type |
| Properties | Class/interface properties with types |
| Complexity | Cyclomatic and cognitive complexity scores |
| Documentation | JSDoc/docstring comments if present |
| Type | Description | Examples |
|---|---|---|
function | Standalone functions | function foo(), const foo = () => |
class | Class definitions | class UserService |
method | Class methods | class.method() |
type | Type aliases and interfaces | type Config = {}, interface User |
enum | Enumerations | enum Status |
variable | Variable declarations | const config = {} |
constant | Constant declarations | const MAX_SIZE = 100 |
auto | Auto-detect element type | Any of the above |
type: "auto" if you're not sure of the element type - Stellarion will find itincludeComments: true to get documentation and understand the purposefile when multiple elements share the same name across the codebaseincludeSignature: true for detailed parameter informationsearch_pattern to find elements, then get_code_element to extract themIf the same name exists in multiple files:
file parameter to get the exact element you wantsearch_pattern to see all locations, then extract the specific one