Flujo Documentation

repository·main·Indexed 20 days ago

https://github.com/mario-andreschak/flujo

An open-source, local-first platform for building, automating, and serving AI workflows visually. Flujo allows users to connect LLMs and Model Context Protocol (MCP) tools into complex graphs triggered by schedules, webhooks, or API calls. It includes a REST API, a JavaScript SDK, and specialized MCP servers for filesystem access, bash execution, and browser automation via Patchright.

Tokens
57.8K
Snippets
134
Records
243
Agent score
69%

What's inside Flujo

  1. Overview of Standalone FLUJO MCP Servers

    main

    FLUJO manages several Model Context Protocol (MCP) processes via stdio transport. These servers provide specialized tools for AI workflows:

    • @mario.andreschak/mcp-flujo: Provides FLUJO application tools and run resources by delegating to the running backend via the localhost control API.
    • @mario.andreschak/mcp-filesystem: Provides confined filesystem tools, MCP Apps HTML resources, and a bounded touched-file resource registry.
    • @mario.andreschak/mcp-bash: Provides cross-platform shell execution (foreground/background) and a PTY-backed terminal with process-tree cleanup.
    • @mario.andreschak/mcp-browser: Provides isolated server-side Patchright browser automation with an MCP Apps browser view.

    Technical Implementation Details:

    • Each package builds to dist/index.js.
    • They use StdioServerTransport.
    • Important: stdout is reserved strictly for MCP protocol frames. All diagnostics and logs must be written to stderr.
    • Configurations are persisted as portable npx --no-install <executable> commands and resolved from the FLUJO_APP_ROOT runtime.
  2. Overview of the MCP API Layer

    main
    The MCP API Layer provides a RESTful HTTP interface for managing Model Context Protocol (MCP) implementations. It acts as a thin transport boundary between the frontend and the backend MCP service (@/backend/services/mcp). The route handlers are responsible for parsing requests, delegating to the mcpService, and mapping results to appropriate HTTP status codes.
  3. Explore Flujo features and architecture

    main
    Flujo provides a visual interface for designing AI-powered workflows. You can explore detailed documentation for specific capabilities in the Features section, or understand the underlying technical design and system components in the Architecture section.
  4. Use the Storage API to manage application data

    main

    The Storage API provides a simple interface for reading, writing, and deleting data using predefined keys. It acts as a bridge between frontend components and backend filesystem storage utilities.

    Architecture

    The system follows a three-tier flow:

    1. Frontend Components: Make HTTP requests to the API.
    2. API Layer (route.ts): Validates request parameters and handles HTTP methods.
    3. Storage Utilities: Persists the validated data to the filesystem.

    Supported Storage Keys

    You must use one of the following valid StorageKey enum values for all operations:

    • models
    • mcp_servers
    • flows
    • chat_history
    • theme
    • global_env_vars
    • encryption_key
  5. Handle errors in the Model Frontend Service

    main

    The modelService provides consistent error handling across all operations. Every method returns a Promise that resolves to a result object. This object contains:

    • success: A boolean flag indicating if the operation was successful.
    • error: An optional message containing error details if success is false.

    UI components should check the success flag to determine whether to proceed or display an error message to the user.

  6. Choose between Guided and Advanced authoring profiles

    main

    FLUJO provides two authoring profiles that compile to the same ReactFlow-compatible definition. Choosing the right profile depends on whether you want a simplified experience or full control over the FlowSpec.

    Guided Profile (Default)

    Designed for humans and compact models. It abstracts away runtime plumbing and focuses on describing work.

    • Exposes: Process steps (label, task, model, server tools), Finish steps, and Run Another Flow steps (helper flow, label, task).
    • Schema: Uses a compact SimpleFlowSpec with ordered steps and optional routes.
    • Automation: Automatically infers Start/Finish nodes, history handoff, layout, node IDs, handles, edges, and common I/O defaults.
    • Data: Uses conversation history for step-to-step data handoff.

    Advanced Profile (Opt-in)

    Preserves the complete FlowSpec surface for complex automation.

    • Exposes: MCP, Resource, Signal, and Trigger nodes; Prompt composition; Conditional/bidirectional edges.
    • State & Variables: Supports variables, subflow resource capture, persistent KV state, and explicit Process → Resource artifact production.
    • Execution Control: Subflow child-job queues (with maximum simultaneous-child settings), unattended execution, and flow-level permission rules.

    Note: The builder preference is stored under flujo-ui:flow-builder:mode. If you switch to Guided mode while a flow contains advanced features, the builder will show a non-destructive notice, but hidden properties remain in the saved node data.

  7. How to update and manage MCP server connection state

    main

    Updating a server configuration via PUT performs a merge and upsert. You can send a partial body to update specific fields.

    Crucially, the disabled field controls the connection state:

    • Setting disabled: true will disconnect the server.
    • Setting disabled: false will (re)connect the server.
  8. How automatic encryption of sensitive data works

    main

    The Environment Variables API automatically protects sensitive data based on naming conventions.

    Detection Logic: Variables with names containing any of the following substrings are treated as sensitive: key, secret, password, token, or auth.

    Storage Behavior:

    • Sensitive variables are encrypted before being persisted.
    • Encrypted values are stored with an encrypted: prefix.
    • If encryption fails, the value is stored with an encrypted_failed: prefix.

    Retrieval Behavior:

    • By default, the API returns ******** for sensitive values.
    • Actual values are only returned if the includeSecrets=true parameter is provided in the request.
  9. Understand the FLUJO API Layer Architecture

    main

    The FLUJO API layer acts as a bridge between the user interface and backend services. It is organized into a clean architecture pattern to ensure separation of concerns and maintainability.

    The data flow follows this hierarchy:

    1. UI Components: React components providing the interface.
    2. Frontend Services: TypeScript modules that encapsulate API calls.
    3. API Layer: Next.js API routes acting as adapters for HTTP requests.
    4. Backend Services: The core business logic implementation.

    This structure prevents circular dependencies and allows each layer to be tested and extended independently.

  10. Understand FLUJO execution statistics storage and lifecycle

    main

    FLUJO records local, metadata-only execution statistics for experimental features. Data is stored as JSONL files (one JSON object per line) in the db/statistics/ directory, partitioned by UTC day using the format YYYY-MM-DD.jsonl.

    Key Lifecycle Behaviors:

    • Concurrency: Appends are serialized independently per partition, allowing concurrent runs to maintain event order without blocking other days.
    • Reliability: Recording is "best-effort." Failures in serialization, appending, recovery, or retention will never reject or alter a flow execution.
    • Retention: Partitions older than 90 days are pruned asynchronously following a successful append. Cleanup is isolated from the write result and may be retried later.
  11. Implement Privacy-Preserving Telemetry Collection

    main

    The telemetry contract is designed for anonymity. When building a collector, adhere to these privacy requirements:

    • ID Rotation: The anonymousDailyId changes every UTC day.
    • No PII: The ID must not be joined to IP addresses, user agents, registry accounts, cookies, or any other persistent identifiers.
    • Log Sanitization: Request logs should omit or promptly discard source IP and user-agent data.
    • Rate Limiting: The endpoint should be rate-limited, but the rate-limiting mechanism must not create a durable client fingerprint.
  12. Review the safe event contract for statistics

    main

    The statistics schema (version 1) is designed to be privacy-preserving and only includes an explicit allowlist of metadata.

    Supported Event Types:

    • run.started, run.paused, and run.finished
    • node.visit
    • model.attempt
    • tool.invocation
    • scheduler.fire (includes fired or queued outcomes)
    • scheduler.skip (includes classified skip reasons)

    Security & Privacy Guarantees:

    • Excluded Data: The following are never recorded: prompts, messages, completions, tool schemas, tool arguments/results, trigger context, URLs, raw provider errors, API keys, encrypted credentials, or decrypted secrets.
    • Credential Handling: Credential grouping uses an installation-local HMAC key. Only a fixed-format opaque fingerprint is included in events; neither the credential nor the HMAC key is ever serialized into records or logs.
    • Error Handling: The statistics service logs only bounded diagnostics (e.g., event type, partition day, invalid-record count) and never logs rejected records or runtime payloads.