Skip to main content
Glama

bcb_comparar

Compare 2 to 5 economic time series within the same period to analyze correlations between indicators from the Brazilian Central Bank.

Instructions

Compara 2 a 5 séries temporais no mesmo período. Útil para análise de correlação entre indicadores.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codigosYesArray com 2 a 5 códigos de séries para comparar
dataInicialYesData inicial (yyyy-MM-dd ou dd/MM/yyyy)
dataFinalYesData final (yyyy-MM-dd ou dd/MM/yyyy)

Implementation Reference

  • The 'handleComparar' function executes the logic for the 'bcb_comparar' tool, fetching time series data from the BCB API for multiple codes and calculating statistics like variation, min, max, and average.
    export async function handleComparar(
      args: { codigos: number[]; dataInicial: string; dataFinal: string },
      timeoutMs?: number,
      maxRetries?: number
    ): Promise<ToolResult> {
      try {
        const resultados = await Promise.all(
          args.codigos.map(async (codigo) => {
            try {
              let url = `${BCB_API_BASE}.${codigo}/dados?formato=json`;
              url += `&dataInicial=${formatDateForApi(args.dataInicial)}`;
              url += `&dataFinal=${formatDateForApi(args.dataFinal)}`;
    
              const data = await fetchBcbApi(url, timeoutMs, maxRetries) as SerieValor[];
              const serieInfo = SERIES_POPULARES.find(s => s.codigo === codigo);
    
              if (!Array.isArray(data) || data.length === 0) {
                return { codigo, nome: serieInfo?.nome || `Série ${codigo}`, erro: "Sem dados no período" };
              }
    
              const valores = data.map(d => parseFloat(d.valor));
              const valorInicial = valores[0];
              const valorFinal = valores[valores.length - 1];
              const variacao = calculateVariation(valorInicial, valorFinal);
    
              return {
                codigo,
                nome: serieInfo?.nome || `Série ${codigo}`,
                categoria: serieInfo?.categoria || "Desconhecida",
                periodicidade: serieInfo?.periodicidade || "Desconhecida",
                totalRegistros: data.length,
                valorInicial, valorFinal,
                variacaoPercentual: Number(variacao.toFixed(4)),
                variacaoFormatada: `${variacao >= 0 ? "+" : ""}${variacao.toFixed(2)}%`,
                maximo: Math.max(...valores),
                minimo: Math.min(...valores),
                media: Number((valores.reduce((a, b) => a + b, 0) / valores.length).toFixed(4))
              };
            } catch (err) {
              const serieInfo = SERIES_POPULARES.find(s => s.codigo === codigo);
              return { codigo, nome: serieInfo?.nome || `Série ${codigo}`, erro: err instanceof Error ? err.message : "Erro desconhecido" };
            }
          })
        );
    
        const seriesComDados = resultados.filter(r => !("erro" in r));
        const seriesComErro = resultados.filter(r => "erro" in r);
    
        const seriesOrdenadas = [...seriesComDados].sort((a, b) => {
  • Input schema definition for the 'bcb_comparar' tool, specifying 'codigos', 'dataInicial', and 'dataFinal'.
    {
      name: "bcb_comparar",
      description: "Compara 2 a 5 séries temporais no mesmo período. Útil para análise de correlação entre indicadores.",
      inputSchema: {
        type: "object" as const,
        properties: {
          codigos: { type: "array" as const, items: { type: "number" as const }, description: "Array com 2 a 5 códigos de séries para comparar" },
          dataInicial: { type: "string" as const, description: "Data inicial (yyyy-MM-dd ou dd/MM/yyyy)" },
          dataFinal: { type: "string" as const, description: "Data final (yyyy-MM-dd ou dd/MM/yyyy)" }
        },
        required: ["codigos", "dataInicial", "dataFinal"]
      }
    }
  • src/tools.ts:863-864 (registration)
    Dispatcher registration for 'bcb_comparar' connecting the tool name to the 'handleComparar' function.
    case "bcb_comparar":
      return handleComparar(args as { codigos: number[]; dataInicial: string; dataFinal: string }, timeoutMs, maxRetries);
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool is useful for correlation analysis, which adds some context about its purpose, but doesn't describe key behavioral traits such as what the output looks like (e.g., returns comparison data, correlation coefficients), whether it performs calculations or just retrieves data, or any limitations like rate limits or authentication needs. For a tool with no annotations, this is a significant gap.

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 concise and well-structured with two sentences: the first states the core functionality, and the second provides usage context. Every sentence earns its place without redundancy, making it easy to understand quickly.

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 the complexity of comparing multiple time series, no annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., a comparison table, correlation metrics), how results are formatted, or any behavioral details like error handling. This leaves significant gaps for an AI agent to understand the tool's full context and usage.

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 already documents all parameters (codigos, dataInicial, dataFinal) with descriptions. The description adds minimal value beyond the schema by implying the parameters are used for comparing time series in a specified period, but it doesn't provide additional semantics like format details for dates beyond what's in the schema or explain the meaning of 'codigos' in context. Baseline 3 is appropriate when the schema does the heavy lifting.

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 tool's purpose: 'Compara 2 a 5 séries temporais no mesmo período' (Compares 2 to 5 time series in the same period). It specifies the verb (compare) and resource (time series) with a clear scope (2-5 series, same period). However, it doesn't explicitly differentiate from sibling tools like bcb_serie_valores or bcb_variacao, which might also involve time series data.

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

Usage Guidelines3/5

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

The description provides implied usage guidance: 'Útil para análise de correlação entre indicadores' (Useful for correlation analysis between indicators). This suggests when to use it (for correlation analysis) but doesn't explicitly state when not to use it or name alternatives among the sibling tools. It lacks specific exclusions or comparisons to other tools.

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/SidneyBissoli/bcb-br-mcp'

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