Skip to main content
Glama

list_components

Retrieve computer components by category with pagination and sorting. Covers processors, graphics cards, motherboards, memory, storage, cases, power supplies, monitors, and coolers from Brazilian stores.

Instructions

Lista componentes por categoria com paginação (processadores, placas-video, placas-mae, memorias, armazenamentos, gabinetes, fontes, monitores)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYesCategoria de componente (ex: 'processadores', 'placas-video')
pageNoNúmero da página
sortNoOrdenação (ex: 'menor-preco', 'maior-preco')

Implementation Reference

  • Main handler function 'listComponents' that fetches components by category, tries to extract data from embedded Vue.js scripts, and falls back to scraping search results page if no script data is found.
    export async function listComponents(params: ListComponentsParams): Promise<string> {
      const { category, page, sort } = params;
    
      // Tentar extrair dados do script embutido na página de categoria
      const categoryUrl = `/${category}?page=${page}${sort ? `&ordem=${sort}` : ""}`;
      const root = await fetchPage(categoryUrl);
    
      // Procurar dados JSON nos scripts da página
      const results = extractFromScripts(root, category);
      if (results.length > 0) {
        return JSON.stringify(results, null, 2);
      }
    
      // Fallback: usar a página de busca com termo da categoria
      const categoryTerms: Record<string, string> = {
        "processadores": "processador",
        "placas-video": "placa de video",
        "placas-mae": "placa mae",
        "memorias": "memoria ram",
        "armazenamentos": "ssd",
        "gabinetes": "gabinete",
        "fontes": "fonte",
        "monitores": "monitor",
        "coolers-processador": "cooler processador",
        "water-coolers": "water cooler",
      };
    
      const searchTerm = categoryTerms[category] ?? category;
      const encoded = encodeURIComponent(searchTerm);
      const searchRoot = await fetchPage(`/pesquisar?q=${encoded}&page=${page}`);
    
      const searchResults: ComponentResult[] = [];
    
      searchRoot.querySelectorAll("div.media").forEach(el => {
        const name = el.querySelector("div.media-content a h4")?.text.trim() ?? "";
        if (!name) return;
    
        const url = el.querySelector("div.media-content > a")?.getAttribute("href") ?? "";
        const image = el.querySelector("div.media-left figure img")?.getAttribute("src") ?? null;
    
        const addLink = el.querySelector("a.button.is-link")?.getAttribute("href") ?? "";
        const catMatch = addLink.match(/meupc\.net\/([^/]+)\/add\//);
        const cat = catMatch ? catMatch[1] : null;
    
        const priceP = el.querySelectorAll("div.media-content > p").find(p => p.text.includes("R$"));
        const priceText = priceP?.text ?? "";
    
        const pixMatch = priceText.match(/R\$\s*([\d.,]+)\s*no PIX/);
        const normalMatch = priceText.match(/R\$\s*([\d.,]+)/);
        const priceStr = pixMatch ? pixMatch[1] : normalMatch ? normalMatch[1] : null;
        const price = parsePrice(priceStr);
    
        searchResults.push({
          name,
          category: cat,
          price,
          url: absoluteUrl(url),
          image: image && !image.includes("placeholder") ? absoluteUrl(image) : null,
        });
      });
    
      return JSON.stringify({
        note: "Dados obtidos via busca (a listagem por categoria usa renderização client-side)",
        category,
        page,
        results: searchResults,
      }, null, 2);
    }
  • Zod schema 'listComponentsSchema' defining input validation: category (enum of 10 categories), page (positive int, default 1), and optional sort string.
    export const listComponentsSchema = z.object({
      category: z.enum(CATEGORIES).describe("Categoria de componente (ex: 'processadores', 'placas-video')"),
      page: z.number().int().positive().default(1).describe("Número da página"),
      sort: z.string().optional().describe("Ordenação (ex: 'menor-preco', 'maior-preco')"),
    });
  • Helper function 'extractFromScripts' that parses embedded JSON data from Vue.js client-side scripts on category pages (looks for window.meupcnetPecas, window.meupcnetData, var pecas).
    function extractFromScripts(root: HTMLElement, category: string): ComponentResult[] {
      const results: ComponentResult[] = [];
    
      root.querySelectorAll("script").forEach(script => {
        const content = script.innerHTML ?? "";
    
        // Tentar encontrar arrays de dados de peças em variáveis window.*
        const patterns = [
          /window\.meupcnetPecas\s*=\s*(\[[\s\S]*?\]);/,
          /window\.meupcnetData\s*=\s*(\{[\s\S]*?\});/,
          /var\s+pecas\s*=\s*(\[[\s\S]*?\]);/,
        ];
    
        for (const pattern of patterns) {
          const match = content.match(pattern);
          if (match) {
            try {
              const data = JSON.parse(match[1]);
              const items = Array.isArray(data) ? data : (data.pecas ?? data.items ?? []);
              for (const item of items) {
                results.push({
                  name: item.nome ?? item.name ?? item.title ?? "",
                  category,
                  price: item.preco ?? item.price ?? item.menor_preco ?? null,
                  url: item.url ? absoluteUrl(item.url) : `${BASE_URL}/peca/${item.hash ?? item.id ?? ""}`,
                  image: item.imagem ?? item.image ?? null,
                });
              }
            } catch {
              // JSON parse falhou, continuar
            }
          }
        }
      });
    
      return results;
    }
  • src/index.ts:25-32 (registration)
    Registration of 'list_components' tool with the MCP server, binding the schema and handler via server.tool().
    server.tool(
      "list_components",
      "Lista componentes por categoria com paginação (processadores, placas-video, placas-mae, memorias, armazenamentos, gabinetes, fontes, monitores)",
      listComponentsSchema.shape,
      async (params) => ({
        content: [{ type: "text", text: await listComponents(params) }],
      })
    );
  • The ComponentResult interface used as the return type of extracted component data.
    export interface ComponentResult {
      name: string;
      category: string | null;
      price: number | null;
      url: string;
      image: string | null;
    }
Behavior2/5

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

With no annotations, the description must disclose behavioral traits. It mentions pagination and sorting but lacks details on authentication, rate limits, or what happens on invalid category. The return format is not described.

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 a single, front-loaded sentence that lists important categories. It could be slightly shortened by omitting the category list since it's in the schema, but remains concise.

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 listing tool with no output schema, the description should detail the response structure (e.g., fields of returned items, pagination metadata). It fails to do so, leaving the agent guessing.

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 description adds minimal extra meaning beyond duplicating the category list and mentioning pagination/sorting. Baseline 3 applies.

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 it lists components by category with pagination, and enumerates the available categories. This differentiates it from sibling tools like search_components and get_component_details.

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

Usage Guidelines4/5

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

The description implies usage for listing components filtered by category, but does not explicitly state when not to use it or provide alternatives. However, the category focus is clear.

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/leosebben/mcp-meupc'

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