Commit 497a0b5
authored
feat(core): Add recordInputs/recordOutputs options to MCP server wrapper (#18600)
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
```typescript
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
Closes #18603 (added automatically)1 parent 8d946bd commit 497a0b5
File tree
11 files changed
+386
-256
lines changed- packages/core
- src/integrations/mcp-server
- test/lib/integrations/mcp-server
11 files changed
+386
-256
lines changedLines changed: 16 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
17 | 25 | | |
18 | 26 | | |
19 | 27 | | |
20 | 28 | | |
| 29 | + | |
21 | 30 | | |
22 | 31 | | |
23 | 32 | | |
24 | 33 | | |
25 | 34 | | |
| 35 | + | |
26 | 36 | | |
27 | 37 | | |
28 | 38 | | |
| |||
45 | 55 | | |
46 | 56 | | |
47 | 57 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 58 | + | |
| 59 | + | |
52 | 60 | | |
53 | 61 | | |
54 | 62 | | |
| |||
95 | 103 | | |
96 | 104 | | |
97 | 105 | | |
| 106 | + | |
98 | 107 | | |
99 | 108 | | |
100 | 109 | | |
101 | 110 | | |
102 | 111 | | |
103 | 112 | | |
| 113 | + | |
104 | 114 | | |
105 | 115 | | |
106 | 116 | | |
| |||
109 | 119 | | |
110 | 120 | | |
111 | 121 | | |
112 | | - | |
| 122 | + | |
113 | 123 | | |
114 | 124 | | |
115 | 125 | | |
116 | | - | |
| 126 | + | |
117 | 127 | | |
118 | 128 | | |
119 | 129 | | |
| |||
Lines changed: 10 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
13 | | - | |
14 | 12 | | |
15 | 13 | | |
16 | | - | |
| 14 | + | |
17 | 15 | | |
18 | 16 | | |
19 | 17 | | |
| |||
57 | 55 | | |
58 | 56 | | |
59 | 57 | | |
| 58 | + | |
60 | 59 | | |
61 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
62 | 66 | | |
63 | 67 | | |
64 | 68 | | |
| |||
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
| 87 | + | |
92 | 88 | | |
93 | 89 | | |
94 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
4 | | - | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
29 | 37 | | |
30 | 38 | | |
31 | 39 | | |
32 | 40 | | |
33 | 41 | | |
| 42 | + | |
34 | 43 | | |
35 | 44 | | |
36 | | - | |
| 45 | + | |
37 | 46 | | |
38 | 47 | | |
39 | 48 | | |
| |||
43 | 52 | | |
44 | 53 | | |
45 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
46 | 62 | | |
47 | 63 | | |
48 | 64 | | |
| |||
52 | 68 | | |
53 | 69 | | |
54 | 70 | | |
55 | | - | |
56 | | - | |
| 71 | + | |
| 72 | + | |
57 | 73 | | |
58 | 74 | | |
59 | 75 | | |
| |||
Lines changed: 15 additions & 49 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 9 | + | |
20 | 10 | | |
21 | 11 | | |
22 | | - | |
| 12 | + | |
23 | 13 | | |
24 | 14 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 15 | + | |
34 | 16 | | |
35 | 17 | | |
36 | | - | |
| 18 | + | |
37 | 19 | | |
38 | 20 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
44 | 24 | | |
45 | 25 | | |
46 | | - | |
| 26 | + | |
47 | 27 | | |
48 | 28 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 29 | + | |
| 30 | + | |
65 | 31 | | |
66 | 32 | | |
67 | 33 | | |
68 | | - | |
| 34 | + | |
69 | 35 | | |
70 | 36 | | |
71 | 37 | | |
| |||
80 | 46 | | |
81 | 47 | | |
82 | 48 | | |
83 | | - | |
| 49 | + | |
84 | 50 | | |
85 | 51 | | |
86 | 52 | | |
| |||
0 commit comments