Skip to content

Commit 4605c1f

Browse files
committed
Revert the handler signature change
1 parent eb1f0af commit 4605c1f

15 files changed

Lines changed: 356 additions & 672 deletions

File tree

packages/b2c-dx-mcp/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
"@modelcontextprotocol/sdk": "1.26.0",
9797
"@oclif/core": "catalog:",
9898
"@salesforce/b2c-tooling-sdk": "workspace:*",
99-
"glob": "catalog:",
10099
"ts-morph": "^27.0.0",
101100
"yaml": "2.8.1",
102101
"zod": "3.25.76"

packages/b2c-dx-mcp/src/registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,6 @@ async function registerTools(tools: McpTool[], server: B2CDxMcpServer, allowNonG
266266

267267
// Register the tool
268268
// TODO: Telemetry - Tool registration includes timing/error tracking
269-
server.addTool(tool.name, tool.description, tool.inputSchema, async (args, context) => tool.handler(args, context));
269+
server.addTool(tool.name, tool.description, tool.inputSchema, async (args) => tool.handler(args));
270270
}
271271
}

packages/b2c-dx-mcp/src/server.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,15 @@ export class B2CDxMcpServer extends McpServer {
7272
name: string,
7373
description: string,
7474
inputSchema: ZodRawShape,
75-
handler: (
76-
args: Record<string, unknown>,
77-
context: RequestHandlerExtra<ServerRequest, ServerNotification>,
78-
) => Promise<CallToolResult>,
75+
handler: (args: Record<string, unknown>) => Promise<CallToolResult>,
7976
): void {
8077
const wrappedHandler = async (
8178
args: Record<string, unknown>,
82-
extra: RequestHandlerExtra<ServerRequest, ServerNotification>,
79+
_extra: RequestHandlerExtra<ServerRequest, ServerNotification>,
8380
): Promise<CallToolResult> => {
8481
const startTime = Date.now();
8582
try {
86-
const result = await handler(args, extra);
83+
const result = await handler(args);
8784
const runTimeMs = Date.now() - startTime;
8885

8986
await this.telemetry

packages/b2c-dx-mcp/src/tools/adapter.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@
7373

7474
import {z, type ZodRawShape, type ZodObject, type ZodType} from 'zod';
7575
import type {B2CInstance} from '@salesforce/b2c-tooling-sdk';
76-
import type {ServerNotification, ServerRequest} from '@modelcontextprotocol/sdk/types.js';
77-
import type {RequestHandlerExtra} from '@modelcontextprotocol/sdk/shared/protocol.js';
7876
import type {McpTool, ToolResult, Toolset} from '../utils/index.js';
7977
import type {Services, MrtConfig} from '../services.js';
8078

@@ -280,10 +278,7 @@ export function createToolAdapter<TInput, TOutput>(
280278
toolsets,
281279
isGA,
282280

283-
async handler(
284-
rawArgs: Record<string, unknown>,
285-
_mcpContext: RequestHandlerExtra<ServerRequest, ServerNotification>,
286-
): Promise<ToolResult> {
281+
async handler(rawArgs: Record<string, unknown>): Promise<ToolResult> {
287282
// 1. Validate input with Zod
288283
const parseResult = zodSchema.safeParse(rawArgs);
289284
if (!parseResult.success) {

packages/b2c-dx-mcp/src/tools/page-designer-decorator/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ pnpm run test:agent -- test/tools/page-designer-decorator/index.test.ts
241241
```
242242

243243
The test suite covers:
244-
245244
- Component discovery (name-based, kebab-case, nested, path-based, custom paths, name collisions)
246245
- Auto mode (basic, type inference, complex props exclusion, UI-only props exclusion, edge cases)
247246
- Interactive mode (all steps: analyze, select_props, configure_attrs, configure_regions, confirm_generation)

packages/b2c-dx-mcp/src/tools/page-designer-decorator/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66

77
import {z, type ZodRawShape} from 'zod';
8-
import type {ServerNotification, ServerRequest} from '@modelcontextprotocol/sdk/types.js';
9-
import type {RequestHandlerExtra} from '@modelcontextprotocol/sdk/shared/protocol.js';
108
import {componentAnalyzer, generateTypeSuggestions, resolveComponent, type TypeSuggestion} from './analyzer.js';
119
import {generateDecoratorCode, type AttributeContext, type MetadataContext} from './templates/decorator-generator.js';
1210
import {pageDesignerDecoratorRules} from './rules.js';
@@ -619,7 +617,7 @@ export function createPageDesignerDecoratorTool(loadServices: () => Services): M
619617
toolsets: ['STOREFRONTNEXT'],
620618
isGA: false,
621619

622-
async handler(args: Record<string, unknown>, _context: RequestHandlerExtra<ServerRequest, ServerNotification>) {
620+
async handler(args: Record<string, unknown>) {
623621
try {
624622
// Validate and parse input
625623
const validatedArgs = pageDesignerDecoratorSchema.parse(args) as PageDesignerDecoratorInput;

packages/b2c-dx-mcp/src/utils/types.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
*/
66

77
import type {z, ZodRawShape} from 'zod';
8-
import type {CallToolResult, ServerNotification, ServerRequest} from '@modelcontextprotocol/sdk/types.js';
9-
import type {RequestHandlerExtra} from '@modelcontextprotocol/sdk/shared/protocol.js';
8+
import type {CallToolResult} from '@modelcontextprotocol/sdk/types.js';
109
import type {Toolset} from './constants.js';
1110

1211
/**
@@ -36,10 +35,7 @@ export interface McpToolConfig<T extends ZodRawShape = ZodRawShape> {
3635
*/
3736
export interface McpTool<T extends ZodRawShape = ZodRawShape> extends McpToolConfig<T> {
3837
/** Handler function that executes the tool */
39-
handler: (
40-
args: z.infer<z.ZodObject<T>>,
41-
context: RequestHandlerExtra<ServerRequest, ServerNotification>,
42-
) => Promise<ToolResult>;
38+
handler: (args: z.infer<z.ZodObject<T>>) => Promise<ToolResult>;
4339
}
4440

4541
/**

packages/b2c-dx-mcp/test/tools/adapter.test.ts

Lines changed: 30 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -183,21 +183,18 @@ describe('tools/adapter', () => {
183183
);
184184

185185
// Test with valid input
186-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
187-
const validResult = await tool.handler({name: 'test', count: 5}, {} as any);
186+
const validResult = await tool.handler({name: 'test', count: 5});
188187
expect(validResult.isError).to.be.undefined;
189188
expect(getResultText(validResult)).to.equal('Received: test, 5');
190189

191190
// Test with missing required field
192-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
193-
const missingResult = await tool.handler({count: 5}, {} as any);
191+
const missingResult = await tool.handler({count: 5});
194192
expect(missingResult.isError).to.be.true;
195193
expect(getResultText(missingResult)).to.include('Invalid input');
196194
expect(getResultText(missingResult)).to.include('name');
197195

198196
// Test with invalid type
199-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
200-
const invalidTypeResult = await tool.handler({name: 'test', count: 'not-a-number'}, {} as any);
197+
const invalidTypeResult = await tool.handler({name: 'test', count: 'not-a-number'});
201198
expect(invalidTypeResult.isError).to.be.true;
202199
expect(getResultText(invalidTypeResult)).to.include('Invalid input');
203200
});
@@ -220,8 +217,7 @@ describe('tools/adapter', () => {
220217
loadServices,
221218
);
222219

223-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
224-
const result = await tool.handler({email: 'not-an-email'}, {} as any);
220+
const result = await tool.handler({email: 'not-an-email'});
225221

226222
expect(result.isError).to.be.true;
227223
expect(getResultText(result)).to.include('Invalid input');
@@ -246,8 +242,7 @@ describe('tools/adapter', () => {
246242
loadServices,
247243
);
248244

249-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
250-
const result = await tool.handler({}, {} as any);
245+
const result = await tool.handler({});
251246

252247
expect(result.isError).to.be.true;
253248
expect(getResultText(result)).to.include('Execution error');
@@ -272,8 +267,7 @@ describe('tools/adapter', () => {
272267
loadServices,
273268
);
274269

275-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
276-
const result = await tool.handler({}, {} as any);
270+
const result = await tool.handler({});
277271

278272
expect(result.isError).to.be.true;
279273
expect(getResultText(result)).to.include('Execution error');
@@ -300,8 +294,7 @@ describe('tools/adapter', () => {
300294
loadServices,
301295
);
302296

303-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
304-
await tool.handler({}, {} as any);
297+
await tool.handler({});
305298

306299
const services = loadServices();
307300
expect(receivedServices).to.equal(services);
@@ -329,8 +322,7 @@ describe('tools/adapter', () => {
329322
loadServices,
330323
);
331324

332-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
333-
const result = await tool.handler({projectName: 'my-storefront'}, {} as any);
325+
const result = await tool.handler({projectName: 'my-storefront'});
334326

335327
expect(result.isError).to.be.undefined;
336328
expect(getResultText(result)).to.equal('Created project: my-storefront');
@@ -357,8 +349,7 @@ describe('tools/adapter', () => {
357349
loadServices,
358350
);
359351

360-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
361-
const result = await tool.handler({}, {} as any);
352+
const result = await tool.handler({});
362353

363354
expect(result.isError).to.be.undefined;
364355
const parsed = JSON.parse(getResultText(result));
@@ -407,14 +398,12 @@ describe('tools/adapter', () => {
407398
);
408399

409400
// Without optional field
410-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
411-
const result1 = await tool.handler({required: 'value'}, {} as any);
401+
const result1 = await tool.handler({required: 'value'});
412402
expect(result1.isError).to.be.undefined;
413403
expect(getResultText(result1)).to.equal('required: value, optional: not provided');
414404

415405
// With optional field
416-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
417-
const result2 = await tool.handler({required: 'value', optional: 'present'}, {} as any);
406+
const result2 = await tool.handler({required: 'value', optional: 'present'});
418407
expect(result2.isError).to.be.undefined;
419408
expect(getResultText(result2)).to.equal('required: value, optional: present');
420409
});
@@ -437,8 +426,7 @@ describe('tools/adapter', () => {
437426
loadServices,
438427
);
439428

440-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
441-
const result = await tool.handler({items: ['a', 'b', 'c']}, {} as any);
429+
const result = await tool.handler({items: ['a', 'b', 'c']});
442430

443431
expect(result.isError).to.be.undefined;
444432
expect(getResultText(result)).to.equal('a, b, c');
@@ -464,8 +452,7 @@ describe('tools/adapter', () => {
464452
);
465453

466454
// Test with too short name
467-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
468-
const result = await tool.handler({name: 'ab', age: 25}, {} as any);
455+
const result = await tool.handler({name: 'ab', age: 25});
469456
expect(result.isError).to.be.true;
470457
expect(getResultText(result)).to.include('Name must be at least 3 characters');
471458
});
@@ -491,8 +478,7 @@ describe('tools/adapter', () => {
491478
);
492479

493480
// Default is now false, so tool should execute without instance
494-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
495-
const result = await tool.handler({}, {} as any);
481+
const result = await tool.handler({});
496482

497483
expect(result.isError).to.be.undefined;
498484
expect(contextReceived?.b2cInstance).to.be.undefined;
@@ -514,8 +500,7 @@ describe('tools/adapter', () => {
514500
loadServices,
515501
);
516502

517-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
518-
const result = await tool.handler({}, {} as any);
503+
const result = await tool.handler({});
519504

520505
expect(result.isError).to.be.true;
521506
expect(getResultText(result)).to.include('B2C instance error');
@@ -549,8 +534,7 @@ describe('tools/adapter', () => {
549534
loadServices,
550535
);
551536

552-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
553-
const result = await tool.handler({}, {} as any);
537+
const result = await tool.handler({});
554538

555539
expect(result.isError).to.be.undefined;
556540
expect(contextReceived?.mrtConfig?.auth).to.be.undefined;
@@ -579,8 +563,7 @@ describe('tools/adapter', () => {
579563
loadServices,
580564
);
581565

582-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
583-
const result = await tool.handler({}, {} as any);
566+
const result = await tool.handler({});
584567

585568
expect(result.isError).to.be.undefined;
586569
expect(contextReceived?.mrtConfig?.auth).to.not.be.undefined;
@@ -612,8 +595,7 @@ describe('tools/adapter', () => {
612595
loadServices,
613596
);
614597

615-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
616-
const result = await tool.handler({}, {} as any);
598+
const result = await tool.handler({});
617599

618600
expect(result.isError).to.be.undefined;
619601
expect(contextReceived?.mrtConfig?.auth).to.not.be.undefined;
@@ -647,8 +629,7 @@ describe('tools/adapter', () => {
647629
loadServices,
648630
);
649631

650-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
651-
const result = await tool.handler({}, {} as any);
632+
const result = await tool.handler({});
652633

653634
expect(result.isError).to.be.undefined;
654635
expect(contextReceived?.mrtConfig?.auth).to.not.be.undefined;
@@ -676,8 +657,7 @@ describe('tools/adapter', () => {
676657
loadServices,
677658
);
678659

679-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
680-
const result = await tool.handler({}, {} as any);
660+
const result = await tool.handler({});
681661

682662
expect(result.isError).to.be.undefined;
683663
expect(contextReceived?.b2cInstance).to.be.undefined;
@@ -704,8 +684,7 @@ describe('tools/adapter', () => {
704684
loadServices,
705685
);
706686

707-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
708-
const result = await tool.handler({}, {} as any);
687+
const result = await tool.handler({});
709688

710689
expect(result.isError).to.be.true;
711690
expect(getResultText(result)).to.include('MRT auth error');
@@ -744,21 +723,16 @@ describe('tools/adapter', () => {
744723
);
745724

746725
// Empty list
747-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
748-
const emptyResult = await tool.handler({items: []}, {} as any);
726+
const emptyResult = await tool.handler({items: []});
749727
expect(getResultText(emptyResult)).to.equal('No items found.');
750728

751729
// With items
752-
const itemsResult = await tool.handler(
753-
{
754-
items: [
755-
{id: 1, name: 'First'},
756-
{id: 2, name: 'Second'},
757-
],
758-
},
759-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
760-
{} as any,
761-
);
730+
const itemsResult = await tool.handler({
731+
items: [
732+
{id: 1, name: 'First'},
733+
{id: 2, name: 'Second'},
734+
],
735+
});
762736
expect(getResultText(itemsResult)).to.include('Found 2 items:');
763737
expect(getResultText(itemsResult)).to.include('1: First');
764738
expect(getResultText(itemsResult)).to.include('2: Second');
@@ -794,13 +768,11 @@ describe('tools/adapter', () => {
794768
loadServices,
795769
);
796770

797-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
798-
const successResult = await tool.handler({operation: 'succeed'}, {} as any);
771+
const successResult = await tool.handler({operation: 'succeed'});
799772
expect(successResult.isError).to.be.undefined;
800773
expect(getResultText(successResult)).to.equal('Operation succeeded');
801774

802-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
803-
const failResult = await tool.handler({operation: 'fail'}, {} as any);
775+
const failResult = await tool.handler({operation: 'fail'});
804776
expect(failResult.isError).to.be.true;
805777
expect(getResultText(failResult)).to.equal('Operation failed');
806778
});

0 commit comments

Comments
 (0)