Skip to main content
Glama
taurgis

SFCC Development MCP Server

by taurgis

get_best_practice_guide

Access SFCC best practice guides to implement features correctly, covering cartridges, templates, hooks, controllers, endpoints, performance, and security.

Instructions

Get a complete best practice and how-to guide with all sections and content. Use this when implementing specific SFCC features like cartridges, ISML templates, OCAPI/SCAPI hooks, SFRA controllers, or custom endpoints. Always consult the relevant guide before writing code to ensure you follow SFCC best practices, security guidelines, and proper architecture patterns.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guideNameYesThe guide name (e.g., 'cartridge_creation', 'isml_templates', 'job_framework', 'localserviceregistry', 'ocapi_hooks', 'scapi_hooks', 'sfra_controllers', 'sfra_models', 'sfra_client_side_js', 'sfra_scss', 'scapi_custom_endpoint', 'performance', 'security')

Implementation Reference

  • The handler configuration for the 'get_best_practice_guide' tool. It includes defaults, input validation requiring 'guideName', the exec function that retrieves the SFCCBestPracticesClient from context and calls getBestPracticeGuide, and a log message.
    get_best_practice_guide: {
      defaults: (args: ToolArguments) => args,
      validate: (args: ToolArguments, toolName: string) => {
        ValidationHelpers.validateArguments(args, CommonValidations.requiredString('guideName'), toolName);
      },
      exec: async (args: ToolArguments, context: ToolExecutionContext) => {
        const client = context.bestPracticesClient as SFCCBestPracticesClient;
        return client.getBestPracticeGuide(args.guideName as string);
      },
      logMessage: (args: ToolArguments) => `Guide ${args.guideName}`,
    },
  • The tool schema definition in the BEST_PRACTICES_TOOLS array, including name, detailed description, and inputSchema with guideName enum listing all available guides.
    {
      name: 'get_best_practice_guide',
      description: 'Get a complete best practice and how-to guide with all sections and content. Use this when implementing specific SFCC features like cartridges, ISML templates, OCAPI/SCAPI hooks, SFRA controllers, or custom endpoints. Always consult the relevant guide before writing code to ensure you follow SFCC best practices, security guidelines, and proper architecture patterns.',
      inputSchema: {
        type: 'object',
        properties: {
          guideName: {
            type: 'string',
            enum: ['cartridge_creation', 'isml_templates', 'job_framework', 'localserviceregistry', 'ocapi_hooks', 'scapi_hooks', 'sfra_controllers', 'sfra_models', 'sfra_client_side_js', 'sfra_scss', 'scapi_custom_endpoint', 'performance', 'security'],
            description: 'The guide name (e.g., \'cartridge_creation\', \'isml_templates\', \'job_framework\', \'localserviceregistry\', \'ocapi_hooks\', \'scapi_hooks\', \'sfra_controllers\', \'sfra_models\', \'sfra_client_side_js\', \'sfra_scss\', \'scapi_custom_endpoint\', \'performance\', \'security\')',
          },
        },
        required: ['guideName'],
      },
    },
  • Registration of the tool configs in the BestPracticesToolHandler class's getToolConfig method, which returns the BEST_PRACTICES_TOOL_CONFIG containing the handler for get_best_practice_guide.
    protected getToolConfig(): Record<string, GenericToolSpec<ToolArguments, any>> {
      return BEST_PRACTICES_TOOL_CONFIG;
    }
  • MCP server registration where BEST_PRACTICES_TOOLS (including get_best_practice_guide schema) is added to the list of available tools in ListToolsRequestHandler.
    tools.push(...BEST_PRACTICES_TOOLS);
  • The core helper function in SFCCBestPracticesClient that implements the logic to securely read, parse, and structure the best practice guide markdown file, including caching, path traversal protection, content validation, title/section/description extraction, and error handling.
    async getBestPracticeGuide(guideName: string): Promise<BestPracticeGuide | null> {
      const cacheKey = `best-practices:guide:${guideName}`;
      const cached = this.cache.getFileContent(cacheKey);
      if (cached) {return JSON.parse(cached);}
    
      try {
        // Enhanced security validation - validate guideName before path construction
        if (!guideName || typeof guideName !== 'string') {
          throw new Error('Invalid guide name: must be a non-empty string');
        }
    
        // Prevent null bytes and dangerous characters in the guide name itself
        if (guideName.includes('\0') || guideName.includes('\x00')) {
          throw new Error('Invalid guide name: contains null bytes');
        }
    
        // Prevent path traversal sequences in the guide name
        if (guideName.includes('..') || guideName.includes('/') || guideName.includes('\\')) {
          throw new Error('Invalid guide name: contains path traversal sequences');
        }
    
        // Only allow alphanumeric characters, underscores, and hyphens
        if (!/^[a-zA-Z0-9_-]+$/.test(guideName)) {
          throw new Error('Invalid guide name: contains invalid characters');
        }
    
        const filePath = path.join(this.docsPath, `${guideName}.md`);
    
        // Additional security validation - ensure the resolved path is within the docs directory
        const resolvedPath = path.resolve(filePath);
        const resolvedDocsPath = path.resolve(this.docsPath);
    
        if (!resolvedPath.startsWith(resolvedDocsPath)) {
          throw new Error('Invalid guide name: path outside allowed directory');
        }
    
        // Ensure the file still ends with .md after path resolution
        if (!resolvedPath.toLowerCase().endsWith('.md')) {
          throw new Error('Invalid guide name: must reference a markdown file');
        }
    
        const content = await fs.readFile(resolvedPath, 'utf-8');
    
        // Basic content validation
        if (!content.trim()) {
          throw new Error(`Empty best practice guide: ${guideName}`);
        }
    
        // Check for binary content
        if (content.includes('\0')) {
          throw new Error(`Invalid content in best practice guide: ${guideName}`);
        }
    
        const lines = content.split('\n');
        const title = lines.find(line => line.startsWith('#'))?.replace('#', '').trim() ?? guideName;
    
        // Extract sections (## headers)
        const sections = lines
          .filter(line => line.startsWith('##'))
          .map(line => line.replace('##', '').trim());
    
        // Extract description (first paragraph after title)
        const descriptionStart = lines.findIndex(line => line.startsWith('#')) + 1;
        const descriptionEnd = lines.findIndex((line, index) =>
          index > descriptionStart && (line.startsWith('#') || line.trim() === ''));
        const description = lines
          .slice(descriptionStart, descriptionEnd > -1 ? descriptionEnd : descriptionStart + 3)
          .join(' ')
          .trim();
    
        const guide: BestPracticeGuide = {
          title,
          description,
          sections,
          content,
        };
    
        this.cache.setFileContent(cacheKey, JSON.stringify(guide));
        return guide;
      } catch (error) {
        this.logger.error(`Error reading best practice guide ${guideName}:`, error);
        return null;
      }
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions that the tool retrieves 'complete' guides with 'all sections and content', which adds useful context about output comprehensiveness. However, it lacks details on potential limitations like response size, error handling, or performance implications, leaving some behavioral aspects unclear.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, starting with the core purpose. Both sentences earn their place by clarifying usage and emphasizing importance, though it could be slightly more concise by integrating the recommendation more seamlessly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (single parameter, no output schema, no annotations), the description is fairly complete. It explains what the tool does, when to use it, and the importance of consulting guides, but lacks details on output format or error cases, which could enhance completeness for a tool without annotations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the single parameter 'guideName' with its enum values. The description does not add any parameter-specific details beyond what the schema provides, such as examples of when to choose specific guides, so it meets the baseline for high schema coverage without extra value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('Get a complete best practice and how-to guide') and resources ('all sections and content'), and explicitly distinguishes it from siblings by specifying when to use it for SFCC features like cartridges, ISML templates, etc., rather than just listing or searching.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It provides explicit guidance on when to use this tool ('when implementing specific SFCC features') and includes a strong recommendation ('Always consult the relevant guide before writing code'), which helps differentiate it from sibling tools that might list or search guides without the same emphasis on pre-implementation consultation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/taurgis/sfcc-dev-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server