Skip to content

Active

AEMET MCP Server

A custom Model Context Protocol server that gives AI assistants access to AEMET, Spain's national weather service, running as a hosted service on AWS.

Read this in Español

Context

AEMET, Spain’s national meteorological agency, publishes its data through an open API. This project started as an experiment: build a Model Context Protocol server on top of that API so AI assistants can use it, and then run it as a real service.

What it does

The server exposes 36 tools through the Model Context Protocol: hourly and daily forecasts, real-time observations, severe weather alerts, climate data, maritime forecasts, radar and more. Any MCP client can connect to it.

You can try it from the GitHub repository, which leads to the landing page where you create an API key to access the service.

Architecture

The service runs on AWS and is defined with Terraform.

  • A static landing page on S3 and CloudFront handles registration.
  • An HTTP API in API Gateway has two routes. /register calls a Lambda function that issues a token and stores it in DynamoDB. /mcp goes through a VPC Link to the server, which runs on ECS Fargate behind bearer-token authentication.
  • The AEMET API key is injected into the container as a secret from SSM Parameter Store.
  • A scheduler starts and stops the service on a timetable, so it only runs when it is likely to be used.

Engineering decisions

I treated security as a core requirement of the server from the start. The main decisions:

  • Validate every input against an allowlist, and never return internal errors to the client.
  • Protect the outbound call: the server only fetches data from AEMET addresses and checks DNS resolution to prevent SSRF.
  • Limit abuse: rate limiting, truncated and size-limited responses, and throttling in API Gateway.
  • Handle tokens carefully: timing-safe comparison, tokens that expire, and logs with automatic secret redaction.
  • Keep the network closed: the container accepts traffic only from the VPC Link.
  • Test the security work: the project has an automated test suite dedicated to these controls.

The server is on GitHub. The infrastructure code is in a separate, private repository.

← All projects