MCP Wrapper Latency Optimization

Context

The WayCup Google Workspace MCP server requires a Service Account key stored in 1Password. Using the op read CLI tool on every startup adds 1-2 seconds of latency, which slows down every Gemini CLI invocation.

Solution: 24h Token Caching

Modified ~/.gemini/mcp-wrapper.sh to include a local caching layer:

  1. Cache Location: ~/.gemini/.ignored_mcp_token
  2. Logic:
    • Checks if the cache file exists and is less than 86,400 seconds (24 hours) old.
    • If valid, it reads the JSON directly into GOOGLE_APPLICATION_CREDENTIALS_JSON.
    • If invalid/missing, it executes op read, updates the cache, and sets file permissions to 600 (user read/write only).

Benefits

  • Speed: Instant CLI startup.
  • Security: Key is still stored securely in 1Password and only cached locally with strict permissions for 24h.
  • Stability: Prevents startup failures if 1Password is temporarily inaccessible.