Gabriel Luiz Freitas Almeida cea8b1aa12 feat: flow event polling for real-time MCP agent activity (#12340)
* feat: add Langflow MCP Client settings page

Add a new settings page that shows coding agents how to connect to
Langflow via the lfx.mcp client. Includes setup instructions and
JSON config for Bob (IBM) and Claude Code.

* fix: clipboard guard and per-button copied state in MCP client page

- Guard navigator.clipboard availability before calling writeText
- Track copied state per button (command vs json) so visual feedback
  matches the action the user took

* feat: add flow events queue for MCP agent activity polling

In-memory event queue service with cursor-based polling endpoint
at GET/POST /api/v1/flows/{flow_id}/events. Enables the frontend
to detect when MCP agents modify flows in near real-time.

* feat: emit flow events from MCP tools and add notify_done tool

Each mutating MCP tool now posts an event to the flow events queue
after successful PATCH. Adds notify_done tool for explicit settle
signaling to the frontend.

* feat: add frontend flow event polling with canvas locking and toast

- useFlowEvents hook with adaptive polling (5s idle, 1s active)
- Canvas locks with "Agent is working..." badge during agent activity
- Flow reloads and summary toast on settle

* test: add tests for flow events hook and MCP event emission

- 9 frontend tests for useFlowEvents hook (polling, accumulation, settle, errors)
- 4 lfx tests for LangflowClient.post_event (payload, defaults, error suppression)
- 7 lfx tests for MCP tool event emission (add/remove/configure/connect/disconnect/notify_done)

* fix: add flow ownership check and fix thread-safety in event queue

Endpoints now verify the authenticated user owns the flow before
allowing event reads or writes. Also copies the event list inside
the lock to prevent concurrent mutation during iteration.

* fix: log warnings on event posting and polling failures

Replace silent error suppression with logger.warning (backend) and
console.warn (frontend) so failures are diagnosable while keeping
best-effort semantics.

* fix: show toast only on successful flow reload after agent settle

Move toast into reloadFlow's onSuccess callback so users aren't told
about changes that failed to load. Also fixes stale closure by adding
missing useEffect dependencies.

* test: improve coverage for flow events

- Add cursor-ahead-of-events tests for get_since settle logic
- Add flow ownership 404 test for events endpoints
- Add event emission tests for freeze/unfreeze/layout/update_flow_from_spec
- Use real flow IDs (from created flows) in API tests

* test: add edge case coverage for flow events

- flow_settled before cursor should not trigger settlement
- create_flow_from_spec emits flow_settled after batch
- Polling resumes at idle interval after settle
- Simultaneous events + settled in single poll

* fix: UX improvements for agent activity polling

- Clear events after settle to prevent stale toast messages
- Truncate toast to 3 summaries max ("and N more")
- Block keyboard shortcuts (undo/redo/copy/paste/cut) during agent lock
- Poll immediately on mount (no 5s blind spot)
- Add concurrency guard to prevent overlapping polls
- Guard against setState on unmounted component

* test: add Playwright E2E test for agent events banner

Verifies that posting events via the API triggers the "Agent is
working..." banner on the canvas, and that a flow_settled event
dismisses it.

* refactor: consolidate lfx event tests into parameterized tests

- Server tests: 10 identical copy-paste classes -> 1 parameterized test
  covering 9 tools, assertions check event type not exact summary
- Client tests: merge redundant exception tests, test multiple error
  types in one test
- Keep distinct tests for create_flow_from_spec and notify_done since
  they have unique behavior (batch settle vs explicit settle)

* fix: UX improvements for agent events banner

- Show latest event summary in banner (e.g. "Agent: Added Memory")
- Slide-in entrance and slide-out exit animations
- Minimum 2s display time so banner doesn't flash
- Freeze banner text during exit animation
- Text eases in when new events arrive

* fix: canvas reload, locking, and toast formatting

- Use applyFlowToCanvas for proper canvas reload on settle
- Zoom to fit after reload instead of zooming to 200%
- Lock icon shows "Agent Working" during agent activity
- ReactFlow nodesDraggable/nodesConnectable respect agent lock
- Toast shows grouped summary (e.g. "Agent removed 3 components")
- Events preserved for consumer, cleared via clearEvents callback

* fix: handle AUTO_LOGIN nullable user_id, remove double processFlows, fix pluralization

- _verify_flow_owner now accepts flows with user_id=None (AUTO_LOGIN)
- Remove redundant processFlows call (applyFlowToCanvas handles it)
- Toast says "connections" not "components" for connection events

* refactor: minor cleanup from code review

- Remove unused FlowEventType export (only used internally)
- Simplify nested ternary in toast pluralization

* chore: remove test artifact

* fix: harden flow events service and address review findings

- Rewrite FlowEventsService to use diskcache for cross-worker
  event visibility (replaces in-memory dict)
- Add Literal constraint and max_length to FlowEventCreate API model
- Restore manual lock toggle (disabled during agent activity),
  serialize saves to prevent race conditions
- Add AbortController to post-settle flow reload to prevent
  stale responses from overwriting wrong canvas
- Clear agent-working state on terminal poll errors (401/403/404)
  so UI doesn't get permanently stuck
- Make notify_done report warning status on delivery failure
- Emit settle event on create_flow_from_spec rollback
- Fix E2E test banner text assertion to match actual render
- Add 14 new tests: cross-worker visibility, validation 422s,
  terminal error unlock, notify_done warning, rollback settle

* fix: resolve CI failures in MemoizedCanvasControls and notify_done tests

- Add waitFor() to lock toggle tests for async handleToggleLock
- Patch logger in notify_done failure test to avoid I/O on closed file
- Replace any[] with unknown[] in test mock type

* fix: address remaining review feedback from erichare

- Fix stale closure in banner effect using bannerVisibleRef
- Add runtime event type validation in FlowEventsService.append()
- Document diskcache ephemeral storage and multi-tab limitations
2026-04-02 23:46:22 +00:00
2025-03-20 00:05:55 +00:00
2026-04-01 20:35:44 +00:00
2024-06-04 09:26:13 -03:00
2026-04-01 20:35:44 +00:00

Langflow logo

Release Notes PyPI - License PyPI - Downloads Twitter YouTube Channel Discord Server Ask DeepWiki

Langflow is a powerful platform for building and deploying AI-powered agents and workflows. It provides developers with both a visual authoring experience and built-in API and MCP servers that turn every workflow into a tool that can be integrated into applications built on any framework or stack. Langflow comes with batteries included and supports all major LLMs, vector databases and a growing library of AI tools.

Highlight features

  • Visual builder interface to quickly get started and iterate.
  • Source code access lets you customize any component using Python.
  • Interactive playground to immediately test and refine your flows with step-by-step control.
  • Multi-agent orchestration with conversation management and retrieval.
  • Deploy as an API or export as JSON for Python apps.
  • Deploy as an MCP server and turn your flows into tools for MCP clients.
  • Observability with LangSmith, LangFuse and other integrations.
  • Enterprise-ready security and scalability.

🖥️ Langflow Desktop

Langflow Desktop is the easiest way to get started with Langflow. All dependencies are included, so you don't need to manage Python environments or install packages manually. Available for Windows and macOS.

📥 Download Langflow Desktop

Quickstart

Requires Python 3.103.13 and uv (recommended package manager).

Install

From a fresh directory, run:

uv pip install langflow -U

The latest Langflow package is installed. For more information, see Install and run the Langflow OSS Python package.

Run

To start Langflow, run:

uv run langflow run

Langflow starts at http://127.0.0.1:7860.

That's it! You're ready to build with Langflow! 🎉

📦 Other install options

Run from source

If you've cloned this repository and want to contribute, run this command from the repository root:

make run_cli

For more information, see DEVELOPMENT.md.

Docker

Start a Langflow container with default settings:

docker run -p 7860:7860 langflowai/langflow:latest

Langflow is available at http://localhost:7860/. For configuration options, see the Docker deployment guide.

🛡️ Security

For security information, see our Security Policy.

🚀 Deployment

Langflow is completely open source and you can deploy it to all major deployment clouds. To learn how to deploy Langflow, see our Langflow deployment guides.

Stay up-to-date

Star Langflow on GitHub to be instantly notified of new releases.

Star Langflow

👋 Contribute

We welcome contributions from developers of all levels. If you'd like to contribute, please check our contributing guidelines and help make Langflow more accessible.


Star History Chart

❤️ Contributors

langflow contributors

Description
Langflow is a powerful tool for building and deploying AI-powered agents and workflows.
Readme MIT 2.3 GiB
Languages
Python 64.5%
TypeScript 23.4%
JavaScript 11.4%
CSS 0.3%
Makefile 0.2%
Other 0.1%