get_class
Fetch ABAP class source code from SAP systems with class name. Optionally specify system ID to choose which system to query. Supports code review, analysis, and automation tasks.
Instructions
Fetch ABAP class source code from SAP system
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Class name (e.g. CL_ABAP_TYPEDESCR) | |
| system_id | No | SAP system ID (e.g. DEV). Omit to use default system. |
Implementation Reference
- src/mcp-server.ts:1023-1029 (handler)Handler for the 'get_class' tool: validates input with NameSchema, then calls AdtClient.getSource() with the ADT URI for ABAP classes to fetch the source code.
case "get_class": { const { name: className } = NameSchema.parse(args); const source = await client.getSource( `/sap/bc/adt/oo/classes/${encodeURIComponent(className.toUpperCase())}/source/main` ); return { content: [{ type: "text", text: source }] }; } - src/mcp-server.ts:232-239 (registration)Registration of the 'get_class' tool in the ListToolsRequestSchema handler. Defines name, description, and input schema requiring 'name' with optional system_id.
name: "get_class", description: "Fetch ABAP class source code from SAP system", inputSchema: { type: "object" as const, properties: { name: { type: "string", description: "Class name (e.g. CL_ABAP_TYPEDESCR)" }, ...SYSTEM_ID_PROP }, required: ["name"], }, }, - src/mcp-server.ts:13-13 (schema)Input validation schema used by get_class: parses the 'name' field as a string.
const NameSchema = z.object({ name: z.string() }); - src/adt-client.ts:56-62 (helper)Helper method on AdtClient that performs a GET request with Accept: text/plain and returns the raw source text. Used by the get_class handler.
async getSource(path: string): Promise<string> { const response = await this.http.get<string>(path, { headers: { Accept: "text/plain" }, responseType: "text", }); return response.data; }