Skip to content

wrapMcpServerWithSentry defaults recordInputs / recordOutputs to true (via dataCollection.genAI) | #24604

Closed as not planned

Description

@tiagovilasboas

Static review of public source at commit b633c8153250. No traffic was sent to any Sentry environment.

MCP server instrumentation resolves capture flags like this:

packages/core/src/integrations/mcp-server/transport.ts:

function resolveMcpOptions(options: McpServerWrapperOptions): ResolvedMcpOptions {
  // ...
  const genAI = getClient()?.getDataCollectionOptions().genAI;
  return {
    recordInputs: options.recordInputs ?? genAI?.inputs ?? true,
    recordOutputs: options.recordOutputs ?? genAI?.outputs ?? true,
  };
}

dataCollection.genAI itself documents { inputs: true, outputs: true } as the default. So a bare Sentry.wrapMcpServerWithSentry(server) will put tool/prompt arguments and results on spans (tokens, file paths, user content, etc.) unless the operator remembers to pass { recordInputs: false, recordOutputs: false } or tighten dataCollection.genAI.

That is great for AI debugging; it is a surprising default for MCP servers that often proxy secrets and private data.

Suggested change:

  • Default MCP wrapper capture to false / metadata-only unless recordInputs/recordOutputs or dataCollection.genAI is explicitly enabled; or
  • Keep genAI defaults but make wrapMcpServerWithSentry() document and prefer explicit { recordInputs, recordOutputs } with a one-time startup log when both resolve to true.
  • Mirror the scrubbing posture already used for network PII in piiFiltering.ts.

Severity: low–medium / privacy & data-minimization defense-in-depth (parallel to the Python SDK EventScrubber recursive default discussion). Not claiming a Sentry platform vulnerability. No proof-of-concept.

Happy to send a focused PR if useful.

Activity

  1. linear-code commented on Sep 22, 2026

    @linear-code
  2. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 22, 2026
  3. Lms24 commented on Sep 23, 2026

    @Lms24
    Member

    Hi @tiagovilasboas, I need some clarifications on this issue:

    • are you reporting a bug, or requesting that the default values of dataCollection get changed?
    • dataCollection defaulting to true for recording inputs and outputs is expected behaviour, see docs

    If your report is a bug, please provide a minimal reproduction, at least your SDK setup, used SDK and version. Also, please follow our bug template, because this issue looks completely AI-generated at the moment.

  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Sep 23, 2026
  5. moved this to Waiting for: Community in GitHub Issues with 👀 3on Sep 23, 2026
  6. tiagovilasboas commented on Sep 23, 2026

    @tiagovilasboas
    Author

    Hi @Lms24 — thanks for the clarification ask.

    This is not a bug report against current dataCollection behavior. I agree with the docs: when dataCollection is used, genAI recording inputs/outputs defaults to true unless you opt out (Data Collected — LLM Inputs And Responses).

    What I meant to file is an enhancement / secure-by-default request scoped to MCP instrumentation, not “dataCollection is broken.”

    Evidence still on current main in packages/core/src/integrations/mcp-server/transport.ts:

    function resolveMcpOptions(options: McpServerWrapperOptions): ResolvedMcpOptions {
      if (options.recordInputs !== undefined && options.recordOutputs !== undefined) {
        return {
          recordInputs: options.recordInputs,
          recordOutputs: options.recordOutputs,
        };
      }
    
      const genAI = getClient()?.getDataCollectionOptions().genAI;
    
      return {
        recordInputs: options.recordInputs ?? genAI?.inputs ?? true,
        recordOutputs: options.recordOutputs ?? genAI?.outputs ?? true,
      };
    }

    Two points that matter for MCP specifically:

    1. Even when the operator never sets dataCollection / genAI, the wrapper still falls through to ?? true, so a bare Sentry.wrapMcpServerWithSentry(server) records tool/prompt args and results.
    2. MCP payloads often carry secrets and private user content (tokens, file paths, messages), which is a harsher default surface than typical LLM chat spans — easy to miss if you only read the genAI docs in an AI-integration context.

    Concrete asks (any one is fine):

    1. Safer MCP-wrapper defaults (recordInputs / recordOutputs false unless explicitly set), or
    2. Keep the current resolution, but require/encourage explicit { recordInputs, recordOutputs } on the wrapper and/or a clear startup note when both resolve to true.

    No crash / incorrect-span reproduction — the concern is default posture for MCP. Happy to reframe/relabel as enhancement, or open a focused docs/PR if you’d rather keep the current defaults.

  7. moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 23, 2026
  8. Lms24 commented on Sep 23, 2026

    @Lms24
    Member

    I still don't know the version you're on. In v11 (which is the code currently on our main branch develop), dataCollection is used by default, and sendDefaultPii is removed. Hence, expected default behaviour is to record in- and outputs.

    I will ask the dataCollection experts in the team though, if there should be differences between genAI and MCP, but I'm fairly confident this is the intended behaviour.

    You can read more about the dataCollection changes in this blog post.

  9. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Sep 23, 2026
  10. self-assigned this
    on Sep 23, 2026
  11. mydea commented on Oct 23, 2026

    @mydea
    Member

    Thanks for raising this! Recording MCP inputs/outputs by default is intended under v11's dataCollection model. Since #25553 you can opt out for MCP specifically with dataCollection: { mcp: { inputs: false, outputs: false } }, or per server via wrapMcpServerWithSentry(server, { recordInputs: false, recordOutputs: false }). Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions