add page-designer-decorator tool for Storefront Next#150
Conversation
patricksullivansf
left a comment
There was a problem hiding this comment.
Great start. thank you! More detailed review soon. Can you update the description with test instructions and add a changeset.
see #133 for an example.
Page Designer Decorator Tool - Manual Test PlanTool Name: 📋 PrerequisitesEnvironment Setup
🎯 Test ScenariosTest Category 1: Component DiscoveryTC-1.1: Name-Based Discovery (PascalCase)Objective: Verify component discovery by name in standard location Steps:
Expected Result:
Test Data: // src/components/ProductCard.tsx
export interface ProductCardProps {
title: string;
price: number;
}
export default function ProductCard({title, price}: ProductCardProps) {
return <div>{title} - ${price}</div>;
}TC-1.2: Name-Based Discovery (Kebab-Case)Objective: Verify component discovery with kebab-case naming Steps:
Expected Result:
TC-1.3: Nested Component DiscoveryObjective: Verify discovery of components in subdirectories Steps:
Expected Result:
TC-1.4: Path-Based InputObjective: Verify backward compatibility with path-based input Steps:
Expected Result:
TC-1.5: Custom Search PathsObjective: Verify custom search paths for monorepo structures Steps:
Expected Result:
TC-1.6: Component Not FoundObjective: Verify error handling for non-existent components Steps:
Expected Result:
Test Category 2: Auto ModeTC-2.1: Basic Auto ModeObjective: Verify auto mode generates decorators for simple component Steps:
Expected Result:
TC-2.2: Auto Mode - Excludes Complex PropsObjective: Verify auto mode excludes complex types Steps:
Expected Result:
TC-2.3: Auto Mode - Excludes UI-Only PropsObjective: Verify auto mode excludes UI-only props Steps:
Expected Result:
TC-2.4: Auto Mode - Type InferenceObjective: Verify automatic type inference for common patterns Steps:
Expected Result:
TC-2.5: Auto Mode - Component Already DecoratedObjective: Verify handling of components with existing decorators Steps:
Expected Result:
TC-2.6: Auto Mode - Custom Component IDObjective: Verify custom component ID override Steps:
Expected Result:
Test Category 3: Interactive ModeTC-3.1: Mode SelectionObjective: Verify mode selection prompt appears Steps:
Expected Result:
TC-3.2: Interactive Mode - Analyze StepObjective: Verify analysis step provides component information Steps:
Expected Result:
TC-3.3: Interactive Mode - Select Props StepObjective: Verify prop selection step Steps:
Expected Result:
TC-3.4: Interactive Mode - Select Props (Missing Metadata)Objective: Verify error when metadata is missing Steps:
Expected Result:
TC-3.5: Interactive Mode - Configure Attributes StepObjective: Verify attribute configuration step Steps:
Expected Result:
TC-3.6: Interactive Mode - Configure Regions StepObjective: Verify region configuration step Steps:
Expected Result:
TC-3.7: Interactive Mode - Confirm Generation StepObjective: Verify final code generation step Steps:
Expected Result:
TC-3.8: Interactive Mode - Confirm Generation (Missing Metadata)Objective: Verify error when metadata missing in final step Steps:
Expected Result:
Test Category 4: Error HandlingTC-4.1: Invalid Input TypeObjective: Verify Zod validation catches invalid input Steps:
Expected Result:
TC-4.2: Invalid Step NameObjective: Verify error for invalid conversation step Steps:
Expected Result:
TC-4.3: Missing Required ParameterObjective: Verify error when component parameter is missing Steps:
Expected Result:
Test Category 5: Edge CasesTC-5.1: Component with No PropsObjective: Verify handling of component with empty props interface Steps:
Expected Result:
TC-5.2: Component with Only Complex PropsObjective: Verify handling when all props are complex Steps:
Expected Result:
TC-5.3: Component with Optional PropsObjective: Verify handling of optional props Steps:
Expected Result:
TC-5.4: Component with Union TypesObjective: Verify handling of union type props Steps:
Expected Result:
TC-5.5: Component Name CollisionObjective: Verify handling when multiple components match name Steps:
Expected Result:
Test Category 6: Environment VariablesTC-6.1: SFCC_WORKING_DIRECTORY SetObjective: Verify tool uses environment variable when set Steps:
Expected Result:
TC-6.2: SFCC_WORKING_DIRECTORY Not SetObjective: Verify fallback to process.cwd() Steps:
Expected Result:
Test Category 7: Real Storefront Next Project IntegrationTC-7.1: Real Component in Storefront Next ProjectObjective: Verify tool works with actual components from a real Storefront Next installation Prerequisites:
Steps:
Expected Result:
TC-7.2: Real Component - Interactive Mode Full WorkflowObjective: Verify complete interactive workflow with real component Prerequisites:
Steps:
Expected Result:
TC-7.3: Real Component - Verify Generated Decorators WorkObjective: Verify generated decorators function correctly in Page Designer Prerequisites:
Steps:
Expected Result:
TC-7.4: Real Component - Monorepo StructureObjective: Verify tool works with monorepo Storefront Next projects Prerequisites:
Steps:
Expected Result:
TC-7.5: Real Component - Existing DecoratorsObjective: Verify tool handles components that already have decorators Prerequisites:
Steps:
Expected Result:
📊 Test Execution ChecklistPre-Test Setup
Test Execution
Post-Test Verification
🐛 Known Issues / LimitationsCurrent Limitations
Expected Behavior
📝 Test Results Template🎯 Success CriteriaAll tests pass when:
📚 Additional Resources
Test Plan Version: 1.0 |
…d test runner script (index.test.mjs) with 24 test cases- Support both temporary directory mode (default) and real Storefront Next project mode- Update test documentation with usage instructions for both modes- Update tool README with manual test runner sectionThe test runner covers component discovery, auto mode, interactive mode,error handling, edge cases, and environment variable scenarios.
Testing instructions should be also available in the MCP tool test variant of the Readme.md. |
|
Not a priority but Im guessing TC- 6.2 (current directory) is of dubious value with cursor where mcp cwd is - |
There was a problem hiding this comment.
@clavery need your opinion on this change to dep management please?
There was a problem hiding this comment.
Only the ones necessary for the build process should be listed here. If it's not necessary to run the install scripts for our use cases it shouldn't be listed.
TC-6.2: Current Directory Fallback BehaviorHow It WorksWhen const workspaceRoot = process.env.SFCC_WORKING_DIRECTORY || process.cwd();If you start the server from the project directory, Example ScenariosScenario 1: Manual Start from Project Directory (Works)# Navigate to your Storefront Next project
cd /path/to/storefront-next
# Start MCP server manually
node /path/to/b2c-dx-mcp/bin/dev.js --toolsets STOREFRONTNEXT --allow-non-ga-tools
# process.cwd() = /path/to/storefront-next ✅
# Component discovery will search in: /path/to/storefront-next/src/components/Scenario 2: MCP Client Spawns from Home Directory (Fails)# Cursor/Claude Desktop spawns server from:
cd ~ # /Users/username/
# Server process starts here
node /path/to/b2c-dx-mcp/bin/dev.js --toolsets STOREFRONTNEXT
# process.cwd() = /Users/username/ ❌
# Component discovery searches in: /Users/username/src/components/ (wrong!)Scenario 3: Using --working-directory Flag (Recommended)# Start from anywhere
cd ~
# But explicitly set working directory
node /path/to/b2c-dx-mcp/bin/dev.js \
--working-directory /path/to/storefront-next \
--toolsets STOREFRONTNEXT \
--allow-non-ga-tools
# Tool uses --working-directory flag value ✅
# Component discovery searches in: /path/to/storefront-next/src/components/Important CaveatWhile starting from the project directory works, it's not reliable because:
Best PracticeAlways set // Cursor mcp.json
{
"mcpServers": {
"b2c-dx": {
"command": "node",
"args": [
"/path/to/b2c-dx-mcp/bin/dev.js",
"--working-directory", "${workspaceFolder}", // ✅ Explicit
"--toolsets", "STOREFRONTNEXT",
"--allow-non-ga-tools"
]
}
}
}This ensures it works regardless of where the MCP client starts the server process. Summary
|
…om runner to Mocha Remove custom test runner (index.test.mjs) and consolidate all test cases into the standard Mocha test suite (index.test.ts) for consistency with the monorepo's test framework.
Add workingDirectory property to Services and update page-designer-decorator tool to use it instead of reading process.env.SFCC_WORKING_DIRECTORY directly. This ensures component searches start from the correct project directory when MCP clients spawn servers from the home directory. - Add workingDirectory to Services (resolved from --working-directory flag/env) - Update page-designer-decorator to use services.workingDirectory - Simplify tool description for LLM consumption - Update tests and documentation accordingly
- Rename tool from to - Remove conflicting placeholder - Reorganize storefrontnext README to scatter tool documentation throughout file - Update all references in code, tests, and documentation This ensures consistent naming with other Storefront Next tools and improves documentation organization by distributing tool details across appropriate sections.
Update createPageDesignerDecoratorTool to accept loadServices function for consistency with other tools. Fix Services API usage to call getWorkingDirectory() method instead of accessing workingDirectory property. Update test mocks to properly construct Services with ResolvedB2CConfig. This fixes build errors and test failures after recent refactoring.
…lers Update tool handler signatures to match MCP SDK's expected format by accepting RequestHandlerExtra context parameter. Context is currently unused but available for future protocol-level features.
Update all test files to pass the new context parameter to tool.handler()
calls. The handler signature was updated to accept a second parameter
(RequestHandlerExtra) for MCP context, but tests were still calling
handlers with a single argument.
Changes:
- Add {} as any as second argument to all tool.handler() calls in tests
- Add eslint-disable comments for @typescript-eslint/no-explicit-any
- Fix prettier formatting issues
- Remove duplicate variable declaration in developer-guidelines test
- Fix no-await-in-loop lint errors with proper disable comments
|
Thanks for the contribution! It looks like @sf-cboscenco is an internal user so signing the CLA is not required. However, we need to confirm this. |
|
nits for later follow up: new lint warnings will impair future developer work |
patricksullivansf
left a comment
There was a problem hiding this comment.
Sorry this was such a grind. I noted a few areas for future follow up. Thanks for pushing this through. Hopefully the remainder of the tool ports will be easier going forward.

Summary
🎯 Overview
Successfully integrated a new MCP tool (
add_page_designer_decorator) into the B2C DX MCP server. This tool enables developers to add Page Designer decorators (@Component,@AttributeDefinition,@RegionDefinition) to React components for Storefront Next projects.Testing
How was this tested?
Tests are being provided also performed a manual test against a local StorefrontNext installation.
pnpm test)pnpm run format)