This MCP-OSM server integrates OpenStreetMap with MCP, enabling you to query and visualize map data through a user-friendly interface. The package provides a web-based map viewer and offers various tools for interacting with map data through the MCP protocol.
Before using MCP-OSM, you need to have:
uv
package manager installedTo configure the MCP-OSM server, you can use environment variables in an .env
file:
FLASK_HOST=127.0.0.1
FLASK_PORT=8889
PGHOST=localhost
PGPORT=5432
PGDB=osm
PGUSER=postgres
PGPASSWORD=postgres
To use MCP-OSM with Claude Desktop, add it to your claude_desktop_config.json
:
{
"mcpServers": {
"OSM PostgreSQL Server": {
"command": "/Users/yourusername/.local/bin/uv",
"args": [
"run",
"--env-file",
".env",
"--with",
"mcp[cli]",
"--with",
"psycopg2",
"--with-editable",
"/path/to/mcp-osm",
"--directory",
"/path/to/mcp-osm",
"mcp",
"run",
"mcp.py"
]
}
}
}
Make sure to replace the paths with your actual installation paths.
When you start the MCP server, it automatically launches a web server at http://localhost:8889/ with the map interface.
Get the current map view:
get_map_view
Set the map view:
set_map_view(center=[lat, lng], zoom=12)
or
set_map_view(bounds=[[lat1, lng1], [lat2, lng2]])
Set a map title:
set_map_title("My Custom Map")
Add a marker:
add_map_marker([lat, lng], popup="Label text")
Add a line:
add_map_line([[lat1, lng1], [lat2, lng2], ...], color="red")
Add a polygon:
add_map_polygon([[lat1, lng1], [lat2, lng2], [lat3, lng3], ...], color="blue", fillColor="lightblue")
query_osm_postgres("SELECT name, ST_AsText(way) FROM planet_osm_point WHERE amenity='restaurant' LIMIT 10")
set_map_view(center=[37.7749, -122.4194], zoom=13)
add_map_marker([37.7749, -122.4194], popup="San Francisco")
results = query_osm_postgres("SELECT name, ST_AsText(way) FROM planet_osm_point WHERE amenity='restaurant' AND ST_DWithin(way, ST_SetSRID(ST_MakePoint(-122.4194, 37.7749), 3857), 1000)")
for result in results:
# Process coordinates from result
add_map_marker([lat, lng], popup=result["name"])
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "OSM-PostgreSQL-Server" '{"command":"/Users/wiseman/.local/bin/uv","args":["run","--env-file",".env","--with","mcp[cli]","--with","psycopg2","--with-editable","/Users/wiseman/src/mcp-osm","--directory","/Users/wiseman/src/mcp-osm","mcp","run","mcp.py"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"OSM PostgreSQL Server": {
"command": "/Users/wiseman/.local/bin/uv",
"args": [
"run",
"--env-file",
".env",
"--with",
"mcp[cli]",
"--with",
"psycopg2",
"--with-editable",
"/Users/wiseman/src/mcp-osm",
"--directory",
"/Users/wiseman/src/mcp-osm",
"mcp",
"run",
"mcp.py"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"OSM PostgreSQL Server": {
"command": "/Users/wiseman/.local/bin/uv",
"args": [
"run",
"--env-file",
".env",
"--with",
"mcp[cli]",
"--with",
"psycopg2",
"--with-editable",
"/Users/wiseman/src/mcp-osm",
"--directory",
"/Users/wiseman/src/mcp-osm",
"mcp",
"run",
"mcp.py"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect