mcp-server-geo-optimizer
Enables forward and reverse geocoding through Google's geocoding provider when configured with GEOCODING_PROVIDER=google and a GEOCODING_API_KEY.
Enables forward and reverse geocoding through Mapbox's geocoding provider when configured with GEOCODING_PROVIDER=mapbox and a GEOCODING_API_KEY.
Enables forward and reverse geocoding through Nominatim, OpenStreetMap's public geocoder, by default.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-server-geo-optimizerFind the optimal route through these addresses: 123 Main St, 456 Oak Ave, 789 Pine Rd"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-server-geo-optimizer
Model Context Protocol server for geographic and route optimization. It exposes tools for TSP/VRP routing, geocoding, distance matrices, clustering, boundary checks, and GeoJSON utilities.
Requirements
Node.js 22+
Optional: a local OSRM instance for road-network distances
Geocoding provider: Nominatim (default), Google, or Mapbox
Related MCP server: OpenStreetMap MCP Server
Install
cd mcp-server-geo-optimizer
npm install
npm run buildCursor MCP config
Build first: Run
npm run buildso thedist/folder exists before pointing Cursor atdist/index.js.
Update the path: Replace
/path/to/mcp-server-geo-optimizerbelow with the absolute path on your machine (e.g.d:/MCP/mcp-server-geo-optimizeron Windows or/home/you/mcp-server-geo-optimizeron Linux/macOS).
{
"mcpServers": {
"geo-optimizer": {
"command": "node",
"args": ["/path/to/mcp-server-geo-optimizer/dist/index.js"],
"env": {
"GEOCODING_PROVIDER": "nominatim",
"GEO_USER_AGENT": "my-team-geo/1.0 (contact: you@example.com)",
"OSRM_URL": "https://router.project-osrm.org"
}
}
}
}After publishing to npm you can switch command to npx with args: ["-y", "mcp-server-geo-optimizer"].
Public APIs: The default
OSRM_URLis the public demo server and Nominatim is the public OpenStreetMap geocoder. Both have strict usage policies and no SLA. The server spaces requests to these two hosts at leastPUBLIC_API_MIN_INTERVAL_MSapart (default 1 s), honoursRetry-After, and sendsGEO_USER_AGENT. SetGEO_USER_AGENTto something that identifies you and includes contact details. For real workloads run your own OSRM (e.g.http://localhost:5000) and raiseOSRM_MAX_TABLE_SIZE.
Quick test
Once added to Cursor's MCP settings, you can ask:
"Find the optimal route through these addresses: 123 Main St, 456 Oak Ave, 789 Pine Rd"
Or verify the server starts manually (it listens on stdio; no HTTP port):
npm run build
node --env-file=.env dist/index.jsThe server does not load .env files itself; use node --env-file=.env (Node 22+) or pass variables through your MCP client's env block. The process should stay running with no output on stdout. Logs appear as JSON on stderr.
Docker
The server speaks MCP over stdio, so keep stdin open with -i:
docker build -t mcp-server-geo-optimizer .
docker run -i --rm -e GEOCODING_PROVIDER=nominatim -e GEO_USER_AGENT="my-team-geo/1.0 (contact: you@example.com)" mcp-server-geo-optimizerEnvironment
Copy .env.example to .env to start from documented defaults.
Variable | Required | Description |
| No |
|
| For | Provider API key. Redacted from all logs and error messages |
| Recommended |
|
| No | http(s) OSRM endpoint (default: public demo server) |
| No | Max coordinates per OSRM table request, checked before any call (default: |
| No | Speed used to convert straight-line km to minutes when OSRM is not used (default: |
| No | Minimum spacing between requests to the public Nominatim and OSRM hosts, |
| No | Outbound HTTP timeout per attempt (default: |
| No | Retries for 5xx, 429, and network errors, |
| No | In-memory LRU TTL for geocoding and OSRM responses (default: |
| No |
|
| No |
|
Logs are written as JSON to stderr. stdout is reserved for MCP stdio.
Tools
All tools are read-only and idempotent. optimize_route, geocode, and distance_matrix may call external services (openWorldHint: true); the others are purely local. Results are compact JSON with distances rounded to metres (3 decimals, km), durations to 2 decimals (minutes), and coordinates to 6 decimals.
Tool | Purpose |
| TSP / VRP over 2-200 waypoints (up to |
| Forward ( |
| Pairwise km and minutes, |
| Deterministic |
|
|
|
|
Routing semantics
Time is measured in minutes from departure at the depot. Each waypoint may set
readyTimeMin,dueTimeMin, andserviceTimeMin. Arriving beforereadyTimeMinwaits;readyTimeMin > dueTimeMinis rejected.Time windows are soft. When no order meets every window, the solver minimises total lateness first, then distance, and reports it instead of failing: each route has a
violationslist, stops carrylateMin, and the top-levelfeasibleflag isfalse. AdueTimeMinon the depot applies to the return leg of closed routes.Up to 8 stops per route are solved exactly; larger routes use nearest neighbour with 2-opt and Or-opt improvement.
With
vehicleCount > 1, stops are assigned by a sweep around the depot, balanced across vehicles and respectingcapacity. Stops whose demand cannot fit any vehicle are listed inunassigned.With
useOsrm: true, both leg distances and leg durations come from the OSRM table, anddistanceSourceisosrm. Otherwise distances are great-circle and durations useaverageSpeedKmh.
Bounding boxes
bounding_box follows RFC 7946: when points straddle the antimeridian, minLng is greater than maxLng and crossesAntimeridian is true (e.g. minLng: 179.8, maxLng: -179.8).
Errors
Invalid arguments are rejected in two stages:
Schema validation by the MCP SDK. Types, ranges, and required fields are checked before the tool runs. These come back as
isError: truewith plain text, not JSON, for exampleMCP error -32602: Input validation error: ....Tool-level checks. Cross-field rules (such as the distance-matrix cell cap,
startIndexrange, or time-window order) and all runtime failures returnisError: truewith a JSON body{"code": "...", "message": "..."}.
Code | Meaning |
| Input failed validation or a request limit |
| Routing or distance-matrix operation failed, including OSRM finding no road route |
| Geocoding provider returned no results or an error |
| Clustering algorithm failed |
| Boundary or GeoJSON operation failed |
| Missing or invalid environment configuration |
| Outbound HTTP request timed out |
| Upstream response was unusable (for example larger than the 5 MB response cap) |
| Unexpected server error |
API keys and tokens are redacted from every error message and log line. With NODE_ENV=production, unexpected errors are reported to clients as Internal error, and details stay on stderr.
Development
This project includes a .cursorrules file. Cursor agents automatically follow the coding standards, file structure, and testing rules defined there (layered architecture, strict TypeScript, mocked HTTP in tests, Conventional Commits).
npm run dev # run with tsx (stdio)
npm test # unit + integration tests
npm run test:coverage # 80% thresholds across src/
npm run typecheck
npm run lint
npm run format:check
dai sunpm run buildArchitecture
Layered design: transport → MCP tools → services → pure domain geo algorithms → HTTP adapters. Services never import the MCP SDK. Domain functions are side-effect free and fully unit tested.
License
MIT
Related MCP Connectors
- geoOAuthco.thinair
Geocoding, routing, isochrones, traffic, weather, and place search for AI agents. 19 MCP tools.
Pay-per-use tool marketplace for AI agents. Search, price-check, and call APIs via MCP.
The OpenRouter for tools. One MCP connection gives any AI agent 254 hosted tools, pay per call.
Hosted MCP with 91 agent tools: X, domains, SEO, Maps, Trends, Search, YouTube, TikTok, and more.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA geospatial MCP server that provides tools for geocoding, routing, elevation profiles, and spatial analysis. It enables AI agents to process GIS file formats like GeoJSON and Shapefiles while performing complex coordinate transformations and distance calculations.4MIT
- AlicenseBqualityDmaintenanceA comprehensive MCP server providing 30 tools for geocoding, routing, and OpenStreetMap data analysis. It enables AI assistants to search for locations, calculate travel routes, and perform quality assurance checks on map data.30181 npm5MIT

Magic Lane MCP Serverofficial
AlicenseBqualityBmaintenanceEnables AI agents to become geospatially intelligent assistants with tools for location search, smart routing, round trip planning, reverse geocoding, isochrone analysis, route visualization, geofence management, and interactive map display.822 npm7Apache 2.0- AlicenseNot gradedqualityBmaintenanceProvides routing, distance/duration matrix, isochrones, snap to road, elevation, and geocoding tools from Openrouteservice for AI agents via MCP.173 npmMIT