This article demonstrates integrating Google Maps with natural language using the Gemini CLI and an MCP server. This powerful combination allows users to automate complex location-based tasks, such as route planning and information retrieval, through simple, intuitive text-based prompts.
The Gemini CLI, when paired with Model Context Protocol (MCP) servers, is a powerful tool for integrating various applications with natural language. When the MCP servers are built using Google Apps Script Web Apps, it becomes easy to integrate Google Workspace and other Google APIs with seamless authorization. This concept has been explored in several articles, which you can find here: Ref, Ref, Ref, Ref, Ref, Ref, Ref. This article introduces the integration of Google Maps and natural language using the Gemini CLI with an MCP server.
The following examples showcase how natural language prompts can use Google Maps. For complete setup and usage instructions, please refer to the repository: https://github.com/tanaikech/ToolsForMCPServer?tab=readme-ov-file#usage
Prompt:
Convert the location of Tokyo Station to the geographic point (latitude and longitude).
Convert the latitude of 35.6812996 and the longitude of 139.7670658 to the location name and the address.
The actual prompts executed with Gemini CLI are as follows.
In the case of Gemini CLI, a Google search can be used. It is considered that a Google search can also achieve the above prompts. Also, the result searched using a Google search might be newer than Maps.newGeocoder()
of Google Apps Script. For example, when I converted "Expo 2025 Osaka, Kansai, Japan" to the geographic point using a tool "maps_convert_location_to_lat_lon", the latitude of 34.6380488 and the longitude of 135.411274 were returned. On the other hand, when the same conversion is run with a Google search, the latitude of 34.653528 and the longitude of 135.386417 are returned. In this case, the result of the Google search is correct.
Prompt:
Create a static map by centering Osaka Station.
The actual prompts executed with Gemini CLI are as follows.
The created static map is as follows.
Prompt:
Your mission is as follows.
1. Search the latitude and longitude of Expo 2025 Osaka and JapanExpo'70 Commemorative Park using Google search.
2. I will use public transport. Create a static map including a route from Expo 2025 Osaka, Kansai, JapanExpo'70 Commemorative Park as an image on Google Drive.
3. Create the detailed route as the text.
4. Create a dynamic map link.
5. Send an email including the map image file as an attachment file, the route text, and a dynamic map link as the email body to ###@gmail.com
6. Remove the created map image file.
The actual prompts executed with Gemini CLI are as follows.
The following email is sent.
Here is the detailed route from Expo 2025 Osaka to JapanExpo'70 Commemorative Park:
**Route from Expo 2025 Osaka to JapanExpo'70 Commemorative Park:**
1. Walk to Yumeshima Station (0.7 km, 9 mins)
* Head southeast (0.2 km, 3 mins)
* Turn left (0.4 km, 5 mins)
* Turn left (81 m, 1 min)
* Take entrance 1 (35 m, 1 min)
2. Subway towards Nagata from Yumeshima Station to Hommachi Station (12.6 km, 19 mins)
3. Walk to Hommachi Station (0.2 km, 3 mins)
4. Subway towards Minoh-kayano from Hommachi Station to Senri-Chuo (14.4 km, 25 mins)
5. Walk to Senri-chuo (0.2 km, 4 mins)
6. Monorail towards Kadomashi from Senri-chuo to Bampakukinenkoen Station (3.2 km, 5 mins)
7. Walk to 10-10 Senribanpakukōen, Suita, Osaka 565-0826, Japan (1.0 km, 16 mins)
* Take exit (東側) (49 m, 1 min)
* Head east (0.2 km, 3 mins)
* Turn left (0.3 km, 4 mins)
* Turn left (75 m, 1 min)
* Turn right (0.3 km, 3 mins)
* Turn left (0.1 km, 2 mins)
Total duration: 1 hour 25 mins
Total fare: ¥870
Dynamic Map Link: https://www.google.com/maps/dir/?api=1&origin=34.653527,135.386416&destination=34.8111,135.5304&travelmode=transit
The following static map is attached to the email.
Prompt:
Now, I am at Osaka Station. Your mission is as follows.
1. Search 5 restaurants nearest here using Google search.
2. Create a static map by adding Osaka Station and the searched restaurants as the markers. Osaka Station should be the center of the map.
3. Show a dynamic map link.
As additional information, in this case, use the address of the location without using the latitude and longitude.
The actual prompts executed with Gemini CLI are as follows.
The created static map is as follows.
Prompt:
Now, I am at Shibuya Station. Your mission is as follows.
1. Search for 5 recommended clothes shops here using Google search.
2. Create a static map by adding Shibuya Station and the searched restaurants as the markers. Shibuya Station should be the center of the map.
3. Show a dynamic map link.
4. Create a document structure without markdown for a detailed introduction to your recommended 5 clothes shops, including the created static map and the dynamic map link.
5. Create a new Google document and add the created document text.
As additional information, use only the address of the location or the location name.
The actual prompts executed with Gemini CLI are as follows.
Created Google document is as follows.
To generate a dynamic Google Maps link, a tool hosted on an MCP server was utilized. This specific tool provides only a description of the methodology for creating the dynamic link. This tool can be confirmed as a tool explanation_create_maps_url
of ToolsForMCPServer. Ref. Subsequently, Gemini CLI uses this description to generate the final, functional Google Maps link. This process is an implementation of Retrieval-Augmented Generation (RAG) in a pseudo manner using an AI agent. By leveraging the MCP server tool as a knowledge source, the AI agent's response is grounded in specific, up-to-date instructions, which helps to mitigate issues where insufficient information would otherwise prevent the system from providing an accurate answer.
While such procedural descriptions could be embedded directly into a project's documentation, like a "GEMINI.md" file, hosting them as tools on an MCP server offers distinct advantages, particularly as the number of tools and descriptions grows. This server-based approach is more cost-effective and simplifies maintenance, as the tools can be updated and managed independently of the core AI model. The decision to adopt the MCP server architecture for this generative AI project was made to overcome the inherent knowledge limitations of the LLM and create a more scalable and maintainable system.
- Natural Language Interaction: The integration of Gemini CLI and MCP servers allows users to interact with Google Maps using natural language prompts, simplifying complex tasks.
- Seamless Integration: This setup provides a seamless way to connect Google Maps with other Google Workspace applications, such as Google Drive and Gmail, for enhanced productivity.
- Dynamic and Static Maps: The system can generate both static and dynamic maps, offering flexibility for different use cases, from email attachments to interactive links.
- Retrieval-Augmented Generation (RAG): The use of RAG with MCP servers ensures that the AI's responses are accurate and up-to-date, overcoming the knowledge limitations of large language models.
- Scalable and Maintainable: The server-based architecture of the MCP server makes the system scalable and easy to maintain, allowing for the addition of new tools and functionalities without modifying the core AI model.