lugh-lang 0.7.3 → 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 +3 -1
- package/lib/guard.mjs +3 -3
- package/lib/protect.mjs +4 -0
- package/lugh.wasm +0 -0
- package/package.json +1 -1
- 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
|
@@ -38,6 +38,8 @@ person the policy log before anything runs for real.
|
|
|
38
38
|
|
|
39
39
|
## Guard mode: a policy in front of any MCP server
|
|
40
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
|
+
|
|
41
43
|
Keep the MCP servers you already use and put Lugh's policy gate in front of them:
|
|
42
44
|
|
|
43
45
|
```bash
|
|
@@ -47,7 +49,7 @@ npx -y lugh-lang guard --policy filesystem -- npx -y @modelcontextprotocol/serve
|
|
|
47
49
|
Each tool call gets an effect (from the server's annotations or your policy),
|
|
48
50
|
then passes the gate: budgets, deny, allow, otherwise your client asks you.
|
|
49
51
|
Refused calls never reach the server, and every decision goes to an audit log.
|
|
50
|
-
Bundled policies: `default`, `filesystem`, `github`, `supabase`, `stripe`.
|
|
52
|
+
Bundled policies: `default`, `filesystem`, `github`, `supabase`, `stripe`, `postgres`, `playwright`, `slack`, `notion`.
|
|
51
53
|
`npx lugh-lang protect` does this for every server in your Claude Code, Claude
|
|
52
54
|
Desktop, Cursor, VS Code and Windsurf configs at once (it asks first; `--undo`
|
|
53
55
|
reverts). Details:
|
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 (default, filesystem, github, supabase, stripe).
|
|
292
|
-
export const PACKS = ["default", "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 | default | 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
CHANGED
|
@@ -46,6 +46,10 @@ export function packFor(entry) {
|
|
|
46
46
|
if (s.includes("github-mcp-server") || s.includes("server-github") || s.includes("githubcopilot.com/mcp")) return "github";
|
|
47
47
|
if (s.includes("supabase")) return "supabase";
|
|
48
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";
|
|
49
53
|
return "default";
|
|
50
54
|
}
|
|
51
55
|
|
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",
|
|
@@ -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
|