---
title: "Google Maps MCP with AgentU"
description: "Connect your AI agents to Google Maps using the Model Context Protocol - search places, get weather, and compute routes."
url: "https://h3manth.com/scribe/google-maps-mcp-with-agentu/"
canonical_url: "https://h3manth.com/scribe/google-maps-mcp-with-agentu/"
markdown_url: "https://h3manth.com/scribe/blog/google-maps-mcp-with-agentu.md"
publishDate: "2025-12-17T08:00:00.000Z"
author: "Hemanth HM"
category: "python"
tags: ["python","ai","agents","mcp","google-maps","agentu"]
word_count: 760
reading_time_minutes: 4
x_markdown_tokens: 1454
content_signal: "ai-train=yes, search=yes, ai-input=yes"
---

# Google Maps MCP with AgentU

> Connect your AI agents to Google Maps using the Model Context Protocol - search places, get weather, and compute routes.

Google just released their Maps MCP (Model Context Protocol) server, giving AI agents direct access to Places, Weather, and Routes APIs. Here's how to connect it with **AgentU** in under 10 lines of code.

## What is MCP?

The Model Context Protocol is an open standard that lets AI agents connect to external tools and services. Instead of writing custom integrations, you just point your agent at an MCP server and it automatically discovers available tools.

Google's Maps MCP server exposes three powerful tools:
- **search_places** - Find businesses, landmarks, anything on Google Maps
- **lookup_weather** - Get current weather conditions
- **compute_routes** - Calculate directions between locations

## Prerequisites

Before you start, you need to:

### 1. Enable the Maps MCP API

```bash
# Set your Google Cloud project
gcloud config set project YOUR_PROJECT_ID

# Enable the MCP endpoint
gcloud beta services mcp enable mapstools.googleapis.com
```

### 2. Configure Your API Key

Go to [Google Cloud Console Credentials](https://console.cloud.google.com/apis/credentials) and either:
- Set your API key to "Don't restrict key", OR
- Add "Maps Grounding Lite API" to the allowed APIs list

## The Code

```python
import asyncio
import json
from agentu import Agent

MAPS_MCP_URL = "https://mapstools.googleapis.com/mcp"
MAPS_API_KEY = "your-google-maps-api-key"
LLM_KEY = "your-llm-api-key"

async def main():
    agent = Agent(
        "maps agent", 
        model="openai/gpt-oss-120b", 
        api_key=LLM_KEY, 
        api_base="https://api.groq.com/openai/v1"
    ).with_mcp([{
        "url": MAPS_MCP_URL, 
        "headers": {"X-Goog-Api-Key": MAPS_API_KEY}
    }])

    result = await agent.infer("Find coffee shops near Times Square, New York")
    data = json.loads(result["result"])
    print(data["summary"])

asyncio.run(main())
```

That's it. The agent automatically:
1. Connects to the Google Maps MCP server
2. Discovers the available tools
3. Uses the LLM to decide which tool to call
4. Returns structured results with a natural language summary

## Example Output

```
Here are some coffee shops near Times Square:

**Times Square Cafe** is a coffee shop located at 1657 Broadway, 
New York, NY 10019. It has a rating of 4.5 stars and is open 24 hours.

**787 coffee** is a coffee shop located at 245 W 46th St, 
New York, NY 10036. It has a rating of 4.9 stars and offers outdoor seating.

**Bibble & Sip** is a bakery and coffee shop located at 253 W 51st St, 
New York, NY 10019. It has a rating of 4.5 stars and serves breakfast.
```

## How It Works

The `.with_mcp()` method accepts a list of MCP server configurations. Each config can be:

```python
# Simple URL
agent.with_mcp(["http://localhost:3000"])

# URL with custom headers (like API keys)
agent.with_mcp([{
    "url": "https://mapstools.googleapis.com/mcp", 
    "headers": {"X-Goog-Api-Key": "your-key"}
}])

# Multiple servers
agent.with_mcp([
    "http://localhost:3000",
    {"url": "https://api.example.com/mcp", "headers": {"Auth": "token"}}
])
```

When you call `.with_mcp()`, AgentU:
1. Sends an `initialize` request to establish the session
2. Calls `tools/list` to discover available tools
3. Registers each tool with your agent

Then when you call `agent.infer()`, the LLM sees all available tools and picks the right one.

## Available Tools

The Google Maps MCP server provides these tools:

### search_places
Search for places using natural language queries.

```python
result = await agent.infer("Find Italian restaurants in San Francisco")
```

### lookup_weather
Get current weather conditions for a location.

```python
result = await agent.infer("What's the weather in Tokyo right now?")
```

### compute_routes
Calculate directions between locations.

```python
result = await agent.infer("How do I get from LAX to Santa Monica?")
```

## Troubleshooting

### 403 Forbidden Error

If you get a 403 error, check these things in order:

1. **MCP endpoint not enabled**: Run the gcloud command above
2. **API key restrictions**: Make sure your key allows `mapstools.googleapis.com`
3. **Billing not enabled**: Google Maps APIs require a billing account

### "MCP_SERVER_DISABLED" Error

This means you need to enable the MCP endpoint specifically:

```bash
gcloud beta services mcp enable mapstools.googleapis.com --project=YOUR_PROJECT_ID
```

Note: This is different from enabling the regular Maps APIs.

## Why MCP?

The Model Context Protocol is becoming the standard way for AI agents to interact with external services. Benefits include:

- **Standardized interface**: One protocol for all tools
- **Auto-discovery**: Agents learn what tools are available automatically
- **Type safety**: Tools come with JSON schemas for parameters
- **Vendor neutral**: Works with any LLM

Google's Maps MCP is just the beginning. Expect more services to expose MCP endpoints as the ecosystem matures.

## Conclusion

Connecting AI agents to Google Maps has never been easier. With AgentU and MCP:

1. **One line** to connect: `.with_mcp([...])`
2. **Zero tool registration**: Tools are discovered automatically
3. **Natural language**: Just ask what you want

The combination of AgentU's simplicity and MCP's standardization makes building location-aware AI agents trivial.

Get started:
- [AgentU on GitHub](https://github.com/hemanth/agentu)
- [Google Maps MCP Documentation](https://developers.google.com/maps)

pip install agentu

Happy mapping! 🗺️
