lugh-lang 0.7.2 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/bin/lugh-lang.mjs +5 -0
- package/lib/guard.mjs +3 -3
- package/lib/protect.mjs +177 -0
- package/lugh.wasm +0 -0
- package/package.json +2 -2
- package/policies/default.lugh +12 -0
- package/policies/notion.lugh +43 -0
- package/policies/playwright.lugh +59 -0
- package/policies/postgres.lugh +29 -0
- package/policies/slack.lugh +36 -0
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ npx lugh-lang test program.lugh # run test blocks
|
|
|
16
16
|
npx lugh-lang check program.lugh # compile only
|
|
17
17
|
npx lugh-lang sandbox # what the simulated world contains
|
|
18
18
|
npx lugh-lang guard --policy <file|pack> -- <mcp server command> # guard a real MCP server
|
|
19
|
+
npx lugh-lang protect [--yes] [--undo] # guard every MCP server in your client configs
|
|
19
20
|
```
|
|
20
21
|
|
|
21
22
|
Commands exit with status 1 when a goal, test or compile step fails.
|
|
@@ -37,6 +38,8 @@ person the policy log before anything runs for real.
|
|
|
37
38
|
|
|
38
39
|
## Guard mode: a policy in front of any MCP server
|
|
39
40
|
|
|
41
|
+
<img src="https://raw.githubusercontent.com/Ashutosh3142857/lugh-lang/main/docs/img/how-it-works.gif" width="820" alt="Lugh guard checking three MCP tool calls: a read runs, a delete is blocked, an insert asks the user first.">
|
|
42
|
+
|
|
40
43
|
Keep the MCP servers you already use and put Lugh's policy gate in front of them:
|
|
41
44
|
|
|
42
45
|
```bash
|
|
@@ -46,7 +49,10 @@ npx -y lugh-lang guard --policy filesystem -- npx -y @modelcontextprotocol/serve
|
|
|
46
49
|
Each tool call gets an effect (from the server's annotations or your policy),
|
|
47
50
|
then passes the gate: budgets, deny, allow, otherwise your client asks you.
|
|
48
51
|
Refused calls never reach the server, and every decision goes to an audit log.
|
|
49
|
-
Bundled policies: `filesystem`, `github`, `supabase`, `stripe`.
|
|
52
|
+
Bundled policies: `default`, `filesystem`, `github`, `supabase`, `stripe`, `postgres`, `playwright`, `slack`, `notion`.
|
|
53
|
+
`npx lugh-lang protect` does this for every server in your Claude Code, Claude
|
|
54
|
+
Desktop, Cursor, VS Code and Windsurf configs at once (it asks first; `--undo`
|
|
55
|
+
reverts). Details:
|
|
50
56
|
[docs/GUARD.md](https://github.com/Ashutosh3142857/lugh-lang/blob/main/docs/GUARD.md).
|
|
51
57
|
|
|
52
58
|
## Running for real
|
package/bin/lugh-lang.mjs
CHANGED
|
@@ -12,6 +12,8 @@ const HELP = `lugh-lang: Lugh, the programming language for AI agents
|
|
|
12
12
|
npx lugh-lang mcp MCP server (stdio) for AI agents
|
|
13
13
|
npx lugh-lang guard --policy <file.lugh> -- <mcp server command>
|
|
14
14
|
put a Lugh policy in front of any MCP server
|
|
15
|
+
npx lugh-lang protect [--yes] [--undo] guard every MCP server in your Claude, Cursor,
|
|
16
|
+
VS Code and Windsurf configs (asks first)
|
|
15
17
|
|
|
16
18
|
The sandbox simulates files, an HTTP API and MCP servers, and every call
|
|
17
19
|
passes the real policy gate. To act on real systems, install Lugh Core:
|
|
@@ -26,6 +28,9 @@ if (cmd === "--version" || cmd === "-v") {
|
|
|
26
28
|
if (cmd === "guard") {
|
|
27
29
|
const { main } = await import("../lib/guard.mjs");
|
|
28
30
|
main(process.argv.slice(3));
|
|
31
|
+
} else if (cmd === "protect") {
|
|
32
|
+
const { main } = await import("../lib/protect.mjs");
|
|
33
|
+
await main(process.argv.slice(3));
|
|
29
34
|
} else {
|
|
30
35
|
const run = await load();
|
|
31
36
|
if (cmd === "mcp") {
|
package/lib/guard.mjs
CHANGED
|
@@ -288,8 +288,8 @@ function lines(stream, onMessage, onBad) {
|
|
|
288
288
|
});
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
-
// A policy is a file path, or the name of a bundled pack (filesystem, github, supabase, stripe).
|
|
292
|
-
export const PACKS = ["filesystem", "github", "supabase", "stripe"];
|
|
291
|
+
// A policy is a file path, or the name of a bundled pack (default, filesystem, github, supabase, stripe, postgres, playwright, slack, notion).
|
|
292
|
+
export const PACKS = ["default", "filesystem", "github", "supabase", "stripe", "postgres", "playwright", "slack", "notion"];
|
|
293
293
|
export function resolvePolicy(name) {
|
|
294
294
|
if (existsSync(name)) return name;
|
|
295
295
|
if (PACKS.includes(name)) return fileURLToPath(new URL(`../policies/${name}.lugh`, import.meta.url));
|
|
@@ -304,7 +304,7 @@ export function main(argv) {
|
|
|
304
304
|
const get = (flag) => { const i = opts.indexOf(flag); return i >= 0 ? opts[i + 1] : undefined; };
|
|
305
305
|
const file = get("--policy");
|
|
306
306
|
if (!file || !cmd.length) {
|
|
307
|
-
process.stderr.write("usage: npx lugh-lang guard --policy <file.lugh | filesystem | github | supabase | stripe> [--audit <log.jsonl>] [--hide-denied] -- <server command> [args...]\n");
|
|
307
|
+
process.stderr.write("usage: npx lugh-lang guard --policy <file.lugh | default | filesystem | github | supabase | stripe | postgres | playwright | slack | notion> [--audit <log.jsonl>] [--hide-denied] -- <server command> [args...]\n");
|
|
308
308
|
process.exit(2);
|
|
309
309
|
}
|
|
310
310
|
let policy;
|
package/lib/protect.mjs
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// lugh-lang protect: put every local MCP server you already use behind Lugh guard.
|
|
2
|
+
//
|
|
3
|
+
// npx lugh-lang protect show the plan, then ask before changing anything
|
|
4
|
+
// npx lugh-lang protect --yes apply without asking
|
|
5
|
+
// npx lugh-lang protect --undo put every config back the way it was
|
|
6
|
+
//
|
|
7
|
+
// It finds MCP configs for Claude Code, Claude Desktop, Cursor, VS Code and
|
|
8
|
+
// Windsurf, and rewrites each local (stdio) server entry from
|
|
9
|
+
// "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "~/docs"]
|
|
10
|
+
// to
|
|
11
|
+
// "command": "npx", "args": ["-y", "lugh-lang", "guard", "--policy", "filesystem", "--",
|
|
12
|
+
// "npx", "-y", "@modelcontextprotocol/server-filesystem", "~/docs"]
|
|
13
|
+
// Nothing else in the file changes. A copy of each file is saved next to it
|
|
14
|
+
// first (<file>.lugh-backup), and --undo unwraps the entries in place, so later
|
|
15
|
+
// edits you made to the file are kept.
|
|
16
|
+
|
|
17
|
+
import { copyFileSync, existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
18
|
+
import { homedir } from "node:os";
|
|
19
|
+
import { join, resolve } from "node:path";
|
|
20
|
+
import { createInterface } from "node:readline";
|
|
21
|
+
|
|
22
|
+
// Where each client keeps its MCP servers. `key` is the object holding the
|
|
23
|
+
// servers; `projects` marks Claude Code's per-project ("local") servers.
|
|
24
|
+
export function configLocations({ home = homedir(), cwd = process.cwd(), platform = process.platform, env = process.env } = {}) {
|
|
25
|
+
const appData = env.APPDATA || join(home, "AppData", "Roaming");
|
|
26
|
+
const appSupport = platform === "darwin" ? join(home, "Library", "Application Support")
|
|
27
|
+
: platform === "win32" ? appData : join(home, ".config");
|
|
28
|
+
const list = [
|
|
29
|
+
{ client: "Claude Code (user and local)", file: join(home, ".claude.json"), key: "mcpServers", projects: true },
|
|
30
|
+
{ client: "Claude Code (this project)", file: join(cwd, ".mcp.json"), key: "mcpServers" },
|
|
31
|
+
{ client: "Claude Desktop", file: join(appSupport, "Claude", "claude_desktop_config.json"), key: "mcpServers" },
|
|
32
|
+
{ client: "Cursor", file: join(home, ".cursor", "mcp.json"), key: "mcpServers" },
|
|
33
|
+
{ client: "Cursor (this project)", file: join(cwd, ".cursor", "mcp.json"), key: "mcpServers" },
|
|
34
|
+
{ client: "VS Code", file: join(appSupport, "Code", "User", "mcp.json"), key: "servers" },
|
|
35
|
+
{ client: "VS Code (this project)", file: join(cwd, ".vscode", "mcp.json"), key: "servers" },
|
|
36
|
+
{ client: "Windsurf", file: join(home, ".codeium", "windsurf", "mcp_config.json"), key: "mcpServers" },
|
|
37
|
+
];
|
|
38
|
+
const seen = new Set();
|
|
39
|
+
return list.filter((l) => { const f = resolve(l.file); if (seen.has(f)) return false; seen.add(f); return true; });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Which bundled policy fits a server, from its command line.
|
|
43
|
+
export function packFor(entry) {
|
|
44
|
+
const s = [entry.command, ...(entry.args || [])].join(" ").toLowerCase();
|
|
45
|
+
if (s.includes("server-filesystem")) return "filesystem";
|
|
46
|
+
if (s.includes("github-mcp-server") || s.includes("server-github") || s.includes("githubcopilot.com/mcp")) return "github";
|
|
47
|
+
if (s.includes("supabase")) return "supabase";
|
|
48
|
+
if (s.includes("mcp.stripe.com") || s.includes("@stripe/mcp")) return "stripe";
|
|
49
|
+
if (s.includes("@playwright/mcp") || s.includes("playwright-mcp")) return "playwright";
|
|
50
|
+
if (s.includes("postgres-mcp") || s.includes("server-postgres") || s.includes("mcp-postgres") || s.includes("postgres-mcp-server")) return "postgres";
|
|
51
|
+
if (s.includes("slack")) return "slack";
|
|
52
|
+
if (s.includes("mcp.notion.com") || s.includes("notion-mcp-server")) return "notion";
|
|
53
|
+
return "default";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const isLugh = (e) => [e.command, ...(e.args || [])].some((a) => typeof a === "string" && /(^|[/@])lugh-lang(@[\w.]+)?$/.test(a));
|
|
57
|
+
|
|
58
|
+
// The guard's own arguments inside a wrapped entry: [... "guard", "--policy", P, (flags), "--", cmd, ...args]
|
|
59
|
+
function unwrapArgs(entry) {
|
|
60
|
+
const args = entry.args || [];
|
|
61
|
+
const g = args.indexOf("guard");
|
|
62
|
+
const sep = args.indexOf("--", g);
|
|
63
|
+
if (g < 0 || sep < 0 || !args.slice(0, g).some((a) => /lugh-lang/.test(a))) return null;
|
|
64
|
+
const inner = args.slice(sep + 1);
|
|
65
|
+
if (!inner.length) return null;
|
|
66
|
+
return { command: inner[0], args: inner.slice(1) };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function wrapEntry(entry, pack, platform = process.platform) {
|
|
70
|
+
const inner = [entry.command, ...(entry.args || [])];
|
|
71
|
+
const guard = ["-y", "lugh-lang", "guard", "--policy", pack, "--", ...inner];
|
|
72
|
+
return platform === "win32"
|
|
73
|
+
? { ...entry, command: "cmd", args: ["/c", "npx", ...guard] }
|
|
74
|
+
: { ...entry, command: "npx", args: guard };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function unwrapEntry(entry) {
|
|
78
|
+
const inner = unwrapArgs(entry);
|
|
79
|
+
return inner ? { ...entry, ...inner } : null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Every server block in one parsed config, with a path for messages.
|
|
83
|
+
function blocks(json, loc) {
|
|
84
|
+
const out = [];
|
|
85
|
+
if (json && typeof json[loc.key] === "object" && json[loc.key]) out.push({ where: "", servers: json[loc.key] });
|
|
86
|
+
if (loc.projects && json && typeof json.projects === "object") {
|
|
87
|
+
for (const [path, p] of Object.entries(json.projects)) {
|
|
88
|
+
if (p && typeof p.mcpServers === "object" && p.mcpServers && Object.keys(p.mcpServers).length) out.push({ where: ` [${path}]`, servers: p.mcpServers });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Work out what would change. Returns one item per config file that has servers.
|
|
95
|
+
export function plan({ undo = false, platform = process.platform, ...where } = {}) {
|
|
96
|
+
const files = [];
|
|
97
|
+
for (const loc of configLocations({ platform, ...where })) {
|
|
98
|
+
if (!existsSync(loc.file)) continue;
|
|
99
|
+
let json;
|
|
100
|
+
try { json = JSON.parse(readFileSync(loc.file, "utf8")); } catch (e) {
|
|
101
|
+
files.push({ ...loc, error: `not valid JSON (${e.message}); left alone` });
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const changes = [];
|
|
105
|
+
for (const b of blocks(json, loc)) {
|
|
106
|
+
for (const [name, entry] of Object.entries(b.servers)) {
|
|
107
|
+
if (!entry || typeof entry !== "object") continue;
|
|
108
|
+
if (undo) {
|
|
109
|
+
const un = unwrapEntry(entry);
|
|
110
|
+
if (un) changes.push({ name: name + b.where, servers: b.servers, key: name, to: un, note: "guard removed" });
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (entry.url || (entry.type && entry.type !== "stdio")) { changes.push({ name: name + b.where, skip: "remote server: guard runs local (stdio) servers; see docs/GUARD.md for mcp-remote" }); continue; }
|
|
114
|
+
if (!entry.command) continue;
|
|
115
|
+
if (unwrapArgs(entry)) { changes.push({ name: name + b.where, skip: "already guarded" }); continue; }
|
|
116
|
+
if (isLugh(entry)) { changes.push({ name: name + b.where, skip: "Lugh's own server" }); continue; }
|
|
117
|
+
const pack = packFor(entry);
|
|
118
|
+
changes.push({ name: name + b.where, servers: b.servers, key: name, to: wrapEntry(entry, pack, platform), note: `guard, policy ${pack}` });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (changes.length) files.push({ ...loc, json, changes });
|
|
122
|
+
}
|
|
123
|
+
return files;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Write the planned changes: backup first, then an atomic replace.
|
|
127
|
+
export function apply(files) {
|
|
128
|
+
let changed = 0;
|
|
129
|
+
for (const f of files) {
|
|
130
|
+
const todo = (f.changes || []).filter((c) => c.to);
|
|
131
|
+
if (!todo.length) continue;
|
|
132
|
+
for (const c of todo) c.servers[c.key] = c.to;
|
|
133
|
+
const backup = f.file + ".lugh-backup";
|
|
134
|
+
copyFileSync(f.file, backup);
|
|
135
|
+
const tmp = f.file + ".lugh-tmp";
|
|
136
|
+
writeFileSync(tmp, JSON.stringify(f.json, null, 2) + "\n");
|
|
137
|
+
renameSync(tmp, f.file);
|
|
138
|
+
changed += todo.length;
|
|
139
|
+
}
|
|
140
|
+
return changed;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function describe(files, undo) {
|
|
144
|
+
if (!files.length) return "No MCP servers found in Claude Code, Claude Desktop, Cursor, VS Code or Windsurf configs.";
|
|
145
|
+
const lines = [];
|
|
146
|
+
for (const f of files) {
|
|
147
|
+
lines.push(`${f.client}: ${f.file}`);
|
|
148
|
+
if (f.error) { lines.push(` ! ${f.error}`); continue; }
|
|
149
|
+
for (const c of f.changes) lines.push(c.to ? ` ✓ ${c.name}: ${c.note}` : ` · ${c.name}: ${c.skip}`);
|
|
150
|
+
}
|
|
151
|
+
return lines.join("\n");
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export async function main(argv) {
|
|
155
|
+
const undo = argv.includes("--undo");
|
|
156
|
+
const yes = argv.includes("--yes") || argv.includes("-y");
|
|
157
|
+
const files = plan({ undo });
|
|
158
|
+
const count = files.flatMap((f) => f.changes || []).filter((c) => c.to).length;
|
|
159
|
+
console.log(describe(files, undo));
|
|
160
|
+
if (!count) {
|
|
161
|
+
console.log(undo ? "\nNothing to undo." : "\nNothing to change.");
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
console.log(undo
|
|
165
|
+
? `\n${count} server(s) will go back to running without guard.`
|
|
166
|
+
: `\n${count} server(s) will run behind Lugh guard. Reads run, risky actions ask you, destructive ones are refused.\nA copy of each file is saved as <file>.lugh-backup; undo any time with: npx lugh-lang protect --undo`);
|
|
167
|
+
if (!yes) {
|
|
168
|
+
if (!process.stdin.isTTY) { console.log("\nRun again with --yes to apply."); return; }
|
|
169
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
170
|
+
const answer = await new Promise((r) => rl.question("\nApply these changes? [y/N] ", r));
|
|
171
|
+
rl.close();
|
|
172
|
+
if (!/^y(es)?$/i.test(answer.trim())) { console.log("No changes made."); return; }
|
|
173
|
+
}
|
|
174
|
+
const n = apply(files);
|
|
175
|
+
console.log(`\nDone: ${n} server(s) ${undo ? "unguarded" : "guarded"}. Restart your MCP clients to pick up the change.`);
|
|
176
|
+
if (!undo) console.log("Every decision is logged to ~/.lugh/guard-audit.jsonl. Policies: https://github.com/Ashutosh3142857/lugh-lang/blob/main/docs/GUARD.md");
|
|
177
|
+
}
|
package/lugh.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lugh-lang",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "Lugh, the programming language for AI agents: check and dry-run programs where policy, budgets and human approval are part of the code. Includes an MCP server.",
|
|
5
5
|
"mcpName": "io.github.Ashutosh3142857/lugh",
|
|
6
6
|
"type": "module",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"exports": { ".": "./lib/runtime.mjs", "./mcp": "./lib/mcp.mjs" },
|
|
9
9
|
"files": ["bin/", "lib/", "policies/", "lugh.wasm", "REFERENCE.md", "README.md"],
|
|
10
10
|
"engines": { "node": ">=18" },
|
|
11
|
-
"scripts": { "test": "node test/mcp.test.mjs && node --test --test-timeout=15000 test/guard.test.mjs" },
|
|
11
|
+
"scripts": { "test": "node test/mcp.test.mjs && node --test --test-timeout=15000 test/guard.test.mjs test/protect.test.mjs" },
|
|
12
12
|
"keywords": ["ai-agents", "mcp-proxy", "mcp-guard", "mcp-security", "agents", "mcp", "model-context-protocol", "mcp-server", "programming-language", "guardrails", "human-in-the-loop", "agent-safety", "policy", "webassembly"],
|
|
13
13
|
"homepage": "https://ashutosh3142857.github.io/lugh-lang/",
|
|
14
14
|
"repository": { "type": "git", "url": "git+https://github.com/Ashutosh3142857/lugh-lang.git", "directory": "npm" },
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Lugh guard policy for any MCP server without a pack of its own.
|
|
2
|
+
# npx -y lugh-lang guard --policy default -- <server command>
|
|
3
|
+
#
|
|
4
|
+
# Reads run freely. Anything that writes, sends, submits, spends money or runs
|
|
5
|
+
# commands asks first. Anything the server marks destructive is refused. Tools
|
|
6
|
+
# that carry no annotations count as submit, so they ask.
|
|
7
|
+
agent DefaultGuard
|
|
8
|
+
budget calls 500
|
|
9
|
+
policy
|
|
10
|
+
allow read
|
|
11
|
+
ask human before write, send, submit, spend, execute
|
|
12
|
+
deny delete
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Lugh guard policy for the Notion MCP server (hosted at mcp.notion.com)
|
|
2
|
+
# npx -y lugh-lang guard --policy notion -- npx -y mcp-remote https://mcp.notion.com/mcp
|
|
3
|
+
#
|
|
4
|
+
# Searching, fetching and querying pages runs freely. Creating, editing,
|
|
5
|
+
# moving and commenting ask first, and so do calendar changes and anything
|
|
6
|
+
# that starts or messages a Notion agent. Deleting pages, databases and
|
|
7
|
+
# comments, and cancelling events, are refused.
|
|
8
|
+
agent NotionGuard
|
|
9
|
+
budget calls 300
|
|
10
|
+
policy
|
|
11
|
+
allow read
|
|
12
|
+
ask human before write, send, submit, execute
|
|
13
|
+
deny delete
|
|
14
|
+
tools
|
|
15
|
+
"notion-delete-*" is delete
|
|
16
|
+
"notion-calendar-cancel-events" is delete
|
|
17
|
+
"notion-create-comment" is send
|
|
18
|
+
"notion-send-message-to-session" is send
|
|
19
|
+
"notion-calendar-create-events" is send
|
|
20
|
+
"notion-calendar-update-events" is send
|
|
21
|
+
"notion-spawn-session" is execute
|
|
22
|
+
"notion-stop-session" is execute
|
|
23
|
+
"notion-update-enabled-skills" is submit
|
|
24
|
+
"notion-resolve-suggested-edit" is submit
|
|
25
|
+
"notion-create-*" is write
|
|
26
|
+
"notion-update-*" is write
|
|
27
|
+
"notion-move-pages" is write
|
|
28
|
+
"notion-duplicate-page" is write
|
|
29
|
+
"notion-restore-pages" is write
|
|
30
|
+
"notion-upload-skill" is write
|
|
31
|
+
"notion-convert-page-to-skill" is write
|
|
32
|
+
"notion-set-*" is write
|
|
33
|
+
"notion-search" is read
|
|
34
|
+
"notion-*-search" is read
|
|
35
|
+
"notion-fetch" is read
|
|
36
|
+
"notion-get-*" is read
|
|
37
|
+
"notion-list-*" is read
|
|
38
|
+
"notion-query-*" is read
|
|
39
|
+
"notion-calendar-list-*" is read
|
|
40
|
+
"notion-search-*" is read
|
|
41
|
+
"notion-download-*" is read
|
|
42
|
+
"notion-read-*" is read
|
|
43
|
+
"notion-wait-session" is read
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Lugh guard policy for the Playwright MCP server (@playwright/mcp)
|
|
2
|
+
# npx -y lugh-lang guard --policy playwright -- npx -y @playwright/mcp@latest
|
|
3
|
+
#
|
|
4
|
+
# Browsing, reading pages and ordinary clicks and typing run freely, so the
|
|
5
|
+
# agent can still get around a site. The moments that commit something ask
|
|
6
|
+
# first: pressing Enter, typing with submit, and clicking anything that looks
|
|
7
|
+
# like buy, pay, send, submit, confirm, delete or sign in. Uploading files
|
|
8
|
+
# asks, and so does running JavaScript in the page or in the server. Clearing
|
|
9
|
+
# cookies and storage is refused. Matching on button labels is a speed bump,
|
|
10
|
+
# not a guarantee: keep the browser profile away from accounts that matter.
|
|
11
|
+
agent PlaywrightGuard
|
|
12
|
+
budget calls 400
|
|
13
|
+
policy
|
|
14
|
+
allow read, write
|
|
15
|
+
ask human before submit, send, execute, spend
|
|
16
|
+
deny delete
|
|
17
|
+
tools
|
|
18
|
+
"browser_click" when element matches "\b(buy|pay|purchase|checkout|check out|order|subscribe|donate|transfer|send|submit|post|publish|confirm|approve|accept|agree|delete|remove|sign in|log in|login|sign up|register)\b" is submit
|
|
19
|
+
"browser_type" when submit matches "true" is submit
|
|
20
|
+
"browser_press_key" when key matches "^enter$" is submit
|
|
21
|
+
"browser_fill_form" when fields matches "password|card|cvc|cvv|iban|ssn" is submit
|
|
22
|
+
"browser_handle_dialog" when accept matches "true" is submit
|
|
23
|
+
"browser_file_upload" is send
|
|
24
|
+
"browser_evaluate" is execute
|
|
25
|
+
"browser_run_code*" is execute
|
|
26
|
+
"browser_route" is execute
|
|
27
|
+
"browser_cookie_clear" is delete
|
|
28
|
+
"browser_cookie_delete" is delete
|
|
29
|
+
"browser_localstorage_clear" is delete
|
|
30
|
+
"browser_localstorage_delete" is delete
|
|
31
|
+
"browser_sessionstorage_clear" is delete
|
|
32
|
+
"browser_sessionstorage_delete" is delete
|
|
33
|
+
"browser_cookie_set" is write
|
|
34
|
+
"browser_*storage_set" is write
|
|
35
|
+
"browser_set_storage_state" is write
|
|
36
|
+
"browser_click" is write
|
|
37
|
+
"browser_type" is write
|
|
38
|
+
"browser_fill_form" is write
|
|
39
|
+
"browser_select_option" is write
|
|
40
|
+
"browser_press_key" is write
|
|
41
|
+
"browser_drag" is write
|
|
42
|
+
"browser_drop" is write
|
|
43
|
+
"browser_mouse_*" is write
|
|
44
|
+
"browser_pdf_save" is write
|
|
45
|
+
"browser_navigate*" is read
|
|
46
|
+
"browser_snapshot" is read
|
|
47
|
+
"browser_take_screenshot" is read
|
|
48
|
+
"browser_console_messages" is read
|
|
49
|
+
"browser_network_request*" is read
|
|
50
|
+
"browser_wait_for" is read
|
|
51
|
+
"browser_tabs" is read
|
|
52
|
+
"browser_hover" is read
|
|
53
|
+
"browser_resize" is read
|
|
54
|
+
"browser_find" is read
|
|
55
|
+
"browser_close" is read
|
|
56
|
+
"browser_*_get" is read
|
|
57
|
+
"browser_*_list" is read
|
|
58
|
+
"browser_get_config" is read
|
|
59
|
+
"browser_verify_*" is read
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Lugh guard policy for Postgres MCP servers
|
|
2
|
+
# npx -y lugh-lang guard --policy postgres -- uvx postgres-mcp --access-mode=unrestricted
|
|
3
|
+
# npx -y lugh-lang guard --policy postgres -- npx -y @modelcontextprotocol/server-postgres postgresql://localhost/mydb
|
|
4
|
+
#
|
|
5
|
+
# Plain reads run freely. SQL that drops, truncates or deletes is refused
|
|
6
|
+
# before it reaches the database. Anything else that changes data or schema
|
|
7
|
+
# asks first, and so does SQL this policy can't classify. Pattern rules are a
|
|
8
|
+
# speed bump, not a parser: connect with a read-only role wherever writes are
|
|
9
|
+
# not needed.
|
|
10
|
+
agent PostgresGuard
|
|
11
|
+
budget calls 200
|
|
12
|
+
policy
|
|
13
|
+
allow read
|
|
14
|
+
ask human before write, execute, submit
|
|
15
|
+
deny delete
|
|
16
|
+
tools
|
|
17
|
+
"*" when sql matches "\b(drop|truncate|delete|revoke)\b" is delete
|
|
18
|
+
"*" when query matches "\b(drop|truncate|delete|revoke)\b" is delete
|
|
19
|
+
"*" when sql matches "\b(insert|update|merge|create|alter|grant|copy|vacuum|reindex|cluster|call|do|into|set|lock|refresh|comment|security|execute|prepare|listen|notify|pg_terminate_backend|pg_cancel_backend|lo_import|lo_export|dblink)\b" is write
|
|
20
|
+
"*" when query matches "\b(insert|update|merge|create|alter|grant|copy|vacuum|reindex|cluster|call|do|into|set|lock|refresh|comment|security|execute|prepare|listen|notify|pg_terminate_backend|pg_cancel_backend|lo_import|lo_export|dblink)\b" is write
|
|
21
|
+
"explain_query" when analyze matches "true" is execute
|
|
22
|
+
"execute_sql" when sql matches "^\s*(select|with|show|explain|table|values)\b" is read
|
|
23
|
+
"query" when sql matches "^\s*(select|with|show|explain|table|values)\b" is read
|
|
24
|
+
"execute_sql" is execute
|
|
25
|
+
"query" is execute
|
|
26
|
+
"explain_query" is read
|
|
27
|
+
"list_*" is read
|
|
28
|
+
"get_*" is read
|
|
29
|
+
"analyze_*" is read
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Lugh guard policy for Slack MCP servers (Slack's own server, korotovsky/slack-mcp-server,
|
|
2
|
+
# and the older @modelcontextprotocol/server-slack)
|
|
3
|
+
# npx -y lugh-lang guard --policy slack -- npx -y @modelcontextprotocol/server-slack
|
|
4
|
+
#
|
|
5
|
+
# Reading channels, threads, users and search results runs freely. Every
|
|
6
|
+
# message, reply or scheduled message asks first, so nothing is posted in
|
|
7
|
+
# your name without you seeing it. Reactions, marking as read and saved items
|
|
8
|
+
# run. Changing user groups and canvases asks. Deleting anything is refused.
|
|
9
|
+
agent SlackGuard
|
|
10
|
+
budget calls 300
|
|
11
|
+
policy
|
|
12
|
+
allow read, write
|
|
13
|
+
ask human before send, submit
|
|
14
|
+
deny delete
|
|
15
|
+
tools
|
|
16
|
+
"*delete*" is delete
|
|
17
|
+
"*send_message*" is send
|
|
18
|
+
"*schedule_message*" is send
|
|
19
|
+
"*post_message*" is send
|
|
20
|
+
"*reply_to_thread*" is send
|
|
21
|
+
"*add_message*" is send
|
|
22
|
+
"*canvas*" is submit
|
|
23
|
+
"usergroups_create" is submit
|
|
24
|
+
"usergroups_update" is submit
|
|
25
|
+
"usergroups_users_update" is submit
|
|
26
|
+
"*reaction*" is write
|
|
27
|
+
"conversations_mark" is write
|
|
28
|
+
"saved_*" is write
|
|
29
|
+
"*list*" is read
|
|
30
|
+
"*get*" is read
|
|
31
|
+
"*search*" is read
|
|
32
|
+
"*read*" is read
|
|
33
|
+
"*history*" is read
|
|
34
|
+
"*replies*" is read
|
|
35
|
+
"*unreads*" is read
|
|
36
|
+
"usergroups_me" is read
|