MCP
Golang
Open Source
Engineering

Building Context-Aware AI with Google Air Quality MCP Server | ContexaAI

Akshay Galande

Author

December 2, 2025

Published

Building Context-Aware AI with Google Air Quality MCP Server | ContexaAI

Building Context-Aware AI with Google Air Quality MCP Server

Integrating reliable, real-time environmental data into Large Language Model (LLM) agents is a recurring development hurdle. The core issue isn't the API itself, but the lack of a standardized, context-aware bridge.

At ContexaAI, we developed and open-sourced the Google Air Quality Model Context Protocol (MCP) Server to solve this. This server, built in Go and hosted on GitHub, acts as a high-performance intermediary, transforming complex geographical data retrieval into a set of structured, LLM-native capabilities.

Here is a breakdown of how this MCP server helps developers build more reliable, context-aware AI applications, without reinventing the integration wheel.

Bridging the Gap: Lat/Long vs. Natural Language

The Google Air Quality API is powerful, but its primary endpoints require precise input: latitude, longitude, and often granular time definitions.

This is the developer pain point our MCP server eliminates:

1. From Coordinates to Context (MCP Prompts)

MCP standardizes how an LLM can request data. The server exposes MCP Prompts that accept natural language, decoupling the complex geo-resolution from the LLM's reasoning.

Instead of the LLM generating a raw API call with hardcoded coordinates, it uses a standardized invocation:

Use the current_air_quality_by_location_prompt with location "San Francisco"

The MCP server handles the entire pipeline: Geolocation → Tool Invocation → Structured Output. This ensures queries are reliable and reduces the likelihood of the LLM "hallucinating" an answer due to poor context or outdated data.

2. Reliable, Typed Function Calls (MCP Tools)

The server exposes the full range of Google AQI functionality as reliable MCP Tools with clearly defined schemas. This is critical for modern agentic workflows, where the LLM's function calling capability is leveraged.

  • get_current_air_quality — Fetches the real-time AQI index for any location. Optionally retrieves Universal AQI (universalAqi: true).
  • get_air_quality_forecast — Provides hourly forecast data (up to 96 hours) for proactive planning.
  • get_air_quality_heatmap_tile — Directly generates URLs for map-overlay PNG tiles (e.g., UAQI, PM2.5, or country-specific indexes) for visualization.

By providing these capabilities as structured tools, we enable developers to integrate AQI data into any MCP-compatible AI client, regardless of the underlying LLM model.

Technical Advantages: Go, Docker, and Git

The implementation decisions were focused on performance and deployment simplicity, making the repository a valuable asset for any developer seeking a robust microservice architecture.

High Performance in Go

The server is built in Go (Golang). Go's efficiency and low memory footprint make it ideal for an intermediary service that handles potentially high volumes of geographically diverse queries. It ensures low latency when retrieving data from the Google API and serving it to the AI client.

Production-Ready Deployment

The repository includes comprehensive Docker support, utilizing a multi-stage build:

  • Minimal Image Size: The final image is lightweight (approx. 54MB) because it only contains the compiled Go binary and necessary runtime files, improving security and cold-start times.
  • Easy Orchestration: The provided docker-compose.yml allows developers to deploy the service locally or on platforms like Kubernetes or Google Cloud Run instantly.

Open Collaboration on Git

This project is an open-source tool, and the GitHub repository is the foundation for its evolution. Developers can leverage the existing implementation, propose new features (e.g., additional country-specific AQI support), or contribute bug fixes.

# Get started with the source code and contribute today!
git clone git@github.com:ContexaAI/google-air-quality-mcp.git

By providing this server via Git, we ensure the integration remains up-to-date and transparent, anchoring AI-powered applications in collaborative, verifiable code.

Start Building Today

This MCP server streamlines the process of integrating Google's Air Quality data, allowing you to focus on high-level agent logic rather than low-level API plumbing.

Explore the Code and Contribute:

GitHub Repository: ContexaAI/google-air-quality-mcp


About ContexaAI: