@W-21105798: Scaffold Custom API MCP Tool#204
Conversation
| const flagConfig = { | ||
| ...extractInstanceFlags(this.flags as Record<string, unknown>), | ||
| ...mrt.config, | ||
| workingDirectory: this.flags['working-directory'], |
| .min(1) | ||
| .nullish() | ||
| .describe( | ||
| 'Cartridge name that will contain the API. Optional; omit to use the first cartridge found under working directory (--working-directory or SFCC_WORKING_DIRECTORY).', |
There was a problem hiding this comment.
As I have some questions related to workingDirectory deprecation, I will leave this as is for now and follow up with Charles when he comes back.
There was a problem hiding this comment.
My preference is to follow the pattern used in all the other tools for now. If later after discussing we decide we need to change our pattern, having everything consistent will make that change easier. Insisting on showing a flag that is correctly marked deprecated is going to confuse our users.
There was a problem hiding this comment.
Since all other places are changed, can we change this to project directory as well to keep them the same?
There was a problem hiding this comment.
resolved for now. will revisit.
| export function createScaffoldCustomApiTool(loadServices: () => Services): McpTool { | ||
| return createToolAdapter<ScaffoldCustomApiInput, ScaffoldCustomApiOutput>( | ||
| { | ||
| name: 'scapi_customapi_scaffold', |
There was a problem hiding this comment.
We have scapi_custom_apis_status tool, can we unify the tool name? Maybe scapi_custom_api_scaffold
There was a problem hiding this comment.
This name "scapi_custom_api_scaffold" is following the LLD. Once LLD is updated, will update here.
There was a problem hiding this comment.
@wei-liu-sf I corrected the name in LLD so that it matches the naming with other scapi tools. Please update it to scapi_custom_api_scaffold. Thank you.
| const flagConfig = { | ||
| ...extractInstanceFlags(this.flags as Record<string, unknown>), | ||
| ...mrt.config, | ||
| workingDirectory: this.flags['working-directory'], |
There was a problem hiding this comment.
getBaseConfigOptions() already supplies workingDirectory so we do not need it here again.
| /** Short description of the API. Default: "A custom B2C Commerce API" */ | ||
| apiDescription?: string; | ||
| /** Include example GET/POST endpoints in schema and script. Default: true */ | ||
| includeExampleEndpoints?: boolean; |
There was a problem hiding this comment.
Wonder when agent will set this to false? Do we need this input?
There was a problem hiding this comment.
it's default to true. I can remove it.
| /** Output directory override. Default: scaffold default or project root */ | ||
| outputDir?: string; | ||
| /** If true, preview only (no files written). Default: false */ | ||
| dryRun?: boolean; |
There was a problem hiding this comment.
What will happen when dryRun is true? Do we need this?
| name: 'scapi_customapi_scaffold', | ||
| description: `Generate a new custom SCAPI endpoint (OAS 3.0 schema, api.json, script.js) in an existing cartridge. \ | ||
| Uses the same scaffold as CLI: b2c scaffold generate custom-api. \ | ||
| Required: apiName (kebab-case). Optional: cartridgeName (defaults to first cartridge found in project), apiType (shopper|admin), apiDescription, includeExampleEndpoints, projectRoot, outputDir, dryRun, force. \ |
There was a problem hiding this comment.
Description can be improved to avoid duplicated inputs info that is specified in the input schema. Also we probably can skip the mention of CLI since that seems not help agent to use the tool.
packages/b2c-dx-mcp/src/tools/scapi/scapi-custom-api-scaffold.ts
Outdated
Show resolved
Hide resolved
| dryRun: args.dryRun ?? false, | ||
| files: [], | ||
| error: | ||
| 'No cartridges found in project. Add a cartridge (directory with .project file) or pass cartridgeName explicitly.', |
There was a problem hiding this comment.
Can we give more details so that agent knows how to add a cartridge project?
| * Generates a new custom SCAPI endpoint using the SDK's custom-api scaffold | ||
| * (schema.yaml, api.json, script.js). Mirrors CLI: b2c scaffold generate custom-api. | ||
| * | ||
| * @module tools/scapi/scapi-customapi-scaffold |
There was a problem hiding this comment.
Can we update file name as well?
| { | ||
| name: 'scapi_custom_api_scaffold', | ||
| description: `Generate a new custom SCAPI endpoint (OAS 3.0 schema, api.json, script.js) in an existing cartridge. \ | ||
| Uses the same scaffold as CLI: b2c scaffold generate custom-api. \ |
There was a problem hiding this comment.
Can we remove LCI from the description? We should try to keep description short and simple. Mention of CLI might confuse agent.
patricksullivansf
left a comment
There was a problem hiding this comment.
thank you! after it merges i'll do a fast follow to address the clean up we discussed
Summary
Implementation of Scaffold Custom API MCP Tool
Testing
Restart the local B2C-DX-MCP
Dependencies
3pl-approvedis set by a maintainerpnpm test)pnpm run format)