Skip to main content
Glama

search_components

Search for PC components on meupc.net using a text query. Results include processors, graphics cards, memory, and more.

Instructions

Busca componentes de PC por texto no meupc.net (processadores, placas de vídeo, memórias, etc.)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesTexto para buscar componentes (ex: 'rtx 4070', 'ryzen 7')
limitNoNúmero máximo de resultados

Implementation Reference

  • Main handler function for the 'search_components' tool. It scrapes meupc.net search results by querying /pesquisar?q=..., parsing each result's name, category (from 'Add na build' link), price (PIX or normal), URL, and image. Returns JSON string of up to 'limit' results.
    export async function searchComponents(params: SearchComponentsParams): Promise<string> {
      const { query, limit } = params;
      const encoded = encodeURIComponent(query);
      const root = await fetchPage(`/pesquisar?q=${encoded}`);
    
      const results: ComponentResult[] = [];
    
      for (const el of root.querySelectorAll("div.media")) {
        if (results.length >= limit) break;
    
        const name = el.querySelector("div.media-content a h4")?.text.trim() ?? "";
        if (!name) continue;
    
        const url = el.querySelector("div.media-content > a")?.getAttribute("href") ?? "";
        const image = el.querySelector("div.media-left figure img")?.getAttribute("src") ?? null;
    
        // Extrair categoria do link "Add na build" (ex: /processadores/add/HASH)
        const addLink = el.querySelector("a.button.is-link")?.getAttribute("href") ?? "";
        const categoryMatch = addLink.match(/meupc\.net\/([^/]+)\/add\//);
        const category = categoryMatch ? categoryMatch[1] : null;
    
        // Extrair preço do parágrafo de preço
        const priceP = el.querySelectorAll("div.media-content > p").find(p => p.text.includes("R$"));
        const priceText = priceP?.text ?? "";
    
        // Tentar pegar preço PIX primeiro, senão preço normal
        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);
    
        results.push({
          name,
          category,
          price,
          url: absoluteUrl(url),
          image: image && !image.includes("placeholder") ? absoluteUrl(image) : null,
        });
      }
    
      return JSON.stringify(results, null, 2);
    }
  • Zod schema defining the input for 'search_components': 'query' (string, required) and 'limit' (positive int, default 10).
    export const searchComponentsSchema = z.object({
      query: z.string().describe("Texto para buscar componentes (ex: 'rtx 4070', 'ryzen 7')"),
      limit: z.number().int().positive().default(10).describe("Número máximo de resultados"),
    });
  • src/index.ts:16-23 (registration)
    Registration of the 'search_components' tool with the MCP server using server.tool(...). Provides description, schema.shape, and an async callback that calls the handler.
    server.tool(
      "search_components",
      "Busca componentes de PC por texto no meupc.net (processadores, placas de vídeo, memórias, etc.)",
      searchComponentsSchema.shape,
      async (params) => ({
        content: [{ type: "text", text: await searchComponents(params) }],
      })
    );
  • The ComponentResult interface used as the return structure for search results (name, category, price, url, image).
    export interface ComponentResult {
      name: string;
      category: string | null;
      price: number | null;
      url: string;
      image: string | null;
    }
  • fetchPage helper used by the handler to fetch and parse HTML from meupc.net. Also includes absoluteUrl and parsePrice utilities.
    export async function fetchPage(path: string): Promise<HTMLElement> {
      const url = path.startsWith("http") ? path : `${BASE_URL}${path.startsWith("/") ? "" : "/"}${path}`;
    
      const controller = new AbortController();
      const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT);
    
      try {
        const response = await fetch(url, {
          headers: {
            "User-Agent": USER_AGENT,
            "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
            "Accept-Language": "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7",
          },
          signal: controller.signal,
        });
    
        if (!response.ok) {
          throw new Error(`HTTP ${response.status}: ${response.statusText} — ${url}`);
        }
    
        const html = await response.text();
        return parse(html);
      } finally {
        clearTimeout(timeout);
      }
    }
    
    export function absoluteUrl(path: string | undefined | null): string {
      if (!path) return "";
      if (path.startsWith("http")) return path;
      return `${BASE_URL}${path.startsWith("/") ? "" : "/"}${path}`;
    }
    
    export function parsePrice(text: string | undefined | null): number | null {
      if (!text) return null;
      const cleaned = text.replace(/[R$\s.]/g, "").replace(",", ".");
      const num = parseFloat(cleaned);
      return isNaN(num) ? null : num;
    }
Behavior2/5

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

No annotations are provided. The description does not disclose behavioral traits such as whether the search is case-sensitive, how results are ordered, any rate limits, or the data source's freshness. As a search tool, it should mention if it uses exact or fuzzy matching.

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 sentence that efficiently conveys the tool's core function. No redundant or unnecessary words are present.

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?

Given no output schema and no annotations, the description is too brief. It does not explain what the response contains (e.g., list of components, IDs, prices) or how to handle errors. For a search tool with only two parameters, it could be more informative.

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 coverage is 100%, so baseline is 3. The description adds example values for 'query' and explains the 'limit' parameter, but this adds only minor value beyond the schema's own descriptions.

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 PC components by text on meupc.net, listing specific component types. It effectively differentiates from siblings like 'list_components' which likely lists all, and 'get_component_details' for 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 when to use (search by text) but does not explicitly state when not to use or mention alternatives. The sibling context provides indirect differentiation, but direct guidance is lacking.

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