@goodtiming/baton-sdk 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -47,9 +47,89 @@ Sending to your own collector instead, or trying the package before you have a k
47
47
 
48
48
  **It is pattern matching, not a guarantee.** `{"name": "Jane Doe"}` passes through untouched. Decide what your server puts in tool params and results on that basis. [What it does and does not catch](https://goodtiming.ai/docs.html#pii).
49
49
 
50
- ## Turning capture off
50
+ **The scrubber is not the only lever.** If some tool results cannot be recorded at all, `resultCaptureMode` below withholds them outright rather than transforming them.
51
51
 
52
- `BATON_DISABLED=1` in the environment of the process running the server, and the SDK installs nothing at all. The switch belongs to whoever RUNS the server. [The long version](https://goodtiming.ai/docs.html#off-switch).
52
+ ## Not capturing responses at all
53
+
54
+ `resultCaptureMode: "off"` and nothing **derived from what your tool returns** leaves your process — not the result, and not the reason text on a failure your handler returns rather than throws. Requests are unaffected: `params` are captured either way.
55
+
56
+ ```ts
57
+ withBaton(server, { dsn, resultCaptureMode: "off" });
58
+ ```
59
+
60
+ Each affected event says so, in its own field (`result_capture: "off"`), rather than leaving a reader to guess from what is missing. That is the difference between the two levers: a scrubber TRANSFORMS a value that still crosses the network, this DECLARES that nothing crosses.
61
+
62
+ **What is still captured, and it is deliberate:** the tool name, the duration, and whether the call failed — so failure detection, pairing and timing all keep working. Also the message of an error your handler **throws**, which is your own code speaking about a call that never returned, and the most useful diagnostic the product has. ⚠ Thrown messages are a classic leak channel — a failed query echoed back, a record id in the message. If that is also a problem for you, say so and we will add a stricter setting.
63
+
64
+ **What it costs you:** anything that needs to read a response body. A call that returns `200` with a useless body can no longer be detected, and those calls sit outside the denominator of body-level analysis rather than counting as passes or failures.
65
+
66
+ ## Failures your handler never saw
67
+
68
+ A wrapper around your tool executor only sees calls that reach it. Three kinds
69
+ never do — the MCP SDK rejects them above your handler — and a fourth used to be
70
+ recorded as a success:
71
+
72
+ | what happened | what you get |
73
+ |---|---|
74
+ | no tool by that name | `tool_call_error`, `failure_kind: "unknown_tool"` |
75
+ | the tool exists and you disabled it | `tool_call_error`, `failure_kind: "tool_disabled"` |
76
+ | the arguments failed your schema | `tool_call_error`, `failure_kind: "invalid_argument"` |
77
+ | your output schema rejected what the tool returned | `tool_call_error`, `failure_kind: "output_schema_mismatch"` |
78
+
79
+ The first three emitted **nothing at all** before `0.5.0`, and the fourth emitted
80
+ `tool_call_end` — a success, for a call your caller saw fail. `failure_kind` names
81
+ which one it was, so nothing downstream has to pattern-match the message.
82
+
83
+ ⚠ **A tool declaring `execution.taskSupport` gets a `tool_call_error` with NO
84
+ `failure_kind`, and the failures it can hit are not in that table.** On 1.x a
85
+ tool declaring `"required"` or `"optional"` is rejected before argument
86
+ validation if it was not registered as a task tool, and a `"required"` one is
87
+ rejected when called without task augmentation; an `"optional"` task tool called
88
+ without one goes to automatic polling instead, which is not a failure at all.
89
+ This package omits the member for either declared value rather than guessing,
90
+ because it cannot distinguish those rejections from a rejected argument without
91
+ mislabelling every ordinary tool on that peer — 1.x stamps `taskSupport` on all
92
+ of them. The event still carries the SDK's own message. A consumer reading
93
+ `failure_kind` must handle its absence, which SPEC §11.4.3 requires anyway.
94
+
95
+ **Why a separate field and not `error_type`.** `error_type` reports the SHAPE the
96
+ SDK handed us, and the two MCP majors disagree about it for the same failure: 1.x
97
+ converts an unknown tool into a returned error flag (`"tool_error"`), v2 throws
98
+ (`"ProtocolError"`). Both are accurate about what happened at the protocol level,
99
+ and neither tells you a tool was missing. `failure_kind` is the same on both.
100
+
101
+ **`failure_kind` survives `resultCaptureMode: "off"`.** It is this package's
102
+ judgement about the shape of a failure, not anything derived from what your tool
103
+ returned — so for the first three the SDK's own message is kept too, and for the
104
+ fourth the message is withheld and the named kind is the only signal left.
105
+
106
+ ## Resources and prompts
107
+
108
+ `registerResource` and `registerPrompt` are instrumented as well as tools, at the
109
+ request level: `resources/list`, `resources/read`, `prompts/list` and
110
+ `prompts/get` each emit a start and then an end or an error — twelve event types.
111
+
112
+ **No SUCCESSFUL read or get captures a body.** Not a read's content, not a
113
+ prompt's rendered messages. A resource URI and a prompt name ARE captured, and
114
+ both go through the scrubber whole — they are text your caller supplied, so they
115
+ can carry paths, query strings and account identifiers.
116
+
117
+ ⚠ **A FAILING one captures the message your code threw, and
118
+ `resultCaptureMode: "off"` does not withhold it.** These twelve events never
119
+ carry the `result_capture` marker — the rule is that nothing on them is derived
120
+ from a result — so a failing read's `error_body` is kept in both modes and the
121
+ wire says nothing either way. That is the same leak channel as a thrown tool
122
+ error above, with one difference worth your attention: for a tool the marker
123
+ tells a consumer what happened, and here there is no marker. If your read fails
124
+ with `could not parse ${body.slice(0, 200)}`, that content leaves your process
125
+ under a mode you set to stop exactly that. Throw a message that names the
126
+ resource, not its contents.
127
+
128
+ ## Turning capture off entirely
129
+
130
+ Not the same thing as **Not capturing responses at all**: that one keeps the signal and drops the response bodies, this one emits nothing at all. It also belongs to a different person — `resultCaptureMode` is set by whoever WRAPS the server, in code; this is set by whoever RUNS it, in the environment.
131
+
132
+ `BATON_DISABLED=1` in the environment of the process running the server, and the SDK installs nothing at all. [The long version](https://goodtiming.ai/docs.html#off-switch).
53
133
 
54
134
  Checking it worked: `handle.sink` is still an object, so finding one there is not a sign the switch failed. It is the sink you passed if you passed one, and a `DisabledSink` otherwise. Either way nothing writes to it, because nothing is wrapped.
55
135
 
@@ -59,7 +139,7 @@ None of it blocks the quickstart above.
59
139
 
60
140
  - Only `StdoutSink` and `HttpSink`. `FileSink` and `MultiSink` are deferred; the Python package has all four.
61
141
  - Only the high-level `McpServer`. The low-level `Server` is not wrapped.
62
- - **Task-based tools are not wrapped, and are not left alone either.** A 1.x tool registered with an object at `.handler` rather than a function produces no `tool_call_*` events at all, and nothing reports that. It still gets the intent parameters added to its advertised schema, because injection runs before the wrap is skipped and the strip only happens inside the wrapper. So `user_goal`, `expected_result` and `overall_task` can arrive in your own handler's arguments. Tools on the same server registered the ordinary way are unaffected.
142
+ - **Task-based tools are not wrapped, and are not left alone either.** A 1.x tool registered with an object at `.handler` rather than a function produces no `tool_call_*` events at all, and nothing reports that. It still gets the intent parameters added to its advertised schema, because injection runs before the wrap is skipped and the strip only happens inside the wrapper. So `user_goal`, `expected_result` and `overall_task` can arrive in your own handler's arguments. Tools on the same server registered the ordinary way are unaffected. ⚠ **The request-level seam above does not rescue this one**: it reports only on tools this package wrapped, so a task-based tool emits nothing even for a rejected argument, where an unknown tool now emits a `tool_call_error`.
63
143
  - Intent parameters need a Zod schema. On the 2.x SDK a tool registered with a non-Zod standard schema is still wrapped and still emits `tool_call_*`; it just advertises no intent parameters.
64
144
  - The per-request `createMcpHandler` deployment shape is unscoped.
65
145