Skip to main content
Glama
marianfoo

SAP Documentation MCP Server

sap_help_search

Search the official SAP Help Portal for product guides, implementation documentation, and technical resources using specific SAP terminology.

Instructions

SEARCH SAP HELP PORTAL: sap_help_search(query="product + topic")

FUNCTION NAME: sap_help_search (or mcp_sap-docs-remote_sap_help_search)

SEARCHES: Official SAP Help Portal (help.sap.com) COVERS: Product guides, implementation guides, technical documentation

TYPICAL WORKFLOW:

  1. sap_help_search(query="product name + configuration topic")

  2. sap_help_get(result_id="sap-help-12345abc")

BEST PRACTICES: • Include product names: "S/4HANA", "BTP", "Fiori" • Add specific tasks: "configuration", "setup", "deployment" • Use official SAP terminology

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch terms for SAP Help Portal. Include product names and specific topics.

Implementation Reference

  • Core handler function for sap_help_search tool. Queries SAP Help Portal's elasticsearch endpoint, processes JSON results into standardized SearchResponse format, implements caching via global.sapHelpSearchCache, and returns formatted results with instructions for sap_help_get.
    export async function searchSapHelp(query: string): Promise<SearchResponse> {
      try {
        const searchParams = {
          transtype: "standard,html,pdf,others",
          state: "PRODUCTION,TEST,DRAFT",
          product: "",
          version: "",
          q: query,
          to: "19", // Limit to 20 results (0-19)
          area: "content",
          advancedSearch: "0",
          excludeNotSearchable: "1",
          language: "en-US",
        };
    
        const searchUrl = `${BASE}/http.svc/elasticsearch?${toQuery(searchParams)}`;
        
        const response = await fetch(searchUrl, {
          headers: {
            Accept: "application/json",
            "User-Agent": "mcp-sap-docs/help-search",
            Referer: BASE,
          },
        });
    
        if (!response.ok) {
          throw new Error(`SAP Help search failed: ${response.status} ${response.statusText}`);
        }
    
        const data: SapHelpSearchResponse = await response.json();
        const results = data?.data?.results || [];
    
        if (!results.length) {
          return {
            results: [],
            error: `No SAP Help results found for "${query}"`
          };
        }
    
        // Store the search results for later retrieval
        const searchResults: SearchResult[] = results.map((hit, index) => ({
          library_id: `sap-help-${hit.loio}`,
          topic: '',
          id: `sap-help-${hit.loio}`,
          title: hit.title,
          url: ensureAbsoluteUrl(hit.url),
          snippet: `${hit.snippet || hit.title} — Product: ${hit.product || hit.productId || "Unknown"} (${hit.version || hit.versionId || "Latest"})`,
          score: 0,
          metadata: {
            source: "help",
            loio: hit.loio,
            product: hit.product || hit.productId,
            version: hit.version || hit.versionId,
            rank: index + 1
          },
          // Legacy fields for backward compatibility
          description: `${hit.snippet || hit.title} — Product: ${hit.product || hit.productId || "Unknown"} (${hit.version || hit.versionId || "Latest"})`,
          totalSnippets: 1,
          source: "help"
        }));
    
        // Store the full search results in a simple cache for retrieval
        // In a real implementation, you might want a more sophisticated cache
        if (!global.sapHelpSearchCache) {
          global.sapHelpSearchCache = new Map();
        }
        results.forEach(hit => {
          global.sapHelpSearchCache!.set(hit.loio, hit);
        });
    
        // Format response similar to other search functions
        const formattedResults = searchResults.slice(0, 20).map((result, i) => 
          `[${i}] **${result.title}**\n   ID: \`${result.id}\`\n   URL: ${result.url}\n   ${result.description}\n`
        ).join('\n');
    
        return {
          results: searchResults.length > 0 ? searchResults : [{
            library_id: "sap-help",
            topic: '',
            id: "search-results",
            title: `SAP Help Search Results for "${query}"`,
            url: '',
            snippet: `Found ${searchResults.length} results from SAP Help:\n\n${formattedResults}\n\nUse sap_help_get with the ID of any result to retrieve the full content.`,
            score: 0,
            metadata: {
              source: "help",
              totalSnippets: searchResults.length
            },
            // Legacy fields for backward compatibility
            description: `Found ${searchResults.length} results from SAP Help:\n\n${formattedResults}\n\nUse sap_help_get with the ID of any result to retrieve the full content.`,
            totalSnippets: searchResults.length,
            source: "help"
          }]
        };
    
      } catch (error: any) {
        return {
          results: [],
          error: `SAP Help search error: ${error.message}`
        };
      }
    }
  • MCP tool registration for sap_help_search, including name, detailed description with usage examples, and input schema validation.
              {
                name: "sap_help_search",
                description: `SEARCH SAP HELP PORTAL: sap_help_search(query="product + topic")
    
    FUNCTION NAME: sap_help_search (or mcp_sap-docs-remote_sap_help_search)
    
    SEARCHES: Official SAP Help Portal (help.sap.com)
    COVERS: Product guides, implementation guides, technical documentation
    
    TYPICAL WORKFLOW:
    1. sap_help_search(query="product name + configuration topic")
    2. sap_help_get(result_id="sap-help-12345abc")
    
    BEST PRACTICES:
    • Include product names: "S/4HANA", "BTP", "Fiori"
    • Add specific tasks: "configuration", "setup", "deployment"
    • Use official SAP terminology`,
                inputSchema: {
                  type: "object",
                  properties: {
                    query: {
                      type: "string",
                      description: "Search terms for SAP Help Portal. Include product names and specific topics.",
                      examples: [
                        "S/4HANA configuration",
                        "Fiori Launchpad setup", 
                        "BTP integration",
                        "ABAP development guide",
                        "SAP Analytics Cloud setup"
                      ]
                    }
                  },
                  required: ["query"]
                }
              },
  • MCP CallToolRequestSchema handler dispatch for sap_help_search: extracts query argument, calls searchSapHelp, transforms response to ChatGPT-compatible JSON format, handles errors and logging.
    if (name === "sap_help_search") {
      const { query } = args as { query: string };
      
      // Enhanced logging with timing
      const timing = logger.logToolStart(name, query, clientMetadata);
      
      try {
        const res: SearchResponse = await searchSapHelp(query);
        
        if (!res.results.length) {
          logger.logToolSuccess(name, timing.requestId, timing.startTime, 0);
          return createErrorResponse(
            res.error || `No SAP Help results found for "${query}". Try different keywords or check your connection.`,
            timing.requestId
          );
        }
        
        // Transform SAP Help search results to ChatGPT-compatible format
        const helpResults: SearchResult[] = res.results.map((r, index) => ({
          // ChatGPT-required format: id, title, url
          id: r.id || `sap-help-${index}`,
          title: r.title || 'SAP Help Document',
          url: r.url || `#${r.id}`,
          // Additional fields for enhanced functionality
          snippet: r.description ? r.description.substring(0, 200) + '...' : '',
          metadata: {
            source: 'sap-help',
            totalSnippets: r.totalSnippets,
            rank: index + 1
          }
        }));
        
        logger.logToolSuccess(name, timing.requestId, timing.startTime, res.results.length);
        
        return createSearchResponse(helpResults);
      } catch (error) {
        logger.logToolError(name, timing.requestId, timing.startTime, error);
        return createErrorResponse(
          `SAP Help search service temporarily unavailable. Please try again later.`,
          timing.requestId
        );
      }
    }
  • TypeScript interfaces defining input/output structures for SAP Help search: SapHelpSearchResult, SapHelpSearchResponse, and related metadata/page content responses used by the handler.
    // SAP Help specific types
    export interface SapHelpSearchResult {
      loio: string;
      title: string;
      url: string;
      productId?: string;
      product?: string;
      version?: string;
      versionId?: string;
      language?: string;
      snippet?: string;
    }
    
    export interface SapHelpSearchResponse {
      data?: {
        results?: SapHelpSearchResult[];
      };
    }
    
    export interface SapHelpMetadataResponse {
      data?: {
        deliverable?: {
          id: string;
          buildNo: string;
        };
        filePath?: string;
      };
    }
    
    export interface SapHelpPageContentResponse {
      data?: {
        currentPage?: {
          t?: string; // title
        };
        deliverable?: {
          title?: string;
        };
        body?: string;
      };
    } 
  • Utility function toQuery converts search parameters to URL query string, used in SAP Help elasticsearch requests.
    function toQuery(params: Record<string, any>): string {
      return Object.entries(params)
        .filter(([, v]) => v !== undefined && v !== null && v !== "")
        .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)
        .join("&");
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes what the tool searches (SAP Help Portal) and what content it covers, but doesn't mention rate limits, authentication requirements, pagination behavior, or the format of search results. The description adds useful context about the source and content scope but lacks operational details.

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 well-structured with clear sections (SEARCHES, COVERS, TYPICAL WORKFLOW, BEST PRACTICES) and uses bullet points effectively. While somewhat detailed, every section adds value and the information is front-loaded with the core purpose. The tool name repetition in the first line is slightly redundant but not excessive.

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 output schema, the description provides good context about what content is searched, how to use it effectively, and its place in a workflow. It could benefit from mentioning what the search results look like (e.g., list of documents with IDs/titles) since there's no output schema, but otherwise covers the essential context well given the tool's complexity.

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

Parameters4/5

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

The schema description coverage is 100%, so the schema already documents the single query parameter. The description adds value by providing best practices for constructing effective queries with specific examples of product names and tasks, and shows the typical query format with examples like 'product + topic'. This goes beyond the schema's basic parameter documentation.

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 searches the SAP Help Portal, specifying it covers product guides, implementation guides, and technical documentation. It distinguishes from sibling tools like sap_community_search and sap_help_get by focusing specifically on the official SAP Help Portal content rather than community forums or retrieving specific results.

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 provides explicit guidance on when to use this tool versus alternatives, showing a typical workflow where this search tool is followed by sap_help_get to retrieve specific results. It also offers best practices for constructing effective queries, including specific product names and tasks.

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/marianfoo/mcp-sap-docs'

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