@babamba2/abap-mcp-adt-powerup 4.8.10 → 4.8.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.ko.md +3 -3
  3. package/README.md +6 -6
  4. package/dist/handlers/common/high/handleActivateObjects.d.ts.map +1 -1
  5. package/dist/handlers/common/high/handleActivateObjects.js +1 -0
  6. package/dist/handlers/common/high/handleActivateObjects.js.map +1 -1
  7. package/dist/handlers/common/low/handleActivateObject.d.ts.map +1 -1
  8. package/dist/handlers/common/low/handleActivateObject.js +1 -0
  9. package/dist/handlers/common/low/handleActivateObject.js.map +1 -1
  10. package/dist/handlers/gui_status/high/handleCreateGuiStatus.d.ts +1 -1
  11. package/dist/handlers/gui_status/high/handleCreateGuiStatus.d.ts.map +1 -1
  12. package/dist/handlers/gui_status/high/handleCreateGuiStatus.js +12 -5
  13. package/dist/handlers/gui_status/high/handleCreateGuiStatus.js.map +1 -1
  14. package/dist/handlers/gui_status/high/handlePatchGuiStatus.d.ts.map +1 -1
  15. package/dist/handlers/gui_status/high/handlePatchGuiStatus.js +3 -1
  16. package/dist/handlers/gui_status/high/handlePatchGuiStatus.js.map +1 -1
  17. package/dist/handlers/gui_status/high/handleUpdateGuiStatus.d.ts.map +1 -1
  18. package/dist/handlers/gui_status/high/handleUpdateGuiStatus.js +1 -1
  19. package/dist/handlers/gui_status/high/handleUpdateGuiStatus.js.map +1 -1
  20. package/dist/handlers/gui_status/low/handleCreateGuiStatus.d.ts +1 -1
  21. package/dist/handlers/gui_status/low/handleCreateGuiStatus.d.ts.map +1 -1
  22. package/dist/handlers/gui_status/low/handleCreateGuiStatus.js +12 -7
  23. package/dist/handlers/gui_status/low/handleCreateGuiStatus.js.map +1 -1
  24. package/dist/handlers/gui_status/readonly/handleGetGuiStatusList.d.ts +15 -0
  25. package/dist/handlers/gui_status/readonly/handleGetGuiStatusList.d.ts.map +1 -1
  26. package/dist/handlers/gui_status/readonly/handleGetGuiStatusList.js +90 -35
  27. package/dist/handlers/gui_status/readonly/handleGetGuiStatusList.js.map +1 -1
  28. package/dist/handlers/system/readonly/handleGetInactiveObjects.d.ts +1 -1
  29. package/dist/handlers/system/readonly/handleGetInactiveObjects.js +1 -1
  30. package/dist/handlers/system/readonly/handleGetInactiveObjects.js.map +1 -1
  31. package/dist/handlers/system/readonly/handleGetJobUsage.d.ts +48 -0
  32. package/dist/handlers/system/readonly/handleGetJobUsage.d.ts.map +1 -0
  33. package/dist/handlers/system/readonly/handleGetJobUsage.js +87 -0
  34. package/dist/handlers/system/readonly/handleGetJobUsage.js.map +1 -0
  35. package/dist/handlers/system/readonly/handleGetTcodeUsage.d.ts +56 -0
  36. package/dist/handlers/system/readonly/handleGetTcodeUsage.d.ts.map +1 -0
  37. package/dist/handlers/system/readonly/handleGetTcodeUsage.js +96 -0
  38. package/dist/handlers/system/readonly/handleGetTcodeUsage.js.map +1 -0
  39. package/dist/handlers/system/readonly/handleGetTransaction.d.ts +32 -6
  40. package/dist/handlers/system/readonly/handleGetTransaction.d.ts.map +1 -1
  41. package/dist/handlers/system/readonly/handleGetTransaction.js +112 -50
  42. package/dist/handlers/system/readonly/handleGetTransaction.js.map +1 -1
  43. package/dist/handlers/system/readonly/handleGetUsageSnippets.d.ts +97 -0
  44. package/dist/handlers/system/readonly/handleGetUsageSnippets.d.ts.map +1 -0
  45. package/dist/handlers/system/readonly/handleGetUsageSnippets.js +204 -0
  46. package/dist/handlers/system/readonly/handleGetUsageSnippets.js.map +1 -0
  47. package/dist/handlers/system/readonly/handleGetWhereUsed.d.ts +77 -12
  48. package/dist/handlers/system/readonly/handleGetWhereUsed.d.ts.map +1 -1
  49. package/dist/handlers/system/readonly/handleGetWhereUsed.js +171 -20
  50. package/dist/handlers/system/readonly/handleGetWhereUsed.js.map +1 -1
  51. package/dist/handlers/system/readonly/handleReloadProfile.d.ts +4 -3
  52. package/dist/handlers/system/readonly/handleReloadProfile.d.ts.map +1 -1
  53. package/dist/handlers/system/readonly/handleReloadProfile.js +13 -5
  54. package/dist/handlers/system/readonly/handleReloadProfile.js.map +1 -1
  55. package/dist/handlers/transport/readonly/handleGetTransport.d.ts +3 -0
  56. package/dist/handlers/transport/readonly/handleGetTransport.d.ts.map +1 -1
  57. package/dist/handlers/transport/readonly/handleGetTransport.js +24 -0
  58. package/dist/handlers/transport/readonly/handleGetTransport.js.map +1 -1
  59. package/dist/handlers/transport/readonly/handleListTransports.d.ts +2 -1
  60. package/dist/handlers/transport/readonly/handleListTransports.d.ts.map +1 -1
  61. package/dist/handlers/transport/readonly/handleListTransports.js +17 -7
  62. package/dist/handlers/transport/readonly/handleListTransports.js.map +1 -1
  63. package/dist/lib/cuaSchema.d.ts +16 -0
  64. package/dist/lib/cuaSchema.d.ts.map +1 -1
  65. package/dist/lib/cuaSchema.js +74 -1
  66. package/dist/lib/cuaSchema.js.map +1 -1
  67. package/dist/lib/handlers/groups/ReadOnlyHandlersGroup.d.ts.map +1 -1
  68. package/dist/lib/handlers/groups/ReadOnlyHandlersGroup.js +10 -0
  69. package/dist/lib/handlers/groups/ReadOnlyHandlersGroup.js.map +1 -1
  70. package/dist/lib/handlers/groups/SystemHandlersGroup.d.ts.map +1 -1
  71. package/dist/lib/handlers/groups/SystemHandlersGroup.js +5 -0
  72. package/dist/lib/handlers/groups/SystemHandlersGroup.js.map +1 -1
  73. package/dist/lib/legacyLockHint.d.ts +15 -0
  74. package/dist/lib/legacyLockHint.d.ts.map +1 -0
  75. package/dist/lib/legacyLockHint.js +34 -0
  76. package/dist/lib/legacyLockHint.js.map +1 -0
  77. package/dist/lib/legacyTableRead.d.ts +1 -1
  78. package/dist/lib/legacyTableRead.d.ts.map +1 -1
  79. package/dist/lib/legacyTableRead.js +4 -0
  80. package/dist/lib/legacyTableRead.js.map +1 -1
  81. package/dist/lib/legacyTransport.d.ts +78 -0
  82. package/dist/lib/legacyTransport.d.ts.map +1 -0
  83. package/dist/lib/legacyTransport.js +233 -0
  84. package/dist/lib/legacyTransport.js.map +1 -0
  85. package/dist/lib/localGroupActivation.d.ts +22 -0
  86. package/dist/lib/localGroupActivation.d.ts.map +1 -1
  87. package/dist/lib/localGroupActivation.js +97 -2
  88. package/dist/lib/localGroupActivation.js.map +1 -1
  89. package/dist/lib/nativeRfc.d.ts.map +1 -1
  90. package/dist/lib/nativeRfc.js +5 -0
  91. package/dist/lib/nativeRfc.js.map +1 -1
  92. package/dist/lib/odataRfc.d.ts +48 -0
  93. package/dist/lib/odataRfc.d.ts.map +1 -1
  94. package/dist/lib/odataRfc.js +73 -0
  95. package/dist/lib/odataRfc.js.map +1 -1
  96. package/dist/lib/profile.d.ts.map +1 -1
  97. package/dist/lib/profile.js +34 -0
  98. package/dist/lib/profile.js.map +1 -1
  99. package/dist/lib/profileEvents.d.ts +16 -0
  100. package/dist/lib/profileEvents.d.ts.map +1 -0
  101. package/dist/lib/profileEvents.js +29 -0
  102. package/dist/lib/profileEvents.js.map +1 -0
  103. package/dist/lib/rfcBackend.d.ts +2 -0
  104. package/dist/lib/rfcBackend.d.ts.map +1 -1
  105. package/dist/lib/rfcBackend.js +20 -4
  106. package/dist/lib/rfcBackend.js.map +1 -1
  107. package/dist/lib/soapRfc.d.ts +17 -0
  108. package/dist/lib/soapRfc.d.ts.map +1 -1
  109. package/dist/lib/soapRfc.js +39 -0
  110. package/dist/lib/soapRfc.js.map +1 -1
  111. package/dist/lib/utils.d.ts +12 -0
  112. package/dist/lib/utils.d.ts.map +1 -1
  113. package/dist/lib/utils.js +15 -1
  114. package/dist/lib/utils.js.map +1 -1
  115. package/dist/lib/zrfcProxy.d.ts.map +1 -1
  116. package/dist/lib/zrfcProxy.js +5 -0
  117. package/dist/lib/zrfcProxy.js.map +1 -1
  118. package/dist/server/BaseMcpServer.d.ts +11 -0
  119. package/dist/server/BaseMcpServer.d.ts.map +1 -1
  120. package/dist/server/BaseMcpServer.js +69 -2
  121. package/dist/server/BaseMcpServer.js.map +1 -1
  122. package/dist/server/StdioServer.d.ts.map +1 -1
  123. package/dist/server/StdioServer.js +9 -0
  124. package/dist/server/StdioServer.js.map +1 -1
  125. package/package.json +5 -5
@@ -1,14 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TOOL_DEFINITION = void 0;
4
+ exports.parseTransactionParam = parseTransactionParam;
5
+ exports.buildTransactionInfo = buildTransactionInfo;
4
6
  exports.handleGetTransaction = handleGetTransaction;
5
- // import { McpError, ErrorCode } from '../../../lib/utils';
6
- const fast_xml_parser_1 = require("fast-xml-parser");
7
- // import { createAdtClient } from '../../../lib/clients';
7
+ const clients_1 = require("../../../lib/clients");
8
+ const legacyTableRead_1 = require("../../../lib/legacyTableRead");
9
+ const handleGetSqlQuery_1 = require("./handleGetSqlQuery");
8
10
  exports.TOOL_DEFINITION = {
9
11
  name: 'GetTransaction',
10
12
  available_in: ['onprem', 'cloud'],
11
- description: '[read-only] Retrieve ABAP transaction (t-code) details — program, screen, authorization object, and transaction type (dialog, report, OO).',
13
+ description: '[read-only] Retrieve ABAP transaction (t-code) details from TSTC / TSTCP — program, screen, and kind (program, parameter transaction with its target t-code and parameters such as an SM30 view, variant transaction). Pass transaction_names for many t-codes in one call.',
12
14
  inputSchema: {
13
15
  type: 'object',
14
16
  properties: {
@@ -16,58 +18,118 @@ exports.TOOL_DEFINITION = {
16
18
  type: 'string',
17
19
  description: 'Name of the ABAP transaction',
18
20
  },
21
+ transaction_names: {
22
+ type: 'array',
23
+ items: { type: 'string' },
24
+ description: 'Several transactions in one call (e.g. ["VA01","ZMY_TCODE"]).',
25
+ },
19
26
  },
20
- required: ['transaction_name'],
21
27
  },
22
28
  };
23
- function _parseTransactionXml(xml) {
24
- const parser = new fast_xml_parser_1.XMLParser({
25
- ignoreAttributes: false,
26
- attributeNamePrefix: '',
27
- parseAttributeValue: true,
28
- trimValues: true,
29
+ const quoteList = (names) => names.map((n) => `'${n.replace(/'/g, "''")}'`).join(',');
30
+ /** SELECT through the ADT data preview, or ZMCP_ADT_DISPATCH TABLE_READ on BASIS < 7.50. */
31
+ async function selectRows(connection, logger, table, fields, where, maxRows) {
32
+ const sql = `SELECT ${fields.join(', ')} FROM ${table} WHERE ${where}`;
33
+ try {
34
+ const response = await (0, clients_1.createAdtClient)(connection, logger)
35
+ .getUtils()
36
+ .getSqlQuery({ sql_query: sql, row_number: maxRows });
37
+ return (0, handleGetSqlQuery_1.parseSqlQueryXml)(response.data, sql, maxRows, logger).rows;
38
+ }
39
+ catch (e) {
40
+ if (!(0, legacyTableRead_1.isLegacyUnsupported)(e))
41
+ throw e;
42
+ const res = await (0, legacyTableRead_1.legacyTableRead)(connection, {
43
+ table,
44
+ fields,
45
+ where,
46
+ maxRows,
47
+ sqlQuery: sql,
48
+ });
49
+ return res.rows;
50
+ }
51
+ }
52
+ /** '/*SM30 VIEWNAME=ZX;UPDATE=X;' → { target: 'SM30', parameters: { VIEWNAME: 'ZX', UPDATE: 'X' } } */
53
+ function parseTransactionParam(param) {
54
+ const p = String(param ?? '').trim();
55
+ if (p.startsWith('@'))
56
+ return { kind: 'variant' };
57
+ const m = /^\/[*N](\S+)\s*(.*)$/i.exec(p);
58
+ if (!m)
59
+ return { kind: null };
60
+ const parameters = {};
61
+ for (const part of m[2].split(';')) {
62
+ const eq = part.indexOf('=');
63
+ if (eq > 0)
64
+ parameters[part.slice(0, eq).trim().toUpperCase()] = part
65
+ .slice(eq + 1)
66
+ .trim();
67
+ }
68
+ return { kind: 'parameter', target: m[1].toUpperCase(), parameters };
69
+ }
70
+ function buildTransactionInfo(names, tstc, tstcp) {
71
+ const byCode = new Map(tstc.map((r) => [String(r.TCODE).toUpperCase(), r]));
72
+ const paramBy = new Map(tstcp.map((r) => [String(r.TCODE).toUpperCase(), String(r.PARAM ?? '')]));
73
+ return names.map((tcode) => {
74
+ const row = byCode.get(tcode);
75
+ if (!row)
76
+ return { tcode, found: false };
77
+ const info = { tcode, found: true, kind: 'program' };
78
+ const program = String(row.PGMNA ?? '').trim();
79
+ const screen = String(row.DYPNO ?? '').trim();
80
+ if (program)
81
+ info.program = program;
82
+ if (screen)
83
+ info.screen = screen;
84
+ const param = paramBy.get(tcode);
85
+ if (param) {
86
+ info.param = param;
87
+ const parsed = parseTransactionParam(param);
88
+ if (parsed.kind)
89
+ info.kind = parsed.kind;
90
+ if (parsed.target)
91
+ info.target_tcode = parsed.target;
92
+ if (parsed.parameters && Object.keys(parsed.parameters).length)
93
+ info.parameters = parsed.parameters;
94
+ }
95
+ return info;
29
96
  });
30
- const result = parser.parse(xml);
31
- // ADT Transaction XML (opr:objectProperties)
32
- if (result['opr:objectProperties']?.['opr:object']) {
33
- const obj = result['opr:objectProperties']['opr:object'];
97
+ }
98
+ async function handleGetTransaction(context, args) {
99
+ const { connection, logger } = context;
100
+ try {
101
+ const names = [
102
+ ...(Array.isArray(args?.transaction_names) ? args.transaction_names : []),
103
+ ...(args?.transaction_name ? [args.transaction_name] : []),
104
+ ]
105
+ .map((n) => String(n).trim().toUpperCase())
106
+ .filter(Boolean);
107
+ const unique = [...new Set(names)];
108
+ if (!unique.length)
109
+ throw new Error('transaction_name or transaction_names is required');
110
+ const where = `TCODE IN (${quoteList(unique)})`;
111
+ const tstc = await selectRows(connection, logger, 'TSTC', ['TCODE', 'PGMNA', 'DYPNO'], where, unique.length + 1);
112
+ const tstcp = await selectRows(connection, logger, 'TSTCP', ['TCODE', 'PARAM'], where, unique.length + 1);
113
+ const transactions = buildTransactionInfo(unique, tstc, tstcp);
114
+ const payload = transactions.length === 1 && !Array.isArray(args?.transaction_names)
115
+ ? { success: true, ...transactions[0] }
116
+ : { success: true, transactions };
34
117
  return {
35
- name: obj.name,
36
- objectType: 'transaction',
37
- description: obj.text,
38
- package: obj.package,
39
- type: obj.type,
118
+ isError: false,
119
+ content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }],
120
+ };
121
+ }
122
+ catch (error) {
123
+ logger?.error('GetTransaction failed', error);
124
+ return {
125
+ isError: true,
126
+ content: [
127
+ {
128
+ type: 'text',
129
+ text: `ADT error: ${String(error?.message ?? error)}`,
130
+ },
131
+ ],
40
132
  };
41
133
  }
42
- // fallback: return raw
43
- return { raw: result };
44
- }
45
- async function handleGetTransaction(context, _args) {
46
- const { connection, logger } = context;
47
- // try {
48
- // if (!args?.transaction_name) {
49
- // throw new McpError(ErrorCode.InvalidParams, 'Transaction name is required');
50
- // }
51
- // logger?.info(`Fetching transaction info for ${args.transaction_name}`);
52
- // const client = createAdtClient(connection);
53
- // const result = await client.readTransaction(args.transaction_name);
54
- // return result;
55
- // } catch (error) {
56
- // logger?.error(`Failed to fetch transaction ${args?.transaction_name}`, error as any);
57
- // // MCP-compliant error response: always return content[] with type "text"
58
- // return {
59
- // isError: true,
60
- // content: [
61
- // {
62
- // type: "text",
63
- // text: `ADT error: ${String(error)}`
64
- // }
65
- // ]
66
- // };
67
- // }
68
- return {
69
- isError: false,
70
- content: [{ type: 'json', json: { message: 'Not implemented' } }],
71
- };
72
134
  }
73
135
  //# sourceMappingURL=handleGetTransaction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"handleGetTransaction.js","sourceRoot":"","sources":["../../../../src/handlers/system/readonly/handleGetTransaction.ts"],"names":[],"mappings":";;;AA8CA,oDA8BC;AA5ED,4DAA4D;AAC5D,qDAA4C;AAE5C,0DAA0D;AAC7C,QAAA,eAAe,GAAG;IAC7B,IAAI,EAAE,gBAAgB;IACtB,YAAY,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAU;IAC1C,WAAW,EACT,4IAA4I;IAC9I,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,gBAAgB,EAAE;gBAChB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,8BAA8B;aAC5C;SACF;QACD,QAAQ,EAAE,CAAC,kBAAkB,CAAC;KAC/B;CACO,CAAC;AAEX,SAAS,oBAAoB,CAAC,GAAW;IACvC,MAAM,MAAM,GAAG,IAAI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CAAE,KAAe,EAAE,OAAO,IAAI,KAAK,CAAC,EAAE;iBACjE;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * GetUsageSnippets handler — line-level where-used hits
3
+ * Endpoint: POST /sap/bc/adt/repository/informationsystem/usageSnippets
4
+ *
5
+ * Input is either the object_identifier values returned by GetWhereUsed, or an
6
+ * object (object_name + object_type) for which the where-used search runs first.
7
+ * Requires @babamba2/mcp-abap-adt-clients >= 3.15.0 (getUsageSnippets).
8
+ */
9
+ import type { HandlerContext } from '../../../lib/handlers/interfaces';
10
+ /** Identifiers per usageSnippets POST. Keeps single requests small on large where-used results. */
11
+ export declare const SNIPPET_BATCH_SIZE = 50;
12
+ export declare const TOOL_DEFINITION: {
13
+ readonly name: "GetUsageSnippets";
14
+ readonly available_in: readonly ["onprem", "cloud", "legacy"];
15
+ readonly description: "[read-only] Line-level where-used hits: for each referencing object, the source lines that use the searched object, with uri \".../source/main#start=<line>,<col>\", line, column and the source line. Pass object_identifiers from GetWhereUsed references[].object_identifier, or object_name + object_type to run the where-used search first (customer_only / package filters apply to that search). Works on ECC 7.40 and S/4HANA.";
16
+ readonly inputSchema: {
17
+ readonly type: "object";
18
+ readonly properties: {
19
+ readonly object_identifiers: {
20
+ readonly type: "array";
21
+ readonly items: {
22
+ readonly type: "string";
23
+ };
24
+ readonly description: "object_identifier values from GetWhereUsed references[]. Takes precedence over object_name / object_type.";
25
+ };
26
+ readonly object_name: {
27
+ readonly type: "string";
28
+ readonly description: "Object to search (used when object_identifiers is not given).";
29
+ };
30
+ readonly object_type: {
31
+ readonly type: "string";
32
+ readonly description: "Object type for object_name: class, interface, program, include, functiongroup, function_module, table, structure, dataelement, domain, view, tabletype (ECC), transaction (ECC), messageclass (ECC), package";
33
+ };
34
+ readonly customer_only: {
35
+ readonly type: "boolean";
36
+ readonly description: "With object_name: only customer referencing objects (Z / Y name, or package Z* / Y* / $*). Default: false.";
37
+ readonly default: false;
38
+ };
39
+ readonly package: {
40
+ readonly type: "string";
41
+ readonly description: "With object_name: package filter on the referencing objects (exact, or prefix with trailing *).";
42
+ };
43
+ readonly max_objects: {
44
+ readonly type: "number";
45
+ readonly description: "Cap on referencing objects whose snippets are fetched. Default: 200. truncated=true when more were available.";
46
+ };
47
+ readonly include_context: {
48
+ readonly type: "boolean";
49
+ readonly description: "Include the multi-line context SAP returns per hit (description). Default: false.";
50
+ readonly default: false;
51
+ };
52
+ readonly timeout_ms: {
53
+ readonly type: "number";
54
+ readonly description: "Optional request timeout in ms per SAP request (the where-used search and each snippet batch).";
55
+ };
56
+ };
57
+ readonly required: readonly [];
58
+ };
59
+ };
60
+ interface UsageSnippetsArgs {
61
+ object_identifiers?: string[];
62
+ object_name?: string;
63
+ object_type?: string;
64
+ customer_only?: boolean;
65
+ package?: string;
66
+ max_objects?: number;
67
+ include_context?: boolean;
68
+ timeout_ms?: number;
69
+ }
70
+ /** Split a list into chunks of `size`. */
71
+ export declare function chunk<T>(items: T[], size: number): T[][];
72
+ export declare function handleGetUsageSnippets(context: HandlerContext, args: UsageSnippetsArgs): Promise<{
73
+ isError: boolean;
74
+ content: {
75
+ type: string;
76
+ json: {
77
+ requested_objects: number;
78
+ available_objects: number;
79
+ truncated: boolean;
80
+ returned_objects: number;
81
+ total_snippets: number;
82
+ objects: any[];
83
+ notes: string[];
84
+ object_name?: string | undefined;
85
+ object_type?: string | undefined;
86
+ source: "object_identifiers" | "where_used";
87
+ };
88
+ }[];
89
+ } | {
90
+ isError: boolean;
91
+ content: {
92
+ type: string;
93
+ text: string;
94
+ }[];
95
+ }>;
96
+ export {};
97
+ //# sourceMappingURL=handleGetUsageSnippets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleGetUsageSnippets.d.ts","sourceRoot":"","sources":["../../../../src/handlers/system/readonly/handleGetUsageSnippets.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AASvE,mGAAmG;AACnG,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAGrC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDlB,CAAC;AAEX,UAAU,iBAAiB;IACzB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,0CAA0C;AAC1C,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,CAMxD;AAED,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;GAkJxB"}
@@ -0,0 +1,204 @@
1
+ "use strict";
2
+ /**
3
+ * GetUsageSnippets handler — line-level where-used hits
4
+ * Endpoint: POST /sap/bc/adt/repository/informationsystem/usageSnippets
5
+ *
6
+ * Input is either the object_identifier values returned by GetWhereUsed, or an
7
+ * object (object_name + object_type) for which the where-used search runs first.
8
+ * Requires @babamba2/mcp-abap-adt-clients >= 3.15.0 (getUsageSnippets).
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.TOOL_DEFINITION = exports.SNIPPET_BATCH_SIZE = void 0;
12
+ exports.chunk = chunk;
13
+ exports.handleGetUsageSnippets = handleGetUsageSnippets;
14
+ const clients_1 = require("../../../lib/clients");
15
+ const utils_1 = require("../../../lib/utils");
16
+ const handleGetWhereUsed_1 = require("./handleGetWhereUsed");
17
+ /** Identifiers per usageSnippets POST. Keeps single requests small on large where-used results. */
18
+ exports.SNIPPET_BATCH_SIZE = 50;
19
+ const DEFAULT_MAX_OBJECTS = 200;
20
+ exports.TOOL_DEFINITION = {
21
+ name: 'GetUsageSnippets',
22
+ available_in: ['onprem', 'cloud', 'legacy'],
23
+ description: '[read-only] Line-level where-used hits: for each referencing object, the source lines that use the searched object, with uri ".../source/main#start=<line>,<col>", line, column and the source line. Pass object_identifiers from GetWhereUsed references[].object_identifier, or object_name + object_type to run the where-used search first (customer_only / package filters apply to that search). Works on ECC 7.40 and S/4HANA.',
24
+ inputSchema: {
25
+ type: 'object',
26
+ properties: {
27
+ object_identifiers: {
28
+ type: 'array',
29
+ items: { type: 'string' },
30
+ description: 'object_identifier values from GetWhereUsed references[]. Takes precedence over object_name / object_type.',
31
+ },
32
+ object_name: {
33
+ type: 'string',
34
+ description: 'Object to search (used when object_identifiers is not given).',
35
+ },
36
+ object_type: {
37
+ type: 'string',
38
+ description: `Object type for object_name: ${handleGetWhereUsed_1.SUPPORTED_WHERE_USED_TYPES}`,
39
+ },
40
+ customer_only: {
41
+ type: 'boolean',
42
+ description: 'With object_name: only customer referencing objects (Z / Y name, or package Z* / Y* / $*). Default: false.',
43
+ default: false,
44
+ },
45
+ package: {
46
+ type: 'string',
47
+ description: 'With object_name: package filter on the referencing objects (exact, or prefix with trailing *).',
48
+ },
49
+ max_objects: {
50
+ type: 'number',
51
+ description: `Cap on referencing objects whose snippets are fetched. Default: ${DEFAULT_MAX_OBJECTS}. truncated=true when more were available.`,
52
+ },
53
+ include_context: {
54
+ type: 'boolean',
55
+ description: 'Include the multi-line context SAP returns per hit (description). Default: false.',
56
+ default: false,
57
+ },
58
+ timeout_ms: {
59
+ type: 'number',
60
+ description: 'Optional request timeout in ms per SAP request (the where-used search and each snippet batch).',
61
+ },
62
+ },
63
+ required: [],
64
+ },
65
+ };
66
+ /** Split a list into chunks of `size`. */
67
+ function chunk(items, size) {
68
+ const out = [];
69
+ for (let i = 0; i < items.length; i += size) {
70
+ out.push(items.slice(i, i + size));
71
+ }
72
+ return out;
73
+ }
74
+ async function handleGetUsageSnippets(context, args) {
75
+ const { connection, logger } = context;
76
+ try {
77
+ const timeoutMs = typeof args?.timeout_ms === 'number' && args.timeout_ms > 0
78
+ ? Math.floor(args.timeout_ms)
79
+ : undefined;
80
+ const maxObjects = typeof args?.max_objects === 'number' && args.max_objects > 0
81
+ ? Math.floor(args.max_objects)
82
+ : DEFAULT_MAX_OBJECTS;
83
+ const client = (0, clients_1.createAdtClient)(connection, logger);
84
+ const utils = client.getUtils();
85
+ if (typeof utils.getUsageSnippets !== 'function') {
86
+ throw new Error('GetUsageSnippets needs @babamba2/mcp-abap-adt-clients >= 3.15.0 (getUsageSnippets is missing).');
87
+ }
88
+ // Referencing object (name/type/package) per identifier, when known.
89
+ const meta = new Map();
90
+ let identifiers = [];
91
+ let source = 'object_identifiers';
92
+ const notes = [];
93
+ if (Array.isArray(args?.object_identifiers)) {
94
+ identifiers = args.object_identifiers.filter((id) => typeof id === 'string' && id.trim() !== '');
95
+ }
96
+ if (identifiers.length === 0) {
97
+ if (!args?.object_name || !args?.object_type) {
98
+ throw new utils_1.McpError(utils_1.ErrorCode.InvalidParams, 'Pass object_identifiers (from GetWhereUsed references[].object_identifier) or object_name + object_type.');
99
+ }
100
+ source = 'where_used';
101
+ const wu = await utils.getWhereUsedList({
102
+ object_name: args.object_name,
103
+ object_type: args.object_type,
104
+ ...(timeoutMs ? { timeoutMs } : {}),
105
+ });
106
+ if (Array.isArray(wu.notes))
107
+ notes.push(...wu.notes);
108
+ const refs = wu.references
109
+ .filter((r) => r.objectIdentifier)
110
+ .map((r) => ({
111
+ name: r.name,
112
+ type: r.type,
113
+ uri: r.uri,
114
+ package_name: r.packageName,
115
+ object_identifier: r.objectIdentifier,
116
+ }));
117
+ const filtered = (0, handleGetWhereUsed_1.applyWhereUsedFilters)(refs, {
118
+ customer_only: args.customer_only,
119
+ package: args.package,
120
+ });
121
+ if (filtered.filtered_out > 0) {
122
+ notes.push(`${filtered.filtered_out} referencing objects removed by customer_only / package`);
123
+ }
124
+ for (const r of filtered.references) {
125
+ meta.set(r.object_identifier, r);
126
+ }
127
+ identifiers = filtered.references.map((r) => r.object_identifier);
128
+ }
129
+ // De-duplicate, keep order
130
+ identifiers = [...new Set(identifiers)];
131
+ const available = identifiers.length;
132
+ const truncated = available > maxObjects;
133
+ if (truncated)
134
+ identifiers = identifiers.slice(0, maxObjects);
135
+ const objects = [];
136
+ let totalSnippets = 0;
137
+ for (const batch of chunk(identifiers, exports.SNIPPET_BATCH_SIZE)) {
138
+ const res = await utils.getUsageSnippets({
139
+ objectIdentifiers: batch,
140
+ ...(timeoutMs ? { timeoutMs } : {}),
141
+ });
142
+ for (const o of res.objects) {
143
+ const m = meta.get(o.objectIdentifier);
144
+ totalSnippets += o.snippets.length;
145
+ objects.push({
146
+ object_identifier: o.objectIdentifier,
147
+ ...(m
148
+ ? {
149
+ name: m.name,
150
+ type: m.type,
151
+ package_name: m.package_name,
152
+ }
153
+ : {}),
154
+ snippets: o.snippets.map((s) => ({
155
+ uri: s.uri,
156
+ source_uri: s.sourceUri,
157
+ line: s.line,
158
+ column: s.column,
159
+ content: s.content,
160
+ matches: s.matches,
161
+ ...(args?.include_context && s.description
162
+ ? { context: s.description }
163
+ : {}),
164
+ })),
165
+ });
166
+ }
167
+ }
168
+ return {
169
+ isError: false,
170
+ content: [
171
+ {
172
+ type: 'json',
173
+ json: {
174
+ source,
175
+ ...(source === 'where_used'
176
+ ? { object_name: args.object_name, object_type: args.object_type }
177
+ : {}),
178
+ requested_objects: identifiers.length,
179
+ available_objects: available,
180
+ truncated,
181
+ returned_objects: objects.length,
182
+ total_snippets: totalSnippets,
183
+ objects,
184
+ notes,
185
+ },
186
+ },
187
+ ],
188
+ };
189
+ }
190
+ catch (error) {
191
+ logger?.error('Failed to read usage snippets', error);
192
+ const hint = (0, handleGetWhereUsed_1.whereUsedErrorHint)(error);
193
+ return {
194
+ isError: true,
195
+ content: [
196
+ {
197
+ type: 'text',
198
+ text: `ADT error: ${error instanceof Error ? error.message : String(error)}${hint ? `\nHint: ${hint}` : ''}`,
199
+ },
200
+ ],
201
+ };
202
+ }
203
+ }
204
+ //# sourceMappingURL=handleGetUsageSnippets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleGetUsageSnippets.js","sourceRoot":"","sources":["../../../../src/handlers/system/readonly/handleGetUsageSnippets.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAkFH,sBAMC;AAED,wDAoJC;AA5OD,kDAAuD;AAEvD,8CAAyD;AACzD,6DAK8B;AAE9B,mGAAmG;AACtF,QAAA,kBAAkB,GAAG,EAAE,CAAC;AACrC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEnB,QAAA,eAAe,GAAG;IAC7B,IAAI,EAAE,kBAAkB;IACxB,YAAY,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAU;IACpD,WAAW,EACT,uaAAua;IACza,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,kBAAkB,EAAE;gBAClB,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EACT,2GAA2G;aAC9G;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,+DAA+D;aAClE;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,gCAAgC,+CAA0B,EAAE;aAC1E;YACD,aAAa,EAAE;gBACb,IAAI,EAAE,SAAS;gBACf,WAAW,EACT,4GAA4G;gBAC9G,OAAO,EAAE,KAAK;aACf;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,iGAAiG;aACpG;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,mEAAmE,mBAAmB,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,CAAC;qBACR,CAAC,CAAC;iBACJ,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;wBACJ,MAAM;wBACN,GAAG,CAAC,MAAM,KAAK,YAAY;4BACzB,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;4BAClE,CAAC,CAAC,EAAE,CAAC;wBACP,iBAAiB,EAAE,WAAW,CAAC,MAAM;wBACrC,iBAAiB,EAAE,SAAS;wBAC5B,SAAS;wBACT,gBAAgB,EAAE,OAAO,CAAC,MAAM;wBAChC,cAAc,EAAE,aAAa;wBAC7B,OAAO;wBACP,KAAK;qBACN;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,EAAE,KAAK,CAAC,+BAA+B,EAAE,KAAY,CAAC,CAAC;QAC7D,MAAM,IAAI,GAAG,IAAA,uCAAkB,EAAC,KAAK,CAAC,CAAC;QACvC,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,cAAc,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;iBAC7G;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -2,12 +2,22 @@
2
2
  * WhereUsed handler using AdtClient utilities
3
3
  * Endpoint: /sap/bc/adt/repository/informationsystem/usageReferences
4
4
  * Uses getWhereUsedList for parsed results
5
+ *
6
+ * On legacy systems (BASIS < 7.50) createAdtClient() returns AdtClientLegacy,
7
+ * whose utils skip the scope step and address DDIC objects through VIT URIs
8
+ * (client library >= 3.15.0).
9
+ *
10
+ * BASIS < 7.40 (e.g. 7.31) has no repository information system resource at
11
+ * all, so the search runs in SAP through ZMCP_ADT_DISPATCH action WHERE_USED
12
+ * (cross-reference tables WBCROSSGT / CROSS / D010INC, DDIC usage DD03L /
13
+ * DD04L) instead.
5
14
  */
6
15
  import type { HandlerContext } from '../../../lib/handlers/interfaces';
16
+ export declare const SUPPORTED_WHERE_USED_TYPES = "class, interface, program, include, functiongroup, function_module, table, structure, dataelement, domain, view, tabletype (ECC), transaction (ECC), messageclass (ECC), package";
7
17
  export declare const TOOL_DEFINITION: {
8
18
  readonly name: "GetWhereUsed";
9
- readonly available_in: readonly ["onprem", "cloud"];
10
- readonly description: "[read-only] Find where-used references (cross-references, usages, dependencies) for ABAP objects — classes, interfaces, tables, data elements, programs, function modules, etc. Returns list of all referencing objects with their types and packages.";
19
+ readonly available_in: readonly ["onprem", "cloud", "legacy"];
20
+ readonly description: "[read-only] Find where-used references (cross-references, usages, dependencies) for ABAP objects — classes, interfaces, tables, data elements, programs, function modules, etc. Returns list of all referencing objects with their types and packages. On ECC a function module may be given by plain name (no GROUP|FM needed). Widely used SAP standard tables (e.g. VBAK) can take about 60 s and return thousands of references — use customer_only / package / max_results to shrink the answer (filtering happens after the SAP search, so it does not shorten the search time). Pass references[].object_identifier to GetUsageSnippets for line-level hits.";
11
21
  readonly inputSchema: {
12
22
  readonly type: "object";
13
23
  readonly properties: {
@@ -17,13 +27,30 @@ export declare const TOOL_DEFINITION: {
17
27
  };
18
28
  readonly object_type: {
19
29
  readonly type: "string";
20
- readonly description: "Type of the ABAP object (class, interface, program, table, etc.)";
30
+ readonly description: "Type of the ABAP object: class, interface, program, include, functiongroup, function_module, table, structure, dataelement, domain, view, tabletype (ECC), transaction (ECC), messageclass (ECC), package";
21
31
  };
22
32
  readonly enable_all_types: {
23
33
  readonly type: "boolean";
24
- readonly description: "If true, searches in all available object types (Eclipse 'select all' behavior). Default: false (uses SAP default scope)";
34
+ readonly description: "If true, searches in all available object types (Eclipse 'select all' behavior). Default: false (uses SAP default scope). Ignored on ECC (no scope resource).";
25
35
  readonly default: false;
26
36
  };
37
+ readonly max_results: {
38
+ readonly type: "number";
39
+ readonly description: "Optional cap on references[] after filtering. Omit or 0 = no cap. truncated=true when more were found.";
40
+ };
41
+ readonly customer_only: {
42
+ readonly type: "boolean";
43
+ readonly description: "Optional. Keep only customer objects: name starting with Z / Y, or package Z* / Y* / $*. Objects in /namespace/ (SAP industry solutions, partners, generated /1.../) are dropped; for a registered customer namespace use package: \"/ACME/*\" instead. Default: false.";
44
+ readonly default: false;
45
+ };
46
+ readonly package: {
47
+ readonly type: "string";
48
+ readonly description: "Optional package filter on references[].package_name: exact name, or prefix with a trailing * (e.g. ZSD*).";
49
+ };
50
+ readonly timeout_ms: {
51
+ readonly type: "number";
52
+ readonly description: "Optional request timeout in ms for the SAP search. Default: SAP_TIMEOUT_LONG (120 s) on ECC, SAP_TIMEOUT_DEFAULT (45 s) otherwise.";
53
+ };
27
54
  };
28
55
  readonly required: readonly ["object_name", "object_type"];
29
56
  };
@@ -32,7 +59,48 @@ interface WhereUsedArgs {
32
59
  object_name: string;
33
60
  object_type: string;
34
61
  enable_all_types?: boolean;
62
+ max_results?: number;
63
+ customer_only?: boolean;
64
+ package?: string;
65
+ timeout_ms?: number;
35
66
  }
67
+ export interface WhereUsedReferenceOut {
68
+ name: string;
69
+ type: string;
70
+ uri: string;
71
+ package_name?: string;
72
+ responsible?: string;
73
+ usage_information?: string;
74
+ object_identifier?: string;
75
+ }
76
+ /**
77
+ * Customer namespace check used by customer_only: Z / Y object name, or Z / Y / $ package.
78
+ * Names in a /namespace/ are not treated as customer objects: on ECC they are mostly SAP
79
+ * industry solutions, partner add-ons or generated objects (/1BCDWB/ SmartForm modules).
80
+ */
81
+ export declare function isCustomerReference(ref: {
82
+ name?: string;
83
+ package_name?: string;
84
+ }): boolean;
85
+ /** Package filter: exact (case-insensitive) or prefix with trailing '*'. */
86
+ export declare function matchesPackage(packageName: string | undefined, pattern: string): boolean;
87
+ /**
88
+ * Apply the optional filters and cap. With no option set the input list is
89
+ * returned unchanged (same order, same entries).
90
+ */
91
+ export declare function applyWhereUsedFilters(references: WhereUsedReferenceOut[], opts: {
92
+ customer_only?: boolean;
93
+ package?: string;
94
+ max_results?: number;
95
+ }): {
96
+ references: WhereUsedReferenceOut[];
97
+ filtered_out: number;
98
+ truncated: boolean;
99
+ };
100
+ /** True on BASIS releases without /sap/bc/adt/repository/informationsystem. */
101
+ export declare function needsDispatchWhereUsed(): boolean;
102
+ /** Add an actionable hint to well-known ADT where-used failures. */
103
+ export declare function whereUsedErrorHint(error: unknown): string | undefined;
36
104
  /**
37
105
  * Returns where-used references for ABAP objects using AdtClient utilities.
38
106
  * Uses getWhereUsedList for parsed structured results.
@@ -47,14 +115,11 @@ export declare function handleGetWhereUsed(context: HandlerContext, args: WhereU
47
115
  enable_all_types: boolean;
48
116
  total_references: number;
49
117
  result_description: string;
50
- references: {
51
- name: string;
52
- type: string;
53
- uri: string;
54
- package_name: string | undefined;
55
- responsible: string | undefined;
56
- usage_information: string | undefined;
57
- }[];
118
+ references: WhereUsedReferenceOut[];
119
+ returned_references: number;
120
+ truncated: boolean;
121
+ filtered_out: number;
122
+ notes: string[];
58
123
  };
59
124
  }[];
60
125
  } | {