geocode
Convert Swiss addresses or place names to precise coordinates using swisstopo data for location-based applications and mapping.
Instructions
Convert a Swiss address or place name to coordinates (swisstopo)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | Swiss address or place name |
Implementation Reference
- src/modules/geodata.ts:166-181 (handler)Handler function for the "geocode" tool (and search_places), which fetches data from the swisstopo API.
export async function handleGeodata(name: string, args: Record<string, unknown>): Promise<string> { switch (name) { case "geocode": case "search_places": { const url = buildUrl(`${BASE}/rest/services/api/SearchServer`, { searchText: args.address as string ?? args.query as string, type: args.type as string ?? "locations", sr: 4326, limit: 10, }); const data = await fetchJSON<SearchResponse>(url); return JSON.stringify({ count: data.results.length, results: data.results.map(slimSearchResult), }); } - src/modules/geodata.ts:90-101 (schema)Tool definition and input schema for the "geocode" tool.
export const geodataTools = [ { name: "geocode", description: "Convert a Swiss address or place name to coordinates (swisstopo)", inputSchema: { type: "object", required: ["address"], properties: { address: { type: "string", description: "Swiss address or place name" }, }, }, },