baton-proxy 0.7.2__tar.gz → 0.7.3__tar.gz

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.
Files changed (60) hide show
  1. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/CHANGELOG.md +8 -0
  2. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/PKG-INFO +23 -2
  3. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/README.md +22 -1
  4. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/pyproject.toml +1 -0
  5. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/src/baton_proxy/__init__.py +1 -1
  6. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/src/baton_proxy/_llm_text.py +4 -5
  7. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/src/baton_proxy/emitter.py +3 -8
  8. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/src/baton_proxy/mcp_error.py +1 -1
  9. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/src/baton_proxy/proxy.py +9 -0
  10. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/src/baton_proxy/sinks.py +10 -0
  11. baton_proxy-0.7.3/src/baton_proxy/wrap.py +558 -0
  12. baton_proxy-0.7.3/tests/test_wrap_cmd.py +584 -0
  13. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/try/kit.py +1 -1
  14. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/.claude/settings.json +0 -0
  15. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/.github/workflows/release.yml +0 -0
  16. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/.github/workflows/test.yml +0 -0
  17. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/.gitignore +0 -0
  18. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/.gitmodules +0 -0
  19. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/CLAUDE.md +0 -0
  20. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/LICENSE +0 -0
  21. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/Makefile +0 -0
  22. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/SECURITY.md +0 -0
  23. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/examples/live-claude-invocation/instructions.md +0 -0
  24. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/examples/live-claude-invocation/result.md +0 -0
  25. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/examples/live-claude-invocation/setup.sh +0 -0
  26. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/examples/live-claude-invocation/unregister.sh +0 -0
  27. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/src/baton_proxy/__main__.py +0 -0
  28. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/src/baton_proxy/config.py +0 -0
  29. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/src/baton_proxy/identity.py +0 -0
  30. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/src/baton_proxy/scrub.py +0 -0
  31. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/src/baton_proxy/transport_http.py +0 -0
  32. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/__init__.py +0 -0
  33. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/fixture_http_server.py +0 -0
  34. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/fixture_responses.py +0 -0
  35. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/fixture_server.py +0 -0
  36. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_a1_emit_e2e.py +0 -0
  37. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_a1_proxy.py +0 -0
  38. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_config.py +0 -0
  39. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_emitter.py +0 -0
  40. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_http_bridge.py +0 -0
  41. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_identity.py +0 -0
  42. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_injection.py +0 -0
  43. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_intent_param.py +0 -0
  44. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_iserror_reclassification.py +0 -0
  45. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_llm_text.py +0 -0
  46. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_pending_eviction.py +0 -0
  47. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_proxy_env.py +0 -0
  48. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_residency_sinks.py +0 -0
  49. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_scrub.py +0 -0
  50. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_sinks.py +0 -0
  51. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_spec_conformance.py +0 -0
  52. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_surface_snapshot.py +0 -0
  53. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_tool_list_events.py +0 -0
  54. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_tooling.py +0 -0
  55. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/tests/test_try_kit.py +0 -0
  56. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/try/.gitignore +0 -0
  57. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/try/CLAUDE.md +0 -0
  58. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/try/PROMPT.md +0 -0
  59. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/try/SECURITY.md +0 -0
  60. {baton_proxy-0.7.2 → baton_proxy-0.7.3}/uv.lock +0 -0
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/).
7
7
 
8
+ ## [0.7.3] — 2026-11-09
9
+
10
+ ### Added
11
+
12
+ - **`baton-proxy wrap <name>` and `baton-proxy unwrap <name>`.** They rewrite one entry in Claude Desktop's config, or in `~/.claude.json` with `--client code`, so you do not edit the JSON by hand. A stdio entry is wrapped as `-- <command>`, and an http entry with a bearer token goes through `--url`. An http entry with no credential, or a new server given with `--url`, runs through `npx -y mcp-remote`, which does the OAuth sign-in in a browser and keeps the token. The original entry is saved, and `unwrap` puts it back exactly.
13
+ - **`wrap --dsn`** takes the DSN from the Console's Settings page and writes the address, the key, the workspace id, the server id and the consent token from it. It is the only way `wrap` sends events to a Console; without it, events stay on this machine.
14
+ - **`baton-proxy wrap-entry`** turns one server entry, read as JSON on stdin, into its wrapped form and prints it. It edits no file, so it works for any client: you or your agent write the result into that client's config. It takes `--url` for a new remote server and `--dsn` for the Console, and refuses what `wrap` refuses.
15
+
8
16
  ## [0.7.2] — 2026-11-01
9
17
 
10
18
  ### Changed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: baton-proxy
3
- Version: 0.7.2
3
+ Version: 0.7.3
4
4
  Summary: MCP proxy that wraps a stdio server or bridges to a remote one, injects an annotation tool, and emits friction events.
5
5
  Author: Good Timing, Inc.
6
6
  License: Apache License
@@ -281,6 +281,27 @@ The token goes in the entry's `env`, not your shell: the MCP client starts the p
281
281
 
282
282
  Either form is started by your MCP client, not by you: the proxy speaks JSON-RPC on stdin, so running it straight from a shell just waits for input.
283
283
 
284
+ ### Or let the proxy edit the config
285
+
286
+ ```sh
287
+ baton-proxy wrap my-server # an entry already in Claude Desktop's config
288
+ baton-proxy wrap linear --url https://mcp.linear.app/mcp # a new server that signs in with OAuth
289
+ baton-proxy wrap my-server --client code # ~/.claude.json; close Claude Code first
290
+ baton-proxy wrap my-server --dsn 'https://baton_pk_…' # send events to the Console
291
+ baton-proxy unwrap my-server # put the original entry back
292
+ ```
293
+
294
+ Any other client (Cursor, VS Code, Windsurf, Codex and so on): `wrap-entry` reads one server entry as JSON on stdin and prints the wrapped entry, and edits no file. Write the result into that client's own config yourself, or let your agent do it, and keep the original to undo:
295
+
296
+ ```sh
297
+ echo '{"command": "npx", "args": ["-y", "@vendor/server"]}' | baton-proxy wrap-entry --dsn '<dsn>'
298
+ baton-proxy wrap-entry --url https://mcp.linear.app/mcp --dsn '<dsn>' < /dev/null # a new remote server
299
+ ```
300
+
301
+ The printed entry holds the DSN's key and any bearer token in full, because it is what goes into the config.
302
+
303
+ `wrap` writes absolute paths, because Claude Desktop starts servers with a short `PATH`. A server that signs in with OAuth runs through `npx -y mcp-remote`, which opens a browser on first start and keeps the token itself, so Node.js must be installed. A connector added in the Claude app is not in any config file: `--url` adds a separate local entry, so turn the app's connector off. To send events to a Console, add a server on its Settings page and pass its DSN: `--dsn 'https://baton_pk_…@baton.goodtiming.ai/ten_…/<server>'`. The DSN carries the address, the key and both ids. Without `--dsn`, events stay on this machine. `--dry-run` shows the entry first.
304
+
284
305
  ## Where events go
285
306
 
286
307
  `BATON_EVENT_SINK` takes a comma-separated list, and the URL scheme picks the sink: `stderr:` writes JSON Lines to stderr, `file:///tmp/events.jsonl` appends one JSON object per event, and `https://collector.example.com` POSTs to `{url}/v0/events`. The default is `stderr:,file:///tmp/baton-proxy.jsonl`, so a bare install writes only to your own machine.
@@ -308,7 +329,7 @@ A misconfigured sink fails loudly at startup rather than silently dropping event
308
329
  | | |
309
330
  |---|---|
310
331
  | [goodtiming.ai/docs.html#proxy](https://goodtiming.ai/docs.html#proxy) | The docs: configuration, what it captures, the intent parameters, the Console |
311
- | [`docs/SPEC.md`](https://github.com/good-timing/baton/blob/main/docs/SPEC.md) | The wire protocol, in the `baton` repo. The contract a collector consumes |
332
+ | [`SPEC.md`](https://github.com/good-timing/baton-spec/blob/main/SPEC.md) | The wire protocol, in the `baton-spec` repo. The contract a collector consumes |
312
333
  | [baton-sdk](https://pypi.org/project/baton-sdk/) | The in-process alternative: capture from inside a server you own, with no proxy hop |
313
334
  | [`CHANGELOG.md`](https://github.com/good-timing/baton-proxy/blob/main/CHANGELOG.md) | What has shipped |
314
335
 
@@ -60,6 +60,27 @@ The token goes in the entry's `env`, not your shell: the MCP client starts the p
60
60
 
61
61
  Either form is started by your MCP client, not by you: the proxy speaks JSON-RPC on stdin, so running it straight from a shell just waits for input.
62
62
 
63
+ ### Or let the proxy edit the config
64
+
65
+ ```sh
66
+ baton-proxy wrap my-server # an entry already in Claude Desktop's config
67
+ baton-proxy wrap linear --url https://mcp.linear.app/mcp # a new server that signs in with OAuth
68
+ baton-proxy wrap my-server --client code # ~/.claude.json; close Claude Code first
69
+ baton-proxy wrap my-server --dsn 'https://baton_pk_…' # send events to the Console
70
+ baton-proxy unwrap my-server # put the original entry back
71
+ ```
72
+
73
+ Any other client (Cursor, VS Code, Windsurf, Codex and so on): `wrap-entry` reads one server entry as JSON on stdin and prints the wrapped entry, and edits no file. Write the result into that client's own config yourself, or let your agent do it, and keep the original to undo:
74
+
75
+ ```sh
76
+ echo '{"command": "npx", "args": ["-y", "@vendor/server"]}' | baton-proxy wrap-entry --dsn '<dsn>'
77
+ baton-proxy wrap-entry --url https://mcp.linear.app/mcp --dsn '<dsn>' < /dev/null # a new remote server
78
+ ```
79
+
80
+ The printed entry holds the DSN's key and any bearer token in full, because it is what goes into the config.
81
+
82
+ `wrap` writes absolute paths, because Claude Desktop starts servers with a short `PATH`. A server that signs in with OAuth runs through `npx -y mcp-remote`, which opens a browser on first start and keeps the token itself, so Node.js must be installed. A connector added in the Claude app is not in any config file: `--url` adds a separate local entry, so turn the app's connector off. To send events to a Console, add a server on its Settings page and pass its DSN: `--dsn 'https://baton_pk_…@baton.goodtiming.ai/ten_…/<server>'`. The DSN carries the address, the key and both ids. Without `--dsn`, events stay on this machine. `--dry-run` shows the entry first.
83
+
63
84
  ## Where events go
64
85
 
65
86
  `BATON_EVENT_SINK` takes a comma-separated list, and the URL scheme picks the sink: `stderr:` writes JSON Lines to stderr, `file:///tmp/events.jsonl` appends one JSON object per event, and `https://collector.example.com` POSTs to `{url}/v0/events`. The default is `stderr:,file:///tmp/baton-proxy.jsonl`, so a bare install writes only to your own machine.
@@ -87,7 +108,7 @@ A misconfigured sink fails loudly at startup rather than silently dropping event
87
108
  | | |
88
109
  |---|---|
89
110
  | [goodtiming.ai/docs.html#proxy](https://goodtiming.ai/docs.html#proxy) | The docs: configuration, what it captures, the intent parameters, the Console |
90
- | [`docs/SPEC.md`](https://github.com/good-timing/baton/blob/main/docs/SPEC.md) | The wire protocol, in the `baton` repo. The contract a collector consumes |
111
+ | [`SPEC.md`](https://github.com/good-timing/baton-spec/blob/main/SPEC.md) | The wire protocol, in the `baton-spec` repo. The contract a collector consumes |
91
112
  | [baton-sdk](https://pypi.org/project/baton-sdk/) | The in-process alternative: capture from inside a server you own, with no proxy hop |
92
113
  | [`CHANGELOG.md`](https://github.com/good-timing/baton-proxy/blob/main/CHANGELOG.md) | What has shipped |
93
114
 
@@ -56,6 +56,7 @@ ignore = ["E501"]
56
56
  # printed entry and the receipt are what a reviewer checks). T20 (no-print)
57
57
  # guards library code, which this is not.
58
58
  "try/kit.py" = ["T201"]
59
+ "src/baton_proxy/wrap.py" = ["T201"]
59
60
 
60
61
  [tool.pytest.ini_options]
61
62
  testpaths = ["tests"]
@@ -7,7 +7,7 @@ handshake, and emits friction events to a collector.
7
7
  See README.md for usage.
8
8
  """
9
9
 
10
- __version__ = "0.7.2"
10
+ __version__ = "0.7.3"
11
11
 
12
12
  # The product/version token, single-sourced here so the emitter's `sdk_version`
13
13
  # field and the HTTP bridge's outbound `User-Agent` header can never drift.
@@ -27,7 +27,7 @@ _REPORT_POINTER = (
27
27
  "wrong, or a request no tool covers; its description says when and how."
28
28
  )
29
29
 
30
- # The Console splits user_goal on "; success is" (SPEC §11.5.1 rule 2).
30
+ # The format SPEC §5.1.1 gives for user_goal.
31
31
  _USER_GOAL_FORMAT = "'<n>: <what this call is for>; success is <what its result should show>'"
32
32
 
33
33
  # Keep the key list: without it, agents leave context empty.
@@ -210,10 +210,9 @@ RETIRED_PARAM_NAMES = (EXPECTED_RESULT_PARAM_NAME, OVERALL_TASK_PARAM_NAME)
210
210
  # pins its own copy in its own suite (this suite ships in the Try Kit, where a
211
211
  # clone has no siblings to read), so change all three together.
212
212
  #
213
- # The leading number says which user message the call answers, and the
214
- # Console cuts a turn where it changes (SPEC §11.5.1 rule 2). Only the leading
215
- # label tracks ``intent_param_mode``, so it agrees with the schema's ``required``
216
- # list.
213
+ # The leading number says which user message the call answers (SPEC §5.1.1).
214
+ # Only the leading label tracks ``intent_param_mode``, so it agrees with the
215
+ # schema's ``required`` list.
217
216
  #
218
217
  # Do not reword without scoring the result on live agents.
219
218
  _USER_GOAL_PARAM_BODY = (
@@ -42,7 +42,7 @@ from baton_proxy.identity import (
42
42
  Principal,
43
43
  )
44
44
  from baton_proxy.scrub import Scrubber
45
- from baton_proxy.sinks import Sink, make_sink
45
+ from baton_proxy.sinks import Sink, is_remote_spec, make_sink
46
46
 
47
47
  logger = logging.getLogger(__name__)
48
48
 
@@ -336,10 +336,7 @@ class Emitter:
336
336
  """
337
337
  if not self._config.using_placeholder_consent:
338
338
  return
339
- assert self._config.event_sink is not None
340
- # Any sink that leaves the machine is "remote" — http(s) and s3.
341
- parts = [p.strip() for p in self._config.event_sink.split(",") if p.strip()]
342
- if any(p.startswith(("http://", "https://", "s3://")) for p in parts):
339
+ if is_remote_spec(self._config.event_sink):
343
340
  raise ValueError(
344
341
  "Refusing to ship events to a remote sink (http/https/s3) with "
345
342
  "placeholder BATON_CONSENT_TOKEN='local' — set BATON_CONSENT_TOKEN "
@@ -361,9 +358,7 @@ class Emitter:
361
358
  """
362
359
  if not self._config.using_placeholder_vendor:
363
360
  return
364
- assert self._config.event_sink is not None
365
- parts = [p.strip() for p in self._config.event_sink.split(",") if p.strip()]
366
- if any(p.startswith(("http://", "https://", "s3://")) for p in parts):
361
+ if is_remote_spec(self._config.event_sink):
367
362
  raise ValueError(
368
363
  "Refusing to ship events to a remote sink (http/https/s3) with "
369
364
  "the placeholder BATON_VENDOR_ID='local' — set BATON_VENDOR_ID "
@@ -4,7 +4,7 @@
4
4
  JSON-RPC response whose ``CallToolResult`` body sets the error flag; a JSON-RPC
5
5
  ``error`` member means a protocol fault, not a tool failure. A producer that
6
6
  classifies on the ``error`` member alone files tool failures as successes.
7
- SPEC §6.1 and §11.4.3 (``baton/docs/SPEC.md``) carry the rule.
7
+ SPEC §6.1 and §11.4.3 (``baton-spec/SPEC.md``) carry the rule.
8
8
 
9
9
  ⚠ **One spelling here, and it is ``isError``.** SPEC §11.4.3's producer rule
10
10
  asks an *in-process* sensor to duck-type both ``is_error`` and ``isError``,
@@ -1668,6 +1668,10 @@ def _run_http_loop(processor: MessageProcessor, client: Any, injection: _Injecti
1668
1668
 
1669
1669
  def main(argv: list[str] | None = None) -> int:
1670
1670
  argv = list(sys.argv[1:] if argv is None else argv)
1671
+ if argv and argv[0] in ("wrap", "unwrap", "wrap-entry"):
1672
+ from baton_proxy.wrap import cli
1673
+
1674
+ return cli(argv)
1671
1675
 
1672
1676
  parser = argparse.ArgumentParser(
1673
1677
  prog="baton-proxy",
@@ -1676,6 +1680,11 @@ def main(argv: list[str] | None = None) -> int:
1676
1680
  "HTTPS Streamable-HTTP MCP server (--url), injects an annotation "
1677
1681
  "tool into the handshake, and emits friction events to a collector."
1678
1682
  ),
1683
+ epilog=(
1684
+ "To edit a client config for you: `baton-proxy wrap <name>` and "
1685
+ "`baton-proxy unwrap <name>` (see `baton-proxy wrap -h`). For any other "
1686
+ "client, `baton-proxy wrap-entry` wraps one entry and edits no file."
1687
+ ),
1679
1688
  )
1680
1689
  parser.add_argument(
1681
1690
  "--url",
@@ -270,6 +270,16 @@ def _split_spec(url_spec: str | None) -> list[str]:
270
270
  return [p.strip() for p in url_spec.split(",") if p.strip()]
271
271
 
272
272
 
273
+ def spec_schemes(url_spec: str | None) -> list[str]:
274
+ """The scheme of each leg, as ``_make_one`` reads it (urlparse lowercases it)."""
275
+ return [urllib.parse.urlparse(p).scheme for p in _split_spec(url_spec)]
276
+
277
+
278
+ def is_remote_spec(url_spec: str | None) -> bool:
279
+ """True when any leg of the spec sends events off the machine (http, https, s3)."""
280
+ return any(s in ("http", "https", "s3") for s in spec_schemes(url_spec))
281
+
282
+
273
283
  def find_file_sink_path(event_sink_url: str | None) -> str | None:
274
284
  """Return the first ``file://`` path in a (possibly comma-separated) sink
275
285
  URL spec, or None if no file sink is present.