enable_st05_trace
Enable ST05 performance tracing for a SAP user to diagnose database and buffer issues. Activate SQL, buffer, enqueue, RFC, HTTP, or authorization traces with optional ABAP stack traces. Trace runs continuously until stopped.
Instructions
Enable ST05 performance trace (SQL trace, buffer trace, etc.) for a specific user. By default enables SQL trace with stack trace. The trace runs continuously until disabled with disable_st05_trace.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user | No | SAP username to trace (default: current user) | |
| sql | No | Enable SQL trace (default: true) | |
| buffer | No | Enable buffer trace (default: false) | |
| enqueue | No | Enable enqueue trace (default: false) | |
| rfc | No | Enable RFC trace (default: false) | |
| http | No | Enable HTTP trace (default: false) | |
| auth | No | Enable authorization trace (default: false) | |
| stack_trace | No | Include ABAP stack traces (default: true) | |
| system_id | No | SAP system ID (e.g. DEV). Omit to use default system. |
Implementation Reference
- src/mcp-server.ts:1339-1371 (handler)Handler for enable_st05_trace - parses args with EnableSt05Schema, calls client.enableSt05Trace(), parses XML response, and returns formatted output
case "enable_st05_trace": { const opts = EnableSt05Schema.parse(args); const result = await client.enableSt05Trace({ user: opts.user, sql: opts.sql, buffer: opts.buffer, enqueue: opts.enqueue, rfc: opts.rfc, http: opts.http, auth: opts.auth, stackTrace: opts.stack_trace, }); const sqlOn = result.match(/<ts:sqlOn>(\w+)<\/ts:sqlOn>/)?.[1]; const bufOn = result.match(/<ts:bufOn>(\w+)<\/ts:bufOn>/)?.[1]; const enqOn = result.match(/<ts:enqOn>(\w+)<\/ts:enqOn>/)?.[1]; const rfcOn = result.match(/<ts:rfcOn>(\w+)<\/ts:rfcOn>/)?.[1]; const httpOn = result.match(/<ts:httpOn>(\w+)<\/ts:httpOn>/)?.[1]; const authOn = result.match(/<ts:authOn>(\w+)<\/ts:authOn>/)?.[1]; const stackOn = result.match(/<ts:stackTraceOn>(\w+)<\/ts:stackTraceOn>/)?.[1]; const traceUser = result.match(/<ts:traceUser>([^<]*)<\/ts:traceUser>/)?.[1] || "(all)"; const lines = [ "ST05 trace enabled:", ` User: ${traceUser}`, ` SQL: ${sqlOn}`, ` Buffer: ${bufOn}`, ` Enqueue: ${enqOn}`, ` RFC: ${rfcOn}`, ` HTTP: ${httpOn}`, ` Auth: ${authOn}`, ` Stack trace: ${stackOn}`, ]; return { content: [{ type: "text", text: lines.join("\n") }] }; } - src/mcp-server.ts:91-100 (schema)Zod schema for enable_st05_trace input validation
const EnableSt05Schema = z.object({ user: z.string().optional(), sql: z.boolean().optional(), buffer: z.boolean().optional(), enqueue: z.boolean().optional(), rfc: z.boolean().optional(), http: z.boolean().optional(), auth: z.boolean().optional(), stack_trace: z.boolean().optional(), }); - src/mcp-server.ts:834-851 (registration)Tool registration for enable_st05_trace in ListToolsRequestSchema handler
name: "enable_st05_trace", description: "Enable ST05 performance trace (SQL trace, buffer trace, etc.) for a specific user. By default enables SQL trace with stack trace. The trace runs continuously until disabled with disable_st05_trace.", inputSchema: { type: "object" as const, properties: { user: { type: "string", description: "SAP username to trace (default: current user)" }, sql: { type: "boolean", description: "Enable SQL trace (default: true)" }, buffer: { type: "boolean", description: "Enable buffer trace (default: false)" }, enqueue: { type: "boolean", description: "Enable enqueue trace (default: false)" }, rfc: { type: "boolean", description: "Enable RFC trace (default: false)" }, http: { type: "boolean", description: "Enable HTTP trace (default: false)" }, auth: { type: "boolean", description: "Enable authorization trace (default: false)" }, stack_trace: { type: "boolean", description: "Include ABAP stack traces (default: true)" }, ...SYSTEM_ID_PROP, }, required: [], }, }, - src/adt-client.ts:1455-1516 (helper)Helper method in AdtClient that sends ST05 trace state XML to the SAP ADT ST05 endpoint
async enableSt05Trace(options: { user?: string; sql?: boolean; buffer?: boolean; enqueue?: boolean; rfc?: boolean; http?: boolean; auth?: boolean; stackTrace?: boolean; }): Promise<string> { const state = await this.getSt05TraceState(); const instanceMatch = state.match(/<ts:instance>([^<]+)<\/ts:instance>/); const hostMatch = state.match(/<ts:host>([^<]+)<\/ts:host>/); const instance = instanceMatch?.[1] ?? ""; const host = hostMatch?.[1] ?? ""; const traceUser = (options.user ?? this.config.username).toUpperCase(); const xml = `<?xml version="1.0" encoding="UTF-8"?> <ts:traceStateInstanceTable xmlns:ts="http://www.sap.com/adt/tools/performance/tracestate"> <ts:traceStateInstance> <ts:instance>${this.escapeXml(instance)}</ts:instance> <ts:host>${this.escapeXml(host)}</ts:host> <ts:isLocal>true</ts:isLocal> <ts:isSelected>true</ts:isSelected> <ts:modificationUser>${this.escapeXml(this.config.username.toUpperCase())}</ts:modificationUser> <ts:modificationDateTime>${new Date().toISOString().replace(/\.\d+Z$/, "Z")}</ts:modificationDateTime> <ts:traceTypes> <ts:sqlOn>${options.sql !== false}</ts:sqlOn> <ts:bufOn>${options.buffer ?? false}</ts:bufOn> <ts:enqOn>${options.enqueue ?? false}</ts:enqOn> <ts:rfcOn>${options.rfc ?? false}</ts:rfcOn> <ts:httpOn>${options.http ?? false}</ts:httpOn> <ts:apcOn>false</ts:apcOn> <ts:amcOn>false</ts:amcOn> <ts:authOn>${options.auth ?? false}</ts:authOn> </ts:traceTypes> <ts:traceProperties> <ts:includeMissingTableNameOn>false</ts:includeMissingTableNameOn> <ts:authErrorsOnly>false</ts:authErrorsOnly> <ts:stackTraceOn>${options.stackTrace !== false}</ts:stackTraceOn> <ts:includedTables/> <ts:excludedTables/> </ts:traceProperties> <ts:traceFilter> <ts:traceUser>${this.escapeXml(traceUser)}</ts:traceUser> <ts:transactionCode/> <ts:program/> <ts:rfcFunction/> <ts:url/> <ts:wpId/> </ts:traceFilter> </ts:traceStateInstance> </ts:traceStateInstanceTable>`; return (await this.putWithCsrf( "/sap/bc/adt/st05/trace/state", xml, "application/vnd.sap.adt.perf.trace.state.v1+xml", "application/vnd.sap.adt.perf.trace.state.v1+xml" )).data as string; }