@lefine/mcp 0.2.7 → 1.0.0-rc.1

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 CHANGED
@@ -1,69 +1,119 @@
1
1
  # @lefine/mcp
2
2
 
3
- Lefine for AI agents. Claude, Cursor and other MCP clients can translate your app, edit and publish
4
- website pages, and make localized videos, with you approving anything that goes live.
3
+ Lefine as an MCP server for Claude, Cursor, VS Code, Codex and other AI apps. It does two things:
5
4
 
6
- ## Sign in
5
+ 1. **Passes through** Lefine's tools (`https://dash.lefine.ai/v1/mcp`) with your sign-in, so the agent can
6
+ translate your app, edit pages and drafts, and launch new markets. The list comes from the server, so a
7
+ new action reaches you without updating this package.
8
+ 2. **Adds local tools** that only a process on your machine can offer: upload a picture or a whole folder,
9
+ import your translation files, and read which Lefine project a code folder belongs to.
10
+
11
+ Who approves a publish depends on how you signed in. An AI app you connected with `npx @lefine/mcp setup` (sign-in in the browser) asks a person first, in the app or on a Lefine approval page. A plain API key (`LEFINE_TOKEN`) publishes right away, unless the workspace owner turned on **Ask me before agents publish or change content** (Lefine, Settings, API keys, Agent approvals). That switch is off by default.
12
+
13
+ ## Install
7
14
 
8
15
  ```sh
9
- npx lefine login
16
+ npx @lefine/mcp # in a terminal: the setup wizard
10
17
  ```
11
18
 
12
- Or set `LEFINE_TOKEN` to a key from Lefine, Settings > API keys. To let the agent reach Content,
13
- Studio or your connected apps, make the key there and tick them under "Also reach".
19
+ The wizard finds your AI apps (Claude Code, Cursor, VS Code, Windsurf, Codex, Gemini CLI, Zed), adds Lefine to
20
+ the ones you pick, checks that the server answers and tells you the one click each app needs to sign in.
21
+ `--list`, `--doctor`, `--remove`, `--yes`, `--readonly`, `--project`, `--print` work as in `npx lefine setup`.
14
22
 
15
- ## Add it to your client
16
-
17
- **Claude Desktop** (`claude_desktop_config.json`), and any client that starts a local server:
23
+ To run it as a server by hand, in a client config that starts a process (Claude Desktop, some IDEs):
18
24
 
19
25
  ```json
20
- {
21
- "mcpServers": {
22
- "lefine": { "command": "npx", "args": ["-y", "lefine", "mcp"] }
23
- }
24
- }
26
+ { "mcpServers": { "lefine": { "command": "npx", "args": ["-y", "@lefine/mcp"] } } }
25
27
  ```
26
28
 
27
- **Claude, ChatGPT, Claude Code, Cursor, VS Code and other remote-capable clients** can skip this
28
- package and connect to the server directly. They sign in to Lefine with OAuth, so there is no key to
29
- copy:
29
+ When stdin is not a terminal (an AI app started it) this package is the stdio server. Existing configs that say
30
+ `npx -y @lefine/mcp` or `npx -y lefine mcp` keep working. Needs Node 20 or newer.
30
31
 
31
- ```sh
32
- claude mcp add --transport http lefine https://dash.lefine.ai/v1/mcp
33
- ```
34
-
35
- In Claude, add the same URL under Settings > Connectors > Add custom connector. A key also works:
36
- add `--header "Authorization: Bearer <key>"`.
32
+ **Sign in** with `npx @lefine/mcp setup` (or `npx lefine login`), or set `LEFINE_TOKEN` to a key from
33
+ Lefine, Settings > API keys. Tick Content or Studio on the key if the agent needs them.
37
34
 
38
- ## What the agent gets
35
+ ## Tools
39
36
 
40
- Five tools, whatever your plan:
37
+ From the server (always in sync, listed with `tools/list` and kept for 5 minutes):
41
38
 
42
39
  | Tool | What it does |
43
40
  |---|---|
44
- | `lefine_context` | The workspace, the modules that are on, and what the key may do. |
41
+ | `lefine_context` | The workspace, the modules that are on, what the key may read, write and publish. Call it first. |
45
42
  | `lefine_find` | Find an action by words, with its input schema. |
43
+ | `lefine_lookup` | Find a page, key, media file, app, project, type or global by name ("z5k privacy page"). |
46
44
  | `lefine_read` | Run an action that only reads. |
47
- | `lefine_write` | Run an action that writes drafts. Nothing goes live. |
48
- | `lefine_publish` | Run an action that goes live or spends credits. It asks you first. |
45
+ | `lefine_write` | Run an action that writes drafts. Nothing goes live. `steps` runs up to 50 at once. |
46
+ | `lefine_publish` | Run an action that goes live. A connected AI app asks a person first (a batch is one yes for the exact list); an API key publishes right away unless Agent approvals is on. |
47
+ | `lefine_edit` | Change fields of one page, global or key by name, as a draft. `dryRun` shows the diff. |
48
+ | `lefine_launch`, `lefine_launch_status` | Take the workspace into a new market; read how it went. |
49
49
 
50
- Every action, with what it needs: run `npx lefine actions` (add words to filter, e.g. `npx lefine actions content`).
50
+ Added here, answered on your machine:
51
51
 
52
- The tools live on Lefine's server, so a new action reaches you without updating this package.
52
+ | Tool | What it does |
53
+ |---|---|
54
+ | `lefine_project` | Reads `lefine.ts` and `lefine.config.*` in the working folder (as text, never run) for the app and project ids, so the agent does not ask you. |
55
+ | `lefine_upload_file` `{path, project?, alt?, folder?}` | One png, jpg, gif, webp, avif, mp4 or PDF (not svg) to a Content project's media library. Answers `mediaId` and `url`. |
56
+ | `lefine_upload_folder` `{path, project?, pattern?, skip?}` | Up to 50 files per call, 4 at a time, as a table. `pattern` is a glob (`*` top level, `**/*.png` deep). `skip` takes the next batch. |
57
+ | `lefine_import_locale_files` `{path, app?, format?, locale?, namespace?, dryRun?, confirmPlan?}` | `.json` `.arb` `.yaml` `.yml` `.xml` `.xlf` `.xliff` `.properties` `.po` files into a Strings app. First call is a dry run: counts and a plan id, nothing written. The second call (`dryRun: false`) is a normal Lefine write: the server may ask a person to approve it. `confirmPlan` is only the plan id (a stale one stops the import), not an approval. Imports are drafts. |
58
+ | `lefine_find_similar_key`, `lefine_add_key` | For coding agents: find a key before adding one; add refuses duplicates and bad ICU. |
59
+
60
+ `project` and `app` take a name, a slug or an id; an unclear name lists the candidates. Left out, they come from
61
+ `lefine.config.*` / `lefine.ts` in the working folder, or the workspace's only project.
53
62
 
54
- ## Options
63
+ ## Flags
55
64
 
56
- - `LEFINE_TOKEN`: the key to use (wins over the saved one).
57
- - `LEFINE_API_URL`: another Lefine server. A saved key is only sent to the server it was saved for.
58
- - `lefine-mcp --version`, `lefine-mcp --help`.
65
+ ```
66
+ --read-only Only reading tools. Hides write, publish, edit, launch and the local write tools,
67
+ and asks the server for a read ceiling (?level=read), so a tool this package does
68
+ not know still cannot write.
69
+ --toolsets=a,b Only these modules: strings, content, studio, social, sites, brain, integrations.
70
+ Actions of other modules are refused; local tools of other modules are hidden.
71
+ --allow-dir <folder> Let local tools read this folder too (repeatable).
72
+ --tools-ttl <seconds> How long the server's tool list is kept (default 300; 0 asks every time).
73
+ --version, --help
74
+ ```
59
75
 
60
- Logs go to stderr; stdout carries only MCP messages.
76
+ Environment: `LEFINE_TOKEN`, `LEFINE_API_URL`, `LEFINE_PROFILE`, `LEFINE_MCP_READ_ONLY=1`,
77
+ `LEFINE_MCP_TOOLSETS`, `LEFINE_MCP_ALLOW_DIRS`, `LEFINE_MCP_TOOLS_TTL`. Logs go to stderr; stdout carries only
78
+ MCP messages.
79
+
80
+ ## Security
81
+
82
+ What the local tools can read and write, exactly:
83
+
84
+ - **Read: only inside the folder the server runs in**, plus each `--allow-dir`. `../`, absolute paths elsewhere and
85
+ symlinks that lead out are refused. In any letter case, `.git`, `.ssh`, `.aws`, `.gnupg`, `.kube`, `.docker`,
86
+ `.config`, `.lefine`, `node_modules`, `.env*`, `.git-credentials`, `.pgpass`, `.netrc`, `.npmrc`, `.pypirc`,
87
+ `.htpasswd`, `id_rsa*`, `id_ed25519*`, `*.pem`, `*.key`, `*.p12`, `*.pfx`, shell history and `credentials*` are never
88
+ read, even inside an allowed folder.
89
+ - **No broad root.** If the server starts in `/`, your home directory or a parent of it (`/Users`, `/home`), the local
90
+ file tools are off (one line on stderr) until you pass `--allow-dir <project folder>`. `--allow-dir` itself is
91
+ refused for `/`, home, its parents, `~/.ssh`, `~/.aws` and the like.
92
+ - **Which files:** uploads take png, jpg, gif, webp, avif, mp4 and PDF (not svg), 8 MB, and the first bytes must
93
+ match the name. Locale import takes only `.json .arb .yaml .yml .xml .xlf .xliff .properties .po`; `format`
94
+ chooses the parser and never widens what is read.
95
+ - **Write: only through the server.** The local tools never call a write on the API themselves. Uploads, imports and
96
+ `lefine_add_key` are sent as the server's own `lefine_write` call, so the server's approvals (a person says yes in
97
+ Lefine), its MCP ledger and the `--read-only` ceiling apply. The dry run of an import stays local and writes
98
+ nothing. A plan id is not consent.
99
+ - **The key stays on your machine.** It goes only to the server it was saved for and never appears in tool
100
+ output. `lefine.ts` and `lefine.config.*` are read as text: a cloned repository cannot run code by starting
101
+ this server. Text from your files is marked as data in answers; do not let an agent treat it as instructions.
102
+ - **Publishing asks a person first for a connected AI app, not for an API key.** With `LEFINE_TOKEN` and Agent approvals off (the default), a publish runs at once; each change is still recorded. Turn Agent approvals on in Lefine settings, or use `--read-only`, if an agent must not publish alone.
103
+ - Not covered: a folder renamed between the path check and the read could redirect the open. Someone who can
104
+ do that already has your account's files.
105
+
106
+ A 401 means the key is wrong or expired: run `npx @lefine/mcp setup`.
107
+
108
+ ## Remote, without this package
109
+
110
+ Clients that speak remote MCP can skip the package and sign in with OAuth, no key to copy:
61
111
 
62
- ## Two tools for coding agents
112
+ ```sh
113
+ claude mcp add --transport http --scope user lefine https://dash.lefine.ai/v1/mcp
114
+ ```
63
115
 
64
- `npx lefine mcp` (and this alias) add two tools next to the server's, answered on your machine:
116
+ Then `/mcp` in Claude Code, pick lefine, Authenticate. Read-only: `https://dash.lefine.ai/v1/mcp?level=read`.
117
+ The local tools above need this package, because the remote server cannot see your disk.
65
118
 
66
- - `lefine_find_similar_key`: keys whose name or source text is like the one you want, closest first. Agents call it first.
67
- - `lefine_add_key`: adds one key with its source text, and refuses with the reason when the key exists in any namespace,
68
- the same text already has a key, the namespace does not exist (`newNamespace: true` to make one), or the text is not
69
- valid ICU. A new key is not live until someone publishes.
119
+ Every action and what it needs: `npx lefine actions` (add words to filter).
package/bin/lefine-mcp.js CHANGED
@@ -1,11 +1,25 @@
1
1
  #!/usr/bin/env node
2
- // @lefine/mcp is `lefine mcp` now. This name keeps working for configs that already say `npx -y @lefine/mcp`.
2
+ // `npx @lefine/mcp` is the friendly front door to Lefine's MCP server.
3
+ // In a terminal, no arguments: the setup wizard (same code as `npx lefine setup`).
4
+ // `setup`, `--remove`, `--list`, `--doctor`, `--print`: the same as `lefine setup ...`.
5
+ // Started by an AI app (stdin is not a terminal): the stdio server, as before. Existing configs that say
6
+ // `npx -y @lefine/mcp` keep working.
3
7
  import { readFileSync } from "node:fs";
4
8
  import { createRequire } from "node:module";
5
9
  import { dirname, join } from "node:path";
6
10
  import { pathToFileURL } from "node:url";
11
+ import { metaOutput } from "./meta.js";
12
+ import { routeArgs } from "./route.js";
13
+
14
+ const own = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
15
+ const meta = metaOutput(process.argv.slice(2), own.version);
16
+ if (meta !== null) {
17
+ process.stdout.write(meta);
18
+ process.exit(0);
19
+ }
7
20
 
8
21
  const manifest = createRequire(import.meta.url).resolve("lefine/package.json");
9
22
  const { bin } = JSON.parse(readFileSync(manifest, "utf-8"));
10
- process.argv.splice(2, 0, "mcp");
23
+ const args = process.argv.slice(2);
24
+ process.argv.splice(2, args.length, ...routeArgs(args, { stdinIsTTY: process.stdin.isTTY === true, stdoutIsTTY: process.stdout.isTTY === true }));
11
25
  await import(pathToFileURL(join(dirname(manifest), bin.lefine)).href);
package/bin/meta.js ADDED
@@ -0,0 +1,31 @@
1
+ // `--version` and `--help` of the `lefine-mcp` bin: its own name and version, and the flags the server takes.
2
+ // Pure, so a test can read it. Only as the first argument: `setup --help` still belongs to `lefine setup`.
3
+
4
+ export const HELP = `lefine-mcp: Lefine's MCP server and setup (npx @lefine/mcp)
5
+
6
+ Usage:
7
+ npx @lefine/mcp in a terminal: the setup wizard
8
+ npx @lefine/mcp setup [flags] add Lefine to your AI apps (--list, --remove, --doctor, --print, --yes, --client <name>, --readonly, --project)
9
+ npx @lefine/mcp [flags] started by an AI app (stdin is not a terminal): the stdio server
10
+
11
+ Server flags:
12
+ --read-only only reading tools (also asks the server for a read ceiling)
13
+ --toolsets <list> only these modules, comma separated (strings, content, studio, social, sites, brain, integrations)
14
+ --allow-dir <dir> a folder besides the working folder that local tools may read (repeatable)
15
+ --tools-ttl <seconds> how long the server's tool list is kept (default 300)
16
+ --version, --help
17
+
18
+ Sign in: npx @lefine/mcp setup (or npx lefine login, or set LEFINE_TOKEN)
19
+ Environment: LEFINE_TOKEN, LEFINE_API_URL, LEFINE_PROFILE, LEFINE_MCP_READ_ONLY=1, LEFINE_MCP_TOOLSETS,
20
+ LEFINE_MCP_ALLOW_DIRS, LEFINE_MCP_TOOLS_TTL
21
+ Publishing: an API key publishes right away unless Agent approvals is on in Lefine settings.
22
+ Logs go to stderr; stdout carries only MCP messages.
23
+ `;
24
+
25
+ /** What to print for `--version` / `--help` as the first argument, or null when the call is something else. */
26
+ export function metaOutput(args, version) {
27
+ const [first] = args;
28
+ if (first === "--version" || first === "-v") return `${version}\n`;
29
+ if (first === "--help" || first === "-h") return HELP;
30
+ return null;
31
+ }
package/bin/route.js ADDED
@@ -0,0 +1,16 @@
1
+ // Which `lefine` command an `npx @lefine/mcp ...` call means. Pure, so a test can read it.
2
+ //
3
+ // started by an AI app (stdin is not a terminal), or `mcp`: the stdio server, as always
4
+ // `setup` and its flags (--remove --list --doctor --print --yes ...): the setup wizard, same as `lefine setup`
5
+ // no arguments in a terminal: the setup wizard (a person typed `npx @lefine/mcp`)
6
+ const SETUP_FLAGS = new Set(["--remove", "--list", "--doctor", "--print", "--yes", "-y", "--client", "--readonly", "--project", "--local", "--json", "--no-backup", "--no-check", "--api-url"]);
7
+
8
+ /** Arguments to hand to the `lefine` bin, after node and the script. */
9
+ export function routeArgs(args, { stdinIsTTY, stdoutIsTTY }) {
10
+ const [first] = args;
11
+ if (first === "setup") return args;
12
+ if (first === "mcp") return args;
13
+ if (first !== undefined && SETUP_FLAGS.has(first.split("=")[0])) return ["setup", ...args];
14
+ if (args.length === 0 && stdinIsTTY && stdoutIsTTY) return ["setup"];
15
+ return ["mcp", ...args];
16
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lefine/mcp",
3
- "version": "0.2.7",
4
- "description": "Lefine as an MCP server for Claude Desktop, Cursor and other agents (same as `npx lefine mcp`)",
3
+ "version": "1.0.0-rc.1",
4
+ "description": "Set up Lefine in your AI apps with one command (npx @lefine/mcp), and the stdio server an app starts",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "bin": {
@@ -36,6 +36,6 @@
36
36
  "node": ">=20"
37
37
  },
38
38
  "dependencies": {
39
- "lefine": "^0.8.1"
39
+ "lefine": "^0.11.0"
40
40
  }
41
41
  }