Skip to content

Flex

Flex (apps/flex/) is the flagship app of the webmcp-auto-ui project. It’s a full-featured AI canvas that combines a multi-provider LLM agent, simultaneous multi-MCP server connections, a floating/grid widget system, and a suite of debug and export tools. It showcases everything the v0.8 architecture can do.

When you open Flex, you’ll see a clean, dark interface. At the top, a toolbar displays the MCP connection status (with available tool count), an LLM model selector (remote models such as Claude, Gemini, ChatGPT; Gemma E2B/E4B via WASM; or Ollama local), a light/dark theme toggle, a real-time token counter, and a HyperSkill export button.

In the center, the canvas takes up all available space. Widgets generated by the agent appear either in float mode (draggable and resizable windows) or grid mode (responsive grid). Each widget carries a provenance badge showing which tool and server generated it.

On the left, a collapsible sidebar provides access to advanced settings: LLM model, Ollama server URL, temperature, max tokens, max tools, prompt cache, custom system prompt, and schema optimization options (sanitize, flatten). A recipe panel (RecipeModal) lists available WebMCP and MCP recipes.

At the bottom, a slide-out drawer (LogDrawer) uses the AgentConsole component from the UI package to display real-time agent logs: iterations, LLM requests, responses, tool calls with arguments and results, and final metrics.

At the very bottom, an input bar lets you type questions in natural language. A Stop button lets you interrupt generation in progress.

graph TD
subgraph Frontend
Page["+page.svelte<br/>Canvas + Chat + Panels"]
FlexGrid["FlexGrid.svelte<br/>Float/Grid layout"]
Settings["SettingsDrawer.svelte<br/>Advanced config"]
Debug["DebugPanel.svelte<br/>Prompt + metrics"]
Logs["LogDrawer.svelte<br/>AgentConsole"]
History["HistoryModal.svelte<br/>Conversation history"]
Recipe["RecipeModal.svelte<br/>MCP/WebMCP recipes"]
end
subgraph Packages
Agent["@webmcp-auto-ui/agent<br/>runAgentLoop, providers,<br/>TokenTracker, ContextRAG"]
Core["@webmcp-auto-ui/core<br/>McpMultiClient"]
SDK["@webmcp-auto-ui/sdk<br/>canvas store, HyperSkill"]
UI["@webmcp-auto-ui/ui<br/>Components, layouts,<br/>bus, layoutAdapter"]
end
subgraph Backend
Proxy["api/chat/+server.ts<br/>LLM Proxy"]
end
Page --> FlexGrid
Page --> Settings
Page --> Debug
Page --> Logs
Page --> History
Page --> Recipe
Page --> Agent
Page --> Core
Page --> SDK
Page --> UI
Agent --> Proxy
ComponentDetail
FrameworkSvelteKit + Svelte 5 ($state, $derived, $effect)
StylesTailwindCSS 3.4
Iconslucide-svelte
LLM providersRemoteLLMProvider (remote LLM via proxy), WasmProvider (Gemma in-browser), LocalLLMProvider (Ollama)
MCPMcpMultiClient (simultaneous multi-server)
Statecanvas reactive store from SDK
Token trackingTokenTracker with TokenBubble UI
RAGContextRAG (experimental Nano-RAG)
ExportencodeHyperSkill / summarizeChat
Adapter@sveltejs/adapter-node (SSR)

Packages used:

  • @webmcp-auto-ui/agent: runAgentLoop, RemoteLLMProvider, WasmProvider, LocalLLMProvider, buildSystemPrompt, fromMcpTools, trimConversationHistory, summarizeChat, TokenTracker, buildToolsFromLayers, runDiagnostics, buildDiscoveryCache, ContextRAG, autoui
  • @webmcp-auto-ui/core: McpMultiClient
  • @webmcp-auto-ui/sdk: canvas, listSkills, encodeHyperSkill
  • @webmcp-auto-ui/ui: McpStatus, ModelLoader, AgentProgress, EphemeralBubble, TokenBubble, bus, layoutAdapter
EnvironmentPortCommand
Dev3007npm -w apps/flex run dev
Production3007node index.js (via systemd)
Terminal window
npm -w apps/flex run dev
# Available at http://localhost:3007

Flex supports three provider families:

  • Remote LLM (e.g. Claude, Gemini, ChatGPT, Mistral) via a server-side proxy compatible with any OpenAI-compatible API
  • Gemma WASM (E2B, E4B) loaded directly in the browser via LiteRT. A ModelLoader progress bar shows download progress (~33 MB)
  • Ollama local via LocalLLMProvider for running models like Llama 3.2 on your machine

The provider is selected via the LLMSelector component. Smart defaults automatically adjust optimization options based on the chosen provider (e.g., flatten enabled for Gemma, sanitize for Claude).

Connect to multiple MCP servers simultaneously. Each server’s tools are merged into the agent’s layers. MCP recipes are automatically loaded if the server exposes a list_recipes tool.

Widgets aren’t read-only. When the user clicks an element in a widget (table row, card, chart point…), the interaction is captured, translated into a message for the LLM, and injected into the agent loop to generate new contextual widgets.

Switch between:

  • Composer: full editing, free input, debug panel, export
  • Consumer: read-only view of generated widgets
  • Float: draggable and resizable windows via FloatingLayout. The agent can move and resize widgets via onMove, onResize, onStyle callbacks
  • Grid: responsive grid via FlexLayout

Export the complete canvas as a gzip-compressed HyperSkill URL. The export optionally includes an LLM-generated conversation summary (summarizeChat) and provenance metadata.

The DebugPanel displays in real time:

  • The effective system prompt (with layers)
  • Available tools with their JSON schemas
  • Compatibility diagnostics (via runDiagnostics)
  • Token metrics (input, output, cache, cost)

Enabled via a checkbox in the toolbar. ContextRAG compacts the agent’s context using embeddings to retain only the most relevant passages.

VariableDescriptionDefault
LLM_API_KEYRemote LLM provider API key (server-side .env)required
maxContextTokensMax context window150,000
maxTokensMax tokens per response4,096
maxToolsMax tools per request8
temperatureGeneration temperature1.0
cacheEnabledPrompt cache (provider-dependent)true
schemaSanitizeJSON schema sanitizationauto
schemaFlattenSchema flatteningauto
truncateResultsMCP result truncationauto
compressHistoryHistory compressionauto

The main component orchestrates everything: it declares reactive state ($state), builds layers from connected MCP servers and local packs ($derived), initializes LLM providers, and drives the agent loop via runAgentLoop. Agent callbacks feed the canvas, logs, ephemeral bubbles, and token tracker.

A SvelteKit endpoint using llmProxy from the agent package to relay requests to the remote LLM provider API. The API key is read from the server-side environment or from the request body (for BYOK mode).

Manages widget display in float (draggable windows) or grid mode. Each widget is rendered via WidgetRenderer and framed by a provenance badge.

Side drawer with all advanced settings: model, provider, generation parameters, schema options, custom prompt, MCP connection.

Bottom drawer using AgentConsole to display structured agent logs with timestamps and color-coded types.

To modify Flex:

  1. Add an LLM provider: extend the getProvider() function in +page.svelte
  2. Add local widgets: create a WebMcpServer and add it to the layers
  3. Modify the system prompt: use the “System prompt” field in Settings to prefix the generated prompt
  4. Change the layout: toggle between float and grid via the toolbar button
Server path/opt/webmcp-demos/flex/ (root)
systemd servicewebmcp-flex
ExecStartnode index.js
Terminal window
./scripts/deploy.sh flex