lingual-mcp 0.1.0 → 0.1.2

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,12 +1,29 @@
1
1
  # lingual-mcp
2
2
 
3
- Universal Model Context Protocol (MCP) server powered by [`pi-lingual`](https://github.com/3ZEROS12/pi-lingual) (`pi-lingual/core`).
3
+ Model Context Protocol server for [`pi-lingual`](https://github.com/3ZEROS12/pi-lingual): the same mode engine, reachable from any MCP client.
4
4
 
5
- Works with **Claude Code**, **Claude Desktop**, **Cursor**, **Windsurf**, **Cline**, and any MCP client — with both **Zero-Key Template Mode** (no API key needed) and **Direct Endpoint Mode** (`OPENAI_BASE_URL` / `LINGUAL_ENDPOINT`).
5
+ Works with **Claude Code**, **Claude Desktop**, **Cursor**, **Windsurf**, **Cline**, and anything else that speaks MCP. Two run modes: **template mode** (no API key — the client's own model executes the compiled prompt) and **endpoint mode** (the server calls an OpenAI-compatible endpoint).
6
6
 
7
- ## Quick Setup
7
+ ## Install
8
8
 
9
- Not published to npm yet, so point the client at this checkout (the built `dist/` is produced by `npm run build`):
9
+ ```bash
10
+ npm install -g lingual-mcp # or: npx -y lingual-mcp
11
+ ```
12
+
13
+ Point the client at it:
14
+
15
+ ```json
16
+ {
17
+ "mcpServers": {
18
+ "lingual": {
19
+ "command": "npx",
20
+ "args": ["-y", "lingual-mcp"]
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ From a checkout instead:
10
27
 
11
28
  ```json
12
29
  {
@@ -19,30 +36,49 @@ Not published to npm yet, so point the client at this checkout (the built `dist/
19
36
  }
20
37
  ```
21
38
 
22
- Once the package is on npm, the same entry collapses to `"command": "npx", "args": ["-y", "lingual-mcp"]`.
39
+ ## Tools
23
40
 
24
- Verify a local build before wiring it up:
41
+ | Tool | Arguments | Purpose |
42
+ | :--- | :--- | :--- |
43
+ | `lingual_transform_spec` | `text`, `loadout`, `sourceLang?`, `targetLang?`, `reasoning?`, `context?`, `includeVocab?` | Compiles a draft into a preset's product: `spec`, `commit`, `oss`, `yap`, `direct`, or any custom mode id. Code fences and stack traces stay untouched. |
44
+ | `lingual_bilingual_companion` | `text`, `sourceLang?`, `targetLang?`, `reasoning?`, `includeVocab?` | Dual-register phrasing (spoken vs. written), native nuance, and vocabulary callouts, using the companion slots from your `lingual.json`. |
45
+ | `lingual_prompt_template` | `loadout`, `sourceLang?`, `targetLang?`, `includeVocab?` | Returns the compiled system prompt and slot schema so the host agent can run it with its own model. |
25
46
 
26
- ```bash
27
- npm install && npm run check # typecheck + MCP protocol tests
28
- ```
47
+ Shared argument semantics:
48
+
49
+ - `loadout` accepts the five presets (`spec`, `commit`, `oss`, `yap`, `direct`), `companion` where it applies, and **any mode id declared in `~/.pi/agent/lingual.json`**. Custom ids are resolved at request time and offered in the tool schema.
50
+ - `reasoning` is one of `off`, `minimal`, `low`, `medium`, `high`. An explicit value overrides the level the mode pins (`spec` pins `low`, the rest pin `off`).
51
+ - `context` injects extra material for context-aware modes: a staged diff for `commit`, the previous turn for a review mode.
52
+ - `includeVocab: false` drops the vocabulary slot from both the prompt and the response.
53
+ - `sourceLang` is auto-detected from the script when omitted; `targetLang` defaults to `en`.
54
+
55
+ ## Prompts
29
56
 
30
- ### Tools and Prompts
57
+ | Prompt | Arguments | Purpose |
58
+ | :--- | :--- | :--- |
59
+ | `spec_prompt` | `raw_idea`, `source_lang?`, `target_lang?` | Reusable prompt that structures a raw idea into a specification. |
60
+ | `conventional_commit` | `changes_summary`, `source_lang?`, `target_lang?` | Reusable prompt that turns a change summary into a Conventional Commit. |
31
61
 
32
- | Kind | Name | Arguments | Purpose |
33
- | :--- | :--- | :--- | :--- |
34
- | tool | `lingual_transform_spec` | `text`, `loadout` (`spec` / `commit` / `oss` / `yap` / `direct`), `sourceLang?`, `targetLang?` | Turns messy native-language thought into a structured spec, a Conventional Commit, maintainer peer comms, a dense tech post, or a direct technical-English rewrite, leaving code blocks and stack traces untouched. |
35
- | tool | `lingual_bilingual_companion` | `text`, `sourceLang?`, `targetLang?` | Dual-register phrasing (spoken vs. written), native nuance, and key vocabulary callouts. |
36
- | tool | `lingual_prompt_template` | `loadout`, `sourceLang?`, `targetLang?` | Zero-key mode: returns the compiled system prompt and few-shot rules for a loadout so the host agent executes it with its own model. |
37
- | prompt | `spec_prompt` | `raw_idea`, `source_lang?`, `target_lang?` | Reusable prompt that structures a raw idea into a specification. |
38
- | prompt | `conventional_commit` | `changes_summary`, `source_lang?`, `target_lang?` | Reusable prompt that turns a change summary into a Conventional Commit message. |
62
+ Both are compiled through the same mode resolution, so a custom `spec` or `commit` mode in `lingual.json` changes what the prompts emit.
39
63
 
40
- ### Optional Environment Variables (for server-side LLM execution)
64
+ ## Endpoint mode
65
+
66
+ Set any of these to let the server call a model itself:
41
67
 
42
68
  | Variable | Description |
43
69
  | :--- | :--- |
44
70
  | `LINGUAL_ENDPOINT` / `OPENAI_BASE_URL` | OpenAI-compatible base URL (e.g. `https://api.openai.com/v1` or `http://127.0.0.1:3425/v1`) |
45
- | `LINGUAL_API_KEY` / `OPENAI_API_KEY` | API key (loopback endpoints default to `"local"` if omitted) |
46
- | `LINGUAL_MODEL` / `OPENAI_MODEL` | Model ID (default: `gpt-4o-mini`) |
71
+ | `LINGUAL_API_KEY` / `OPENAI_API_KEY` | API key; loopback endpoints default to `"local"` when omitted |
72
+ | `LINGUAL_MODEL` / `OPENAI_MODEL` | Model id (default: `gpt-4o-mini`) |
73
+
74
+ `~/.pi/agent/lingual.json` is also read, so `endpoint`, `apiKey`, `model`, `explainLang`, `globalKillList`, and `modes` carry over from your Pi setup.
75
+
76
+ Without credentials, the transform and companion tools return `unconfigured_zero_key_fallback` with a `compiledSystemPrompt` field; `lingual_prompt_template` and the MCP prompts work with no key at all.
77
+
78
+ ## Notes
79
+
80
+ - The server reports its `package.json` version in the MCP handshake.
81
+ - Requires `pi-lingual` `^0.9.0` for the core engine.
82
+ - `lingual-mcp` is not a Pi extension: it runs beside your editor's agent, not inside Pi.
47
83
 
48
- If no external credentials are set, `lingual_prompt_template`, MCP `prompts` (`spec_prompt`, `conventional_commit`), and the `unconfigured_zero_key_fallback` mode still work out of the box using your host agent's own LLM.
84
+ MIT © [Jason Song](https://github.com/3ZEROS12)
package/dist/index.d.ts CHANGED
@@ -1,14 +1,32 @@
1
1
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
- import { LingualConfig } from 'pi-lingual/core';
2
+ import { LingualConfig, ReasoningEffort, CustomModeConfig, PromptSlotConfig } from 'pi-lingual/core';
3
3
 
4
+ interface McpServerOptions {
5
+ /** Replaces the on-disk `lingual.json` snapshot; tests and embedders pin their own config. */
6
+ diskConfig?: Partial<LingualConfig>;
7
+ }
4
8
  interface ResolvedMcpLlmConfig {
5
9
  configured: boolean;
6
10
  endpoint?: string;
7
11
  apiKey?: string;
8
12
  model?: string;
9
13
  }
14
+ declare const REASONING_LEVELS: readonly ReasoningEffort[];
15
+ declare const PRESET_IDS: readonly ["spec", "commit", "oss", "yap", "direct"];
16
+ declare const PKG_VERSION: string;
10
17
  declare function resolveMcpLlmConfig(diskConfig: Partial<LingualConfig>, env?: NodeJS.ProcessEnv): ResolvedMcpLlmConfig;
11
- declare function createLingualMcpServer(): Server;
18
+ declare function normalizeReasoningArg(raw: unknown): ReasoningEffort | undefined;
19
+ /** Resolves a preset, a factory mode, or a user mode declared in `lingual.json`. */
20
+ declare function resolveMode(id: string, sourceLang: string, explainLang: string, custom?: CustomModeConfig[]): CustomModeConfig | null;
21
+ declare function stripVocabSlots(slots?: PromptSlotConfig[]): PromptSlotConfig[] | undefined;
22
+ /** An explicit request-level reasoning level wins over the level a mode pins. */
23
+ declare function applyModeOverrides(mode: CustomModeConfig, options: {
24
+ reasoning?: ReasoningEffort;
25
+ includeVocab?: boolean;
26
+ }): CustomModeConfig;
27
+ declare function modeIds(disk: Partial<LingualConfig>, extra?: readonly string[]): string[];
28
+
29
+ declare function createLingualMcpServer(options?: McpServerOptions): Server;
12
30
  declare function runLingualMcpServer(): Promise<void>;
13
31
 
14
- export { type ResolvedMcpLlmConfig, createLingualMcpServer, resolveMcpLlmConfig, runLingualMcpServer };
32
+ export { type McpServerOptions, PKG_VERSION, PRESET_IDS, REASONING_LEVELS, type ResolvedMcpLlmConfig, applyModeOverrides, createLingualMcpServer, modeIds, normalizeReasoningArg, resolveMcpLlmConfig, resolveMode, runLingualMcpServer, stripVocabSlots };