Skip to main content
Glama

buscar_ceps_por_logradouro

Find Brazilian postal codes (CEPs) by street name in a specific city and state. Use this tool to locate all postal codes associated with a particular address.

Instructions

Busca todos os CEPs associados a um logradouro em uma cidade e estado.

Args:
    uf: Sigla do estado (ex: SP, RJ)
    cidade: Nome da cidade (ex: São Paulo)
    logradouro: Nome da rua, avenida, praça etc (ex: Praça da Sé)

Returns:
    Lista de dicionários com endereços que correspondem à busca.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ufYes
cidadeYes
logradouroYes

Implementation Reference

  • cep.py:33-55 (handler)
    The main handler function for the 'buscar_ceps_por_logradouro' tool. It queries the ViaCEP API with the provided state (uf), city (cidade), and street (logradouro) to retrieve a list of matching CEPs and addresses. Includes error handling for API failures and invalid addresses. The @mcp.tool() decorator registers it as an MCP tool.
    @mcp.tool()
    async def buscar_ceps_por_logradouro(uf: str, cidade: str, logradouro: str) -> list:
        """Busca todos os CEPs associados a um logradouro em uma cidade e estado.
    
        Args:
            uf: Sigla do estado (ex: SP, RJ)
            cidade: Nome da cidade (ex: São Paulo)
            logradouro: Nome da rua, avenida, praça etc (ex: Praça da Sé)
    
        Returns:
            Lista de dicionários com endereços que correspondem à busca.
        """
        url = f"https://viacep.com.br/ws/{uf}/{cidade}/{logradouro}/json/"
        try:
            async with httpx.AsyncClient(timeout=10.0) as client:
                response = await client.get(url)
                response.raise_for_status()
                data = response.json()
                if isinstance(data, dict) and "erro" in data:
                    return [{"erro": "Endereço não encontrado."}]
                return data
        except Exception as e:
            return [{"erro": f"Erro ao buscar logradouro: {str(e)}"}]
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 describes the search functionality and return format ('Lista de dicionários com endereços'), but doesn't mention potential limitations like partial matches, empty results, rate limits, or authentication requirements. It adequately covers basic behavior 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.

Conciseness5/5

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

The description is perfectly structured and concise. It begins with the core purpose, then provides a well-organized parameter section with clear examples, and concludes with return value information. Every sentence adds essential value with zero waste.

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?

Given the tool's moderate complexity (3 required parameters, no output schema, no annotations), the description is quite complete. It covers purpose, parameters with examples, and return format. However, without annotations or output schema, it could benefit from more behavioral context about how the search works and what the returned dictionaries contain.

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

Parameters5/5

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

The description provides excellent parameter semantics beyond the 0% schema coverage. It clearly explains each parameter's purpose with concrete examples: 'uf: Sigla do estado (ex: SP, RJ)', 'cidade: Nome da cidade (ex: São Paulo)', and 'logradouro: Nome da rua, avenida, praça etc (ex: Praça da Sé)'. This fully compensates for the lack of schema 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's purpose with specific verb ('Busca') and resource ('CEPs associados a um logradouro'), including the required geographic context ('em uma cidade e estado'). It distinguishes itself from the sibling 'buscar_cep' by specifying it searches for multiple CEPs associated with a street rather than a single CEP.

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 provides clear context for when to use this tool (searching for all CEPs associated with a street in a city/state). It doesn't explicitly mention when NOT to use it or name alternatives, though the distinction from 'buscar_cep' is implied by the different functionality described.

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/wendellbigato/mcp-cep'

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