Skip to main content
Glama
mercadolibre

Mercado Pago MCP Server

Official
by mercadolibre

search_documentation

Search Mercado Pago documentation in Spanish or Portuguese to find API integration guidance and technical resources for specific regional sites.

Instructions

Search Mercado Pago documentation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
languageYesLanguage of the documentation (es: Spanish, pt: Portuguese)
queryYesSearch query
siteIdYesSite ID for documentation
limitNoMaximum number of results to return (default: 10)

Implementation Reference

  • The main handler function that performs the API call to search Mercado Pago documentation, processes the results, formats them as Markdown, and returns the response.
      private async handleSearchDocumentation(args: SearchDocumentationArgs, context: RequestContext) {
        try {
          const response = await this.api.get<SearchResult[]>(
            '/docs/v1/search',
            {
              params: {
                term: args.query,
                lang: args.language,
                siteId: args.siteId,
                maxResults: args.limit || 10
              }
            }
          );
    
          const results = response.data;
          if (!results || !Array.isArray(results)) {
            throw new McpError(
              ErrorCode.InternalError,
              'No search results available for the given query'
            );
          }
    
          if (results.length === 0) {
            return {
              content: [
                {
                  type: 'text',
                  text: `No documentation found for query "${args.query}". Try a different search term.`
                }
              ]
            };
          }
    
          // Format results as markdown
          const markdown = results.map(result => {
            if (!result.title && !result.content) {
              this.logger.debug('Incomplete search result', { result });
              return null;  // Skip invalid results
            }
    
            const title = result.title || 'Untitled';
            const content = result.content || 'No description available';
            const siteDomain = DemoMercadoPagoServer.SITE_DOMAINS[args.siteId];
            const url = this.buildDocumentationUrl(siteDomain, args.language, result.url || '');
            const score = result.score || 0;
    
            return `## ${title}
    ${content}
    
    🔗 [Read more](${url})
    
    Score: ${score}
    `;
          }).join('\n\n---\n\n');
    
          const formattedResults = `# Search Results for "${args.query}"
    Showing ${results.length} results
    
    ${results.length > 0 ? markdown : 'No results found.'}`;
    
          return {
            content: [
              {
                type: 'text',
                text: formattedResults
              }
            ]
          };
        } catch (error) {
          const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
          return {
            content: [
              {
                type: 'text',
                text: `Error searching documentation: ${errorMessage}`
              }
            ],
            isError: true
          };
        }
      }
  • TypeScript interface defining the input arguments for the search_documentation tool.
    interface SearchDocumentationArgs {
      language: Language;  // maps to lang
      query: string;      // maps to term
      siteId: SiteId;     // Required parameter
      limit?: number;     // maps to maxResults
    }
  • src/index.ts:267-300 (registration)
    Registration of the search_documentation tool in the ListTools response, including name, description, and input schema.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        {
          name: 'search_documentation',
              description: 'Search Mercado Pago documentation',
              inputSchema: {
                type: 'object',
                properties: {
                  language: {
                    type: 'string',
                    enum: ['es', 'pt'],
                    description: 'Language of the documentation (es: Spanish, pt: Portuguese)'
                  },
                  query: {
                    type: 'string',
                    description: 'Search query'
                  },
                  siteId: {
                    type: 'string',
                    description: 'Site ID for documentation',
                    enum: ['MLB', 'MLM', 'MLA', 'MLU', 'MLC', 'MCO', 'MPE']
                  },
                  limit: {
                    type: 'number',
                    description: 'Maximum number of results to return (default: 10)',
                    minimum: 1,
                    maximum: 100
                  }
                },
                required: ['language', 'query', 'siteId']
          }
        }
      ],
    }));
  • src/index.ts:307-314 (registration)
    Dispatch logic in CallToolRequest handler that routes calls to search_documentation to its handler.
    if (request.params.name === 'search_documentation') {
      if (this.isSearchDocumentationArgs(request.params.arguments)) {
        const result = await this.handleSearchDocumentation(request.params.arguments, context);
        this.logRequestEnd(context);
        return result;
      }
      throw new McpError(ErrorCode.InvalidParams, 'Invalid search_documentation arguments');
    }
  • Type guard helper function to validate input arguments for search_documentation.
    private isSearchDocumentationArgs(args: unknown): args is SearchDocumentationArgs {
      if (!args || typeof args !== 'object') return false;
      const a = args as any;
      const validLanguage = (a.language && ['es', 'pt'].includes(a.language as Language));
      const validQuery = typeof a.query === 'string';
      const validSiteId = (a.siteId && DemoMercadoPagoServer.VALID_SITES.includes(a.siteId as SiteId));
      const validLimit = a.limit === undefined || (typeof a.limit === 'number' && a.limit >= 1 && a.limit <= 100);
      return validLanguage && validQuery && validSiteId && validLimit;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but offers minimal information. It doesn't mention whether this is a read-only operation, potential rate limits, authentication requirements, error conditions, or what the search results look like. 'Search' implies read-only, but this isn't explicitly stated.

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

Conciseness5/5

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

The description is a single, clear sentence with zero wasted words. It's appropriately sized for a simple search tool and front-loads the core functionality effectively.

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

Completeness2/5

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

For a search tool with 4 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what the search returns, how results are ranked, pagination behavior, or error handling. The schema covers parameters well, but the overall context for tool usage is incomplete.

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 fully documents all parameters. The description adds no additional parameter semantics beyond what's in the schema, meeting the baseline for high coverage but not providing extra value.

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

Purpose4/5

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

The description clearly states the verb ('Search') and resource ('Mercado Pago documentation'), making the purpose immediately understandable. It doesn't need to differentiate from siblings since none exist, but it could be more specific about what kind of search this performs (e.g., full-text, title-only).

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives, prerequisites, or typical use cases. The description is a simple statement of function without context about appropriate scenarios or limitations.

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/mercadolibre/demo-mercadopago-mcp-server'

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