Skip to main content
Glama

search_postcode

Find Swiss postal codes by entering a city or locality name. Uses official Swiss geodata to return all matching PLZ entries.

Instructions

Search Swiss postcodes by city or locality name. Returns all PLZ entries matching the name. Source: Swiss federal geodata (swisstopo).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
city_nameYesCity or locality name, e.g. "Zürich", "Bern", "Locarno"

Implementation Reference

  • The handler function for the `search_postcode` tool, which searches for Swiss postcodes by city or locality name using the swisstopo API.
    case "search_postcode": {
      const cityName = String(args.city_name ?? "").trim();
      if (!cityName) {
        throw new Error("city_name must not be empty.");
      }
    
      const findUrl = buildUrl(`${BASE}/rest/services/api/MapServer/find`, {
        layer: PLZ_LAYER,
        searchText: cityName,
        searchField: "langtext",
        returnGeometry: false,
        sr: 4326,
      });
      const findData = await fetchJSON<PlzFindResponse>(findUrl);
    
      const entries = findData.results.map((r) => ({
        postcode: r.attributes.plz,
        locality: r.attributes.langtext,
        additionalNumber: r.attributes.zusziff !== "00" ? r.attributes.zusziff : undefined,
      }));
    
      // Deduplicate by PLZ (multiple records can share same PLZ with different suffixes)
      const seen = new Set<number>();
      const unique = entries.filter((e) => {
        if (seen.has(e.postcode)) return false;
        seen.add(e.postcode);
        return true;
      });
    
      return JSON.stringify({
        query: cityName,
        count: unique.length,
        results: unique,
        source: "swisstopo — Amtliches Ortschaftenverzeichnis",
      });
    }
  • The schema definition for the `search_postcode` tool.
      name: "search_postcode",
      description:
        "Search Swiss postcodes by city or locality name. Returns all PLZ entries matching the name. Source: Swiss federal geodata (swisstopo).",
      inputSchema: {
        type: "object",
        required: ["city_name"],
        properties: {
          city_name: {
            type: "string",
            description: "City or locality name, e.g. \"Zürich\", \"Bern\", \"Locarno\"",
          },
        },
      },
    },
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. It discloses the data source ('Swiss federal geodata (swisstopo)') and that it returns 'all PLZ entries matching', which adds useful context. However, it lacks details on rate limits, error handling, or response format, leaving behavioral gaps.

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 two sentences with zero waste: the first states purpose and usage, the second adds data source. It is front-loaded with essential information and appropriately sized for a simple tool.

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 low complexity (1 parameter, no annotations, no output schema), the description is reasonably complete. It covers purpose, usage, and data source, but lacks output details (e.g., format of returned entries) which would be helpful since there's no output schema.

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 the single parameter 'city_name' with examples. The description adds no additional parameter semantics beyond what the schema provides, such as partial match behavior or case sensitivity, meeting the baseline for high schema coverage.

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 verb 'search' and resource 'Swiss postcodes', specifies the search criteria 'by city or locality name', and distinguishes from sibling tools like 'lookup_postcode' and 'list_postcodes_in_canton' by focusing on name-based search rather than code lookup or canton-based listing.

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 implicitly provides usage context by stating it searches 'by city or locality name' and 'returns all PLZ entries matching the name', which helps differentiate from alternatives. However, it does not explicitly mention when not to use it or name specific sibling tools as alternatives.

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/vikramgorla/mcp-swiss'

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