Search DevTools

Jump to any tool or page

Labby

Unexplored

Rust MCP gateway with Code Mode, authentication, setup, logs, CLI, HTTP API, and operator web UI.

dinglebear-ai5 stars1 forksBrowser & Web
View source

Install

Terminal

$npx -y @dinglebear/labby mcp

mcp_config.json

{
  "mcpServers": {
    "ai-dinglebear-labby": {
      "env": {
        "LABBY_LOG": "${LABBY_LOG}",
        "LABBY_REPO": "${LABBY_REPO}",
        "LABBY_VERSION": "${LABBY_VERSION}"
      },
      "args": [
        "-y",
        "@dinglebear/labby",
        "mcp"
      ],
      "command": "npx"
    }
  }
}

Documentation

Labby

Rust MCP gateway with Code Mode, authentication, setup, logs, CLI, HTTP API, and operator web UI.

Canonical remote: git@github.com:dinglebear-ai/labby.git.

The root README is the public entrypoint. The topic docs in docs/ own the detailed contracts; when this file and a topic doc disagree, fix the topic doc first and then refresh this summary.

Contents

What Labby Does

Labby is centered on the current gateway/operator surface:

  • MCP gateway - connect HTTP and stdio upstream MCP servers, inspect their tools/resources/prompts, apply exposure filters, publish protected MCP routes, and optionally collapse the upstream catalog into Code Mode search and execute.
  • Direct stdio proxy - launch one stdio MCP server with labby proxy /path/to/dist.js and expose its unmodified MCP surface over loopback or an owned Tailscale Serve HTTPS port with tailnet, bearer, OAuth, or explicit no-auth policy.
  • Authentication and protected routes - run bearer or OAuth authentication, manage route-scoped access, authorize upstream OAuth connections, and publish protected MCP endpoints.
  • Code Mode snippets - author, store, and run reusable JavaScript snippets against the upstream catalog, with artifacts persisted under $LABBY_HOME.
  • Setup and doctor - bootstrap ~/.labby, provision the host service, and run a health audit across env, reachability, auth, and versions.
  • Filesystem service - scoped, path-safety-checked file operations exposed through the same action dispatch as every other service.
  • Server logs - search and tail the local labby serve log stream.
  • Incus and bare-metal setup - provision and operate a dedicated Labby gateway host without introducing a separate fleet or deployment product.
  • Generated discovery - publish code-owned service, action, environment, proxy configuration, API route, OpenAPI, MCP help, CLI help, and feature-matrix artifacts under docs/generated.

The registered services on this branch are exactly doctor, fs, gateway, lab_admin, server_logs, setup, and snippets. The older marketplace/stash/acp/nodes/deploy/logs/device product services were removed by the "Slim labby gateway host" pass; their domain types survive in labby-runtime/labby-apis but are no longer registered services and have no CLI commands. Use the generated catalogs below for the current surface instead of copying command or action lists by hand.

Quick Start

Proxy One Stdio MCP Server

After installing Labby, configure proxy defaults once and launch a JavaScript stdio server without proxy flags:

labby setup proxy
labby doctor proxy
labby proxy /path/to/dist.js

The built-in zero-flag policy is Tailscale Serve plus tailnet authorization on a random high port. Child flags follow the first child token unchanged, and an explicit separator is available for unusual commands:

labby proxy /path/to/dist.js --workspace /srv/data --read-only
labby proxy -- npx -y @modelcontextprotocol/server-filesystem /srv/data

Use labby proxy --local --auth none ... for explicit loopback-only development. Bearer and OAuth setup, exact-port resource audiences, safe Serve ownership, configuration precedence, output modes, and recovery are covered in the stdio MCP proxy guide.

Install A Release

Linux/macOS:

curl -fsSL https://raw.githubusercontent.com/dinglebear-ai/labby/main/scripts/install.sh | sh
labby setup
labby serve --host 127.0.0.1 --port 8765

MCP clients that prefer npm launchers can run Labby through the Node wrapper:

npx -y @dinglebear/labby mcp

Windows PowerShell:

irm https://raw.githubusercontent.com/dinglebear-ai/labby/main/scripts/install.ps1 | iex
labby setup
labby serve --host 127.0.0.1 --port 8765

The install scripts download the requested GitHub Release asset, verify its checksum, and install labby onto the user PATH. They do not perform operator provisioning or environment setup. The scripts only install the binary (from a release or fallback source build); all first-run provisioning is handled inside labby via labby serve bootstrap and labby setup.

Override install behavior with LABBY_INSTALL_DIR, LABBY_INSTALL_VERSION, or LABBY_INSTALL_REPO.

Build From Source

Prerequisites:

  • Rust 1.97.1 or newer. CI/release verifies with Rust 1.97.1.
  • just for repo commands.
  • cargo-nextest for the main test suite.
  • pnpm 9.15.9 for the Labby web UI. The repo pins this in .mise.toml and apps/gateway-admin/package.json.
  • openssl if you want to generate a bearer token manually.
git clone git@github.com:dinglebear-ai/labby.git
cd labby
just install
just web-build
labby serve --host 127.0.0.1 --port 8765

just install builds the all-features release binary and symlinks it to ~/.local/bin/labby.

On macOS, install the gateway as a persistent per-user service instead of running labby serve in a terminal:

just macos-service-install
just macos-service-status

This installs a launchd LaunchAgent that keeps Labby listening on 127.0.0.1:8765, restarts it after login or exit, and writes logs under ~/.labby/. Use just macos-service-restart after changing service settings or just macos-service-uninstall to remove it. The cross-platform just service-install, just service-status, just service-restart, and just service-uninstall bindings select launchd on macOS and systemd on Linux. This is suitable for a Tailscale Serve/Funnel route whose OAuth callback targets the local gateway.

First Run

For loopback development, labby serve can bootstrap a missing bearer token for you. If LABBY_MCP_HTTP_TOKEN is absent and LABBY_AUTH_MODE is not oauth, it generates a token, writes a minimal ~/.labby/.env, reloads it into the running process, prints the setup URL, and continues. The token itself is stored in ~/.labby/.env rather than printed.

Bootstrap writes these required setup keys if no env exists yet:

  • LABBY_MCP_HTTP_TOKEN (generated random 64-character hex token)
  • LABBY_MCP_TRANSPORT=http
  • LABBY_MCP_HTTP_HOST=127.0.0.1
  • LABBY_MCP_HTTP_PORT=8765
  • LABBY_AUTH_MODE=bearer

It also enforces secure file creation via Labby's env_merge path (0600 perms on Unix) and then skips creating anything else until the web wizard runs.

For explicit setup:

mkdir -p ~/.labby
printf 'LABBY_AUTH_MODE=bearer\nLABBY_MCP_HTTP_TOKEN=%s\n' "$(openssl rand -hex 32)" > ~/.labby/.env
chmod 600 ~/.labby/.env
labby setup
labby serve --host 127.0.0.1 --port 8765

Open http://127.0.0.1:8765/. Build static Labby assets with just web-build first when running from a source checkout.

Self-Host The Gateway

The recommended self-hosted gateway substrate is an amd64 Ubuntu 26.04 Incus system container. Bare metal is the secondary supported shape for a dedicated gateway host or VM. Docker is retained for explicit development/image smoke, but it is not the recommended production boundary for Labby because stdio MCP servers and agent CLIs are installed and launched at runtime.

scripts/incus-bootstrap.sh --version vX.Y.Z
incus exec labby -- systemctl status labby --no-pager
incus exec labby -- curl -fsS http://127.0.0.1:8765/ready

See docs/runtime/INCUS.md for the full Incus runbook, bare-metal variant, /dev/net/tun Tailscale passthrough, manual claude/codex/gemini login checklist, and rollback commands.

Core Workflows

Start Labby

labby serve --host 127.0.0.1 --port 8765
labby mcp

labby serve starts the hosted HTTP runtime: /v1 product APIs, /mcp streamable HTTP MCP, auth routes, OAuth relay endpoints, and static Labby web assets when an export is available. labby mcp is the stdio MCP entrypoint for local MCP clients.

Manage Upstream MCP Gateways

labby gateway add \
  --name github \
  --url https://example.com/mcp \
  --bearer-token-env GITHUB_MCP_TOKEN \
  -y

labby gateway reload
labby gateway list

Stdio upstreams execute local commands when tested or reconciled, so gateway tests and config mutations use the shared destructive-action confirmation gate. The stdio spawn guard allows known runtimes such as npx, uvx, docker, node, python, python3, deno, pipx, and dnx; customize it in [gateway] inside config.toml.

Use Code Mode

When [code_mode].enabled = true, Labby hides raw proxied upstream tools from MCP list_tools() and exposes the canonical synthetic codemode tool.

labby gateway code status
labby gateway code enable
labby gateway code exec --code 'async () => tools.length'

MCP call shapes:

{ "code": "async () => (await codemode.search(\"github issues\")).results" }
{ "code": "async () => callTool(\"github::search_issues\", {\"query\":\"repo:dinglebear-ai/labby gateway\"})" }
{ "code": "async () => codemode.run(\"gateway-summary\", {\"includeHealth\": true})" }

Code Mode can call exposed upstream MCP tools only. It cannot call Labby actions from inside the sandbox.

Work With Code Mode Snippets

labby snippets list
labby snippets get gateway-summary
labby snippets create --name my-snippet --file ./my-snippet.js
labby snippets validate my-snippet
labby snippets exec my-snippet
labby snippets test my-snippet

Snippets are stored per-user under $LABBY_HOME and executed through the gateway Code Mode runner, so they can reach exposed upstream tools but not Labby actions. The snippets service is gateway-gated: it is unavailable in builds without the gateway feature.

Audit Health And Logs

labby doctor            # audit every configured service
labby doctor system     # local env vars, Docker, disk, toolchain
labby doctor auth       # auth/OAuth env vars, files, permissions
labby doctor proxy      # zero-route stdio-proxy config/dependency preflight
labby doctor proxy --app-url URL --mcp-url URL --route /path
                        # routed public reverse-proxy checks remain available
labby doctor oauth-relay
labby health            # lightweight liveness/readiness probe
labby logs              # tail the active deployment's service journal

labby doctor --json is the CI-friendly form; the exit code reflects the worst severity found.

Removed surfaces. Earlier releases documented labby marketplace, labby stash, labby nodes, and labby deploy, along with ACP chat, the MCP Registry browser, and device/fleet runtimes. Those products have been deleted from source, manifests, packaging, and CI — not merely feature-gated. scripts/check-retired-features.sh guards against reintroduction, and the historical designs are archived under docs/archive/retired-labby. Plugin marketplace assets now live in the separate dendrite repo.

Drive The API

Generic action dispatch:

curl -s -X POST http://127.0.0.1:8765/v1/gateway \
  -H "Authorization: Bearer $LABBY_MCP_HTTP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"action":"gateway.list","params":{}}'

Dedicated product routes also exist for catalog discovery (/v1/{service}/actions), setup, doctor, snippets, filesystem, server logs, gateway OAuth (/v1/gateway/oauth/*), OAuth relay, auth allowlists (/v1/auth/allowed-emails), /v1/openapi, and the browser session routes under /auth/*. See generated API routes and OpenAPI.

Runtime Surfaces

SurfaceEntry PointNotes
CLIlabby <command>Current commands are generated in docs/generated/cli-help.md. Use --json for machine-readable output and `--color auto
MCP stdiolabby mcpLocal editor/desktop MCP clients.
MCP HTTPlabby serve plus /mcpStreamable HTTP MCP with bearer or OAuth JWT auth.
HTTP APIlabby serve plus /v1/*Generic POST /v1/{service} action dispatch plus dedicated product routes.
Web UIlabby serve plus exported assetsMain routes are / (overview), /gateways, /gateway, /snippets, /usage, /settings (with core, services, services/[service], surfaces, features, doctor, extract, advanced subpages), /docs, /design-system, and /mcp/code-mode.

MCP service tools use the shared action shape:

{
  "action": "mcp.list",
  "params": { "search": "postgres", "limit": 10 }
}

Every service tool also supports help and schema through the shared dispatcher. Destructive MCP actions use elicitation when the client supports it; headless clients pass "confirm": true inside params.

Configuration

Configuration is split deliberately:

DataLocationExamples
Secrets and endpoint values~/.labby/.envLABBY_MCP_HTTP_TOKEN, LABBY_GOOGLE_CLIENT_SECRET, upstream bearer token env values
Preferencesconfig.tomltransport, CORS, auth mode, workspace root, gateway spawn guard, and upstream behavior

config.toml is searched in this order:

  1. ./config.toml
  2. ~/.labby/config.toml
  3. ~/.config/labby/config.toml

Startup loads the first config.toml, initializes tracing, then loads ~/.labby/.env and a CWD .env if present. Runtime precedence is:

  1. CLI flags
  2. Environment variables
  3. config.toml
  4. Built-in defaults

Useful environment variables:

VariablePurpose
LABBY_MCP_HTTP_TOKENStatic bearer token for protected admin/API/MCP routes.
LABBY_AUTH_MODEbearer or oauth.
LABBY_PUBLIC_URLPublic base URL for OAuth metadata, issuer/audience, callbacks, and allowed-host derivation.
LABBY_GOOGLE_CLIENT_ID / LABBY_GOOGLE_CLIENT_SECRETGoogle OAuth credentials for OAuth mode.
LABBY_AUTH_ADMIN_EMAILBootstrap admin email; required in OAuth mode.
LABBY_OAUTH_ENCRYPTION_KEYBase64 32-byte key required for encrypted upstream OAuth credentials. Rotation requires reauthorizing affected upstreams.
LABBY_WEB_ASSETS_DIROverride static Labby export directory.
LABBY_WEB_UI_AUTH_DISABLEDDevelopment-only browser auth bypass.
LABBY_LOG / LABBY_LOG_FORMAT / LABBY_LOG_COLORTracing filter, text/json format, and non-TTY color policy.
LABBY_LOG_DIROptional rolling JSON file log directory.
LABBY_ACTOR_KEY_SECRETStable secret for redacted actor correlation in logs.
LABBY_ADMIN_ENABLEDRuntime opt-in for the lab_admin tool.

Bearer auth is an operator/admin shortcut for Labby routes. Public protected MCP routes validate route-scoped Labby OAuth JWTs; do not treat LABBY_MCP_HTTP_TOKEN as a public resource credential.

When driving the web UI with automation while OAuth is enabled, pass the bearer token as a same-origin header. /auth/session recognizes that token and returns a synthetic admin session:

TOKEN=$(awk -F= '/^LABBY_MCP_HTTP_TOKEN=/{print $2}' ~/.labby/.env)
agent-browser open http://127.0.0.1:8765/gateways \
  --headers "{\"Authorization\":\"Bearer $TOKEN\"}"

See runtime configuration, environment variables, and OAuth.

Current Catalogs

Do not maintain action, feature, env, or coverage inventories by hand in this README. The generated artifacts are authoritative for the current branch:

ArtifactPurpose
service-catalog.mdRegistered services, exposure, features, categories, and surfaces.
action-catalog.mdPer-service actions and destructive metadata.
env-reference.mdEnv vars generated from service metadata.
api-routes.mdMounted HTTP routes.
openapi.jsonOpenAPI 3.1 schema.
feature-matrix.mdCargo feature invariants.
mcp-help.mdMCP help projection.
cli-help.mdClap command help snapshot.

Refresh and verify them with:

just docs-generate
just docs-check

docs-check verifies generated-artifact freshness and invariants. It is not a Markdown link checker, live health check, or onboarding policy audit.

Architecture

The workspace has 11 members and uses Rust 2024, resolver 3, a single [workspace.package] version, shared [workspace.dependencies], and shared [workspace.lints] (unsafe_code = "forbid", mod_module_files = "deny", disallowed_macros = "deny"). The MCP SDK is pinned exactly as rmcp = "=3.1.0".

PathRole
crates/labby-primitivesDependency-free leaf crate: ActionSpec/ParamSpec, PluginMeta/EnvVar/Category, UiSchema, static SSRF checks.
crates/labby-apisShared SDK contracts for core HTTP behavior, setup, and doctor.
crates/labby-authOAuth/JWT/session middleware, route support, and upstream OAuth runtime.
crates/labby-runtimeSurface-neutral contracts and helpers: ToolError, gateway config DTOs, dispatch helpers, redaction, path safety, and security helpers.
crates/labby-codemodeClient-neutral Code Mode runner kernel, broker, result shaping, snippets, and TypeScript descriptor generation.
crates/labby-gatewayGateway manager, upstream MCP proxy pool, Code Mode host adapter, discovery/imports, virtual servers, protected routes, and OAuth lifecycle.
crates/labby-openapiOpenAPI 3.1 schema assembly for the HTTP surface.
crates/labby-webEmbedded/filesystem web asset serving with symlink escape defense.
crates/labbyProduct binary crate: CLI, MCP, HTTP API, config loading, gateway dispatch, logs, setup, snippets, filesystem access, and output rendering.
crates/labby-winjobWindows Job Object process-tree support, isolated so the main workspace can keep unsafe_code = "forbid".
crates/xtaskRepo automation tasks; not published.
apps/gateway-adminLabby web UI, statically exported and served by labby serve.
packages/labby-mcpnpm launcher wrapper behind npx -y @dinglebear/labby mcp.
pluginsClaude/Codex plugin assets and skills.
docsTopic documentation and generated inventories.

Shared behavior belongs in the shared execution layer

Sourced from the repository README.

More in Browser & Web