Metadata-Version: 2.5
Name: langchain-mapmap
Version: 0.1.0
Summary: MapMap tools for LangChain agents: car, truck and ADR routing, geocoding, places, matrices, isochrones and map styling through the hosted MapMap MCP server.
Project-URL: Homepage, https://mapmap.ai/agents
Project-URL: Documentation, https://mapmap.ai/docs/mcp
Project-URL: Agent data rights, https://mapmap.ai/.well-known/agent-terms.json
Author-email: Mapmap AI Ltd <hello@mapmap.ai>
License-Expression: MIT
License-File: LICENSE
Keywords: adr,agents,geocoding,langchain,mapmap,maps,mcp,routing,truck-routing
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: GIS
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: langchain-mcp-adapters>=0.1.0
Provides-Extra: test
Requires-Dist: pytest>=8; extra == 'test'
Requires-Dist: uvicorn>=0.30; extra == 'test'
Description-Content-Type: text/markdown

# langchain-mapmap

MapMap tools for LangChain agents: routing for cars, trucks, bikes and walking,
truck routing with ADR dangerous-goods restrictions, geocoding, travel-time matrices, isochrones,
multi-stop day planning and hosted map styling, exposed through the hosted
[MapMap MCP server](https://mapmap.ai/docs/mcp).

The hosted server connects without a key for evaluation, under fair use. For
metered volume an agent gets a card-free key in one API call (see "With a
key" below). Responses may be cached, stored, indexed and used for training;
the machine-readable terms are at
[`/.well-known/agent-terms.json`](https://mapmap.ai/.well-known/agent-terms.json).

## 60-second quickstart

```bash
pip install langchain-mapmap langchain langchain-anthropic
```

```python
import asyncio
from langchain.agents import create_agent
from langchain_mapmap import get_mapmap_tools


async def main() -> None:
    tools = await get_mapmap_tools()  # keyless connect, fair use
    agent = create_agent("anthropic:claude-sonnet-4-5", tools)
    result = await agent.ainvoke(
        {
            "messages": [
                (
                    "user",
                    "Route a 4.0 m tall truck carrying ADR tunnel-code C goods "
                    "from Dover to Birmingham. Which restrictions shaped the route?",
                )
            ]
        }
    )
    print(result["messages"][-1].content)


asyncio.run(main())
```

That is the whole integration: every tool the server registers (`route`,
`check_adr_tunnel`, `geocode`, `matrix`, `optimise_routes`,
`search_along_route`, `plan_day`, `reachable_area`, `nearby_places`,
navigation sessions, place entrances, map-styling and local geometry tools) with their full JSON Schemas. The wrapper adapts whatever `tools/list`
returns, so it needs no update when the server gains a tool.

## Navigation sessions and place entrances

The server's tools for guiding someone to a place turn by turn, and for
finding a place's doors, come through like every other tool:

| Tool | What it does |
|---|---|
| `start_navigation` | Opens a navigation session from an origin to a destination; answers the session id and the first instruction. `arrive_at` (`"point"` by default, `"entrance"` or `{place_id, entrance_kind, wheelchair}`) ends it at the place's best mapped door, and the answer's `arrival` says which. |
| `check_navigation_progress` | Sends one position fix to the session; answers where the traveller is against the route (`on_route`, `off_route`, `rerouted`, `arrived` or `lost_position`) and the next instruction to read out. |
| `end_navigation` | Ends the session and drops what it held. |
| `place_entrances` | Lists the mapped doors of one place by its id. |

Inputs on the existing tools: `include_entrances` on `nearby_places`,
`places_in_view` and `geocode` adds each place's entrances to the answer,
and `arrive_at: "entrance"` on `route` ends the route at the best mapped
door for the mode of travel instead of the middle of the building (the
answer's `arrival` block says which door, or why none was used). The same
`arrive_at` on `start_navigation` ends a session at the door, and every
reroute heads for the same door; with no door that suits, `arrival` is
`applied: false` with the reason and the session ends at the destination
as given.

Facts an agent should pass on, because they are how the service behaves:

- Sessions live in the gateway's memory only and do not survive a gateway
  restart. A session that has gone answers as not found; open a new one
  from where the traveller is.
- A session expires after 2 hours idle; every progress check resets the
  clock.
- A session keeps the route and the last accepted fix only: no trail of
  positions, and nothing about a position is written to disk or logged.
- Entrances are doors mapped in OpenStreetMap and tied to the place on
  evidence; none are estimated today. An empty list means no door is tied
  to the place, not that it has none.

Nothing in this package changes for these tools: it adapts whatever
`tools/list` returns, so they appear as soon as the server you connect to
registers them. A runnable agent: [`examples/navigate_to_entrance.py`](./examples/navigate_to_entrance.py).

## With a key (metered volume)

```python
tools = await get_mapmap_tools(api_key="snk_...")
```

Get a card-free key in one call: `POST https://api.mapmap.ai/v1/keys` with
`{"email": "you@example.com", "accept_tos": true}`. Email verification
upgrades the same key to 50,000 included calls a month. Prices:
[mapmap.ai/pricing.json](https://mapmap.ai/pricing.json).

## Self-hosted

Point the wrapper at your own gateway's MCP endpoint:

```python
tools = await get_mapmap_tools(url="https://maps.internal.example/mcp")
```

## Synchronous code

```python
from langchain_mapmap import get_mapmap_tools_sync

tools = get_mapmap_tools_sync()
```

## Data rights

MapMap will never ToS-ban caching, storing, indexing or training on API
responses. Content derived from OpenStreetMap remains under ODbL: credit
`© OpenStreetMap contributors` when you republish. Full manifest:
<https://mapmap.ai/.well-known/agent-terms.json>.

## Publishing (maintainers)

Never from a laptop. `.github/workflows/publish-python-packages.yml` builds,
tests and `twine check`s this package on every pull request that touches it,
and publishes it to PyPI through trusted publishing (no stored token) when
dispatched on main with the version typed in full:

```bash
# Dry run: build, test and twine check only
gh workflow run publish-python-packages.yml -R Mapmapai/mapmap --ref main \
  -f package=langchain-mapmap

# Publish: confirm_version must equal the version in pyproject.toml
gh workflow run publish-python-packages.yml -R Mapmapai/mapmap --ref main \
  -f package=langchain-mapmap -f confirm_version=0.1.0
```

For a later release, bump `version` in `pyproject.toml` (and the CHANGELOG)
first: PyPI never accepts the same version twice.

## Licence

MIT. The MapMap service itself is governed by <https://mapmap.ai/terms>.
