Skip to content

DNS Resolution Error with Claude Code #179

Description

@daygon2007

Describe the bug:
When using the analytics-mcp server with Claude Code, all API calls fail with a DNS resolution error: Failed to resolve analyticsadmin.googleapis.com. This occurs regardless of network connectivity (DNS resolves fine in the shell).

Steps to Reproduce:

  1. Add analytics-mcp to Claude Code via claude mcp add
  2. Start a Claude Code session
  3. Ask Claude to call any analytics-mcp tool (e.g. get_account_summaries)
  4. Observe DNS resolution failure

Expected behavior:
Successfully retrieve Google Analytics account data

Root cause:
gRPC's c-ares DNS resolver (used by this package) fails to resolve Google API endpoints when spawned as a subprocess by Claude Code on macOS. This is a known gRPC/macOS compatibility issue.

Fix:
Add GRPC_DNS_RESOLVER=native to the MCP server environment config to force gRPC to use the system's native DNS resolver.

For Claude Code, add it to your ~/.claude.json MCP config:

"env": {
  "GOOGLE_APPLICATION_CREDENTIALS": "PATH_TO_CREDENTIALS",
  "GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID",
  "GRPC_DNS_RESOLVER": "native"
}

Or via CLI:

claude mcp add analytics-mcp \
  --scope user \
  -e "GOOGLE_APPLICATION_CREDENTIALS=PATH_TO_CREDENTIALS" \
  -e "GOOGLE_PROJECT_ID=YOUR_PROJECT_ID" \
  -e "GRPC_DNS_RESOLVER=native" \
  -- pipx run analytics-mcp

Environment:

  • macOS (Apple Silicon)
  • Python 3.12
  • Claude Code v2.1.175

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions