@lingochunk/mcp 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alex Olkhovskiy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # LingoChunk MCP
2
+
3
+ A [Model Context Protocol](https://modelcontextprotocol.io) server (and Claude
4
+ Code plugin) that turns a coding agent into a language tutor grounded in **your
5
+ own LingoChunk listening history**: your FSRS-graded vocabulary, native-audio
6
+ transcripts and clips, and your library.
7
+
8
+ It is a thin client over the LingoChunk public API (`/api/v1`): read-only tools
9
+ for your vocabulary, transcripts and audio, plus write tools to add review cards,
10
+ export Anki decks and save lessons. The app stays closed source; this repo is
11
+ just the client, the committed API spec, and two lesson skills.
12
+
13
+ > Status: local/preview. Not yet published to npm and not yet a public repo.
14
+
15
+ ## What it gives an agent
16
+
17
+ Eleven tools, each wrapping one public endpoint. The first seven are read-only;
18
+ the last four (phase 3) write to your account.
19
+
20
+ | Tool | Scope | What it does |
21
+ |---|---|---|
22
+ | `get_vocabulary` | `vocab:read` | Your vocabulary, aggregated per word with FSRS maturity (known/learning/new/due). Filterable; incremental sync via `since` + `cursor` (additive-only, so full-resync periodically). |
23
+ | `lookup_word` | `vocab:read` | One word: your own context plus a shared-lexicon gender/CEFR fallback. Grounds an LLM's guesses. |
24
+ | `list_library` | `content:read` | Your ready-to-study episodes (own + followed collections), cursor-paginated. |
25
+ | `get_transcript` | `content:read` | A submission's timestamped sentences + translations, sliceable by sentence or time range. |
26
+ | `get_audio_url` | `content:read` | A short-lived presigned URL to the full native audio (Range-capable). |
27
+ | `search_examples` | `content:read` | Example sentences across your library, by word (`lemma`) or text (`q`). A capped sample, not exhaustive. |
28
+ | `get_audio_clip` | `content:read` | Cuts a short native-audio snippet, **saves it to a local file**, and returns `{path, media_type, size_bytes}` for embedding in lessons. |
29
+ | `list_decks` | `cards:write` or `decks:export` | Your study decks with card counts, for picking a `deck_id` to add to or export. |
30
+ | `add_card` | `cards:write` | Adds a card to your review queue (FSRS, starts new): `kind=vocab` from your vocabulary, or `kind=custom` front/back. Omit `deck_id` to use the deck for the card's own submission. |
31
+ | `export_anki_deck` | `decks:export` | Exports a deck to Anki `.apkg` (no LLM), polling internally; returns a download URL when ready. A deck with no linked episode can't be exported. |
32
+ | `save_lesson` | `lessons:write` | Saves a self-contained HTML lesson to your private library (10 MB cap, 100 max); returns metadata + a short-lived view URL. |
33
+
34
+ Plus two skills:
35
+
36
+ - **`lingochunk-lesson`** - builds a single self-contained HTML lesson (data-URI
37
+ audio; gap-fill, multiple-choice, listening and blur-reveal exercises) from the
38
+ tools above, filtering out words you already know.
39
+ - **`lingochunk-discuss`** - a lighter, conversational "talk me through this
40
+ episode" workflow.
41
+
42
+ ## Prerequisites
43
+
44
+ - Node.js >= 18.
45
+ - A LingoChunk **personal access token**: in LingoChunk, open Settings -> API
46
+ access, create a token, and grant the scopes you need (`vocab:read` +
47
+ `content:read` cover the read tools; add `cards:write`, `decks:export` and
48
+ `lessons:write` for the write tools). The token is shown once and starts with
49
+ `lcp_`. The 403 errors from the tools name the exact scope you are missing.
50
+
51
+ ## Use it
52
+
53
+ ### Option A - Claude Code plugin (bundles the server + the skills)
54
+
55
+ Build once, then point Claude Code at this directory as a plugin. The bundled
56
+ `.mcp.json` runs the server from `dist/` via `${CLAUDE_PLUGIN_ROOT}`, and the
57
+ `skills/` are auto-discovered.
58
+
59
+ ```bash
60
+ npm install # installs deps and builds dist/ (via the prepare script)
61
+ export LINGOCHUNK_TOKEN=lcp_your_token_here
62
+ ```
63
+
64
+ **Run `npm install` before adding the plugin.** `dist/` is gitignored and does
65
+ not exist in a fresh checkout; the `prepare` script builds it during
66
+ `npm install`. Until it does, `.mcp.json` points at a `dist/index.js` that is not
67
+ there and the server will not start.
68
+
69
+ Then add the plugin from its local path in Claude Code (plugin install from a
70
+ local directory), or copy the MCP block from `.mcp.json` into your Claude Code
71
+ MCP config, replacing `${CLAUDE_PLUGIN_ROOT}` with the absolute path to this repo.
72
+
73
+ ### Option B - standalone MCP server
74
+
75
+ Once published to npm this will be a one-liner:
76
+
77
+ ```bash
78
+ claude mcp add lingochunk --env LINGOCHUNK_TOKEN=lcp_... -- npx -y @lingochunk/mcp
79
+ ```
80
+
81
+ Until then, build locally and run it directly:
82
+
83
+ ```bash
84
+ npm install
85
+ claude mcp add lingochunk --env LINGOCHUNK_TOKEN=lcp_... -- node /absolute/path/to/lingochunk-mcp/dist/index.js
86
+ ```
87
+
88
+ ## Configuration
89
+
90
+ | Variable | Required | Default | Meaning |
91
+ |---|---|---|---|
92
+ | `LINGOCHUNK_TOKEN` | yes | - | Your personal access token (`lcp_...`). |
93
+ | `LINGOCHUNK_BASE_URL` | no | `https://lingochunk.com` | API origin override (for self-host/testing). |
94
+ | `LINGOCHUNK_CLIP_DIR` | no | `~/.cache/lingochunk-mcp` | Where `get_audio_clip` writes clip files (a private per-user dir, created mode 0700). |
95
+
96
+ The token is only ever sent as an `Authorization: Bearer` header to the
97
+ configured origin; it is never written to disk or logged.
98
+
99
+ ## Building a lesson
100
+
101
+ Ask your agent something like "build me a lesson from yesterday's German episode"
102
+ or "quiz me on the words I'm learning". The `lingochunk-lesson` skill drives the
103
+ workflow: pick the source, pull a transcript slice, gather and **filter** your
104
+ vocabulary (never quizzing you on mastered words), fetch short audio clips, and
105
+ render one shareable HTML file. See `skills/lingochunk-lesson/`.
106
+
107
+ ## Repository layout
108
+
109
+ ```
110
+ src/ the MCP server (TypeScript, stdio)
111
+ skills/lingochunk-lesson/ the lesson skill
112
+ skills/lingochunk-lesson/assets/lesson-template.html self-contained HTML template
113
+ skills/lingochunk-discuss/ the "discuss an episode" skill
114
+ docs/integrations/fluent.md how to plug this into the fluent tutor plugin
115
+ spec/openapi-public-v1.json the committed public API spec (the contract)
116
+ scripts/smoke.ts live smoke test (run by hand, never in CI)
117
+ test/ vitest unit tests (mocked fetch)
118
+ .claude-plugin/plugin.json Claude Code plugin manifest
119
+ .mcp.json MCP server definition for the plugin
120
+ ```
121
+
122
+ ## Development
123
+
124
+ ```bash
125
+ npm install # deps + build (prepare)
126
+ npm run build # compile src/ -> dist/
127
+ npm run typecheck # type-check without emitting
128
+ npm test # vitest unit tests (mocked fetch; no network)
129
+ ```
130
+
131
+ `spec/openapi-public-v1.json` is the source contract; it is exported from the
132
+ LingoChunk repo (`make generate-openapi-public`) and refreshed here on each API
133
+ release. This copy was taken from LingoChunk commit `3c226795`.
134
+
135
+ ### Live smoke test
136
+
137
+ `scripts/smoke.ts` exercises a **real** API and is not part of `npm test`. Build
138
+ first, then run it by hand with a real token:
139
+
140
+ ```bash
141
+ npm run build
142
+ LINGOCHUNK_TOKEN=lcp_... [LINGOCHUNK_BASE_URL=http://localhost:8000] \
143
+ node --experimental-strip-types scripts/smoke.ts
144
+ ```
145
+
146
+ ## License
147
+
148
+ MIT.
@@ -0,0 +1,68 @@
1
+ import type { Config } from "./config.js";
2
+ /** An error returned by the LingoChunk API (non-2xx), carrying the HTTP status,
3
+ * the API's `detail` message, and its stable machine-readable `code` (e.g.
4
+ * ``ambiguous_lemma``) when present, so tools can branch on the outcome. */
5
+ export declare class ApiError extends Error {
6
+ readonly status: number;
7
+ readonly detail: string;
8
+ readonly retryAfter?: number | undefined;
9
+ readonly code?: string | undefined;
10
+ constructor(status: number, detail: string, retryAfter?: number | undefined, code?: string | undefined);
11
+ }
12
+ /** A binary audio clip plus the media type the server reported. */
13
+ export interface AudioClip {
14
+ data: Buffer;
15
+ contentType: string;
16
+ }
17
+ /** Result of POST /decks/{id}/export. */
18
+ export interface DeckExportStart {
19
+ status: "ready" | "queued";
20
+ poll: string;
21
+ }
22
+ /** Result of GET /decks/{id}/export/status. */
23
+ export interface DeckExportStatus {
24
+ status: "ready" | "pending" | "failed" | "none";
25
+ download_url?: string;
26
+ }
27
+ export type QueryValue = string | number | boolean | undefined | null;
28
+ /** How long any single request may take before we abort it. */
29
+ export declare const REQUEST_TIMEOUT_MS = 30000;
30
+ /** Refuse to buffer a clip larger than this (a runaway or wrong endpoint). */
31
+ export declare const MAX_CLIP_BYTES: number;
32
+ /** Coerce a FastAPI error `detail` into a single readable line.
33
+ *
34
+ * Intentional errors (400/403/404/429) carry a string detail. Automatic
35
+ * request-validation errors (422) carry a LIST of `{loc, msg, ...}` objects;
36
+ * without this they would collapse to the bare status text ("Unprocessable
37
+ * Entity") and lose the field message that tells the agent what to fix. A
38
+ * detail of any other shape is stringified (truncated) rather than dropped.
39
+ * Returns undefined when there is nothing usable, so the caller keeps the
40
+ * status text. */
41
+ export declare function formatDetail(detail: unknown): string | undefined;
42
+ /** Thin, typed client over the public `/api/v1` surface. One instance per
43
+ * process, holding the configured base URL + token. */
44
+ export declare class LingoChunkClient {
45
+ private readonly config;
46
+ constructor(config: Config);
47
+ private buildUrl;
48
+ private authHeaders;
49
+ private raiseForStatus;
50
+ /** GET a JSON endpoint. */
51
+ private getJson;
52
+ /** POST a JSON body to an endpoint and parse the JSON response. */
53
+ private postJson;
54
+ getVocabulary(params: Record<string, QueryValue>): Promise<unknown>;
55
+ lookupWord(params: Record<string, QueryValue>): Promise<unknown>;
56
+ listLibrary(params: Record<string, QueryValue>): Promise<unknown>;
57
+ getTranscript(submissionId: string, params: Record<string, QueryValue>): Promise<unknown>;
58
+ getAudioUrl(submissionId: string): Promise<unknown>;
59
+ searchExamples(params: Record<string, QueryValue>): Promise<unknown>;
60
+ listDecks(): Promise<unknown>;
61
+ addCard(body: object): Promise<unknown>;
62
+ createLesson(body: object): Promise<unknown>;
63
+ /** Start an Anki export (no body). 400 for a deck with no linked submission. */
64
+ exportDeck(deckId: number): Promise<DeckExportStart>;
65
+ exportDeckStatus(deckId: number): Promise<DeckExportStatus>;
66
+ /** GET a clip as raw audio bytes (the endpoint streams audio, not JSON). */
67
+ getAudioClip(submissionId: string, start: number, end: number): Promise<AudioClip>;
68
+ }
package/dist/client.js ADDED
@@ -0,0 +1,215 @@
1
+ /** An error returned by the LingoChunk API (non-2xx), carrying the HTTP status,
2
+ * the API's `detail` message, and its stable machine-readable `code` (e.g.
3
+ * ``ambiguous_lemma``) when present, so tools can branch on the outcome. */
4
+ export class ApiError extends Error {
5
+ status;
6
+ detail;
7
+ retryAfter;
8
+ code;
9
+ constructor(status, detail, retryAfter, code) {
10
+ super(`LingoChunk API ${status}: ${detail}`);
11
+ this.status = status;
12
+ this.detail = detail;
13
+ this.retryAfter = retryAfter;
14
+ this.code = code;
15
+ this.name = "ApiError";
16
+ }
17
+ }
18
+ /** How long any single request may take before we abort it. */
19
+ export const REQUEST_TIMEOUT_MS = 30_000;
20
+ /** Refuse to buffer a clip larger than this (a runaway or wrong endpoint). */
21
+ export const MAX_CLIP_BYTES = 25 * 1024 * 1024;
22
+ /** Never read more than this much of an error body into the message. */
23
+ const MAX_ERROR_BODY = 10_000;
24
+ function truncate(value, max = 300) {
25
+ return value.length > max ? `${value.slice(0, max)}...` : value;
26
+ }
27
+ function safeStringify(value) {
28
+ try {
29
+ return JSON.stringify(value);
30
+ }
31
+ catch {
32
+ return String(value);
33
+ }
34
+ }
35
+ /** Coerce a FastAPI error `detail` into a single readable line.
36
+ *
37
+ * Intentional errors (400/403/404/429) carry a string detail. Automatic
38
+ * request-validation errors (422) carry a LIST of `{loc, msg, ...}` objects;
39
+ * without this they would collapse to the bare status text ("Unprocessable
40
+ * Entity") and lose the field message that tells the agent what to fix. A
41
+ * detail of any other shape is stringified (truncated) rather than dropped.
42
+ * Returns undefined when there is nothing usable, so the caller keeps the
43
+ * status text. */
44
+ export function formatDetail(detail) {
45
+ if (typeof detail === "string") {
46
+ return detail.trim() || undefined;
47
+ }
48
+ if (Array.isArray(detail)) {
49
+ const parts = detail
50
+ .map(formatDetailItem)
51
+ .filter((p) => p !== undefined);
52
+ return parts.length ? parts.join("; ") : undefined;
53
+ }
54
+ if (detail && typeof detail === "object") {
55
+ return truncate(safeStringify(detail));
56
+ }
57
+ return undefined;
58
+ }
59
+ function formatDetailItem(item) {
60
+ if (typeof item === "string")
61
+ return item;
62
+ if (item && typeof item === "object") {
63
+ const rec = item;
64
+ if (typeof rec.msg === "string") {
65
+ const loc = Array.isArray(rec.loc)
66
+ ? rec.loc
67
+ .filter((p) => typeof p === "string" || typeof p === "number")
68
+ .join(".")
69
+ : "";
70
+ return loc ? `${loc}: ${rec.msg}` : rec.msg;
71
+ }
72
+ return truncate(safeStringify(item));
73
+ }
74
+ return undefined;
75
+ }
76
+ /** Thin, typed client over the public `/api/v1` surface. One instance per
77
+ * process, holding the configured base URL + token. */
78
+ export class LingoChunkClient {
79
+ config;
80
+ constructor(config) {
81
+ this.config = config;
82
+ }
83
+ buildUrl(path, params) {
84
+ const url = new URL(`${this.config.baseUrl}/api/v1${path}`);
85
+ if (params) {
86
+ for (const [key, value] of Object.entries(params)) {
87
+ if (value !== undefined && value !== null && value !== "") {
88
+ url.searchParams.set(key, String(value));
89
+ }
90
+ }
91
+ }
92
+ return url;
93
+ }
94
+ authHeaders(accept) {
95
+ return {
96
+ Authorization: `Bearer ${this.config.token}`,
97
+ Accept: accept,
98
+ "User-Agent": "lingochunk-mcp",
99
+ };
100
+ }
101
+ async raiseForStatus(res) {
102
+ let detail = res.statusText || `HTTP ${res.status}`;
103
+ let code;
104
+ // Only read a JSON error body, and only a bounded slice of it: a 5xx from a
105
+ // proxy can be a whole HTML page, which we neither want to buffer nor dump
106
+ // into the tool message. Non-JSON errors fall back to the status text.
107
+ if ((res.headers.get("content-type") ?? "").includes("json")) {
108
+ try {
109
+ const raw = (await res.text()).slice(0, MAX_ERROR_BODY);
110
+ const body = JSON.parse(raw);
111
+ const formatted = formatDetail(body?.detail);
112
+ if (formatted)
113
+ detail = formatted;
114
+ if (typeof body?.code === "string")
115
+ code = body.code;
116
+ }
117
+ catch {
118
+ // Malformed or truncated JSON error body; keep the status text.
119
+ }
120
+ }
121
+ const retryHeader = res.headers.get("retry-after");
122
+ const retryAfter = retryHeader ? Number(retryHeader) : undefined;
123
+ throw new ApiError(res.status, detail, Number.isFinite(retryAfter) ? retryAfter : undefined, code);
124
+ }
125
+ /** GET a JSON endpoint. */
126
+ async getJson(path, params) {
127
+ const res = await fetch(this.buildUrl(path, params), {
128
+ method: "GET",
129
+ headers: this.authHeaders("application/json"),
130
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
131
+ });
132
+ if (!res.ok) {
133
+ await this.raiseForStatus(res);
134
+ }
135
+ return (await res.json());
136
+ }
137
+ /** POST a JSON body to an endpoint and parse the JSON response. */
138
+ async postJson(path, body) {
139
+ const headers = this.authHeaders("application/json");
140
+ if (body !== undefined)
141
+ headers["Content-Type"] = "application/json";
142
+ const res = await fetch(this.buildUrl(path), {
143
+ method: "POST",
144
+ headers,
145
+ body: body === undefined ? undefined : JSON.stringify(body),
146
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
147
+ });
148
+ if (!res.ok) {
149
+ await this.raiseForStatus(res);
150
+ }
151
+ return (await res.json());
152
+ }
153
+ // --- Read endpoints (thin pass-throughs; the tools shape the arguments) ---
154
+ getVocabulary(params) {
155
+ return this.getJson("/vocab", params);
156
+ }
157
+ lookupWord(params) {
158
+ return this.getJson("/vocab/lookup", params);
159
+ }
160
+ listLibrary(params) {
161
+ return this.getJson("/library", params);
162
+ }
163
+ getTranscript(submissionId, params) {
164
+ return this.getJson(`/submissions/${encodeURIComponent(submissionId)}/transcript`, params);
165
+ }
166
+ getAudioUrl(submissionId) {
167
+ return this.getJson(`/submissions/${encodeURIComponent(submissionId)}/audio-url`);
168
+ }
169
+ searchExamples(params) {
170
+ return this.getJson("/sentences/search", params);
171
+ }
172
+ // --- Write endpoints (phase 3) ------------------------------------------
173
+ listDecks() {
174
+ return this.getJson("/decks");
175
+ }
176
+ addCard(body) {
177
+ return this.postJson("/cards", body);
178
+ }
179
+ createLesson(body) {
180
+ return this.postJson("/lessons", body);
181
+ }
182
+ /** Start an Anki export (no body). 400 for a deck with no linked submission. */
183
+ exportDeck(deckId) {
184
+ return this.postJson(`/decks/${deckId}/export`);
185
+ }
186
+ exportDeckStatus(deckId) {
187
+ return this.getJson(`/decks/${deckId}/export/status`);
188
+ }
189
+ /** GET a clip as raw audio bytes (the endpoint streams audio, not JSON). */
190
+ async getAudioClip(submissionId, start, end) {
191
+ const res = await fetch(this.buildUrl(`/submissions/${encodeURIComponent(submissionId)}/clip`, {
192
+ start,
193
+ end,
194
+ }), {
195
+ method: "GET",
196
+ headers: this.authHeaders("audio/*"),
197
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
198
+ });
199
+ if (!res.ok) {
200
+ await this.raiseForStatus(res);
201
+ }
202
+ // Guard against buffering something huge: a short clip is a few hundred KB,
203
+ // so a Content-Length past the cap means a wrong/overlong request. Reject
204
+ // before reading the body into memory.
205
+ const declared = Number(res.headers.get("content-length"));
206
+ if (Number.isFinite(declared) && declared > MAX_CLIP_BYTES) {
207
+ throw new Error(`Clip is too large (${Math.round(declared / (1024 * 1024))} MB); ` +
208
+ "request a shorter time range.");
209
+ }
210
+ const data = Buffer.from(await res.arrayBuffer());
211
+ const contentType = res.headers.get("content-type") ?? "audio/mpeg";
212
+ return { data, contentType };
213
+ }
214
+ }
215
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA;;6EAE6E;AAC7E,MAAM,OAAO,QAAS,SAAQ,KAAK;IAEtB;IACA;IACA;IACA;IAJX,YACW,MAAc,EACd,MAAc,EACd,UAAmB,EACnB,IAAa;QAEtB,KAAK,CAAC,kBAAkB,MAAM,KAAK,MAAM,EAAE,CAAC,CAAC;QALpC,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAQ;QACd,eAAU,GAAV,UAAU,CAAS;QACnB,SAAI,GAAJ,IAAI,CAAS;QAGtB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AAsBD,+DAA+D;AAC/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AACzC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAC/C,wEAAwE;AACxE,MAAM,cAAc,GAAG,MAAM,CAAC;AAE9B,SAAS,QAAQ,CAAC,KAAa,EAAE,GAAG,GAAG,GAAG;IACxC,OAAO,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;AAClE,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,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AAM,EAAE,KAAK;YACb,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;YACpC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,kBAAkB,CAAC;SAChD,CACF,CAAC;QACF,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC;QACD,4EAA4E;QAC5E,0EAA0E;QAC1E,uCAAuC;QACvC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAC3D,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,cAAc,EAAE,CAAC;YAC3D,MAAM,IAAI,KAAK,CACb,sBAAsB,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,QAAQ;gBAChE,+BAA+B,CAClC,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;QAClD,MAAM,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,YAAY,CAAC;QACpE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAC/B,CAAC;CACF"}
@@ -0,0 +1,22 @@
1
+ /** Runtime configuration, read once from the environment at startup. */
2
+ export interface Config {
3
+ /** Base origin of the LingoChunk API, e.g. https://lingochunk.com (no trailing slash). */
4
+ baseUrl: string;
5
+ /** Personal access token (prefix "lcp_") sent as a Bearer credential. */
6
+ token: string;
7
+ /** Directory audio clips are written to (get_audio_clip returns the file path). */
8
+ clipDir: string;
9
+ }
10
+ /**
11
+ * Build the config from environment variables.
12
+ *
13
+ * - LINGOCHUNK_TOKEN (required) the personal access token, created in the
14
+ * LingoChunk account settings. Must start with "lcp_".
15
+ * - LINGOCHUNK_BASE_URL (optional) override the API origin (default production).
16
+ * - LINGOCHUNK_CLIP_DIR (optional) where audio clips are saved (default a
17
+ * private per-user cache dir, ~/.cache/lingochunk-mcp).
18
+ *
19
+ * Throws a clear error when the token is missing, so onboarding fails loudly
20
+ * rather than sending unauthenticated requests.
21
+ */
22
+ export declare function loadConfig(env?: NodeJS.ProcessEnv): Config;
package/dist/config.js ADDED
@@ -0,0 +1,44 @@
1
+ import os from "node:os";
2
+ import path from "node:path";
3
+ const DEFAULT_BASE_URL = "https://lingochunk.com";
4
+ /**
5
+ * Build the config from environment variables.
6
+ *
7
+ * - LINGOCHUNK_TOKEN (required) the personal access token, created in the
8
+ * LingoChunk account settings. Must start with "lcp_".
9
+ * - LINGOCHUNK_BASE_URL (optional) override the API origin (default production).
10
+ * - LINGOCHUNK_CLIP_DIR (optional) where audio clips are saved (default a
11
+ * private per-user cache dir, ~/.cache/lingochunk-mcp).
12
+ *
13
+ * Throws a clear error when the token is missing, so onboarding fails loudly
14
+ * rather than sending unauthenticated requests.
15
+ */
16
+ export function loadConfig(env = process.env) {
17
+ const token = (env.LINGOCHUNK_TOKEN ?? "").trim();
18
+ if (!token) {
19
+ throw new Error("LINGOCHUNK_TOKEN is required. Create a personal access token in your " +
20
+ "LingoChunk account settings and pass it as LINGOCHUNK_TOKEN (it starts " +
21
+ "with 'lcp_').");
22
+ }
23
+ const baseUrl = (env.LINGOCHUNK_BASE_URL ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
24
+ // Fail fast on a malformed origin rather than throwing an opaque error on the
25
+ // first request. A bare host like "localhost:8000" parses with a bogus scheme,
26
+ // so also require http(s).
27
+ let parsed;
28
+ try {
29
+ parsed = new URL(baseUrl);
30
+ }
31
+ catch {
32
+ throw new Error(`LINGOCHUNK_BASE_URL is not a valid URL: ${baseUrl}`);
33
+ }
34
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
35
+ throw new Error(`LINGOCHUNK_BASE_URL must be an http(s) URL (e.g. https://lingochunk.com), got: ${baseUrl}`);
36
+ }
37
+ // Default to a private per-user cache dir rather than the world-readable
38
+ // shared temp dir: clips are the user's own study audio, so they should not
39
+ // land somewhere every account on the machine can read.
40
+ const clipDir = env.LINGOCHUNK_CLIP_DIR?.trim() ||
41
+ path.join(os.homedir(), ".cache", "lingochunk-mcp");
42
+ return { baseUrl, token, clipDir };
43
+ }
44
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAY7B,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAElD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC7D,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAClD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,uEAAuE;YACrE,yEAAyE;YACzE,eAAe,CAClB,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,mBAAmB,IAAI,gBAAgB,CAAC,CAAC,OAAO,CACnE,MAAM,EACN,EAAE,CACH,CAAC;IACF,8EAA8E;IAC9E,+EAA+E;IAC/E,2BAA2B;IAC3B,IAAI,MAAW,CAAC;IAChB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,2CAA2C,OAAO,EAAE,CAAC,CAAC;IACxE,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CACb,kFAAkF,OAAO,EAAE,CAC5F,CAAC;IACJ,CAAC;IAED,yEAAyE;IACzE,4EAA4E;IAC5E,wDAAwD;IACxD,MAAM,OAAO,GACX,GAAG,CAAC,mBAAmB,EAAE,IAAI,EAAE;QAC/B,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC;IAEtD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { loadConfig } from "./config.js";
5
+ import { LingoChunkClient } from "./client.js";
6
+ import { registerTools } from "./tools.js";
7
+ const VERSION = "0.2.1";
8
+ async function main() {
9
+ // Fail fast (to stderr, never stdout - stdout is the MCP wire) if the token
10
+ // is missing, so onboarding surfaces the problem immediately.
11
+ const config = loadConfig();
12
+ const client = new LingoChunkClient(config);
13
+ const server = new McpServer({ name: "lingochunk", version: VERSION });
14
+ registerTools(server, client, config);
15
+ const transport = new StdioServerTransport();
16
+ await server.connect(transport);
17
+ }
18
+ main().catch((err) => {
19
+ const message = err instanceof Error ? err.message : String(err);
20
+ process.stderr.write(`lingochunk-mcp failed to start: ${message}\n`);
21
+ process.exit(1);
22
+ });
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB,KAAK,UAAU,IAAI;IACjB,4EAA4E;IAC5E,8DAA8D;IAC9D,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAE5C,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IACvE,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAEtC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IAC5B,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,OAAO,IAAI,CAAC,CAAC;IACrE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { type LingoChunkClient } from "./client.js";
3
+ import type { Config } from "./config.js";
4
+ export declare function registerTools(server: McpServer, client: LingoChunkClient, config: Config): void;
package/dist/tools.js ADDED
@@ -0,0 +1,475 @@
1
+ import { promises as fs } from "node:fs";
2
+ import path from "node:path";
3
+ import { z } from "zod";
4
+ import { ApiError } from "./client.js";
5
+ /** Format a successful JSON result as a single text block. */
6
+ function jsonResult(value) {
7
+ return { content: [{ type: "text", text: JSON.stringify(value, null, 2) }] };
8
+ }
9
+ /** AbortSignal.timeout rejects with a DOMException named "TimeoutError" (a
10
+ * manual abort is "AbortError"); both mean the request gave up waiting. */
11
+ function isTimeoutError(err) {
12
+ return (err instanceof Error &&
13
+ (err.name === "TimeoutError" || err.name === "AbortError"));
14
+ }
15
+ /** Node's fetch reports a network failure as "fetch failed" with the real
16
+ * reason on `.cause` (e.g. getaddrinfo ENOTFOUND). Surface that reason. */
17
+ function causeMessage(err) {
18
+ const cause = err.cause;
19
+ if (cause instanceof Error && cause.message)
20
+ return cause.message;
21
+ if (typeof cause === "string" && cause)
22
+ return cause;
23
+ return undefined;
24
+ }
25
+ /** Turn an error into a tool error result the agent can read and act on. */
26
+ function errorResult(err) {
27
+ let text;
28
+ if (err instanceof ApiError) {
29
+ text = `LingoChunk API error ${err.status}: ${err.detail}`;
30
+ // A machine-readable code (when present) is more specific than the status.
31
+ if (err.code === "ambiguous_lemma") {
32
+ text +=
33
+ "\nRetry with the 'pos' (or 'submission_id') value named above to pick " +
34
+ "one.";
35
+ }
36
+ else if (err.code === "duplicate_card") {
37
+ text += "\nThe card already exists; this is safe to ignore, not to retry.";
38
+ }
39
+ else if (err.code === "lesson_cap") {
40
+ text +=
41
+ "\nYou are at the lesson limit; delete an old lesson in your LingoChunk " +
42
+ "library (Settings) to make room.";
43
+ }
44
+ else if (err.status === 401) {
45
+ text += "\nCheck LINGOCHUNK_TOKEN is a valid, un-revoked token (prefix lcp_).";
46
+ }
47
+ else if (err.status === 403) {
48
+ text +=
49
+ "\nThe token lacks the scope named above. Mint a new token in " +
50
+ "LingoChunk settings that includes it.";
51
+ }
52
+ else if (err.status === 429 && err.retryAfter !== undefined) {
53
+ text += `\nRate limited; retry after ${err.retryAfter}s.`;
54
+ }
55
+ }
56
+ else if (isTimeoutError(err)) {
57
+ text =
58
+ "The request to the LingoChunk API timed out after 30s. Check your " +
59
+ "connection (and LINGOCHUNK_BASE_URL) and try again.";
60
+ }
61
+ else if (err instanceof Error) {
62
+ text = err.message;
63
+ const cause = causeMessage(err);
64
+ if (cause)
65
+ text += `: ${cause}`;
66
+ }
67
+ else {
68
+ text = String(err);
69
+ }
70
+ return { content: [{ type: "text", text }], isError: true };
71
+ }
72
+ /** Run a fetch and format its JSON, converting any error into a tool error. */
73
+ async function runJson(fn) {
74
+ try {
75
+ return jsonResult(await fn());
76
+ }
77
+ catch (err) {
78
+ return errorResult(err);
79
+ }
80
+ }
81
+ /** Run a handler that builds its own result, converting errors uniformly. */
82
+ async function runResult(fn) {
83
+ try {
84
+ return await fn();
85
+ }
86
+ catch (err) {
87
+ return errorResult(err);
88
+ }
89
+ }
90
+ const AUDIO_EXTENSIONS = {
91
+ "audio/mp4": ".m4a",
92
+ "audio/mpeg": ".mp3",
93
+ "audio/webm": ".webm",
94
+ "audio/wav": ".wav",
95
+ "audio/ogg": ".ogg",
96
+ };
97
+ function extensionFor(contentType) {
98
+ const base = contentType.split(";")[0].trim().toLowerCase();
99
+ return AUDIO_EXTENSIONS[base] ?? ".audio";
100
+ }
101
+ function sanitise(value) {
102
+ return value.replace(/[^a-zA-Z0-9._-]/g, "_");
103
+ }
104
+ /** Adapt a validated (zod-inferred) args object to the client's query shape.
105
+ * The client skips undefined/null/empty values, so this is a plain view. */
106
+ function params(obj) {
107
+ return obj;
108
+ }
109
+ const EXPORT_POLL_INTERVAL_MS = 2_000;
110
+ const EXPORT_POLL_BUDGET_MS = 60_000;
111
+ // Fallback wait when a 429 carries no Retry-After.
112
+ const EXPORT_RETRY_FALLBACK_MS = 5_000;
113
+ function sleep(ms) {
114
+ return new Promise((resolve) => setTimeout(resolve, ms));
115
+ }
116
+ /** POST the export, absorbing a 429 by sleeping for Retry-After (capped by the
117
+ * remaining budget) and retrying rather than aborting the whole tool. Returns
118
+ * false only when the budget runs out mid-backoff. A 400/403/etc bubbles up. */
119
+ async function triggerExport(client, deckId, deadline) {
120
+ for (;;) {
121
+ try {
122
+ await client.exportDeck(deckId);
123
+ return true;
124
+ }
125
+ catch (err) {
126
+ if (!(err instanceof ApiError) || err.status !== 429)
127
+ throw err;
128
+ const remaining = deadline - Date.now();
129
+ if (remaining <= 0)
130
+ return false;
131
+ const wait = err.retryAfter && err.retryAfter > 0
132
+ ? err.retryAfter * 1000
133
+ : EXPORT_RETRY_FALLBACK_MS;
134
+ await sleep(Math.min(wait, remaining));
135
+ }
136
+ }
137
+ }
138
+ /** Start a deck export, then poll its status for up to ~60s and return a compact
139
+ * result the agent can act on. The endpoint does not re-enqueue while a job is
140
+ * in flight, so a 429 while triggering is absorbed with a Retry-After backoff
141
+ * (not an abort). A 400 (e.g. a deck with no linked submission) or 403 bubbles
142
+ * up as an ApiError for errorResult. */
143
+ async function exportAndPoll(client, deckId) {
144
+ const deadline = Date.now() + EXPORT_POLL_BUDGET_MS;
145
+ if (!(await triggerExport(client, deckId, deadline))) {
146
+ return jsonResult({
147
+ status: "pending",
148
+ message: "Rate limited before the export could start; call export_anki_deck " +
149
+ "again shortly.",
150
+ });
151
+ }
152
+ for (;;) {
153
+ const st = await client.exportDeckStatus(deckId);
154
+ if (st.status === "ready") {
155
+ return jsonResult({ status: "ready", download_url: st.download_url });
156
+ }
157
+ if (st.status === "failed") {
158
+ return jsonResult({
159
+ status: "failed",
160
+ message: "Export failed; call export_anki_deck again to retry.",
161
+ });
162
+ }
163
+ if (st.status === "none") {
164
+ return jsonResult({
165
+ status: "none",
166
+ message: "No export is available to download; call export_anki_deck again to " +
167
+ "trigger a fresh one.",
168
+ });
169
+ }
170
+ if (Date.now() >= deadline) {
171
+ return jsonResult({
172
+ status: "pending",
173
+ message: "Still generating. Call export_anki_deck again shortly to check " +
174
+ "status; it will not start a second job while one is in flight. Only " +
175
+ "re-trigger if a later call reports 'failed' or 'none'.",
176
+ });
177
+ }
178
+ await sleep(EXPORT_POLL_INTERVAL_MS);
179
+ }
180
+ }
181
+ export function registerTools(server, client, config) {
182
+ server.registerTool("get_vocabulary", {
183
+ title: "Get vocabulary",
184
+ description: "List the user's vocabulary, aggregated per word with FSRS maturity " +
185
+ "(state/stability/due/reps). Grounded in the user's real listening " +
186
+ "history. Filter by language, status (known|learning|new|due), or CEFR; " +
187
+ "use 'since' (an ISO 8601 time from a prior 'updated_at') plus 'cursor' " +
188
+ "for incremental sync. Sync is additive-only, so full-resync periodically. " +
189
+ "The list is cursor-paginated (limit up to 200); follow next_cursor until " +
190
+ "it is null to read the complete set.",
191
+ inputSchema: {
192
+ language: z
193
+ .string()
194
+ .transform((v) => v.toLowerCase())
195
+ .optional()
196
+ .describe("Filter to one learning language, ISO 639-1, e.g. 'de' " +
197
+ "(normalised to lowercase)."),
198
+ status: z
199
+ .enum(["known", "learning", "new", "due"])
200
+ .optional()
201
+ .describe("Filter by learning status derived from FSRS state."),
202
+ cefr: z
203
+ .string()
204
+ .transform((v) => v.toUpperCase())
205
+ .refine((v) => ["A1", "A2", "B1", "B2", "C1", "C2"].includes(v), {
206
+ message: "cefr must be one of A1, A2, B1, B2, C1, C2",
207
+ })
208
+ .optional()
209
+ .describe("Filter by CEFR level; one of A1-C2 (normalised to uppercase)."),
210
+ since: z
211
+ .string()
212
+ .refine((v) => !Number.isNaN(Date.parse(v)), {
213
+ message: "since must be a date or datetime string, e.g. 2026-07-01 or " +
214
+ "2026-07-01T10:00:00Z",
215
+ })
216
+ .optional()
217
+ .describe("Return only words changed at/after this date or datetime."),
218
+ limit: z.number().int().min(1).max(200).optional(),
219
+ cursor: z
220
+ .string()
221
+ .optional()
222
+ .describe("Opaque cursor from a previous page's next_cursor."),
223
+ },
224
+ }, async (args) => runJson(() => client.getVocabulary(params(args))));
225
+ server.registerTool("lookup_word", {
226
+ title: "Look up a word",
227
+ description: "Look up one word: the user's own context (translation, gender, CEFR, " +
228
+ "FSRS state) if they have cards for it, backed by the shared enrichment " +
229
+ "lexicon as a gender/CEFR fallback. Use this to ground an LLM's guesses " +
230
+ "about a word rather than inventing them.",
231
+ inputSchema: {
232
+ lemma: z.string().min(1).describe("Dictionary (base) form to look up."),
233
+ language: z
234
+ .string()
235
+ .min(1)
236
+ .transform((v) => v.toLowerCase())
237
+ .describe("Language of the word, ISO 639-1 (normalised to lowercase)."),
238
+ pos: z.string().optional().describe("Part of speech, if known (e.g. NOUN)."),
239
+ },
240
+ }, async (args) => runJson(() => client.lookupWord(params(args))));
241
+ server.registerTool("list_library", {
242
+ title: "List library",
243
+ description: "List the user's ready-to-study episodes (their own submissions plus " +
244
+ "collections they follow), newest first. Cursor-paginated. Use the " +
245
+ "returned submission ids with get_transcript / get_audio_url / " +
246
+ "get_audio_clip.",
247
+ inputSchema: {
248
+ limit: z.number().int().min(1).max(200).optional(),
249
+ cursor: z
250
+ .string()
251
+ .optional()
252
+ .describe("Opaque cursor from a previous page's next_cursor."),
253
+ },
254
+ }, async (args) => runJson(() => client.listLibrary(params(args))));
255
+ server.registerTool("get_transcript", {
256
+ title: "Get transcript",
257
+ description: "Fetch a submission's transcript: timestamped sentences with " +
258
+ "translations. Sliceable by sentence-position range (from_sentence/" +
259
+ "to_sentence) or time range in seconds (from_time/to_time) so you can " +
260
+ "pull an excerpt instead of a whole episode. transcript_state tells you " +
261
+ "if it is ready, still processing, or unavailable.",
262
+ inputSchema: {
263
+ submission_id: z.string().min(1).describe("The submission id."),
264
+ from_sentence: z.number().int().min(1).optional(),
265
+ to_sentence: z.number().int().min(1).optional(),
266
+ from_time: z.number().min(0).optional().describe("Start of window (s)."),
267
+ to_time: z.number().min(0).optional().describe("End of window (s)."),
268
+ },
269
+ }, async ({ submission_id, ...rest }) => runJson(() => client.getTranscript(submission_id, params(rest))));
270
+ server.registerTool("get_audio_url", {
271
+ title: "Get audio URL",
272
+ description: "Get a short-lived presigned URL to a submission's full native audio " +
273
+ "(supports HTTP Range). Use for streaming; for a durable snippet to " +
274
+ "embed in a lesson, use get_audio_clip instead.",
275
+ inputSchema: {
276
+ submission_id: z.string().min(1).describe("The submission id."),
277
+ },
278
+ }, async ({ submission_id }) => runJson(() => client.getAudioUrl(submission_id)));
279
+ server.registerTool("search_examples", {
280
+ title: "Search example sentences",
281
+ description: "Search the user's readable library for sentences. 'lemma' returns the " +
282
+ "curated example sentences for that word; 'q' does a case-insensitive " +
283
+ "substring match on sentence text. At least one is required, and 'lemma' " +
284
+ "takes precedence when both are given. Results are a capped sample, not " +
285
+ "exhaustive.",
286
+ inputSchema: {
287
+ lemma: z
288
+ .string()
289
+ .max(200)
290
+ .optional()
291
+ .describe("Find example sentences for this dictionary form."),
292
+ q: z
293
+ .string()
294
+ .max(200)
295
+ .optional()
296
+ .describe("Case-insensitive substring match on sentence text."),
297
+ language: z
298
+ .string()
299
+ .transform((v) => v.toLowerCase())
300
+ .optional()
301
+ .describe("Restrict to one language (normalised to lowercase)."),
302
+ limit: z.number().int().min(1).max(100).optional(),
303
+ },
304
+ }, async (args) => {
305
+ // The API also 400s on this, but validating here names both fields and
306
+ // saves a round trip.
307
+ if (!args.lemma && !args.q) {
308
+ return errorResult(new Error("search_examples needs at least one of 'lemma' or 'q'."));
309
+ }
310
+ return runJson(() => client.searchExamples(params(args)));
311
+ });
312
+ server.registerTool("get_audio_clip", {
313
+ title: "Get audio clip",
314
+ description: "Cut a native-audio snippet [start, end] (seconds, max 60s) from a " +
315
+ "submission and SAVE IT to a local file, returning the file path. Use " +
316
+ "these small clips to embed audio in a self-contained HTML lesson (e.g. " +
317
+ "as a data URI). Rate limited.",
318
+ inputSchema: {
319
+ submission_id: z.string().min(1).describe("The submission id."),
320
+ start: z.number().min(0).describe("Clip start in seconds."),
321
+ end: z.number().gt(0).describe("Clip end in seconds (start < end)."),
322
+ },
323
+ }, async ({ submission_id, start, end }) => runResult(async () => {
324
+ // The API enforces these too; checking here gives a precise message and
325
+ // avoids a wasted request.
326
+ if (!(start < end)) {
327
+ throw new Error("get_audio_clip needs start < end.");
328
+ }
329
+ if (end - start > 60) {
330
+ throw new Error("get_audio_clip cannot exceed 60 seconds (end - start).");
331
+ }
332
+ const clip = await client.getAudioClip(submission_id, start, end);
333
+ // 0o700: the clip dir holds the user's own study audio, so keep it
334
+ // readable only by them (mode applies to dirs this call creates).
335
+ await fs.mkdir(config.clipDir, { recursive: true, mode: 0o700 });
336
+ const filename = `clip-${sanitise(submission_id)}-${start}-${end}${extensionFor(clip.contentType)}`;
337
+ const filePath = path.join(config.clipDir, filename);
338
+ await fs.writeFile(filePath, clip.data);
339
+ return jsonResult({
340
+ path: filePath,
341
+ media_type: clip.contentType,
342
+ size_bytes: clip.data.byteLength,
343
+ });
344
+ }));
345
+ // --- Write tools (phase 3) ----------------------------------------------
346
+ server.registerTool("list_decks", {
347
+ title: "List decks",
348
+ description: "List the user's study decks so you can pick a deck_id before adding " +
349
+ "cards (add_card) or exporting (export_anki_deck). Each deck reports its " +
350
+ "language and card counts (total / new / due). Requires the cards:write " +
351
+ "or decks:export scope.",
352
+ inputSchema: {},
353
+ }, async () => runJson(() => client.listDecks()));
354
+ server.registerTool("add_card", {
355
+ title: "Add a card",
356
+ description: "Add a card to the user's LingoChunk review queue (FSRS; it starts as " +
357
+ "'new'). kind=vocab adds a word the user ALREADY has in their vocabulary, " +
358
+ "resolved by lemma against their own content (404 if the lemma is not in " +
359
+ "their vocabulary; 409 code=ambiguous_lemma if it occurs in several " +
360
+ "episodes or under several parts of speech, so pass submission_id or pos " +
361
+ "as the message names). kind=custom adds a freeform card and REQUIRES " +
362
+ "front, back and submission_id (the episode it anchors to); pass " +
363
+ "sentence_position to anchor its example to a specific transcript " +
364
+ "sentence. Omit deck_id and the card goes to the deck for its own " +
365
+ "submission (the same deck the app builds, reviews and exports that " +
366
+ "episode from, so it is immediately visible and exportable); an explicit " +
367
+ "deck_id must belong to that submission (400 otherwise). A 409 " +
368
+ "code=duplicate_card means the card already exists: expected, not worth " +
369
+ "retrying. NOTE: deleting the anchoring episode deletes the card " +
370
+ "(cascade), and a card added while the app's Words tab is open on that " +
371
+ "episode may be overwritten by the app's own save, so add cards when the " +
372
+ "app is not actively editing that deck. Requires the cards:write scope.",
373
+ inputSchema: {
374
+ deck_id: z
375
+ .number()
376
+ .int()
377
+ .optional()
378
+ .describe("Target deck id from list_decks; omit to use the deck for the card's " +
379
+ "own submission. When given, it must belong to that submission."),
380
+ kind: z
381
+ .enum(["vocab", "custom"])
382
+ .describe("vocab = a word from your vocabulary; custom = freeform front/back."),
383
+ lemma: z
384
+ .string()
385
+ .max(200)
386
+ .optional()
387
+ .describe("Dictionary form to add (kind=vocab)."),
388
+ pos: z
389
+ .string()
390
+ .max(20)
391
+ .optional()
392
+ .describe("Part of speech, to disambiguate the lemma (kind=vocab); case-insensitive."),
393
+ submission_id: z
394
+ .string()
395
+ .optional()
396
+ .describe("Disambiguate the lemma to one episode (kind=vocab); the episode the " +
397
+ "card anchors to (REQUIRED for kind=custom)."),
398
+ front: z
399
+ .string()
400
+ .max(200)
401
+ .optional()
402
+ .describe("Front/prompt text (kind=custom; max 200 chars)."),
403
+ back: z
404
+ .string()
405
+ .max(500)
406
+ .optional()
407
+ .describe("Back/answer text (kind=custom; max 500 chars)."),
408
+ note: z
409
+ .string()
410
+ .max(300)
411
+ .optional()
412
+ .describe("Optional note shown on the card (kind=custom; max 300 chars)."),
413
+ sentence_position: z
414
+ .number()
415
+ .int()
416
+ .min(1)
417
+ .optional()
418
+ .describe("1-based transcript position (see get_transcript) to anchor a custom " +
419
+ "card's example; defaults to the submission's first sentence."),
420
+ },
421
+ }, async (args) => {
422
+ // Mirror the server's cross-field rules so the message is precise and no
423
+ // request is wasted.
424
+ if (args.kind === "vocab" && !args.lemma) {
425
+ return errorResult(new Error("add_card kind=vocab requires 'lemma'."));
426
+ }
427
+ if (args.kind === "custom" &&
428
+ !(args.front && args.back && args.submission_id)) {
429
+ return errorResult(new Error("add_card kind=custom requires 'front', 'back' and 'submission_id'."));
430
+ }
431
+ return runJson(() => client.addCard(args));
432
+ });
433
+ server.registerTool("export_anki_deck", {
434
+ title: "Export an Anki deck",
435
+ description: "Export one of the user's decks to an Anki .apkg and return a download " +
436
+ "URL. Running it costs nothing (no LLM). This starts the export and polls " +
437
+ "status for up to ~60s, absorbing rate limits with a Retry-After backoff " +
438
+ "and never starting a second job while one is already in flight. It " +
439
+ "returns {status:'ready', download_url} when the file is ready, " +
440
+ "{status:'pending'} (call again shortly to keep checking) while it " +
441
+ "generates, {status:'failed'} to retry, or {status:'none'} (nothing to " +
442
+ "download; call again to trigger a fresh export). A deck with no linked " +
443
+ "source episode cannot be exported (400). Use list_decks to find a " +
444
+ "deck_id. Requires the decks:export scope.",
445
+ inputSchema: {
446
+ deck_id: z.number().int().describe("The deck to export (from list_decks)."),
447
+ },
448
+ }, async ({ deck_id }) => runResult(() => exportAndPoll(client, deck_id)));
449
+ server.registerTool("save_lesson", {
450
+ title: "Save a lesson",
451
+ description: "Save a single self-contained HTML lesson to the user's private " +
452
+ "LingoChunk library (10 MB max, up to 100 lessons, private by default). " +
453
+ "Returns the lesson metadata plus a short-lived view URL to open it now; " +
454
+ "its durable home is the app's library, where it opens on any device. Use " +
455
+ "this to keep a lesson the lingochunk-lesson skill produced. Requires the " +
456
+ "lessons:write scope.",
457
+ inputSchema: {
458
+ title: z.string().min(1).max(255).describe("Lesson title."),
459
+ language: z
460
+ .string()
461
+ .min(1)
462
+ .max(10)
463
+ .describe("Target language, ISO 639-1."),
464
+ html: z
465
+ .string()
466
+ .min(1)
467
+ .describe("The complete self-contained HTML document."),
468
+ source_submission_ids: z
469
+ .array(z.string())
470
+ .optional()
471
+ .describe("Optional provenance: the episode ids the lesson was built from."),
472
+ },
473
+ }, async (args) => runJson(() => client.createLesson(args)));
474
+ }
475
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,K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M,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CACzD,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@lingochunk/mcp",
3
+ "version": "0.2.1",
4
+ "description": "Model Context Protocol server for the LingoChunk public API: your FSRS-graded vocabulary, native-audio transcripts and clips, and library, as tools for a coding agent.",
5
+ "license": "MIT",
6
+ "private": false,
7
+ "type": "module",
8
+ "bin": {
9
+ "lingochunk-mcp": "dist/index.js"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "engines": {
15
+ "node": ">=18"
16
+ },
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "typecheck": "tsc --noEmit",
20
+ "test": "vitest run",
21
+ "start": "node dist/index.js",
22
+ "smoke": "node --experimental-strip-types scripts/smoke.ts",
23
+ "prepare": "npm run build"
24
+ },
25
+ "dependencies": {
26
+ "@modelcontextprotocol/sdk": "^1.29.0",
27
+ "zod": "^3.23.8"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^22.0.0",
31
+ "typescript": "^5.6.0",
32
+ "vitest": "^2.1.0"
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/lxol/lingochunk-mcp.git"
37
+ },
38
+ "homepage": "https://github.com/lxol/lingochunk-mcp#readme",
39
+ "bugs": {
40
+ "url": "https://github.com/lxol/lingochunk-mcp/issues"
41
+ }
42
+ }