GetAbapSystemSymbols
Resolve ABAP symbols from source code to obtain types, scopes, descriptions, and package information for semantic analysis.
Instructions
[read-only] Resolve ABAP symbols from semantic analysis with SAP system information including types, scopes, descriptions, and packages.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ABAP source code to analyze and resolve symbols for | |
| filePath | No | Optional file path to write the result to |
Implementation Reference
- Main handler function that executes the GetAbapSystemSymbols tool logic. Performs semantic analysis on ABAP code using SimpleAbapSemanticAnalyzer, then resolves symbols with SAP system info using AbapSystemSymbolResolver. Returns symbols with system metadata and resolution statistics.
export async function handleGetAbapSystemSymbols( context: HandlerContext, args: any, ) { const { logger } = context; try { if (!args?.code) { throw new McpError(ErrorCode.InvalidParams, 'ABAP code is required'); } logger?.debug('Running semantic analysis and system symbol resolution'); // First, perform semantic analysis const analyzer = new SimpleAbapSemanticAnalyzer(); const semanticResult = analyzer.analyze(args.code); // Then, resolve symbols with SAP system information const resolver = new AbapSystemSymbolResolver(); const { resolvedSymbols, stats } = await resolver.resolveSymbols( context, semanticResult.symbols, ); logger?.info( `Resolved ${stats.resolvedSymbols}/${stats.totalSymbols} symbols from system`, ); const result: AbapSystemSymbolsResult = { symbols: resolvedSymbols, dependencies: semanticResult.dependencies, errors: semanticResult.errors, scopes: semanticResult.scopes, systemResolutionStats: stats, }; const response = { isError: false, content: [ { type: 'json', json: result, }, ], }; if (args.filePath) { logger?.debug( `Writing system symbol resolution result to file: ${args.filePath}`, ); writeResultToFile(JSON.stringify(result, null, 2), args.filePath); } return response; } catch (error) { logger?.error('Failed to resolve ABAP system symbols', error as any); return { isError: true, content: [ { type: 'text', text: error instanceof Error ? error.message : String(error), }, ], }; } } - Tool definition/schema for GetAbapSystemSymbols. Defines the tool name, description, availability (onprem + cloud), and inputSchema requiring 'code' (ABAP source string) with optional 'filePath' for writing results.
export const TOOL_DEFINITION = { name: 'GetAbapSystemSymbols', available_in: ['onprem', 'cloud'] as const, description: '[read-only] Resolve ABAP symbols from semantic analysis with SAP system information including types, scopes, descriptions, and packages.', inputSchema: { type: 'object', properties: { code: { type: 'string', description: 'ABAP source code to analyze and resolve symbols for', }, filePath: { type: 'string', description: 'Optional file path to write the result to', }, }, required: ['code'], }, } as const; - src/lib/handlers/groups/SystemHandlersGroup.ts:27-30 (registration)Import of the TOOL_DEFINITION and handler from the implementation file into the SystemHandlersGroup.
import { TOOL_DEFINITION as GetAbapSystemSymbols_Tool, handleGetAbapSystemSymbols, } from '../../../handlers/system/readonly/handleGetAbapSystemSymbols'; - src/lib/handlers/groups/SystemHandlersGroup.ts:208-211 (registration)Registration of GetAbapSystemSymbols tool with its definition and handler in the SystemHandlersGroup tool map.
{ toolDefinition: GetAbapSystemSymbols_Tool, handler: (args: any) => handleGetAbapSystemSymbols(this.context, args), }, - SimpleAbapSemanticAnalyzer class that parses ABAP source code to extract symbols (classes, methods, variables, constants, types, forms, functions, includes, interfaces), scopes, dependencies, and errors from textual analysis.
class SimpleAbapSemanticAnalyzer { private symbols: AbapSymbolInfo[] = []; private scopes: AbapScopeInfo[] = []; private dependencies: string[] = []; private errors: AbapParseError[] = []; private currentScope: string = 'global'; public analyze(code: string): { symbols: AbapSymbolInfo[]; dependencies: string[]; errors: AbapParseError[]; scopes: AbapScopeInfo[]; } { // Reset state this.symbols = []; this.scopes = []; this.dependencies = []; this.errors = []; this.currentScope = 'global'; try { this.analyzeCode(code); } catch (error) { this.errors.push({ message: error instanceof Error ? error.message : String(error), line: 1, column: 1, severity: 'error', }); } return { symbols: this.symbols, dependencies: this.dependencies, errors: this.errors, scopes: this.scopes, }; } private analyzeCode(code: string): void {