altalandi-mcp 0.3.0 → 0.7.7

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,71 +1,112 @@
1
- # altalandi-mcp
2
-
3
- An [MCP](https://modelcontextprotocol.io) server that exposes
4
- [Altalandi](https://altalandi.is), native-Icelandic refinement with a
5
- meaning-preservation check, as a tool any MCP client can call. stdio transport.
6
-
7
- ## Set up (Claude Code or Codex)
8
-
9
- Connect this computer once. This opens altalandi.is, you approve, and the key
10
- is stored locally. You never copy it:
11
-
12
- ```bash
13
- npx altalandi login
14
- ```
15
-
16
- Then add the server. No key goes into any config file; the server reads the
17
- one `altalandi login` stored:
18
-
19
- ```bash
20
- claude mcp add altalandi -s user -- npx -y altalandi-mcp # Claude Code
21
- codex mcp add altalandi -- npx -y altalandi-mcp # Codex
22
- ```
23
-
24
- Ask for Icelandic and mention Altalandi, e.g. *"Write this in proper Icelandic
25
- with Altalandi."* The agent calls the **`refine_icelandic`** tool.
26
-
27
- ### Without `altalandi login` (CI, services, other clients)
28
-
29
- Set `ALTALANDI_API_KEY` in the server's environment, from your host's secret
30
- manager. It takes precedence over a stored login. Mint a key at
31
- <https://altalandi.is/portal>. Never commit a plaintext key in MCP JSON.
32
-
33
- ```json
34
- { "mcpServers": { "altalandi": { "command": "npx", "args": ["-y", "altalandi-mcp"] } } }
35
- ```
36
-
37
- ## The tool
38
-
39
- `refine_icelandic({ text, domain?, register?, sourceLang? })` returns the native
40
- Icelandic text, a 0–100 nativeness score, an explicit meaning verdict, and every
41
- warning returned by the API.
42
-
43
- - `domain`: `general` \| `marketing` \| `data-analysis` \| `childrens-fiction`
44
- - `register`: `formal` \| `neutral` \| `warm`
45
- - `sourceLang`: `auto` \| `en` \| `is`
46
-
47
- **Meaning guarantee:** on Icelandic input where the rewrite can't be verified to
48
- preserve meaning, the tool returns the **original unchanged** and flags it,
49
- never a silent change.
50
-
51
- Only **meaning preserved** is a verified result. **MEANING UNVERIFIED** means the
52
- check did not run or could not complete; review that output before use. API
53
- warnings are included under a clear `Warnings:` section in the tool's result.
54
-
55
- ## Config
56
-
57
- | env | default | purpose |
58
- |-----|---------|---------|
59
- | `ALTALANDI_API_KEY` | (the key from `altalandi login`) | your key (Bearer) |
60
- | `ALTALANDI_CONFIG_DIR` | `%APPDATA%\altalandi` / `~/.config/altalandi` | where `altalandi login` stored it |
61
- | `ALTALANDI_BASE_URL` | `https://altalandi.is/api` | API base (override for self-hosting) |
62
-
63
- Each API request has a fixed 300-second deadline, including the response body,
64
- so a stalled provider cannot leave the tool hanging.
65
-
66
- ## Cost
67
-
68
- Calls are paid from the account's prepaid credit in krónur (a new account
69
- starts with trial credit). See <https://altalandi.is/verd>.
70
-
71
- MIT licensed. Requires Node ≥ 18.
1
+ # altalandi-mcp
2
+
3
+ An [MCP](https://modelcontextprotocol.io) server that exposes
4
+ [Altalandi](https://altalandi.is), native-Icelandic refinement with a
5
+ meaning-preservation check, as a tool any MCP client can call. stdio transport.
6
+
7
+ ## Set up (Claude Code or Codex)
8
+
9
+ Connect this computer once. This opens altalandi.is, you approve, and the key
10
+ is stored locally. You never copy it:
11
+
12
+ ```bash
13
+ npx altalandi login
14
+ ```
15
+
16
+ Then add the server. No key goes into any config file; the server reads the
17
+ one `altalandi login` stored:
18
+
19
+ ```bash
20
+ claude mcp add altalandi -s user -- npx -y altalandi-mcp # Claude Code
21
+ codex mcp add altalandi -- npx -y altalandi-mcp # Codex
22
+ ```
23
+
24
+ Ask for Icelandic and mention Altalandi, e.g. *"Write this in proper Icelandic
25
+ with Altalandi."* The agent calls the **`refine_icelandic`** tool.
26
+
27
+ ### Without `altalandi login` (CI, services, other clients)
28
+
29
+ Set `ALTALANDI_API_KEY` in the server's environment, from your host's secret
30
+ manager. It takes precedence over a stored login. Mint a key at
31
+ <https://altalandi.is/portal>. Never commit a plaintext key in MCP JSON.
32
+
33
+ ```json
34
+ { "mcpServers": { "altalandi": { "command": "npx", "args": ["-y", "altalandi-mcp"] } } }
35
+ ```
36
+
37
+ ## The tool
38
+
39
+ `refine_icelandic({ text, domain?, register?, sourceLang?, report? })` returns two
40
+ parts. The first is one Markdown block: the verdict and nativeness score, the text
41
+ before and after (Fyrir / Eftir), a numbered list of changes with their reasons,
42
+ why a rewrite was refused if it was, and what the call cost with the balance and
43
+ free units left (Kostnaður). The second is the full refined text to apply. The
44
+ tool tells the agent to show the block to you as it is after every call, so you see
45
+ what changed and what it cost in the terminal or the editor, not only on the website.
46
+
47
+ - `domain`: `general` \| `marketing` \| `data-analysis` \| `childrens-fiction`
48
+ - `register`: `formal` \| `neutral` \| `warm`
49
+ - `sourceLang`: `auto` \| `en` \| `is`
50
+ - `noStore`: `true` means Altalandi never keeps this text. Otherwise free use (the free
51
+ daily units) is kept, with personal data scrubbed, to improve the service; paid use only
52
+ with consent ([privacy](https://altalandi.is/personuvernd#textabanki)).
53
+ - `report`: `true` also writes `./altalandi-reports/altalandi-<time>-<id>.md`
54
+ (input, output, every change with its reason and layer, warnings, verdict).
55
+ Default: on when `ALTALANDI_REPORT=1`. Reports contain the text, so they are opt-in.
56
+
57
+ **Meaning guarantee:** on Icelandic input where the rewrite can't be verified to
58
+ preserve meaning, the tool returns the **original unchanged** and flags it,
59
+ never a silent change.
60
+
61
+ ## Proofreading
62
+
63
+ `proofread_icelandic({ text, suggestions?, minPrecision?, noStore? })` fixes only
64
+ proven errors in Icelandic you wrote (punctuation, word boundaries, a misspelt word
65
+ one slip from the right one) and keeps your wording. Everything else comes back as
66
+ numbered **suggestions**, each with its reason and, when known, how sure it is. The
67
+ agent shows you each one and applies only those you accept.
68
+
69
+ - `suggestions`: `offer` (default: you choose) \| `apply` (the kinds of suggestion
70
+ measured right at least `minPrecision` of the time are applied and listed; the rest
71
+ are offered) \| `off` (only the safe fixes).
72
+ - `minPrecision`: 0.5 to 0.99, default 0.9. A suggestion with a digit, or one that
73
+ changes a name, is never applied unasked.
74
+
75
+ Then `record_suggestion_decisions({ resultId, decisions })` tells Altalandi which
76
+ suggestions you used or ignored (numbers only, no text, free). That is how the
77
+ suggestions get better.
78
+
79
+ Only **meaning preserved** is a verified result. **MEANING UNVERIFIED** means the
80
+ check did not run or could not complete; review that output before use. API
81
+ warnings are included under a clear `Warnings:` section in the tool's result.
82
+
83
+ ## The Altalandi card
84
+
85
+ In hosts that render MCP Apps (Claude Desktop, claude.ai), results appear in an
86
+ Altalandi card: the text with a copy button, whether the meaning check passed,
87
+ each change with its reason, and for proofreading each suggestion with **Nota**
88
+ and **Hunsa** buttons. The card records the decisions itself. Terminals (Claude
89
+ Code, Codex) get the same text as before. The server offers the card as the
90
+ resource `ui://altalandi/result-v1.html`; both tools return its data as
91
+ `structuredContent`.
92
+
93
+ ## Config
94
+
95
+ | env | default | purpose |
96
+ |-----|---------|---------|
97
+ | `ALTALANDI_API_KEY` | (the key from `altalandi login`) | your key (Bearer) |
98
+ | `ALTALANDI_CONFIG_DIR` | `%APPDATA%\altalandi` / `~/.config/altalandi` | where `altalandi login` stored it |
99
+ | `ALTALANDI_BASE_URL` | `https://altalandi.is/api` | API base (override for self-hosting) |
100
+ | `ALTALANDI_REPORT` | — | `1` = write a report for every call |
101
+ | `ALTALANDI_REPORT_DIR` | `./altalandi-reports` (the server's working folder) | where reports go |
102
+
103
+ Each API request has a fixed 300-second deadline, including the response body,
104
+ so a stalled provider cannot leave the tool hanging.
105
+
106
+ ## Cost
107
+
108
+ Every account gets 2,000 free units a day on the standard writer (about 2,000
109
+ words); past that, calls are paid from prepaid credit in krónur, and a new account
110
+ also starts with 500 kr. of trial credit. See <https://altalandi.is/verd>.
111
+
112
+ MIT licensed. Requires Node ≥ 18.
package/api-client.mjs CHANGED
@@ -52,3 +52,34 @@ export async function requestRefine(
52
52
  clearTimeoutImpl(timeout);
53
53
  }
54
54
  }
55
+
56
+ /** The account behind the key (balance, free units), or null. Best-effort:
57
+ * it only fills the cost lines of the review block. */
58
+ export async function requestMe(baseUrl, apiKey, { fetchImpl = globalThis.fetch } = {}) {
59
+ try {
60
+ const response = await fetchImpl(`${baseUrl}/v1/me`, {
61
+ headers: { authorization: `Bearer ${apiKey}`, accept: "application/json" },
62
+ signal: AbortSignal.timeout(15_000),
63
+ });
64
+ return response.ok ? await response.json() : null;
65
+ } catch {
66
+ return null;
67
+ }
68
+ }
69
+
70
+ /** Report what the person chose for each proofreading suggestion (free; no
71
+ * model runs; no text is sent). Returns {ok, recorded, refused} or {ok: false, error}. */
72
+ export async function requestSuggestionDecisions(baseUrl, apiKey, body, { fetchImpl = globalThis.fetch } = {}) {
73
+ try {
74
+ const response = await fetchImpl(`${baseUrl}/v1/suggestions`, {
75
+ method: "POST",
76
+ headers: { "content-type": "application/json", authorization: `Bearer ${apiKey}` },
77
+ body: JSON.stringify(body),
78
+ signal: AbortSignal.timeout(15_000),
79
+ });
80
+ const data = await response.json().catch(() => ({}));
81
+ return response.ok ? data : { ok: false, error: data.detail || response.statusText };
82
+ } catch (error) {
83
+ return { ok: false, error: error.message };
84
+ }
85
+ }