Forecast Storage MCP Server

Forecast Storage MCP Server

Enables storing and retrieving weather forecasts with text and audio in Google Cloud SQL PostgreSQL, supporting full internationalization, TTL-based caching, and automatic expiration management.

Category
Visit Server

README

Forecast Storage MCP Server

A Model Context Protocol (MCP) server for storing weather forecasts in Google Cloud SQL PostgreSQL.

Features

  • Binary storage for text and audio with unicode support
  • Full internationalization - supports all languages (English, Spanish, Chinese, Japanese, Arabic, etc.)
  • TTL-based caching with automatic expiration
  • Cloud SQL integration with secure connections
  • Storage statistics and per-city breakdown
  • Automatic encoding detection (utf-8, utf-16, utf-32)

Setup

1. Create Cloud SQL Instance

# Create PostgreSQL instance
gcloud sql instances create weather-forecasts \
  --database-version=POSTGRES_17 \
  --tier=db-f1-micro \
  --region=us-central1 \
  --enable-auto-scaling \
  --auto-scaling-min-cpu=1 \
  --auto-scaling-max-cpu=2

# Create database
gcloud sql databases create weather \
  --instance=weather-forecasts

# Set password for postgres user
gcloud sql users set-password postgres \
  --instance=weather-forecasts \
  --password=YOUR_SECURE_PASSWORD

2. Apply Database Schema

# Get the instance IP (or use Cloud SQL Proxy)
gcloud sql instances describe weather-forecasts --format="value(ipAddresses[0].ipAddress)"

# Apply schema
psql -h INSTANCE_IP -U postgres -d weather -f schema.sql

3. Configure Environment

# Copy example environment file
cp .env.example .env

# Edit .env with your values
# GCP_PROJECT_ID=your-project-id
# CLOUD_SQL_PASSWORD=your-secure-password

4. Install Dependencies

pip install -r requirements.txt

5. Run MCP Server

python server.py

MCP Tools

1. upload_forecast

Upload a complete forecast (text + audio) to Cloud SQL.

{
  "city": "chicago",
  "forecast_text": "Weather in Chicago: Sunny, 75°F",
  "audio_data": "<base64-encoded-wav-audio-data>",
  "forecast_at": "2025-12-26T15:00:00Z",
  "ttl_minutes": 30,
  "language": "en",
  "locale": "en-US"
}

Note: audio_data should be base64-encoded WAV audio data, not a file path. This allows the MCP server to work in remote/containerized environments.

2. get_cached_forecast

Retrieve cached forecast if available and not expired.

{
  "city": "chicago",
  "language": "en"
}

Returns:

  • cached: true/false
  • forecast_text: decoded unicode text
  • audio_data: base64-encoded audio
  • age_seconds: age of cached forecast

3. cleanup_expired_forecasts

Remove expired forecasts from database.

{}

4. get_storage_stats

Get database storage statistics.

{}

Returns:

  • Total forecasts
  • Storage sizes
  • Encodings used
  • Languages used
  • Per-city breakdown

5. list_forecasts

List forecast history.

{
  "city": "chicago",
  "limit": 10
}

6. test_connection

Test database connection.

{}

Integration with Weather Agent

The MCP server is designed to integrate with the weather agent system. See the main project README for integration details.

Database Schema

The forecasts table stores:

  • Binary text (BYTEA) with encoding metadata
  • Binary audio (BYTEA)
  • Unicode support (utf-8, utf-16, utf-32)
  • Internationalization (language, locale)
  • TTL management (forecast_at, expires_at)
  • Storage metadata (sizes, encoding, metadata JSONB)

Development

Testing Connection

# Run test connection
python -c "from tools.connection import test_connection; import json; print(json.dumps(test_connection(), indent=2))"

Running Tests

# Add tests in tests/ directory
pytest tests/

Troubleshooting

Connection Issues

  1. Verify Cloud SQL instance is running
  2. Check firewall rules allow connections
  3. Verify credentials in .env file
  4. Test with test_connection tool

Encoding Issues

  • Default encoding is utf-8 (works for most languages)
  • Use utf-16 for heavy CJK (Chinese/Japanese/Korean) text
  • Encoding is auto-detected if not specified

Cost Estimation

Development (db-f1-micro):

  • Instance: ~$7/month (with auto-pause: ~$3.50/month)
  • Storage (10GB): ~$1.70/month
  • Total: ~$5-9/month

Production (db-custom-2-7680):

  • Instance: ~$130/month (with auto-pause: ~$65/month)
  • Storage (50GB): ~$8.50/month
  • Total: ~$70-140/month

License

Part of the weather-lab project.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured