places-mcp

brukhabtu/places-mcp

3.2

If you are the rightful owner of places-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A simple MCP server providing access to the Google Places API using FastMCP's OpenAPI integration.

Google Places MCP Server

A simple MCP (Model Context Protocol) server that provides access to the Google Places API using FastMCP's OpenAPI integration.

Overview

This implementation leverages FastMCP 2.0's from_openapi feature to automatically generate an MCP server from Google's official OpenAPI specification. With just 30 lines of code, it exposes all Google Places API endpoints as MCP tools that LLMs can use.

Features

The MCP server automatically provides tools for all Google Places API endpoints:

  • placeDetails - Get detailed information about a specific place
  • textSearch - Search for places using a text query
  • nearbySearch - Search for places near a specific location
  • findPlaceFromText - Find a specific place from a text input
  • autocomplete - Get place predictions as users type
  • queryAutocomplete - Get query predictions for place searches
  • placePhoto - Retrieve photos for places

Prerequisites

  • Python 3.13+
  • Google Maps API key with Places API enabled
  • FastMCP 2.0+

Installation

  1. Clone the repository with the Google OpenAPI specification:
git clone https://github.com/googlemaps/openapi-specification.git
  1. Install dependencies:
pip install fastmcp httpx
  1. Set your Google API key:
export GOOGLE_API_KEY="your-api-key-here"

Usage

  1. Run the MCP server:
python places_mcp.py
  1. The server will start and display available tools:
Starting Google Places MCP Server...
Available tools: ['placeDetails', 'textSearch', 'nearbySearch', 'findPlaceFromText', 'autocomplete', 'queryAutocomplete', 'placePhoto']
  1. Connect your LLM client to the MCP server to access Google Places functionality.

How It Works

FastMCP's from_openapi method:

  1. Reads the Google Maps OpenAPI specification
  2. Automatically generates MCP tools for each API endpoint
  3. Handles parameter validation and request formatting
  4. Manages authentication via the HTTP client

The implementation is minimal because FastMCP handles all the complexity of:

  • Parsing OpenAPI schemas
  • Creating tool definitions
  • Validating parameters
  • Making HTTP requests
  • Handling responses

Example Tool Usage

When connected to an LLM, you can make requests like:

{
  "tool": "nearbySearch",
  "parameters": {
    "location": "37.7749,-122.4194",
    "radius": 1000,
    "type": "restaurant"
  }
}

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     LLM     │────▢│  MCP Server  │────▢│ Google Places   β”‚
β”‚   Client    │◀────│  (FastMCP)   │◀────│      API        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

License

This project uses the Google Maps OpenAPI specification which is licensed under Apache 2.0.