Skip to main content
Glama

get_trail_closures_nearby

Find hiking trail closures and detours near your location in Switzerland using GPS coordinates. Check for disruptions within a specified radius to plan safe routes.

Instructions

Find Swiss hiking trail closures and detours near a given GPS coordinate. Converts WGS84 coordinates to Swiss LV95 and queries the swisstopo identify endpoint. Returns closures within the specified radius.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latYesLatitude in WGS84 (e.g. 46.9480 for Bern).
lonYesLongitude in WGS84 (e.g. 7.4474 for Bern).
radiusNoSearch radius in metres. Default: 10000 (10 km). Max: 50000.

Implementation Reference

  • The handler function for 'get_trail_closures_nearby', which converts WGS84 coordinates to LV95 and queries the swisstopo identify endpoint.
    async function handleGetTrailClosuresNearby(
      args: Record<string, unknown>
    ): Promise<string> {
      const lat = Number(args.lat);
      const lon = Number(args.lon);
    
      if (isNaN(lat) || isNaN(lon)) {
        throw new Error("lat and lon must be valid numbers");
      }
      if (lat < 45.0 || lat > 48.0 || lon < 5.5 || lon > 11.0) {
        throw new Error("Coordinates appear to be outside Switzerland (lat 45–48, lon 5.5–11)");
      }
    
      const radius = Math.min(50000, Math.max(1, Number(args.radius) || 10000));
    
      // Convert WGS84 → LV95
      const [e, n] = wgs84ToLv95(lat, lon);
    
      // Build map extent based on radius (approx 1 metre = 1 LV95 unit)
      const extent = `${e - radius},${n - radius},${e + radius},${n + radius}`;
    
      const url = buildUrl(`${BASE}/identify`, {
        layers: `all:${LAYER}`,
        geometry: `${e},${n}`,
        geometryType: "esriGeometryPoint",
        sr: 2056,
        tolerance: radius,
        imageDisplay: "1,1,100",
        mapExtent: extent,
        returnGeometry: false,
      });
    
      const data = await fetchJSON<FindResponse>(url);
      const closures = deduplicate((data.results ?? []).map(slimClosure));
    
      const result = {
        count: closures.length,
        query: {
          lat,
          lon,
          radius_m: radius,
          lv95_e: Math.round(e),
          lv95_n: Math.round(n),
        },
        source: "ASTRA / Schweizer Wanderwege (swisstopo ch.astra.wanderland-sperrungen_umleitungen)",
        closures,
      };
    
      const json = JSON.stringify(result);
      if (json.length > 49000) {
        const trimmed = {
          ...result,
          closures: closures.map((c) => ({ ...c, description: c.description.slice(0, 100) })),
        };
        return JSON.stringify(trimmed);
      }
      return json;
    }
  • The definition and registration of the 'get_trail_closures_nearby' tool including its schema.
    {
      name: "get_trail_closures_nearby",
      description:
        "Find Swiss hiking trail closures and detours near a given GPS coordinate. " +
        "Converts WGS84 coordinates to Swiss LV95 and queries the swisstopo identify endpoint. " +
        "Returns closures within the specified radius.",
      inputSchema: {
        type: "object",
        properties: {
          lat: {
            type: "number",
            description: "Latitude in WGS84 (e.g. 46.9480 for Bern).",
          },
          lon: {
            type: "number",
            description: "Longitude in WGS84 (e.g. 7.4474 for Bern).",
          },
          radius: {
            type: "number",
            description: "Search radius in metres. Default: 10000 (10 km). Max: 50000.",
          },
        },
        required: ["lat", "lon"],
      },
    },
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 adds useful context about coordinate conversion (WGS84 to LV95) and the data source (swisstopo identify endpoint), but does not mention rate limits, authentication needs, error handling, or the format of returned closures/detours. The description adequately covers the core 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 efficiently structured in two sentences, front-loading the core purpose and following with implementation details. Every sentence adds value without redundancy, making it easy to parse quickly.

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 explains what the tool does, how it works internally, and the scope of results. However, it lacks details on output format (e.g., structure of closures/detours) and error cases, which would be helpful for an agent invoking it.

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 (lat, lon, radius). The description adds marginal value by implying these parameters are used for coordinate-based searching and radius filtering, but does not provide additional syntax or format details beyond what the schema already specifies.

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 specific action ('Find Swiss hiking trail closures and detours'), resource ('near a given GPS coordinate'), and scope ('within the specified radius'). It distinguishes from sibling tools like 'get_trail_closures' by specifying the 'nearby' aspect and coordinate-based querying.

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 (finding trail closures near GPS coordinates), but does not explicitly mention when not to use it or name alternatives. It implies usage for location-based queries but lacks explicit exclusions or comparisons to similar tools like 'get_trail_closures'.

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