crewai-mapmap 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ __pycache__/
2
+ *.pyc
3
+ dist/
4
+ *.egg-info/
5
+ .venv*/
6
+ .pytest_cache/
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ All notable changes to `crewai-mapmap`. This project follows
4
+ [semantic versioning](https://semver.org/spec/v2.0.0.html).
5
+
6
+ ## 0.1.0 (unreleased, first publish)
7
+
8
+ Not on PyPI yet, so the first publish is 0.1.0 and no version bump is
9
+ needed for the changes below.
10
+
11
+ ### Changed
12
+
13
+ - Package metadata for the first PyPI upload: SPDX `license = "MIT"` with
14
+ `license-files` (PEP 639) in place of the deprecated table form and
15
+ licence classifier; summary names no claim the server does not make; the
16
+ `x402` keyword is dropped.
17
+ - README intro says what the hosted server does today: it connects without
18
+ a key for evaluation under fair use, and a card-free key meters volume.
19
+
20
+ ### Added
21
+
22
+ - README section and `examples/navigate_to_entrance.py` for the MCP
23
+ server's navigation-session and place-entrance tools
24
+ (`start_navigation`, `check_navigation_progress`, `end_navigation`,
25
+ `place_entrances`, `include_entrances` on the place tools and
26
+ `arrive_at: "entrance"` on `route` and `start_navigation`). The wrapper needed no code change:
27
+ it adapts whatever `tools/list` returns, so these appear as soon as the
28
+ server registers them.
29
+ - Tests (`pip install -e ".[test]" && pytest`): a local stand-in MCP
30
+ server checks that new tools and their inputs come through as CrewAI
31
+ tools and that the API key is sent as a bearer token.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mapmap AI Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,165 @@
1
+ Metadata-Version: 2.5
2
+ Name: crewai-mapmap
3
+ Version: 0.1.0
4
+ Summary: MapMap tools for CrewAI agents: car, truck and ADR routing, geocoding, places, matrices, isochrones and map styling through the hosted MapMap MCP server.
5
+ Project-URL: Homepage, https://mapmap.ai/agents
6
+ Project-URL: Documentation, https://mapmap.ai/docs/mcp
7
+ Project-URL: Agent data rights, https://mapmap.ai/.well-known/agent-terms.json
8
+ Author-email: Mapmap AI Ltd <hello@mapmap.ai>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: adr,agents,crewai,geocoding,mapmap,maps,mcp,routing,truck-routing
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Scientific/Engineering :: GIS
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: crewai-tools[mcp]>=0.45.0
23
+ Provides-Extra: test
24
+ Requires-Dist: pytest>=8; extra == 'test'
25
+ Requires-Dist: uvicorn>=0.30; extra == 'test'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # crewai-mapmap
29
+
30
+ MapMap tools for CrewAI agents: routing for cars, trucks, bikes and walking,
31
+ truck routing with ADR dangerous-goods restrictions, geocoding, travel-time matrices, isochrones,
32
+ multi-stop day planning and hosted map styling, exposed through the hosted
33
+ [MapMap MCP server](https://mapmap.ai/docs/mcp).
34
+
35
+ The hosted server connects without a key for evaluation, under fair use. For
36
+ metered volume an agent gets a card-free key in one API call (see "With a
37
+ key" below). Responses may be cached, stored, indexed and used for training;
38
+ the machine-readable terms are at
39
+ [`/.well-known/agent-terms.json`](https://mapmap.ai/.well-known/agent-terms.json).
40
+
41
+ ## 60-second quickstart
42
+
43
+ ```bash
44
+ pip install crewai-mapmap crewai
45
+ ```
46
+
47
+ ```python
48
+ from crewai import Agent, Crew, Task
49
+ from crewai_mapmap import mapmap_tools
50
+
51
+ with mapmap_tools() as tools: # keyless connect, fair use
52
+ dispatcher = Agent(
53
+ role="Fleet dispatcher",
54
+ goal="Plan compliant truck routes",
55
+ backstory="Plans ADR-compliant routes for a haulage fleet.",
56
+ tools=tools,
57
+ )
58
+ task = Task(
59
+ description=(
60
+ "Route a 4.0 m tall truck carrying ADR tunnel-code C goods "
61
+ "from Dover to Birmingham and explain which restrictions "
62
+ "shaped the route."
63
+ ),
64
+ expected_output="A route summary with the avoided restrictions.",
65
+ agent=dispatcher,
66
+ )
67
+ print(Crew(agents=[dispatcher], tasks=[task]).kickoff())
68
+ ```
69
+
70
+ That is the whole integration: every tool the server registers (`route`,
71
+ `check_adr_tunnel`, `geocode`, `matrix`, `optimise_routes`,
72
+ `search_along_route`, `plan_day`, `reachable_area`, `nearby_places`,
73
+ navigation sessions, place entrances, map-styling and local geometry tools) with their full JSON Schemas. The wrapper adapts whatever `tools/list`
74
+ returns, so it needs no update when the server gains a tool.
75
+
76
+ ## Navigation sessions and place entrances
77
+
78
+ The server's tools for guiding someone to a place turn by turn, and for
79
+ finding a place's doors, come through like every other tool:
80
+
81
+ | Tool | What it does |
82
+ |---|---|
83
+ | `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. |
84
+ | `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. |
85
+ | `end_navigation` | Ends the session and drops what it held. |
86
+ | `place_entrances` | Lists the mapped doors of one place by its id. |
87
+
88
+ Inputs on the existing tools: `include_entrances` on `nearby_places`,
89
+ `places_in_view` and `geocode` adds each place's entrances to the answer,
90
+ and `arrive_at: "entrance"` on `route` ends the route at the best mapped
91
+ door for the mode of travel instead of the middle of the building (the
92
+ answer's `arrival` block says which door, or why none was used). The same
93
+ `arrive_at` on `start_navigation` ends a session at the door, and every
94
+ reroute heads for the same door; with no door that suits, `arrival` is
95
+ `applied: false` with the reason and the session ends at the destination
96
+ as given.
97
+
98
+ Facts an agent should pass on, because they are how the service behaves:
99
+
100
+ - Sessions live in the gateway's memory only and do not survive a gateway
101
+ restart. A session that has gone answers as not found; open a new one
102
+ from where the traveller is.
103
+ - A session expires after 2 hours idle; every progress check resets the
104
+ clock.
105
+ - A session keeps the route and the last accepted fix only: no trail of
106
+ positions, and nothing about a position is written to disk or logged.
107
+ - Entrances are doors mapped in OpenStreetMap and tied to the place on
108
+ evidence; none are estimated today. An empty list means no door is tied
109
+ to the place, not that it has none.
110
+
111
+ Nothing in this package changes for these tools: it adapts whatever
112
+ `tools/list` returns, so they appear as soon as the server you connect to
113
+ registers them. A runnable agent: [`examples/navigate_to_entrance.py`](./examples/navigate_to_entrance.py).
114
+
115
+ ## With a key (metered volume)
116
+
117
+ ```python
118
+ with mapmap_tools(api_key="snk_...") as tools:
119
+ ...
120
+ ```
121
+
122
+ Get a card-free key in one call: `POST https://api.mapmap.ai/v1/keys` with
123
+ `{"email": "you@example.com", "accept_tos": true}`. Email verification
124
+ upgrades the same key to 50,000 included calls a month. Prices:
125
+ [mapmap.ai/pricing.json](https://mapmap.ai/pricing.json).
126
+
127
+ ## Self-hosted
128
+
129
+ Point the wrapper at your own gateway's MCP endpoint:
130
+
131
+ ```python
132
+ with mapmap_tools(url="https://maps.internal.example/mcp") as tools:
133
+ ...
134
+ ```
135
+
136
+ ## Data rights
137
+
138
+ MapMap will never ToS-ban caching, storing, indexing or training on API
139
+ responses. Content derived from OpenStreetMap remains under ODbL: credit
140
+ `© OpenStreetMap contributors` when you republish. Full manifest:
141
+ <https://mapmap.ai/.well-known/agent-terms.json>.
142
+
143
+ ## Publishing (maintainers)
144
+
145
+ Never from a laptop. `.github/workflows/publish-python-packages.yml` builds,
146
+ tests and `twine check`s this package on every pull request that touches it,
147
+ and publishes it to PyPI through trusted publishing (no stored token) when
148
+ dispatched on main with the version typed in full:
149
+
150
+ ```bash
151
+ # Dry run: build, test and twine check only
152
+ gh workflow run publish-python-packages.yml -R Mapmapai/mapmap --ref main \
153
+ -f package=crewai-mapmap
154
+
155
+ # Publish: confirm_version must equal the version in pyproject.toml
156
+ gh workflow run publish-python-packages.yml -R Mapmapai/mapmap --ref main \
157
+ -f package=crewai-mapmap -f confirm_version=0.1.0
158
+ ```
159
+
160
+ For a later release, bump `version` in `pyproject.toml` (and the CHANGELOG)
161
+ first: PyPI never accepts the same version twice.
162
+
163
+ ## Licence
164
+
165
+ MIT. The MapMap service itself is governed by <https://mapmap.ai/terms>.
@@ -0,0 +1,138 @@
1
+ # crewai-mapmap
2
+
3
+ MapMap tools for CrewAI agents: routing for cars, trucks, bikes and walking,
4
+ truck routing with ADR dangerous-goods restrictions, geocoding, travel-time matrices, isochrones,
5
+ multi-stop day planning and hosted map styling, exposed through the hosted
6
+ [MapMap MCP server](https://mapmap.ai/docs/mcp).
7
+
8
+ The hosted server connects without a key for evaluation, under fair use. For
9
+ metered volume an agent gets a card-free key in one API call (see "With a
10
+ key" below). Responses may be cached, stored, indexed and used for training;
11
+ the machine-readable terms are at
12
+ [`/.well-known/agent-terms.json`](https://mapmap.ai/.well-known/agent-terms.json).
13
+
14
+ ## 60-second quickstart
15
+
16
+ ```bash
17
+ pip install crewai-mapmap crewai
18
+ ```
19
+
20
+ ```python
21
+ from crewai import Agent, Crew, Task
22
+ from crewai_mapmap import mapmap_tools
23
+
24
+ with mapmap_tools() as tools: # keyless connect, fair use
25
+ dispatcher = Agent(
26
+ role="Fleet dispatcher",
27
+ goal="Plan compliant truck routes",
28
+ backstory="Plans ADR-compliant routes for a haulage fleet.",
29
+ tools=tools,
30
+ )
31
+ task = Task(
32
+ description=(
33
+ "Route a 4.0 m tall truck carrying ADR tunnel-code C goods "
34
+ "from Dover to Birmingham and explain which restrictions "
35
+ "shaped the route."
36
+ ),
37
+ expected_output="A route summary with the avoided restrictions.",
38
+ agent=dispatcher,
39
+ )
40
+ print(Crew(agents=[dispatcher], tasks=[task]).kickoff())
41
+ ```
42
+
43
+ That is the whole integration: every tool the server registers (`route`,
44
+ `check_adr_tunnel`, `geocode`, `matrix`, `optimise_routes`,
45
+ `search_along_route`, `plan_day`, `reachable_area`, `nearby_places`,
46
+ navigation sessions, place entrances, map-styling and local geometry tools) with their full JSON Schemas. The wrapper adapts whatever `tools/list`
47
+ returns, so it needs no update when the server gains a tool.
48
+
49
+ ## Navigation sessions and place entrances
50
+
51
+ The server's tools for guiding someone to a place turn by turn, and for
52
+ finding a place's doors, come through like every other tool:
53
+
54
+ | Tool | What it does |
55
+ |---|---|
56
+ | `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. |
57
+ | `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. |
58
+ | `end_navigation` | Ends the session and drops what it held. |
59
+ | `place_entrances` | Lists the mapped doors of one place by its id. |
60
+
61
+ Inputs on the existing tools: `include_entrances` on `nearby_places`,
62
+ `places_in_view` and `geocode` adds each place's entrances to the answer,
63
+ and `arrive_at: "entrance"` on `route` ends the route at the best mapped
64
+ door for the mode of travel instead of the middle of the building (the
65
+ answer's `arrival` block says which door, or why none was used). The same
66
+ `arrive_at` on `start_navigation` ends a session at the door, and every
67
+ reroute heads for the same door; with no door that suits, `arrival` is
68
+ `applied: false` with the reason and the session ends at the destination
69
+ as given.
70
+
71
+ Facts an agent should pass on, because they are how the service behaves:
72
+
73
+ - Sessions live in the gateway's memory only and do not survive a gateway
74
+ restart. A session that has gone answers as not found; open a new one
75
+ from where the traveller is.
76
+ - A session expires after 2 hours idle; every progress check resets the
77
+ clock.
78
+ - A session keeps the route and the last accepted fix only: no trail of
79
+ positions, and nothing about a position is written to disk or logged.
80
+ - Entrances are doors mapped in OpenStreetMap and tied to the place on
81
+ evidence; none are estimated today. An empty list means no door is tied
82
+ to the place, not that it has none.
83
+
84
+ Nothing in this package changes for these tools: it adapts whatever
85
+ `tools/list` returns, so they appear as soon as the server you connect to
86
+ registers them. A runnable agent: [`examples/navigate_to_entrance.py`](./examples/navigate_to_entrance.py).
87
+
88
+ ## With a key (metered volume)
89
+
90
+ ```python
91
+ with mapmap_tools(api_key="snk_...") as tools:
92
+ ...
93
+ ```
94
+
95
+ Get a card-free key in one call: `POST https://api.mapmap.ai/v1/keys` with
96
+ `{"email": "you@example.com", "accept_tos": true}`. Email verification
97
+ upgrades the same key to 50,000 included calls a month. Prices:
98
+ [mapmap.ai/pricing.json](https://mapmap.ai/pricing.json).
99
+
100
+ ## Self-hosted
101
+
102
+ Point the wrapper at your own gateway's MCP endpoint:
103
+
104
+ ```python
105
+ with mapmap_tools(url="https://maps.internal.example/mcp") as tools:
106
+ ...
107
+ ```
108
+
109
+ ## Data rights
110
+
111
+ MapMap will never ToS-ban caching, storing, indexing or training on API
112
+ responses. Content derived from OpenStreetMap remains under ODbL: credit
113
+ `© OpenStreetMap contributors` when you republish. Full manifest:
114
+ <https://mapmap.ai/.well-known/agent-terms.json>.
115
+
116
+ ## Publishing (maintainers)
117
+
118
+ Never from a laptop. `.github/workflows/publish-python-packages.yml` builds,
119
+ tests and `twine check`s this package on every pull request that touches it,
120
+ and publishes it to PyPI through trusted publishing (no stored token) when
121
+ dispatched on main with the version typed in full:
122
+
123
+ ```bash
124
+ # Dry run: build, test and twine check only
125
+ gh workflow run publish-python-packages.yml -R Mapmapai/mapmap --ref main \
126
+ -f package=crewai-mapmap
127
+
128
+ # Publish: confirm_version must equal the version in pyproject.toml
129
+ gh workflow run publish-python-packages.yml -R Mapmapai/mapmap --ref main \
130
+ -f package=crewai-mapmap -f confirm_version=0.1.0
131
+ ```
132
+
133
+ For a later release, bump `version` in `pyproject.toml` (and the CHANGELOG)
134
+ first: PyPI never accepts the same version twice.
135
+
136
+ ## Licence
137
+
138
+ MIT. The MapMap service itself is governed by <https://mapmap.ai/terms>.
@@ -0,0 +1,65 @@
1
+ """Walk someone to a station's entrance, turn by turn, with a CrewAI agent.
2
+
3
+ The agent finds the station's mapped doors (`place_entrances`, or
4
+ `include_entrances` on a place search), opens a navigation session on foot
5
+ (`start_navigation`), checks two simulated position fixes
6
+ (`check_navigation_progress`) and ends the session (`end_navigation`).
7
+
8
+ pip install crewai-mapmap crewai
9
+ export OPENAI_API_KEY=... # or configure the LLM CrewAI should use
10
+ export MAPMAP_API_KEY=snk_... # optional on the hosted server (fair use)
11
+ python examples/navigate_to_entrance.py
12
+
13
+ Facts the task asks the agent to keep: sessions do not survive a gateway
14
+ restart (open a new one if a session has gone), expire after 2 hours idle,
15
+ and keep the route and the last accepted fix only; entrances are doors
16
+ mapped in OpenStreetMap, none are estimated, and an empty list means no
17
+ door is tied to the place, not that it has none.
18
+ """
19
+
20
+ from __future__ import annotations
21
+
22
+ import os
23
+
24
+ from crewai import Agent, Crew, Task
25
+
26
+ from crewai_mapmap import mapmap_tools
27
+
28
+ DESCRIPTION = """\
29
+ The traveller is at Euston Square station (51.5246, -0.1340) and walks with a
30
+ wheelchair.
31
+ 1. Find King's Cross station and list its entrances. Say which door is
32
+ step-free if one is mapped wheelchair=yes. If the list is empty, say that
33
+ no door is tied to the station in the map data, not that it has none.
34
+ 2. Open a walking navigation session to it that ends at its step-free door
35
+ (arrive_at {"place_id": <the station id>, "wheelchair": true}), say which
36
+ door the session ends at (or the reason it could not choose one) and
37
+ give the first instruction.
38
+ 3. Check progress with these two fixes, in order:
39
+ (51.5249, -0.1325) at 2026-11-20T16:00:10Z, then
40
+ (51.5254, -0.1305) at 2026-11-20T16:00:25Z,
41
+ and say what to do next each time.
42
+ 4. End the session.
43
+ If a session has gone (expired after 2 hours idle, or the server restarted),
44
+ open a new one from the last position rather than retrying the old id.
45
+ """
46
+
47
+
48
+ def main() -> None:
49
+ with mapmap_tools(api_key=os.environ.get("MAPMAP_API_KEY")) as tools:
50
+ guide = Agent(
51
+ role="Walking guide",
52
+ goal="Get the traveller to the right door of the station",
53
+ backstory="Guides people on foot, door to door, from map data.",
54
+ tools=tools,
55
+ )
56
+ task = Task(
57
+ description=DESCRIPTION,
58
+ expected_output="The entrances, the first instruction and the next step after each fix.",
59
+ agent=guide,
60
+ )
61
+ print(Crew(agents=[guide], tasks=[task]).kickoff())
62
+
63
+
64
+ if __name__ == "__main__":
65
+ main()
@@ -0,0 +1,51 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "crewai-mapmap"
7
+ version = "0.1.0"
8
+ description = "MapMap tools for CrewAI agents: car, truck and ADR routing, geocoding, places, matrices, isochrones and map styling through the hosted MapMap MCP server."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Mapmap AI Ltd", email = "hello@mapmap.ai" }]
14
+ keywords = [
15
+ "crewai",
16
+ "mcp",
17
+ "mapmap",
18
+ "maps",
19
+ "routing",
20
+ "geocoding",
21
+ "truck-routing",
22
+ "adr",
23
+ "agents",
24
+ ]
25
+ classifiers = [
26
+ "Development Status :: 4 - Beta",
27
+ "Intended Audience :: Developers",
28
+ "Programming Language :: Python :: 3",
29
+ "Programming Language :: Python :: 3.10",
30
+ "Programming Language :: Python :: 3.11",
31
+ "Programming Language :: Python :: 3.12",
32
+ "Programming Language :: Python :: 3.13",
33
+ "Topic :: Scientific/Engineering :: GIS",
34
+ "Topic :: Software Development :: Libraries :: Python Modules",
35
+ ]
36
+ dependencies = ["crewai-tools[mcp]>=0.45.0"]
37
+
38
+ [project.optional-dependencies]
39
+ # The tests serve a local stand-in MCP server (mcp's FastMCP under uvicorn).
40
+ test = ["pytest>=8", "uvicorn>=0.30"]
41
+
42
+ [project.urls]
43
+ Homepage = "https://mapmap.ai/agents"
44
+ Documentation = "https://mapmap.ai/docs/mcp"
45
+ "Agent data rights" = "https://mapmap.ai/.well-known/agent-terms.json"
46
+
47
+ [tool.hatch.build.targets.wheel]
48
+ packages = ["src/crewai_mapmap"]
49
+
50
+ [tool.pytest.ini_options]
51
+ testpaths = ["tests"]
@@ -0,0 +1,68 @@
1
+ """MapMap tools for CrewAI agents.
2
+
3
+ A thin wrapper over ``crewai-tools``' ``MCPServerAdapter`` that connects to
4
+ the hosted MapMap MCP server (https://mcp.mapmap.ai/mcp) and yields every
5
+ tool it registers (route, check_adr_tunnel, geocode, matrix, optimise_routes,
6
+ plan_day, reachable_area, nearby_places, start_navigation, check_navigation_progress,
7
+ end_navigation, place_entrances, map styling, local geometry) as
8
+ CrewAI tools. Whatever ``tools/list`` answers is what you get, so this
9
+ wrapper does not name a count that a release could leave behind.
10
+
11
+ No key is needed to connect (fair use). For metered volume, get a card-free
12
+ key in one call (POST https://api.mapmap.ai/v1/keys) and pass it as
13
+ ``api_key``.
14
+
15
+ Data rights: agents may cache, store, index and train on MapMap responses,
16
+ forever. See https://mapmap.ai/.well-known/agent-terms.json.
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ from typing import Any
22
+
23
+ from crewai_tools import MCPServerAdapter
24
+
25
+ __all__ = [
26
+ "MAPMAP_MCP_URL",
27
+ "mapmap_server_params",
28
+ "mapmap_tools",
29
+ ]
30
+
31
+ __version__ = "0.1.0"
32
+
33
+ MAPMAP_MCP_URL = "https://mcp.mapmap.ai/mcp"
34
+
35
+
36
+ def mapmap_server_params(
37
+ url: str = MAPMAP_MCP_URL,
38
+ api_key: str | None = None,
39
+ ) -> dict[str, Any]:
40
+ """Server parameters for ``MCPServerAdapter`` pointing at MapMap.
41
+
42
+ Use this directly if you want to combine MapMap with other MCP servers
43
+ in one adapter; otherwise :func:`mapmap_tools` is all you need.
44
+ """
45
+ params: dict[str, Any] = {"url": url, "transport": "streamable-http"}
46
+ if api_key:
47
+ params["headers"] = {"Authorization": f"Bearer {api_key}"}
48
+ return params
49
+
50
+
51
+ def mapmap_tools(
52
+ url: str = MAPMAP_MCP_URL,
53
+ api_key: str | None = None,
54
+ ) -> MCPServerAdapter:
55
+ """MapMap's MCP tools as a CrewAI ``MCPServerAdapter``.
56
+
57
+ Use as a context manager so the MCP session is cleanly closed::
58
+
59
+ with mapmap_tools() as tools:
60
+ agent = Agent(..., tools=tools)
61
+
62
+ Args:
63
+ url: MCP endpoint. Defaults to the hosted server; point it at your
64
+ self-hosted gateway's ``:8200/mcp`` to use your own deployment.
65
+ api_key: Optional MapMap API key (``snk_...``) sent as a bearer
66
+ token for metered calls.
67
+ """
68
+ return MCPServerAdapter(mapmap_server_params(url, api_key))
@@ -0,0 +1,113 @@
1
+ """A local stand-in for the MapMap MCP server, for the passthrough tests.
2
+
3
+ It registers a few tools under the names agreed for MapMap's
4
+ navigation sessions and place entrances (``start_navigation``,
5
+ ``check_navigation_progress``, ``end_navigation``, ``place_entrances``, and
6
+ ``include_entrances`` / ``arrive_at`` inputs on ``nearby_places``,
7
+ ``route`` and ``start_navigation``). The schemas here are illustrative: the real ones are whatever
8
+ the server's ``tools/list`` answers. The point under test is that this
9
+ package adapts whatever the server registers, with no list of its own, and
10
+ sends the API key as a bearer token.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import socket
16
+ import threading
17
+ import time
18
+ from collections.abc import Iterator
19
+ from typing import Any
20
+
21
+ import pytest
22
+ import uvicorn
23
+ from mcp.server.fastmcp import FastMCP
24
+
25
+
26
+ def _free_port() -> int:
27
+ with socket.socket() as s:
28
+ s.bind(("127.0.0.1", 0))
29
+ return int(s.getsockname()[1])
30
+
31
+
32
+ def build_server() -> FastMCP:
33
+ mcp = FastMCP("mapmap-test", stateless_http=True, json_response=True)
34
+
35
+ @mcp.tool()
36
+ def start_navigation(
37
+ origin: dict[str, Any],
38
+ destination: dict[str, Any],
39
+ costing: str = "auto",
40
+ arrive_at: str | dict[str, Any] | None = None,
41
+ ) -> dict[str, Any]:
42
+ """Open a navigation session (stand-in). ``arrive_at`` is "point",
43
+ "entrance" or {place_id?, entrance_kind?, wheelchair?}, as on ``route``."""
44
+ answer: dict[str, Any] = {
45
+ "session_id": "nav_" + "0" * 32,
46
+ "first_instruction": {"text": "Head north."},
47
+ "costing": costing,
48
+ }
49
+ if arrive_at not in (None, "point"):
50
+ answer["arrival"] = {"applied": True, "requested": arrive_at}
51
+ return answer
52
+
53
+ @mcp.tool()
54
+ def check_navigation_progress(session_id: str, lat: float, lon: float) -> dict[str, Any]:
55
+ """Send one fix (stand-in)."""
56
+ return {"session_id": session_id, "state": "on_route"}
57
+
58
+ @mcp.tool()
59
+ def end_navigation(session_id: str) -> dict[str, Any]:
60
+ """End a session (stand-in)."""
61
+ return {"session_id": session_id, "ended": True}
62
+
63
+ @mcp.tool()
64
+ def place_entrances(place_id: str) -> dict[str, Any]:
65
+ """The mapped doors of one place (stand-in)."""
66
+ return {"id": place_id, "entrances": [], "note": "no door is tied to this place"}
67
+
68
+ @mcp.tool()
69
+ def nearby_places(lat: float, lon: float, include_entrances: bool = False) -> dict[str, Any]:
70
+ """Places near a point (stand-in)."""
71
+ return {"places": [], "include_entrances": include_entrances}
72
+
73
+ @mcp.tool()
74
+ def route(locations: list[dict[str, float]], arrive_at: str | None = None) -> dict[str, Any]:
75
+ """A route (stand-in)."""
76
+ return {"arrival": {"applied": arrive_at == "entrance"}}
77
+
78
+ return mcp
79
+
80
+
81
+ class _Recorder:
82
+ """ASGI middleware that records the Authorization header of each request."""
83
+
84
+ def __init__(self, app: Any) -> None:
85
+ self.app = app
86
+ self.authorization: list[str | None] = []
87
+
88
+ async def __call__(self, scope: Any, receive: Any, send: Any) -> None:
89
+ if scope["type"] == "http":
90
+ headers = dict(scope.get("headers") or [])
91
+ value = headers.get(b"authorization")
92
+ self.authorization.append(value.decode() if value else None)
93
+ await self.app(scope, receive, send)
94
+
95
+
96
+ @pytest.fixture(scope="session")
97
+ def fake_mapmap() -> Iterator[tuple[str, _Recorder]]:
98
+ """Serves the stand-in on 127.0.0.1 and yields (mcp_url, recorder)."""
99
+ server = build_server()
100
+ app = _Recorder(server.streamable_http_app())
101
+ port = _free_port()
102
+ config = uvicorn.Config(app, host="127.0.0.1", port=port, log_level="warning", lifespan="on")
103
+ uv = uvicorn.Server(config)
104
+ thread = threading.Thread(target=uv.run, daemon=True)
105
+ thread.start()
106
+ deadline = time.time() + 10
107
+ while not uv.started:
108
+ if time.time() > deadline:
109
+ raise RuntimeError("the stand-in MCP server did not start")
110
+ time.sleep(0.05)
111
+ yield f"http://127.0.0.1:{port}/mcp", app
112
+ uv.should_exit = True
113
+ thread.join(timeout=5)
@@ -0,0 +1,96 @@
1
+ """crewai-mapmap passes the server's tools through, new ones included."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import re
7
+ import tomllib
8
+ from pathlib import Path
9
+
10
+ import crewai_mapmap
11
+ from crewai_mapmap import MAPMAP_MCP_URL, mapmap_server_params, mapmap_tools
12
+
13
+ PACKAGE = Path(__file__).resolve().parents[1]
14
+ SESSION_AND_ENTRANCE_TOOLS = {
15
+ "start_navigation",
16
+ "check_navigation_progress",
17
+ "end_navigation",
18
+ "place_entrances",
19
+ }
20
+
21
+
22
+ def test_server_params_are_keyless_by_default() -> None:
23
+ assert mapmap_server_params() == {"url": MAPMAP_MCP_URL, "transport": "streamable-http"}
24
+
25
+
26
+ def test_api_key_becomes_a_bearer_header() -> None:
27
+ params = mapmap_server_params(api_key="snk_test")
28
+ assert params["headers"] == {"Authorization": "Bearer snk_test"}
29
+
30
+
31
+ def test_version_matches_pyproject() -> None:
32
+ project = tomllib.loads((PACKAGE / "pyproject.toml").read_text())["project"]
33
+ assert crewai_mapmap.__version__ == project["version"]
34
+
35
+
36
+ def _schema_properties(tool: object) -> dict:
37
+ schema = getattr(tool, "args_schema")
38
+ return schema.model_json_schema()["properties"]
39
+
40
+
41
+ def test_session_and_entrance_tools_arrive_with_their_inputs(fake_mapmap) -> None:
42
+ url, _ = fake_mapmap
43
+ with mapmap_tools(url=url) as tools:
44
+ by_name = {tool.name: tool for tool in tools}
45
+ assert SESSION_AND_ENTRANCE_TOOLS <= set(by_name)
46
+ assert "include_entrances" in _schema_properties(by_name["nearby_places"])
47
+ assert "arrive_at" in _schema_properties(by_name["route"])
48
+ assert {"origin", "destination", "arrive_at"} <= set(
49
+ _schema_properties(by_name["start_navigation"])
50
+ )
51
+ assert {"session_id", "lat", "lon"} <= set(
52
+ _schema_properties(by_name["check_navigation_progress"])
53
+ )
54
+
55
+
56
+ def test_a_session_tool_call_reaches_the_server_with_the_key(fake_mapmap) -> None:
57
+ url, recorder = fake_mapmap
58
+ recorder.authorization.clear()
59
+ with mapmap_tools(url=url, api_key="snk_test") as tools:
60
+ start = next(tool for tool in tools if tool.name == "start_navigation")
61
+ result = start.run(
62
+ origin={"lat": 51.5246, "lon": -0.134},
63
+ destination={"place_id": "osm:w123:poi"},
64
+ costing="pedestrian",
65
+ arrive_at={"place_id": "osm:w123:poi", "wheelchair": True},
66
+ )
67
+ text = result if isinstance(result, str) else json.dumps(result, default=str)
68
+ assert "nav_" in text
69
+ # The object form of arrive_at reaches the server intact.
70
+ assert "arrival" in text and "wheelchair" in text
71
+ assert recorder.authorization
72
+ assert set(recorder.authorization) == {"Bearer snk_test"}
73
+
74
+
75
+ def test_readme_names_the_tools_and_states_the_facts() -> None:
76
+ readme = " ".join((PACKAGE / "README.md").read_text().split())
77
+ for name in SESSION_AND_ENTRANCE_TOOLS | {"include_entrances"}:
78
+ assert f"`{name}`" in readme, name
79
+ assert '`arrive_at: "entrance"`' in readme
80
+ assert "every reroute heads for the same door" in readme
81
+ assert "do not survive a gateway restart" in readme
82
+ assert "2 hours idle" in readme
83
+ assert "last accepted fix only" in readme
84
+ assert "OpenStreetMap" in readme and "none are estimated" in readme
85
+ assert "not that it has none" in readme
86
+ assert chr(0x2014) not in readme, "no em dashes in outward text"
87
+
88
+
89
+ def test_readme_names_no_tool_count() -> None:
90
+ readme = (PACKAGE / "README.md").read_text()
91
+ assert not re.search(r"\b\d+ (MCP )?tools\b", readme)
92
+
93
+
94
+ def test_example_compiles() -> None:
95
+ source = (PACKAGE / "examples" / "navigate_to_entrance.py").read_text()
96
+ compile(source, "navigate_to_entrance.py", "exec")