Skip to content

[MCP compact mode] Support fields parameter or response filtering for manageable output size #278

@chrisblattman

Description

@chrisblattman

Problem

When using gws mcp in compact mode (--tool-mode compact) with an AI assistant (Claude Code), the Gmail users.messages.get method returns the full raw API response — including all transport headers (DKIM signatures, ARC chains, SPF records, anti-spam metadata, X-Microsoft-Antispam-MessageData, etc.).

A single email that contains a 2-sentence body returns 50-120KB of JSON. When an AI assistant needs to triage 20+ emails, that's 1-2MB of raw data, most of which is irrelevant routing metadata. This makes compact mode impractical for the primary use case it seems designed for — AI tool use.

What I expected

A way to filter the response, equivalent to Gmail API's fields parameter. For example:

fields: "id,threadId,labelIds,snippet,payload/headers(name=From;Subject;Date),payload/parts/body"

Or even a simpler approach: a --slim flag or response profile that strips transport/security headers and returns only human-relevant fields (From, To, Subject, Date, body text, labels, snippet).

What I tried

  • format: "metadata" with metadataHeaders — doesn't return the specified headers in compact mode (known issue per README)
  • format: "minimal" — returns snippet and labels but no sender/subject, so it's not useful for triage
  • format: "full" — returns everything (50-120KB per message)

Environment

  • gws v0.7.0
  • macOS, compact MCP mode (gws mcp -s gmail,calendar --tool-mode compact)
  • AI client: Claude Code (Anthropic)

Suggested solutions (any of these would help)

  1. Pass through the Gmail API fields parameter in compact mode's params object
  2. Fix metadataHeaders in compact mode so format: "metadata" works as expected
  3. Add a response profile option (e.g., --response-profile slim) that strips transport headers and decodes base64 body content before returning
  4. Auto-decode base64 body parts — currently the email body comes back as base64-encoded strings in payload.parts[].body.data, requiring the AI client to decode them

Impact

Without filtering, compact mode generates responses that are 50-100x larger than what AI assistants need. This effectively blocks adoption for email-heavy workflows (triage, morning briefings, inbox management) which are among the most common AI assistant use cases for Gmail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions