This example shows how to use an app generation prompt to create a JavaScript or Python client application to access MCP for ArcGIS Location Services. The application is responsible for establishing a connection to the MCP server and invoking the available tools including geocoding, reverse geocoding, routing, and elevation.
A mapping library is required for this example to display the results from the MCP server in an interactive map.

Resulting interactive mapping application using MCP for ArcGIS Location Services and the ArcGIS Maps SDK for JavaScript.
Prerequisites
Your MCP client must be properly configured to access MCP for ArcGIS Location Services. For setup instructions, go to Get started.
Example
As a best practice, use a separate access token to render maps in your application. This token may be different from the one used by your MCP server.
-
Create an API key with the following privilege(s)
Privileges are a set of permissions assigned to ArcGIS accounts, developer credentials, and applications that grant access to secure resources and functionality in ArcGIS. :- Location services > Basemaps
-
Create an
.envfile in the root of your project and add the API key:MAP_API_KEY=your_api_key_here -
Run the following prompt to build the application. Use the dropdown to select the language you want to use.
Node.js Node.js Python Build a standalone Node.js + Express interactive map app using MCP for ArcGIS Location Services.Create:- server.js- package.json- mcp.example.json- README.md- public/index.html- public/app.js- public/styles.cssCore features:- Geocode (find_address_candidates)- Reverse geocode (reverse_geocode)- Route solve (solve_route)- Elevation (elevation_at_locations)- ArcGIS interactive map visualizationMCP requirements:- Read mcp.json from local folder, fallback to ../mcp.json- Use servers.alp-mcp-server.url + headers- JSON-RPC initialize + tools/call- Support JSON and SSE responses- Parse SSE data lines, use last valid JSON payload- Normalize errors/outputCredential split:- Keep MCP bearer token for MCP server auth- Use separate map API key from app.mapApiKey or MAP_API_KEY / ARCGIS_API_KEYEndpoints:- GET /api/health- GET /api/tools- GET /api/arcgis-token- GET /arcgis-config.js- POST /api/geocode- POST /api/reverse- POST /api/route- POST /api/elevationMap/UI behavior:- Left control panel + right interactive map + result panel- Mode buttons: geocode, reverse, route, elevation- Click behaviors:- reverse mode fills x/y- route mode sets start/end- elevation mode appends points- Blue point markers for all operation points (#3284ff)- Blue route line (#4285F4) with blue start/end markers on top- Route zoom via view.goTo(routeGraphic)- Geocode popup includes route-ready x,y rounded to 5 decimalsRun:- express dependency- scripts: start/dev = node server.js- default port 3000 with PORT overrideAcceptance:- All 4 workflows work end-to-end- Route line/markers render and zoom correctly- Geocode popup includes 5-decimal x,y- Map click workflows work in reverse/route/elevation modesBuild a standalone Python interactive map app using FastAPI and MCP for ArcGIS Location Services.Requirements:Create:- app.py- requirements.txt- mcp.example.json- README.md- templates/index.html- static/app.js- static/styles.cssCore features:- Geocode (find_address_candidates)- Reverse geocode (reverse_geocode)- Route solve (solve_route)- Elevation (elevation_at_locations)- ArcGIS interactive map visualization using ArcGIS Maps SDK for JavaScriptMCP requirements:- Read mcp.json from the local folder, with fallback to ../mcp.json- Use servers.alp-mcp-server.url + headers- JSON-RPC initialize + tools/call- Support JSON and SSE responses- Parse SSE data lines and use the last valid JSON payload- Normalize errors and tool output cleanly- Implement a reusable MCP client/helper for initialize and tool calls instead of duplicating request logic per routeCredential split:- Keep MCP bearer token for MCP server auth- Use a separate browser map API key from app.mapApiKey or MAP_API_KEY / ARCGIS_API_KEY- Do not hardcode secretsHTTP routes:- GET /- GET /api/health- GET /api/tools- GET /api/arcgis-token- GET /arcgis-config.js- POST /api/geocode- POST /api/reverse- POST /api/route- POST /api/elevationMap/UI behavior:- Left control panel + right interactive map + result panel- Mode buttons: geocode, reverse, route, elevation- Click behaviors:- reverse mode fills x/y- route mode sets start/end- elevation mode appends points- Blue point markers for all operation points (#3284ff)- Blue route line (#4285F4) with blue start/end markers on top- Route zoom via view.goTo(routeGraphic)- Geocode popup includes route-ready x/y rounded to 5 decimalsPython implementation expectations:- Use Python for the MCP bridge, routing, config loading, and token/config endpoints- Use FastAPI with Jinja2 templates for the HTML shell and FastAPI static file serving for `/static`- Use `httpx` for outbound HTTP requests to the MCP server- Keep dependencies minimal: `fastapi`, `uvicorn`, `httpx`, `jinja2`, and only add others if clearly needed- Default port 3000 with PORT override- Start the app with `uvicorn app:app --host 0.0.0.0 --port ${PORT:-3000}`- Initialize the MCP session once at startup if practical; otherwise lazily initialize and cache the session state for reuse across requests- If `mcp.json` is missing, malformed, or missing `servers.alp-mcp-server`, fail clearly with a readable startup or request error- Document required configuration in README, including where `mcp.json` should live and how to run the appRoute contracts:- `GET /` serves the main HTML page- `GET /api/health` returns a simple JSON health response- `GET /api/tools` returns the discovered MCP tools or a normalized error- `GET /api/arcgis-token` returns JSON containing the browser map credential, using the configured API key rather than the MCP bearer token- `GET /arcgis-config.js` returns a small JavaScript config payload the frontend can read- `POST /api/geocode` accepts a search string and returns normalized candidate results- `POST /api/reverse` accepts x/y coordinates and returns a normalized reverse geocode result- `POST /api/route` accepts start/end and optional ordered stops and returns normalized route geometry, directions, and summary fields- `POST /api/elevation` accepts one or more x/y points and returns normalized elevation resultsInput and error handling:- Validate request bodies with explicit FastAPI/Pydantic models- Return clear 4xx errors for invalid input and 5xx errors for upstream MCP failures- Surface MCP error messages in a normalized JSON shape the frontend can display- Handle empty results without crashing the UI- Keep response shapes consistent across success and error casesREADME expectations:- Include setup and run instructions for the FastAPI app- Document required environment variables and browser map credential setup- Include example `mcp.json` placement and configuration notes- Include example requests for geocode, reverse geocode, route, and elevationAcceptance:- All 4 workflows work end-to-end- Route line and markers render and zoom correctly- Geocode popup includes 5-decimal x/y- Map click workflows work in reverse/route/elevation modes- App starts from the Python entrypoint and serves both API routes and frontend assetsThe agent should:
- Create a folder containing the application.
- Provide instructions on how to run the application.
- Implement a custom connector to MCP for ArcGIS Location Services using the provided URL and access token.
- Use the connector to call MCP tools for geocoding, reverse geocoding, routing, and elevation based on user input.
- Build an interactive map interface that updates dynamically with results from MCP tool calls.