feat(tracking): serve an MCP endpoint from the Burr UI server (#1050)

* feat(tracking): serve an MCP endpoint from the Burr UI server

Adds /mcp to the tracking server so coding assistants and scripts can
inspect tracked runs over the Model Context Protocol, using the same
backend as the REST API (apache/burr#1036).

- inspect tools (default, read-only): list_projects, list_apps, get_app,
  get_step, diff_state, key_history, export_test_case
- annotate tools (opt-in): annotate_step, list_annotations
- Small results by default (paged step lists, 2,000-character value
  previews); max_chars=None returns full values.
- BURR_MCP_ENABLED=auto|true|false (auto serves /mcp when mcp>=2 is
  installed), BURR_MCP_GROUPS, and BURR_MCP_MAX_CHARS, a server-side
  ceiling on value size that callers cannot raise.
- Stateless JSON transport; GET /mcp answers 405 with a hint instead of
  an SSE stream that never ends. The SDK's DNS-rebinding protection
  rejects non-localhost Host headers with 421.
- The transport runs inside the UI app's lifespan and is recreated if
  the app starts again.
- _transform_state_to_test_case moves from burr.cli to burr.testing so
  the server can use it without the CLI's dependencies.
- New apache-burr[mcp] extra, installed in CI; docs in Tracking Burr.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(tracking): cover /mcp on a UI mounted with mount_burr_ui()

Now that mount_burr_ui() runs the UI's lifespan (#1041), the MCP
transport starts there too. Add a test for it, and point the mount_mcp()
docstring at mount_burr_ui().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(tracking): turn MCP off by default and drop its localhost-only Host check

Following the maintainer decisions in #1036:

- BURR_MCP_ENABLED now defaults to false, and auto is gone. true still
  fails at startup when mcp>=2 is not installed.
- /mcp answers any Host and Origin, like the REST API next to it. The
  SDK's DNS-rebinding default answered only localhost (421 otherwise),
  so an enabled endpoint did not work behind a hostname or proxy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>


----
Implements #1036.

This 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=true, only mcp 2.x is supported, and there is no MCP-specific auth or Host policy.

Changes
burr/tracking/server/mcp_endpoint.py (new) holds the tools and mount_mcp().
inspect group (default, read-only): list_projects, list_apps, get_app, get_step, diff_state, key_history, export_test_case.
annotate group (opt-in): annotate_step, list_annotations. On a backend without annotations (S3), the server logs a warning and skips them.
Results 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=None returns full values.
The transport is stateless with JSON responses. It answers any Host and Origin, like the REST API, so the SDK's 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's session manager can only run once, so the transport is recreated if the app's lifespan runs again.
run.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:
BURR_MCP_ENABLED=true|false. false (default) doesn't serve /mcp. true serves it, and fails at startup if mcp>=2 isn't installed.
BURR_MCP_GROUPS picks the tool groups.
BURR_MCP_MAX_CHARS is a server-side ceiling on value size that callers can't raise, even with max_chars=None. It is unset by default. This was suggested in review on Add an MCP endpoint to the Burr UI server #1036.
_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's dependencies. The CLI now imports it from there.
pyproject.toml gets a new mcp extra (tracking-server plus mcp>=2,<3). The CI test job installs it so the new tests run.
Docs: a new "MCP endpoint" section in docs/concepts/tracking.rst.
How I tested this
tests/tracking/test_mcp_endpoint.py (new, 26 tests):
Every tool, called through the SDK's in-process client on runs tracked by a small Burr app, including a failed step.
Paging, previews and full values, the server-side ceiling, tool groups, and annotations.
Over 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.
/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.
Settings 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>=2.
The 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.
A real server started with burr (local backend, BURR_SERVE_STATIC=false), called over HTTP with the MCP Python SDK client:
Called 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.
Saved an export_test_case result, loaded it with burr.testing, and ran it against the action.
Checked that an annotation written through MCP shows up in /api/v0/{project}/annotations.
BURR_MCP_MAX_CHARS=300 capped values, BURR_MCP_ENABLED=false gave a 404, and an unknown group failed at startup.
After 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.
Claude 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's last step failed and with what error, and how a state key changed over another app's steps. Both answers were correct.
black, isort, flake8 (pre-commit versions) and the ASF header check on the changed files.
Notes
fix(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't 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.
fix(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.
The 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.
Who 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.
Clients tested: the MCP Python SDK client and Claude Code. I haven't tried Cursor. Backends tested: only the local one, not S3.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
8 files changed
tree: e63e4887bcd3de0913846c2882344ca40e982d4e
  1. .github/
  2. burr/
  3. burr-redirect/
  4. docs/
  5. examples/
  6. scripts/
  7. telemetry/
  8. tests/
  9. website/
  10. .asf.yaml
  11. .gitignore
  12. .htaccess
  13. .pre-commit-config.yaml
  14. .rat-excludes
  15. .style.yapf
  16. burr_logo.png
  17. burr_logo.svg
  18. chatbot.gif
  19. CONTRIBUTING.rst
  20. DISCLAIMER
  21. LICENSE
  22. LICENSE-sdist
  23. LICENSE-wheel
  24. NOTICE
  25. pyproject.toml
  26. README.md
  27. SECURITY.md
  28. setup.cfg
README.md

Apache Burr (incubating)

Discord Downloads PyPI Downloads GitHub Last Commit X

Apache Burr (incubating) makes it easy to develop applications that make decisions (chatbots, agents, simulations, etc...) from simple python building blocks.

Apache Burr works well for any application that uses LLMs, and can integrate with any of your favorite frameworks. Burr includes a UI that can track/monitor/trace your system in real time, along with pluggable persisters (e.g. for memory) to save & load application state.

Link to documentation. Quick (<3min) video intro here. Longer video intro & walkthrough. Blog post here. Join discord for help/questions here.

Quick start

Install from pypi:

pip install "apache-burr[start]"

[!NOTE] Burr requires Python 3.10+. (Since 0.43.0, the optional CLI included with [start], [learn], and [cli] already required Python 3.10+; as of the next release, Python 3.9 is no longer supported anywhere.)

(see the docs if you're using poetry)

Then run the UI server:

burr

This will open up Burr‘s telemetry UI. It comes loaded with some default data so you can click around. It also has a demo chat application to help demonstrate what the UI captures, enabling you to see things changing in real-time. Hit the “Demos” side bar on the left and select chatbot. To chat it requires the OPENAI_API_KEY environment variable to be set, but you can still see how it works if you don’t have an API key set.

Next, start coding / running examples:

git clone https://github.com/apache/burr && cd burr/examples/hello-world-counter
python application.py

You'll see the counter example running in the terminal, along with the trace being tracked in the UI. See if you can find it.

For more details see the getting started guide.

How does Apache Burr work?

With Apache Burr you express your application as a state machine (i.e. a graph/flowchart). You can (and should!) use it for anything in which you have to manage state, track complex decisions, add human feedback, or dictate an idempotent, self-persisting workflow.

The core API is simple -- the Burr hello-world looks like this (plug in your own LLM, or copy from the docs for gpt-X)

from burr.core import action, State, ApplicationBuilder

@action(reads=[], writes=["prompt", "chat_history"])
def human_input(state: State, prompt: str) -> State:
    # your code -- write what you want here, for example
    chat_item = {"role" : "user", "content" : prompt}
    return state.update(prompt=prompt).append(chat_history=chat_item)

@action(reads=["chat_history"], writes=["response", "chat_history"])
def ai_response(state: State) -> State:
    # query the LLM however you want (or don't use an LLM, up to you...)
    response = _query_llm(state["chat_history"]) # Burr doesn't care how you use LLMs!
    chat_item = {"role" : "system", "content" : response}
    return state.update(response=response).append(chat_history=chat_item)

app = (
    ApplicationBuilder()
    .with_actions(human_input, ai_response)
    .with_transitions(
        ("human_input", "ai_response"),
        ("ai_response", "human_input")
    ).with_state(chat_history=[])
    .with_entrypoint("human_input")
    .build()
)
*_, state = app.run(halt_after=["ai_response"], inputs={"prompt": "Who was Aaron Burr, sir?"})
print("answer:", app.state["response"])

Apache Burr includes:

  1. A (dependency-free) low-abstraction python library that enables you to build and manage state machines with simple python functions
  2. A UI you can use to view execution telemetry for introspection and debugging
  3. A set of integrations to make it easier to persist state, connect to telemetry, and integrate with other systems

Burr at work

What can you do with Apache Burr?

Apache Burr can be used to power a variety of applications, including:

  1. A simple gpt-like chatbot
  2. A stateful RAG-based chatbot
  3. An LLM-based adventure game
  4. An interactive assistant for writing emails

As well as a variety of (non-LLM) use-cases, including a time-series forecasting simulation, and hyperparameter tuning.

And a lot more!

Using hooks and other integrations you can (a) integrate with any of your favorite vendors (LLM observability, storage, etc...), and (b) build custom actions that delegate to your favorite libraries (like Apache Hamilton).

Apache Burr will not tell you how to build your models, how to query APIs, or how to manage your data. It will help you tie all these together in a way that scales with your needs and makes following the logic of your system easy. Burr comes out of the box with a host of integrations including tooling to build a UI in streamlit and watch your state machine execute.

Start building

See the documentation for getting started, and follow the example. Then read through some of the concepts and write your own application!

Comparison against common frameworks

While Apache Burr is attempting something (somewhat) unique, there are a variety of tools that occupy similar spaces:

CriteriaApache BurrLanggraphtemporalLangchainSuperagentApache Hamilton
Explicitly models a state machine✅✅❌❌❌❌
Framework-agnostic✅✅✅✅❌✅
Asynchronous event-based orchestration❌❌✅❌❌❌
Built for core web-service logic✅✅❌✅✅✅
Open-source user-interface for monitoring/tracing✅❌❌❌❌✅
Works with non-LLM use-cases✅❌❌❌❌✅

Why the name Burr?

Apache Burr is named after Aaron Burr, founding father, third VP of the United States, and murderer/arch-nemesis of Alexander Hamilton. What‘s the connection with (Apache) Hamilton? We imagine a world in which Burr and Hamilton lived in harmony and saw through their differences to better the union. Originally Apache Burr was built as a harness to handle state between executions of Apache Hamilton DAGs (because DAGs don’t have cycles), but realized that it has a wide array of applications and decided to release it more broadly.

Testimonials

“After evaluating several other obfuscating LLM frameworks, their elegant yet comprehensive state management solution proved to be the powerful answer to rolling out robots driven by AI decision-making.”

Ashish Ghosh CTO, Peanut Robotics

“Of course, you can use it [LangChain], but whether it‘s really production-ready and improves the time from ‘code-to-prod’ [...], we’ve been doing LLM apps for two years, and the answer is no [...] All these ‘all-in-one’ libs suffer from this [...]. Honestly, take a look at Burr. Thank me later.”

Reddit user cyan2k LocalLlama, Subreddit

“Using Burr is a no-brainer if you want to build a modular AI application. It is so easy to build with, and I especially love their UI which makes debugging a piece of cake. And the always-ready-to-help team is the cherry on top.”

Ishita Founder, Watto.ai

“I just came across Burr and I‘m like WOW, this seems like you guys predicted this exact need when building this. No weird esoteric concepts just because it’s AI.”

Matthew Rideout Staff Software Engineer, Paxton AI

“Burr's state management part is really helpful for creating state snapshots and building debugging, replaying, and even evaluation cases around that.”

Rinat Gareev Senior Solutions Architect, Provectus

“I have been using Burr over the past few months, and compared to many agentic LLM platforms out there (e.g. LangChain, CrewAi, AutoGen, Agency Swarm, etc), Burr provides a more robust framework for designing complex behaviors.”

Hadi Nayebi Co-founder, CognitiveGraphs

"Moving from LangChain to Burr was a game-changer!

  • Time-Saving: It took me just a few hours to get started with Burr, compared to the days and weeks I spent trying to navigate LangChain.
  • Cleaner Implementation: With Burr, I could finally have a cleaner, more sophisticated, and stable implementation. No more wrestling with complex codebases.
  • Team Adoption: I pitched Burr to my teammates, and we pivoted our entire codebase to it. It's been a smooth ride ever since."

Aditya K. DS Architect, TaskHuman

Roadmap

While Apache Burr is stable and well-tested, we have quite a few tools/features on our roadmap!

  1. FastAPI integration + hosted deployment -- make it really easy to get Apache Burr in an app in production without thinking about REST APIs
  2. Various efficiency/usability improvements for the core library (see planned capabilities for more details). This includes:
    1. First-class support for retries + exception management
    2. More integration with popular frameworks (LCEL, LLamaIndex, Apache Hamilton, etc...)
    3. Capturing & surfacing extra metadata, e.g. annotations for particular point in time, that you can then pull out for fine-tuning, etc.
    4. Improvements to the pydantic-based typing system
  3. Tooling for hosted execution of state machines, integrating with your infrastructure (Ray, modal, FastAPI + EC2, etc...)
  4. Additional storage integrations. More integrations with technologies like MySQL, S3, etc. so you can run Apache Burr on top of what you have available.

If you want to avoid self-hosting the above solutions we‘re building Burr Cloud. To let us know you’re interested sign up here for the waitlist to get access.

Contributing

We welcome contributors! To get started on developing, see the developer-facing docs.

Contributors

Code contributions

Users who have contributed core functionality, integrations, or examples.

Bug hunters/special mentions

Users who have contributed small docs fixes, design suggestions, and found bugs

License

Apache Burr is released under the Apache 2.0 License. See LICENSE for details.

Community

Contributing

We're very supportive of changes by new contributors, big or small! Make sure to discuss potential changes by creating an issue or commenting on an existing one before opening a pull request. Good first contributions include creating an example or an integration with your favorite Python library!

To contribute, checkout our contributing guidelines, our developer setup guide, and the Code of Conduct.

Security

To report a vulnerability, see SECURITY.md. Do not file security reports as GitHub issues.