Skip to content

Implement request caching and rate limiting #71

@cablate

Description

@cablate

Overview

Every MCP tool call currently makes a live Google Maps API request. Adding a cache layer and rate limiting will reduce latency, lower API costs, and prevent quota exhaustion.

Proposed Work

Caching

  • Introduce an in-memory LRU cache (e.g., lru-cache) keyed on the serialized request parameters
  • Configurable TTL per tool (e.g., place details can be cached longer than nearby search)
  • Cache bypass via an optional noCache parameter or environment variable

Rate Limiting

  • Respect Google Maps API quotas (requests per second / per day)
  • Implement a simple token-bucket or sliding-window rate limiter
  • Return a graceful error message when the rate limit is reached rather than crashing

Configuration

  • Expose cache TTL and rate limit settings via environment variables with sensible defaults

Acceptance Criteria

  • Repeated identical requests within TTL are served from cache without a network call
  • Exceeding the configured rate limit returns a structured error to the MCP client
  • All settings have documented defaults in README

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions