Skip to main content
Glama

get_trail_closures

Retrieve current Swiss hiking trail closures and detours from official ASTRA data. Filter by closure reason or type to plan safe routes.

Instructions

Get current Swiss hiking trail closures and detours from the official ASTRA/Schweizer Wanderwege dataset. Filter by closure reason (e.g. Steinschlag, Bauarbeiten, Hangrutsch) or type (closure, detour). If no parameters are given, returns all active closures. Data source: swisstopo ch.astra.wanderland-sperrungen_umleitungen.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
reasonNoOptional search term for closure reason (e.g. 'Steinschlag', 'Bauarbeiten', 'Hangrutsch', 'Hochwasser'). Matches against the reason field (German or English). Case-insensitive partial match.
typeNoOptional: filter by type — 'closure' (Sperrung) or 'detour' (Umleitung). If omitted, returns both.
limitNoMaximum number of results to return. Default: 20. Max: 100.

Implementation Reference

  • The implementation of the get_trail_closures tool, which fetches and filters trail closures based on reason and type.
    async function handleGetTrailClosures(
      args: Record<string, unknown>
    ): Promise<string> {
      const reason = typeof args.reason === "string" ? args.reason.trim() : undefined;
      const typeFilter = typeof args.type === "string" ? args.type.trim() : undefined;
      const limit = Math.min(100, Math.max(1, Number(args.limit) || 20));
    
      let closures: SlimClosure[];
    
      if (reason) {
        // Search by reason — try reason_de field (primary) and also reason_en
        const [deResults, enResults] = await Promise.all([
          fetchJSON<FindResponse>(
            buildUrl(`${BASE}/find`, {
              layer: LAYER,
              searchText: reason,
              searchField: "reason_de",
              returnGeometry: false,
            })
          ),
          fetchJSON<FindResponse>(
            buildUrl(`${BASE}/find`, {
              layer: LAYER,
              searchText: reason,
              searchField: "reason_en",
              returnGeometry: false,
            })
          ),
        ]);
        const combined = [...(deResults.results ?? []), ...(enResults.results ?? [])];
        closures = deduplicate(combined.map(slimClosure));
      } else {
        // No reason filter — fetch all via sperrungen_type_de field with broad searches
        const [closureResults, detourResults] = await Promise.all([
          fetchJSON<FindResponse>(
            buildUrl(`${BASE}/find`, {
              layer: LAYER,
              searchText: "Sperrung",
              searchField: "sperrungen_type_de",
              returnGeometry: false,
            })
          ),
          fetchJSON<FindResponse>(
            buildUrl(`${BASE}/find`, {
              layer: LAYER,
              searchText: "detour",
              searchField: "sperrungen_type",
              returnGeometry: false,
            })
          ),
        ]);
        const combined = [...(closureResults.results ?? []), ...(detourResults.results ?? [])];
        closures = deduplicate(combined.map(slimClosure));
      }
    
      // Apply type filter
      closures = filterByType(closures, typeFilter);
    
      // Apply limit
      const total = closures.length;
      closures = closures.slice(0, limit);
    
      const result = {
        count: closures.length,
        total_found: total,
        filter: {
          reason: reason ?? null,
          type: typeFilter ?? null,
          limit,
        },
        source: "ASTRA / Schweizer Wanderwege (swisstopo ch.astra.wanderland-sperrungen_umleitungen)",
        closures,
      };
    
      const json = JSON.stringify(result);
      if (json.length > 49000) {
        // Trim descriptions to keep under 50K
        const trimmed = {
          ...result,
          closures: closures.map((c) => ({ ...c, description: c.description.slice(0, 100) })),
        };
        return JSON.stringify(trimmed);
      }
      return json;
    }
  • The dispatcher function that registers and routes calls to get_trail_closures and get_trail_closures_nearby.
    export async function handleHiking(
      name: string,
      args: Record<string, unknown>
    ): Promise<string> {
      switch (name) {
        case "get_trail_closures":
          return handleGetTrailClosures(args);
        case "get_trail_closures_nearby":
          return handleGetTrailClosuresNearby(args);
        default:
          throw new Error(`Unknown hiking tool: ${name}`);
      }
    }
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 effectively communicates this is a read-only query tool (implied by 'Get') and specifies the data source and scope ('active closures'). However, it lacks details on rate limits, authentication needs, response format, or pagination behavior beyond the 'limit' parameter in the schema.

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 front-loaded with the core purpose, followed by filtering options and default behavior, ending with data source attribution. Every sentence adds value with zero waste, making it efficient and well-structured.

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 parameters, no output schema, no annotations), the description is reasonably complete. It covers purpose, filtering, default behavior, and data source. However, it could improve by addressing response format or error handling, especially since no output schema exists.

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 fully documents all parameters. The description adds minimal value beyond the schema by mentioning filtering by 'reason' and 'type', but does not provide additional syntax, format details, or examples not already in the schema descriptions. Baseline 3 is appropriate.

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 action ('Get'), resource ('current Swiss hiking trail closures and detours'), and data source ('official ASTRA/Schweizer Wanderwege dataset'). It distinguishes from sibling 'get_trail_closures_nearby' by not mentioning location-based filtering, focusing instead on reason/type filtering.

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 the tool ('Filter by closure reason or type') and default behavior ('If no parameters are given, returns all active closures'). However, it does not explicitly state when NOT to use it or mention alternatives like the sibling 'get_trail_closures_nearby' for location-based queries.

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