)]}'
{
  "commit": "6cfac8715ddeb0da27ff2e81bb35d629e5edfda0",
  "tree": "e63e4887bcd3de0913846c2882344ca40e982d4e",
  "parents": [
    "60e910fa28c87ed37f8b7719ac15228015df7f49"
  ],
  "author": {
    "name": "Yongjun Hong",
    "email": "yongjunh@apache.org",
    "time": "Sat Nov 28 02:56:47 2026 +0900"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Sat Nov 28 04:56:47 2026 +1100"
  },
  "message": "feat(tracking): serve an MCP endpoint from the Burr UI server (#1050)\n\n* feat(tracking): serve an MCP endpoint from the Burr UI server\n\nAdds /mcp to the tracking server so coding assistants and scripts can\ninspect tracked runs over the Model Context Protocol, using the same\nbackend as the REST API (apache/burr#1036).\n\n- inspect tools (default, read-only): list_projects, list_apps, get_app,\n  get_step, diff_state, key_history, export_test_case\n- annotate tools (opt-in): annotate_step, list_annotations\n- Small results by default (paged step lists, 2,000-character value\n  previews); max_chars\u003dNone returns full values.\n- BURR_MCP_ENABLED\u003dauto|true|false (auto serves /mcp when mcp\u003e\u003d2 is\n  installed), BURR_MCP_GROUPS, and BURR_MCP_MAX_CHARS, a server-side\n  ceiling on value size that callers cannot raise.\n- Stateless JSON transport; GET /mcp answers 405 with a hint instead of\n  an SSE stream that never ends. The SDK\u0027s DNS-rebinding protection\n  rejects non-localhost Host headers with 421.\n- The transport runs inside the UI app\u0027s lifespan and is recreated if\n  the app starts again.\n- _transform_state_to_test_case moves from burr.cli to burr.testing so\n  the server can use it without the CLI\u0027s dependencies.\n- New apache-burr[mcp] extra, installed in CI; docs in Tracking Burr.\n\nCo-Authored-By: Claude Opus 5.5 \u003cnoreply@anthropic.com\u003e\n\n* test(tracking): cover /mcp on a UI mounted with mount_burr_ui()\n\nNow that mount_burr_ui() runs the UI\u0027s lifespan (#1041), the MCP\ntransport starts there too. Add a test for it, and point the mount_mcp()\ndocstring at mount_burr_ui().\n\nCo-Authored-By: Claude Opus 5.5 \u003cnoreply@anthropic.com\u003e\n\n* feat(tracking): turn MCP off by default and drop its localhost-only Host check\n\nFollowing the maintainer decisions in #1036:\n\n- BURR_MCP_ENABLED now defaults to false, and auto is gone. true still\n  fails at startup when mcp\u003e\u003d2 is not installed.\n- /mcp answers any Host and Origin, like the REST API next to it. The\n  SDK\u0027s DNS-rebinding default answered only localhost (421 otherwise),\n  so an enabled endpoint did not work behind a hostname or proxy.\n\nCo-Authored-By: Claude Opus 5.5 \u003cnoreply@anthropic.com\u003e\n\n\n----\nImplements #1036.\n\nThis adds an MCP endpoint at /mcp on the Burr UI server, as sketched in the issue. Coding assistants and scripts can inspect tracked runs through the same BackendBase the REST API uses. It follows the maintainer decisions on #1036: the endpoint is off unless BURR_MCP_ENABLED\u003dtrue, only mcp 2.x is supported, and there is no MCP-specific auth or Host policy.\n\nChanges\nburr/tracking/server/mcp_endpoint.py (new) holds the tools and mount_mcp().\ninspect group (default, read-only): list_projects, list_apps, get_app, get_step, diff_state, key_history, export_test_case.\nannotate group (opt-in): annotate_step, list_annotations. On a backend without annotations (S3), the server logs a warning and skips them.\nResults are small by default. Step lists and key histories return the last 50 entries, and values over 2,000 characters come back as a preview plus their size. start/limit reach the rest, and max_chars\u003dNone returns full values.\nThe transport is stateless with JSON responses. It answers any Host and Origin, like the REST API, so the SDK\u0027s localhost-only DNS-rebinding default is turned off. GET /mcp returns a 405 with a hint instead of an SSE stream that never ends. The SDK\u0027s session manager can only run once, so the transport is recreated if the app\u0027s lifespan runs again.\nrun.py: create_burr_ui_app() calls _mount_mcp() before the React catch-all route. Three settings control it, and a bad value fails at startup:\nBURR_MCP_ENABLED\u003dtrue|false. false (default) doesn\u0027t serve /mcp. true serves it, and fails at startup if mcp\u003e\u003d2 isn\u0027t installed.\nBURR_MCP_GROUPS picks the tool groups.\nBURR_MCP_MAX_CHARS is a server-side ceiling on value size that callers can\u0027t raise, even with max_chars\u003dNone. It is unset by default. This was suggested in review on Add an MCP endpoint to the Burr UI server #1036.\n_transform_state_to_test_case moves from burr.cli.__main__ to burr.testing. That lets the server produce the burr-test-case fixture format without the CLI\u0027s dependencies. The CLI now imports it from there.\npyproject.toml gets a new mcp extra (tracking-server plus mcp\u003e\u003d2,\u003c3). The CI test job installs it so the new tests run.\nDocs: a new \"MCP endpoint\" section in docs/concepts/tracking.rst.\nHow I tested this\ntests/tracking/test_mcp_endpoint.py (new, 26 tests):\nEvery tool, called through the SDK\u0027s in-process client on runs tracked by a small Burr app, including a failed step.\nPaging, previews and full values, the server-side ceiling, tool groups, and annotations.\nOver HTTP with TestClient: tools/list, GET returns 405, a remote Host and Origin work as they do on the REST API, and the lifespan can run twice.\n/mcp on a UI mounted with mount_burr_ui(). This test fails without fix(tracking): run the Burr UI lifespan when it is mounted with mount_burr_ui() #1041.\nSettings validation, no /mcp and no warning when BURR_MCP_ENABLED is unset (with mcp 1.x, 2.x or none installed; the version is faked), and true failing without mcp\u003e\u003d2.\nThe full tests/ suite on this branch in Linux containers with mcp 2.3.0, excluding the persister integration and Bedrock tests: Python 3.12 had 814 passed and 1 skipped; Python 3.10 had 812 passed and 3 skipped.\nA real server started with burr (local backend, BURR_SERVE_STATIC\u003dfalse), called over HTTP with the MCP Python SDK client:\nCalled each tool on tracked runs. On a 1,500-step app, the default get_app returned 3,317 B, against 92,107 B for all steps.\nSaved an export_test_case result, loaded it with burr.testing, and ran it against the action.\nChecked that an annotation written through MCP shows up in /api/v0/{project}/annotations.\nBURR_MCP_MAX_CHARS\u003d300 capped values, BURR_MCP_ENABLED\u003dfalse gave a 404, and an unknown group failed at startup.\nAfter the default changed: with BURR_MCP_ENABLED unset, POST /mcp gave a 404. With true, tools/list returned the seven tools for both Host: localhost:7241 and Host: burr.example.com.\nClaude Code 2.1.311 as the client, running claude -p with only this server in --mcp-config. It connected over HTTP and listed the seven inspect tools. It then used list_projects, list_apps, get_app and key_history to answer two questions about tracked runs: which app\u0027s last step failed and with what error, and how a state key changed over another app\u0027s steps. Both answers were correct.\nblack, isort, flake8 (pre-commit versions) and the ASF header check on the changed files.\nNotes\nfix(tracking): validate identifiers and keep server paths inside the storage directory #948 adds ID validation to the tracking server and LocalBackend. As agreed on Add an MCP endpoint to the Burr UI server #1036, this PR doesn\u0027t check IDs itself, so until fix(tracking): validate identifiers and keep server paths inside the storage directory #948 lands, a .. in an ID reaches the local backend the same way it does through /api/v0 today.\nfix(tracking): run the Burr UI lifespan when it is mounted with mount_burr_ui() #1041 is merged, so /mcp also works when the UI is mounted with mount_burr_ui(). This PR is rebased on it and adds a test for that case.\nThe module is mcp_endpoint.py, not mcp.py as in the issue. Running python burr/tracking/server/run.py puts that directory first on sys.path, where a mcp.py would shadow the mcp package.\nWho can reach /mcp is up to the deployer, as with the rest of the UI server. If Burr later adds host protection, it should cover /api/v0 and /mcp together.\nClients tested: the MCP Python SDK client and Claude Code. I haven\u0027t tried Cursor. Backends tested: only the local one, not S3.\n\n---------\n\nCo-authored-by: Claude Opus 5.5 \u003cnoreply@anthropic.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "b2e26059e35606e1f2da78e8a582014e7a7a6482",
      "old_mode": 33188,
      "old_path": ".github/workflows/python-package.yml",
      "new_id": "bc81f4cd6c9f1f1f727d6e9247f64668109ecf97",
      "new_mode": 33188,
      "new_path": ".github/workflows/python-package.yml"
    },
    {
      "type": "modify",
      "old_id": "60675bb2cf78a89a7707db243b9c7904e4af8467",
      "old_mode": 33188,
      "old_path": "burr/cli/__main__.py",
      "new_id": "76e70b43fa2c7037853f0e3f3ca49271a3e3826f",
      "new_mode": 33188,
      "new_path": "burr/cli/__main__.py"
    },
    {
      "type": "modify",
      "old_id": "bd89af77f24ab9f7f08dd021d56da36dc4b366b4",
      "old_mode": 33188,
      "old_path": "burr/testing/__init__.py",
      "new_id": "9831a12751c8fcc743cfa2d352794873ee10ab10",
      "new_mode": 33188,
      "new_path": "burr/testing/__init__.py"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "3e952135f7e1fdf2b9b32788bbe7a86e03ce25e7",
      "new_mode": 33188,
      "new_path": "burr/tracking/server/mcp_endpoint.py"
    },
    {
      "type": "modify",
      "old_id": "cbdee7ad69e5478ad2da174f7a7b1588614f14b9",
      "old_mode": 33188,
      "old_path": "burr/tracking/server/run.py",
      "new_id": "a7803134841e64f31e77dc24497adf2379b22210",
      "new_mode": 33188,
      "new_path": "burr/tracking/server/run.py"
    },
    {
      "type": "modify",
      "old_id": "f3eafaed7c4aaa52598288faf4805f25ebddafd3",
      "old_mode": 33188,
      "old_path": "docs/concepts/tracking.rst",
      "new_id": "fa8979a3478aeb9fac42f08016b2a5224fdee606",
      "new_mode": 33188,
      "new_path": "docs/concepts/tracking.rst"
    },
    {
      "type": "modify",
      "old_id": "a429b3be06cc6c879af1de248e1d8578ba3e4313",
      "old_mode": 33188,
      "old_path": "pyproject.toml",
      "new_id": "ec53e91faf66872313b7ae6da16e0d3053daa2c1",
      "new_mode": 33188,
      "new_path": "pyproject.toml"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "a7347979ac4d5841f2840d7d03ed3f471f246d58",
      "new_mode": 33188,
      "new_path": "tests/tracking/test_mcp_endpoint.py"
    }
  ]
}
