Grounding Lite MCP Server
Provides custom tools to the Gemini model for spatially grounding responses using Google Maps Platform APIs (Places, Routes, Elevation).
README
Grounding Lite Sample App

Overview
This repository contains a sample application demonstrating the use of Grounding Lite with the Gemini API to provide spatially grounded responses using Google Maps Platform data. The application uses the agent to converse and a companion 3D Google Maps.
Please refer to the official documentation for more details: Grounding Lite Documentation.
Architecture
The application employs a client-server architecture where a Node.js backend hosts the Model Context Protocol (MCP) server, allowing the Gemini model to dynamically access real-time geographic information via Google Maps Platform tools.
Key Components
- Client (Web App): Built with Vite and Lit, handles user chat interaction and displays the dynamic 3D map (using the Maps JavaScript API).
- Backend Server (Node/Express): Acts as a central proxy, managing communication between the Client, the Gemini API, and hosting the MCP Server.
- Grounding Lite MCP Server: Exposes a set of custom tools to the Gemini model, providing the capability to ground its responses in real-world geographic data.
- MCP Tools: Custom functions defined by the MCP server that translate natural language requests into structured Google Maps Platform API calls (
Places API,Routes API,Elevation API). - Gemini API: The Large Language Model (LLM) that leverages the provided MCP tools for geographically accurate, grounded responses.
Data Flow Diagram (Grounding Lite)
graph TD
subgraph Client/UI
C[Client Web App]
end
style Client/UI fill:#FFFFFF
subgraph Backend Services
B[Backend Server]
end
subgraph Gemini and APIs
G[AI API]
P[Maps Platform other APis]
end
subgraph Grounding Lite
M[MCP Server] --> T[MCP Tools]
end
C --> B("User Query")
%% Combined edges to prevent overwriting in some renderers
B --> G("Send Query + Tool Schema<br/>Send Tool Results")
G --> B("Model Decision (Tool Call)<br/>Final Grounded Response")
B --> M("Execute MCP Tool")
T --> P("Call Specific GMP API")
P --> T("Return Data")
T --> B("Return Tool Results")
B --> C("Display Response")
Prerequisites
- A Google Cloud Project with the necessary APIs enabled
- Create API keys
- Server API Key:
- Grounding Lite MCP Service
- Gemini API (aka Generative Language API)
- Complementary APIs to manage the 3D map:
- Routes API for the polyline
- Places API (New) for the name of the businesses on markers
- Elevation API to adjust camera altitude to the map location
- Client API key:
- Maps JavaScript API
- Places UI Kit
- Server API Key:
- Node.js and npm installed.
Installation
Key Dependencies
- Vite: A fast, modern development server and build tool for web projects.
- @google/genai: The official SDK for interacting with the Google Gemini API.
- @modelcontextprotocol/sdk: The SDK for creating and interacting with Model Context Protocol (MCP) servers.
- Lit: A simple library for building fast, lightweight web components.
- Tailwind CSS: A utility-first CSS framework for rapidly building custom user interfaces.
- Express: A minimal and flexible Node.js web application framework used for the backend server.
- dotenv: A zero-dependency module that loads environment variables from a
.envfile.
- Install the dependencies:
npm install
- Configure your environment:
Create a .env file in the root directory and add your API keys.
For the frontend (Google Maps JavaScript API loading), use:
GOOGLE_MAPS_API_KEY="YOUR_GOOGLE_MAPS_API_KEY"
For the server-side (Maps Platform MCP calls and Gemini API calls), use:
SERVER_API_KEY="YOUR_SERVER_API_KEY_HERE"
Architecture
Running the Application
This application uses concurrently to run both the Vite frontend server and the Node.js backend server (which hosts the Model Context Protocol (MCP) server).
Development Mode
Run the application in development mode:
npm run dev
This command executes: concurrently "vite" "npm run dev:server:watch"
- The frontend (Vite) will typically run on
http://localhost:5173. - The backend server (Node.js/Express) handles the MCP server setup and API routes.
Production Build
- Build the application:
npm run build
- Start the production server:
npm start
# or
npm run start:prod
Cloud Run Deployment
This application can be deployed to Google Cloud Run by building and deploying directly from the source code.
-
Ensure prerequisites are met: You must have the Google Cloud CLI installed and authenticated.
-
Deploy the application: Run the following command, replacing the environment variable placeholders and project ID with your values.
Note: For this sample app to function correctly, you must pass the
SERVER_API_KEY(for server-side Google Maps Platform and Gemini APIs) andGOOGLE_MAPS_API_KEY(for client-side Maps JavaScript API) as environment variables. -
Use the deployment script: We have provided a generic deployment script,
deploy.sh, which readsSERVER_API_KEYandGOOGLE_MAPS_API_KEYdirectly from your local.envfile and passes them securely to thegcloud run deploycommand.The generic script requires the GCP Project ID and Region as arguments:
./deploy.sh YOUR_GCP_PROJECT_ID us-central1
Terms of Service
This is a sample application provided for demonstration purposes.
This sample application is not a Google Maps Platform Core Service. Therefore, the Google Maps Platform Terms of Service (e.g. Technical Support Services, Service Level Agreements, and Deprecation Policy) do not apply to the code in this solution.
Support
This sample application is offered via an open source license. It is not governed by the Google Maps Platform Support Technical Support Services Guidelines, the SLA, or the Deprecation Policy (however, any Google Maps Platform services used by the sample application remain subject to the Google Maps Platform Terms of Service).
If you find a bug, or have a feature request, please file an issue on GitHub. If you would like to get answers to technical questions from other Google Maps Platform developers, ask through one of our developer community channels. If you'd like to contribute, please check the Contributing guide.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。