SuperAPI AI Directory

lugh-lang

lugh-lang is an open-source programming language and safety guardrail tool for AI agents. It provides the Lugh language, which lets agent programs declare directly in code which resources are accessible, what budget can be spent, and when human approval is required, with the runtime enforcing these policies on every operation. It also provides guard mode: with a single command (npx lugh-lang protect), it adds a unified policy layer to existing MCP servers in clients such as Claude Code, Cursor, and VS Code, so that read-type calls execute directly, risky calls ask the user first, delete-type calls never reach the server, and every decision is logged. The project also includes a browser Playground, a VS Code extension, an MCP server, a standard library, templates, and examples, and is open-sourced under the MIT license.

Open website

About this tool

Purpose

lugh-lang primarily addresses the problem that AI agents may perform destructive operations when executing tool calls. It has two parts: first, the Lugh programming language, used to write agent programs, turning key constraints such as permissions, spending limits, human approval, failure recovery, and audit logging into syntax that is checked before the program runs and recorded while it runs; second, guard mode, which adds a policy layer to MCP servers you already use without rewriting existing configuration.

Key capabilities

  • Policy first: Every action belongs to one of seven effect types, and policies are written for these types. Operations that are not explicitly allowed require approval, so a missing policy line only makes the agent more cautious. Policy denials and budget overruns cannot be caught by attempt, so the agent cannot bypass the limits.
  • Guard mode: A single command wraps all local MCP server entries in Claude Code, Claude Desktop, Cursor, VS Code, and Windsurf, showing the plan first, keeping a backup, and supporting --undo to restore. Read-type calls run directly, destructive calls such as DROP / TRUNCATE / DELETE never reach the server, and other changes ask the user first. You can also protect just a single server.
  • Ready-made policies: Preset policies are provided for servers such as filesystem, github, supabase, stripe, postgres, playwright, slack, and notion, and you can also write your own in a few lines of code.
  • Lugh language: A single .lugh file can serve simultaneously as an API, a web UI, and an approval workflow. An ask human inside a route pauses the request until someone clicks approve or reject in the inbox. Pages are server-rendered HTML with no build step required.
  • Standard library: Includes over 100 functions covering strings and regex, collections, math and statistics, dates, JSON and CSV, hashing and UUID, schema validation, templates, SQLite, a test runner, scheduled tasks, and token authentication.
  • MCP integration: npx lugh-lang mcp provides an MCP server where agents can read the language reference, write programs, check and dry-run them, and then display the policy log.
  • Multi-platform support: The browser Playground runs Lugh compiled to WebAssembly with no installation required; the VS Code extension provides highlighting, snippets, live error checking, and run commands; the Claude Code plugin provides the /lugh:protect skill.
  • Templates and examples: templates/ provides starting points for common agents such as a refund desk, an inbox assistant, and issue triage, each with a one-click Playground link.

Usage

  • Protect existing MCP servers: run npx lugh-lang protect and confirm the plan when prompted.
  • Run a program: npx lugh-lang run program.lugh executes in a sandbox and prints the policy log; the test, check, and sandbox subcommands are also available.
  • Install the MCP server in Claude Code: claude mcp add lugh -- npx -y lugh-lang mcp.
  • Local Playground: lugh playground at http://127.0.0.1:8000 Provide the page.
  • Runtime environment: The Python runtime requires Python 3.9+ and has no dependencies; the native runtime requires Rust 1.70+ to build. The browser adapter requires pip install playwright && playwright install chromium. After setting ANTHROPIC_API_KEY, think uses a real LLM, and LUGH_MODEL selects the model.

Use cases

  • Developers who use tools such as Claude Code, Cursor, and VS Code and connect to databases, GitHub, Slack, payment, and other services via MCP, and want to prevent agents from performing high-risk operations such as deleting, sending messages, and clicking to purchase.
  • Teams that need to set spending limits, human approval, and audit logs for agents.
  • Developers who want to build a full-stack agent application with an approval workflow using a single file.
  • Let the LLM write Lugh programs itself and run them under plan safety: only reads require no asking, and deletions are always blocked.

Limitations

  • The adapters in the Playground act on a simulated world (several files, one HTTP API, and five MCP servers), do not touch real resources, and each run has a 10-second budget.
  • The two runtimes produce consistent results on the included examples, but performance data varies by machine; actual agent time is usually dominated by network and model latency.
  • Some planned capabilities (such as the v0.8 bytecode VM, the v0.9 package manager and language server, and v1.0 TLS and signed audit logs) are marked in the materials as future versions, and whether they are currently available has not been clearly stated.
  • Information on fees, pricing, and commercial support has not been provided; the project is open source under the MIT license.