Skip to content

feat(core): Add recordInputs/recordOutputs options to MCP server wrapper #18603

@github-actions

Description

@github-actions

Note

The pull request "feat(core): Add recordInputs/recordOutputs options to MCP server wrapper" was created by @betegon but did not reference an issue. Therefore this issue was created for better visibility in external tools like Linear.

Adds granular control over capturing tool/prompt inputs and outputs in MCP server instrumentation.

NOT a breaking change: both options default to sendDefaultPii, so existing behavior is preserved.

Motivation

Previously, capturing MCP tool/prompt inputs and outputs required enabling sendDefaultPii: true, which also enables capturing IP addresses, user data, and other sensitive information.

Bbut MCP inputs/outputs are important and user will want to record them, so it shouldn't require exposing all PII. This change decouples input/output capture from the broader PII setting, giving users granular control:

  • Want inputs/outputs for debugging but not IP addresses? → recordInputs: true + sendDefaultPii: false
  • Want full PII including network info? → sendDefaultPii: true (same as before)

New Options for wrapMcpServerWithSentry

  • recordInputs: Controls whether tool/prompt input arguments are captured in spans
  • recordOutputs: Controls whether tool/prompt output results are captured in spans

Usage

const mcpServer = new McpServer({name: "my-server"})

// Default: inherits from sendDefaultPii
const server = wrapMcpServerWithSentry(mcpServer);

// Explicit control
const server = wrapMcpServerWithSentry(
  mcpServer,
  { recordInputs: true, recordOutputs: false }
);

PII Simplification

  • piiFiltering.ts now only handles network PII (client.address, client.port, mcp.resource.uri)
  • Input/output capture is controlled at the source via recordInputs/recordOutputs rather than filtering after capture

Files Changed

  • types.ts - Added McpServerWrapperOptions type
  • index.ts - Added options parameter with sendDefaultPii defaults
  • attributeExtraction.ts - Conditional input argument capture
  • spans.ts - Threading recordInputs through span creation
  • transport.ts - Passing options to transport wrappers
  • correlation.ts - Conditional output result capture
  • piiFiltering.ts - Simplified to network PII only
  • Tests updated accordingly

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions