list_cross_traces
Retrieve captured ABAP Cross Trace results for a user. Shows trace IDs, request types (OData V2/V4, URL, RFC), and service names to analyze trace data.
Instructions
List captured ABAP Cross Trace results for a user. Shows trace IDs, request types (OData V2/V4, URL, RFC, etc.), and service names.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user | No | SAP username (default: current user) | |
| system_id | No | SAP system ID (e.g. DEV). Omit to use default system. |
Implementation Reference
- src/mcp-server.ts:910-920 (registration)Registration of the 'list_cross_traces' tool in the MCP tool list, including its description and input schema (takes optional 'user' parameter).
name: "list_cross_traces", description: "List captured ABAP Cross Trace results for a user. Shows trace IDs, request types (OData V2/V4, URL, RFC, etc.), and service names.", inputSchema: { type: "object" as const, properties: { user: { type: "string", description: "SAP username (default: current user)" }, ...SYSTEM_ID_PROP, }, required: [], }, }, - src/mcp-server.ts:1472-1506 (handler)Handler for 'list_cross_traces' tool. Parses args with CrossTraceUserSchema, calls client.listCrossTraces(), parses XML response to extract trace IDs, request types, request names, and record counts, then formats output with top services summary.
case "list_cross_traces": { const { user } = CrossTraceUserSchema.parse(args); const result = await client.listCrossTraces(user); const traces = [...result.matchAll(/<sxt:trace>([\s\S]*?)<\/sxt:trace>/g)]; if (traces.length === 0) { return { content: [{ type: "text", text: "No cross traces found." }] }; } const typeMap: Record<string, string> = { T: "Transaction", C: "RFC", U: "URL", S: "Submit", B: "Batch", V: "Update", O: "OData V2", "4": "OData V4", D: "Daemon", Q: "SQL Service", }; const counts: Record<string, number> = {}; const traceLines: string[] = []; for (const [, t] of traces) { const tid = t.match(/<sxt:traceId>([^<]+)<\/sxt:traceId>/)?.[1] ?? "?"; const rtype = t.match(/<sxt:requestType>([^<]*)<\/sxt:requestType>/)?.[1] ?? "?"; const rname = t.match(/<sxt:requestName>([^<]*)<\/sxt:requestName>/)?.[1] ?? "?"; const nrecs = t.match(/<sxt:numberOfRecords>([^<]+)<\/sxt:numberOfRecords>/)?.[1] ?? "0"; const typeName = typeMap[rtype] ?? rtype; counts[rname] = (counts[rname] || 0) + 1; traceLines.push(` ${tid} ${typeName.padEnd(10)} ${rname} (${nrecs} records)`); } const summary = Object.entries(counts) .sort((a, b) => b[1] - a[1]) .slice(0, 10) .map(([cname, count]) => ` ${cname}: ${count}`) .join("\n"); const lines = [ `${traces.length} cross trace(s):\n`, `Top services:\n${summary}\n`, `All traces:`, ...traceLines, ]; return { content: [{ type: "text", text: lines.join("\n") }] }; } - src/mcp-server.ts:113-114 (schema)Input schema 'CrossTraceUserSchema' used to validate arguments for the list_cross_traces handler (optional 'user' field).
const CrossTraceUserSchema = z.object({ user: z.string().optional() }); const CrossTraceRecordsSchema = z.object({ trace_id: z.string() }); - src/adt-client.ts:405-412 (helper)Helper method 'listCrossTraces' in AdtClient that makes a GET request to /sap/bc/adt/crosstrace/traces?traceUser=... to fetch cross traces from the SAP system.
async listCrossTraces(user?: string): Promise<string> { const traceUser = (user ?? this.config.username).toUpperCase(); const response = await this.http.get<string>( `/sap/bc/adt/crosstrace/traces?traceUser=${encodeURIComponent(traceUser)}`, { headers: { Accept: "application/vnd.sap.adt.crosstrace.traces.v1+xml" }, responseType: "text" } ); return response.data; }