Skip to main content
Glama
taurgis

SFCC Development MCP Server

by taurgis

search_sfra_documentation

Search SFRA documentation to find implementation details for controllers, models, routing, middleware, cart functionality, and customer management.

Instructions

Search across all SFRA documentation for specific terms, concepts, or functionality. Use this when you need to find specific SFRA features, understand how to implement controller patterns, locate model information, or find information about routing, middleware, request handling, response management, cart functionality, product models, or customer management. Enhanced with relevance scoring and categorization.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch term or concept (e.g., 'middleware', 'routing', 'render', 'querystring', 'cache', 'cart', 'product', 'billing', 'shipping', 'account', 'pricing')

Implementation Reference

  • Core handler implementing the search logic: loads all SFRA docs, searches content line-by-line, computes relevance scores based on title/desc/matches, extracts contexts around matches, sorts by relevance.
    async searchSFRADocumentation(query: string): Promise<Array<{
      document: string;
      title: string;
      category: string;
      type: string;
      relevanceScore: number;
      matches: Array<{section: string; content: string; lineNumber: number}>;
    }>> {
      const cacheKey = `sfra:search:${query.toLowerCase()}`;
      const cached = this.cache.getSearchResults(cacheKey);
      if (cached) {return cached;}
    
      const documents = await this.getAvailableDocuments();
      const results = [];
      const queryLower = query.toLowerCase();
      const queryWords = queryLower.split(/\s+/).filter(word => word.length > 1);
    
      for (const doc of documents) {
        const documentContent = await this.getSFRADocument(doc.name);
        if (!documentContent) {continue;}
    
        const matches = [];
        const lines = documentContent.content.split('\n');
        let currentSection = '';
        let relevanceScore = 0;
    
        // Calculate relevance score based on title and description matches
        if (doc.title.toLowerCase().includes(queryLower)) {
          relevanceScore += 10;
        }
        if (doc.description.toLowerCase().includes(queryLower)) {
          relevanceScore += 5;
        }
    
        // Search through content
        for (let i = 0; i < lines.length; i++) {
          const line = lines[i];
          const lineLower = line.toLowerCase();
    
          if (line.startsWith('##')) {
            currentSection = line.replace(/^##\s*/, '').trim();
          }
    
          // Check for query matches
          let matchFound = false;
          let lineRelevance = 0;
    
          if (lineLower.includes(queryLower)) {
            matchFound = true;
            lineRelevance += 3;
          } else {
            // Check for partial matches with query words
            const wordMatches = queryWords.filter(word => lineLower.includes(word));
            if (wordMatches.length > 0) {
              matchFound = true;
              lineRelevance += wordMatches.length;
            }
          }
    
          if (matchFound) {
            // Get context around the match
            const contextStart = Math.max(0, i - 2);
            const contextEnd = Math.min(lines.length, i + 3);
            const context = lines.slice(contextStart, contextEnd)
              .map((contextLine, idx) => {
                const actualLineNumber = contextStart + idx;
                return actualLineNumber === i ? `>>> ${contextLine}` : contextLine;
              })
              .join('\n');
    
            matches.push({
              section: currentSection || 'Introduction',
              content: context,
              lineNumber: i + 1,
            });
    
            relevanceScore += lineRelevance;
          }
        }
    
        if (matches.length > 0) {
          results.push({
            document: doc.name,
            title: doc.title,
            category: doc.category,
            type: doc.type,
            relevanceScore,
            matches,
          });
        }
      }
    
      // Sort by relevance score (highest first)
      results.sort((a, b) => b.relevanceScore - a.relevanceScore);
    
      this.cache.setSearchResults(cacheKey, results);
      return results;
    }
  • Tool definition including name, description, and input schema requiring a 'query' string parameter.
    {
      name: 'search_sfra_documentation',
      description: 'Search across all SFRA documentation for specific terms, concepts, or functionality. Use this when you need to find specific SFRA features, understand how to implement controller patterns, locate model information, or find information about routing, middleware, request handling, response management, cart functionality, product models, or customer management. Enhanced with relevance scoring and categorization.',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: "Search term or concept (e.g., 'middleware', 'routing', 'render', 'querystring', 'cache', 'cart', 'product', 'billing', 'shipping', 'account', 'pricing')",
          },
        },
        required: ['query'],
      },
    },
  • Tool registration configuration: validation for 'query' arg, exec handler delegating to SFRAClient, logging.
    search_sfra_documentation: {
      defaults: (args: ToolArguments) => args,
      validate: (args: ToolArguments, toolName: string) => {
        ValidationHelpers.validateArguments(args, CommonValidations.requiredString('query'), toolName);
      },
      exec: async (args: ToolArguments, context: ToolExecutionContext) => {
        const client = context.sfraClient as SFRAClient;
        return client.searchSFRADocumentation(args.query as string);
      },
      logMessage: (args: ToolArguments) => `Search SFRA ${args.query}`,
    },
  • Array listing all SFRA tool names including search_sfra_documentation for type safety and registration reference.
    export const SFRA_TOOL_NAMES = [
      'get_available_sfra_documents',
      'get_sfra_document',
      'search_sfra_documentation',
      'get_sfra_documents_by_category',
      'get_sfra_categories',
    ] as const;
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by disclosing key behavioral traits: it searches 'across all SFRA documentation' (scope), mentions 'relevance scoring and categorization' (ranking/grouping behavior), and implies it returns multiple results rather than single documents. However, it doesn't specify output format, pagination, or error conditions.

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 with two sentences: the first establishes purpose and usage guidelines, the second adds behavioral context. Every sentence adds value, though the list of examples in the first sentence could be slightly more concise while still maintaining clarity.

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?

For a single-parameter search tool with no annotations and no output schema, the description does well by covering purpose, usage guidelines, and key behavioral traits. However, it doesn't describe the output format or structure, which would be helpful given the absence of an output schema.

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% for the single 'query' parameter, so the schema already fully documents it. The description adds no additional parameter information beyond what's in the schema, maintaining the baseline score of 3 for adequate but not enhanced parameter semantics.

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 specific action ('Search across all SFRA documentation') and resource ('SFRA documentation'), distinguishing it from siblings like 'search_best_practices' or 'get_sfra_document' by emphasizing comprehensive search across all documentation rather than retrieving specific documents or searching other content types.

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?

The description explicitly states when to use this tool ('Use this when you need to find specific SFRA features, understand how to implement controller patterns...') and provides multiple concrete examples of use cases, making it clear this is for broad documentation searches rather than targeted retrieval or other search types offered by siblings.

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