Skip to content

Commit a001ded

Browse files
committed
fix(adt-mcp): address SonarCloud blockers in PR 101
Pin the Copilot Bun setup action, reduce duplicated tool logic, and simplify Sonar-reported code paths in adt-mcp.\n\nCo-authored-by: Codex <noreply@openai.com>
1 parent e3dce0a commit a001ded

7 files changed

Lines changed: 336 additions & 281 deletions

File tree

.github/workflows/copilot-setup-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
uses: actions/checkout@v4
2323

2424
- name: Install bun
25-
uses: oven-sh/setup-bun@v2
25+
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
2626

2727
- name: Install dependencies
2828
run: bun install

packages/adt-mcp/src/lib/tools/call-hierarchy.ts

Lines changed: 37 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,29 @@ async function fetchCallHierarchy(
6363
return { objectUri: resolvedUri, result };
6464
}
6565

66-
export function registerGetCallersOfTool(
66+
type CallHierarchyToolConfig = {
67+
endpoint: 'callers' | 'callees';
68+
failureLabel: string;
69+
resultKey: 'callers' | 'callees';
70+
toolDescription: string;
71+
toolName: 'get_callers_of' | 'get_callees_of';
72+
};
73+
74+
function registerCallHierarchyTool(
6775
server: McpServer,
6876
ctx: ToolContext,
77+
config: CallHierarchyToolConfig,
6978
): void {
7079
server.tool(
71-
'get_callers_of',
72-
'Find all callers (upward call hierarchy) of an ABAP method, function module, or subroutine',
80+
config.toolName,
81+
config.toolDescription,
7382
callHierarchyShape,
7483
async (args) => {
7584
try {
7685
const client = ctx.getClient(args);
7786
const res = await fetchCallHierarchy(
7887
client,
79-
'callers',
88+
config.endpoint,
8089
args.objectName,
8190
args.objectType,
8291
args.objectUri,
@@ -101,7 +110,7 @@ export function registerGetCallersOfTool(
101110
{
102111
objectName: args.objectName,
103112
objectUri: res.objectUri,
104-
callers: res.result,
113+
[config.resultKey]: res.result,
105114
},
106115
null,
107116
2,
@@ -115,7 +124,7 @@ export function registerGetCallersOfTool(
115124
content: [
116125
{
117126
type: 'text' as const,
118-
text: `Get callers failed: ${error instanceof Error ? error.message : String(error)}`,
127+
text: `${config.failureLabel}: ${error instanceof Error ? error.message : String(error)}`,
119128
},
120129
],
121130
};
@@ -124,63 +133,30 @@ export function registerGetCallersOfTool(
124133
);
125134
}
126135

136+
export function registerGetCallersOfTool(
137+
server: McpServer,
138+
ctx: ToolContext,
139+
): void {
140+
registerCallHierarchyTool(server, ctx, {
141+
toolName: 'get_callers_of',
142+
toolDescription:
143+
'Find all callers (upward call hierarchy) of an ABAP method, function module, or subroutine',
144+
endpoint: 'callers',
145+
resultKey: 'callers',
146+
failureLabel: 'Get callers failed',
147+
});
148+
}
149+
127150
export function registerGetCalleesOfTool(
128151
server: McpServer,
129152
ctx: ToolContext,
130153
): void {
131-
server.tool(
132-
'get_callees_of',
133-
'Find all callees (downward call hierarchy) of an ABAP method, function module, or subroutine',
134-
callHierarchyShape,
135-
async (args) => {
136-
try {
137-
const client = ctx.getClient(args);
138-
const res = await fetchCallHierarchy(
139-
client,
140-
'callees',
141-
args.objectName,
142-
args.objectType,
143-
args.objectUri,
144-
args.maxResults ?? 50,
145-
);
146-
if (!res) {
147-
return {
148-
isError: true,
149-
content: [
150-
{
151-
type: 'text' as const,
152-
text: `Object '${args.objectName}' not found`,
153-
},
154-
],
155-
};
156-
}
157-
return {
158-
content: [
159-
{
160-
type: 'text' as const,
161-
text: JSON.stringify(
162-
{
163-
objectName: args.objectName,
164-
objectUri: res.objectUri,
165-
callees: res.result,
166-
},
167-
null,
168-
2,
169-
),
170-
},
171-
],
172-
};
173-
} catch (error) {
174-
return {
175-
isError: true,
176-
content: [
177-
{
178-
type: 'text' as const,
179-
text: `Get callees failed: ${error instanceof Error ? error.message : String(error)}`,
180-
},
181-
],
182-
};
183-
}
184-
},
185-
);
154+
registerCallHierarchyTool(server, ctx, {
155+
toolName: 'get_callees_of',
156+
toolDescription:
157+
'Find all callees (downward call hierarchy) of an ABAP method, function module, or subroutine',
158+
endpoint: 'callees',
159+
resultKey: 'callees',
160+
failureLabel: 'Get callees failed',
161+
});
186162
}

0 commit comments

Comments
 (0)