@better-i18n/mcp-server 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 +41 -98
- package/dist/client.d.ts +3 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +40 -3
- package/dist/client.js.map +1 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +21 -9
- package/dist/context.js.map +1 -1
- package/dist/index.js +26 -15
- package/dist/index.js.map +1 -1
- package/dist/tools/bulkCreateKeys.d.ts.map +1 -1
- package/dist/tools/bulkCreateKeys.js +4 -4
- package/dist/tools/bulkCreateKeys.js.map +1 -1
- package/dist/tools/createTranslationKey.d.ts.map +1 -1
- package/dist/tools/createTranslationKey.js +3 -3
- package/dist/tools/createTranslationKey.js.map +1 -1
- package/dist/tools/listKeys.d.ts +2 -2
- package/dist/tools/listKeys.d.ts.map +1 -1
- package/dist/tools/listKeys.js +6 -37
- package/dist/tools/listKeys.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,58 +1,48 @@
|
|
|
1
1
|
# @better-i18n/mcp-server
|
|
2
2
|
|
|
3
|
-
MCP (Model Context Protocol) server for [Better i18n](https://better-i18n.com)
|
|
3
|
+
MCP (Model Context Protocol) server for [Better i18n](https://better-i18n.com). Enables AI assistants like Claude and GPT to manage translations directly from your IDE.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- 🤖 **AI-Powered Translation
|
|
8
|
-
- 📝 **Create
|
|
7
|
+
- 🤖 **AI-Powered Translation** - Let AI handle your i18n workflow
|
|
8
|
+
- 📝 **Create & Update Keys** - Add new keys with source text and translations
|
|
9
9
|
- 🔄 **Bulk Operations** - Create/update multiple keys at once
|
|
10
|
-
- 🔍 **Smart
|
|
11
|
-
- 🌍 **Multi-language
|
|
10
|
+
- 🔍 **Smart Filtering** - Find keys by name, namespace, or missing translations
|
|
11
|
+
- 🌍 **Multi-language** - Manage all your target languages
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
15
|
-
### Global Installation (Recommended)
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npm install -g @better-i18n/mcp-server
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
### With npx
|
|
22
|
-
|
|
23
|
-
You can also run it directly without installing:
|
|
24
|
-
|
|
25
15
|
```bash
|
|
16
|
+
# With npx (no install needed)
|
|
26
17
|
npx @better-i18n/mcp-server
|
|
18
|
+
|
|
19
|
+
# Or install globally
|
|
20
|
+
npm install -g @better-i18n/mcp-server
|
|
27
21
|
```
|
|
28
22
|
|
|
29
23
|
## Setup
|
|
30
24
|
|
|
31
25
|
### 1. Get Your API Key
|
|
32
26
|
|
|
33
|
-
1. Go to [better-i18n.com
|
|
34
|
-
2.
|
|
35
|
-
3.
|
|
36
|
-
|
|
37
|
-
### 2. Add i18n.config.ts to Your Project
|
|
27
|
+
1. Go to [dash.better-i18n.com](https://dash.better-i18n.com)
|
|
28
|
+
2. Navigate to Settings → API Keys
|
|
29
|
+
3. Create and copy your API key
|
|
38
30
|
|
|
39
|
-
|
|
31
|
+
### 2. Add i18n config to your project
|
|
40
32
|
|
|
41
|
-
```
|
|
42
|
-
|
|
33
|
+
```ts
|
|
34
|
+
// i18n.ts
|
|
35
|
+
import { createI18n } from "@better-i18n/next";
|
|
43
36
|
|
|
44
37
|
export const i18n = createI18n({
|
|
45
|
-
|
|
46
|
-
projectSlug: "your-project", // Your project slug
|
|
38
|
+
project: "your-org/your-project", // Format: "org-slug/project-slug"
|
|
47
39
|
defaultLocale: "en",
|
|
48
40
|
});
|
|
49
41
|
```
|
|
50
42
|
|
|
51
|
-
### 3. Configure
|
|
43
|
+
### 3. Configure Cursor
|
|
52
44
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
Add to your MCP settings (`~/.cursor/mcp.json` or project's `.cursor/mcp.json`):
|
|
45
|
+
Add to `~/.cursor/mcp.json`:
|
|
56
46
|
|
|
57
47
|
```json
|
|
58
48
|
{
|
|
@@ -68,90 +58,43 @@ Add to your MCP settings (`~/.cursor/mcp.json` or project's `.cursor/mcp.json`):
|
|
|
68
58
|
}
|
|
69
59
|
```
|
|
70
60
|
|
|
71
|
-
Or with global install:
|
|
72
|
-
|
|
73
|
-
```json
|
|
74
|
-
{
|
|
75
|
-
"mcpServers": {
|
|
76
|
-
"better-i18n": {
|
|
77
|
-
"command": "better-i18n-mcp",
|
|
78
|
-
"env": {
|
|
79
|
-
"BETTER_I18N_API_KEY": "your-api-key-here"
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
```
|
|
85
|
-
|
|
86
61
|
## Available Tools
|
|
87
62
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
63
|
+
| Tool | Description |
|
|
64
|
+
|------|-------------|
|
|
65
|
+
| `getProjectInfo` | Get project overview: namespaces, languages, key count |
|
|
66
|
+
| `listKeys` | List all translation keys with filtering |
|
|
67
|
+
| `createTranslationKey` | Create a single key with translations |
|
|
68
|
+
| `bulkCreateKeys` | Create multiple keys at once |
|
|
69
|
+
| `updateTranslation` | Update a single translation |
|
|
70
|
+
| `bulkUpdateTranslations` | Update multiple translations at once |
|
|
96
71
|
|
|
97
|
-
|
|
98
|
-
Create a single translation key with source text and optional translations.
|
|
72
|
+
## Example Prompts
|
|
99
73
|
|
|
100
|
-
|
|
101
|
-
Create multiple translation keys with all translations in one request.
|
|
102
|
-
|
|
103
|
-
```json
|
|
104
|
-
{
|
|
105
|
-
"keys": [
|
|
106
|
-
{
|
|
107
|
-
"key": "nav.home",
|
|
108
|
-
"namespace": "nav",
|
|
109
|
-
"sourceText": "Home",
|
|
110
|
-
"translations": { "tr": "Ana Sayfa", "de": "Startseite" }
|
|
111
|
-
}
|
|
112
|
-
]
|
|
113
|
-
}
|
|
114
|
-
```
|
|
74
|
+
Ask your AI assistant:
|
|
115
75
|
|
|
116
|
-
|
|
117
|
-
Update a single translation for a specific language.
|
|
76
|
+
> "List all my translation keys"
|
|
118
77
|
|
|
119
|
-
|
|
120
|
-
Update translations for multiple keys at once.
|
|
78
|
+
> "Add Turkish translations for all keys missing Turkish"
|
|
121
79
|
|
|
122
|
-
|
|
80
|
+
> "Create a new key nav.home with text 'Home' and translate to German and Turkish"
|
|
123
81
|
|
|
124
|
-
|
|
82
|
+
> "Show me translation coverage stats"
|
|
125
83
|
|
|
126
|
-
|
|
84
|
+
## How It Works
|
|
127
85
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
86
|
+
1. MCP server detects your project from `i18n.ts` config
|
|
87
|
+
2. AI assistant uses tools to read/write translations
|
|
88
|
+
3. Changes sync to Better i18n dashboard
|
|
89
|
+
4. CDN serves updated translations to your app
|
|
131
90
|
|
|
132
91
|
## Environment Variables
|
|
133
92
|
|
|
134
93
|
| Variable | Required | Description |
|
|
135
94
|
|----------|----------|-------------|
|
|
136
|
-
| `BETTER_I18N_API_KEY` | Yes | Your API key
|
|
137
|
-
| `BETTER_I18N_API_URL` | No | API URL (
|
|
138
|
-
|
|
139
|
-
## Development
|
|
140
|
-
|
|
141
|
-
```bash
|
|
142
|
-
# Clone the repo
|
|
143
|
-
git clone https://github.com/better-i18n/better-i18n.git
|
|
144
|
-
cd packages/mcp-server
|
|
145
|
-
|
|
146
|
-
# Install dependencies
|
|
147
|
-
npm install
|
|
148
|
-
|
|
149
|
-
# Run in development mode
|
|
150
|
-
npm run dev
|
|
151
|
-
|
|
152
|
-
# Build
|
|
153
|
-
npm run build
|
|
154
|
-
```
|
|
95
|
+
| `BETTER_I18N_API_KEY` | Yes | Your API key |
|
|
96
|
+
| `BETTER_I18N_API_URL` | No | API URL (auto-detected) |
|
|
97
|
+
| `BETTER_I18N_DEBUG` | No | Enable verbose logging |
|
|
155
98
|
|
|
156
99
|
## License
|
|
157
100
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tRPC client for
|
|
2
|
+
* tRPC client for Better i18n API with API key authentication
|
|
3
3
|
*/
|
|
4
4
|
export interface ClientConfig {
|
|
5
5
|
apiUrl: string;
|
|
6
6
|
apiKey: string;
|
|
7
|
+
debug?: boolean;
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
9
10
|
* Create a tRPC client authenticated with API key
|
|
@@ -11,7 +12,7 @@ export interface ClientConfig {
|
|
|
11
12
|
* @param config - API URL, API key, and optional organization ID
|
|
12
13
|
* @returns Configured tRPC client
|
|
13
14
|
*/
|
|
14
|
-
export declare function
|
|
15
|
+
export declare function createBetterI18nClient(config: ClientConfig & {
|
|
15
16
|
organizationId?: string;
|
|
16
17
|
}): import("@trpc/client").TRPCClient<any>;
|
|
17
18
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,YAAY,GAAG;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,0CAgExF"}
|
package/dist/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tRPC client for
|
|
2
|
+
* tRPC client for Better i18n API with API key authentication
|
|
3
3
|
*/
|
|
4
4
|
import { createTRPCClient, httpBatchLink } from "@trpc/client";
|
|
5
5
|
/**
|
|
@@ -8,18 +8,22 @@ import { createTRPCClient, httpBatchLink } from "@trpc/client";
|
|
|
8
8
|
* @param config - API URL, API key, and optional organization ID
|
|
9
9
|
* @returns Configured tRPC client
|
|
10
10
|
*/
|
|
11
|
-
export function
|
|
11
|
+
export function createBetterI18nClient(config) {
|
|
12
12
|
// Ensure URL ends with /api/trpc for tRPC endpoint
|
|
13
13
|
const url = config.apiUrl.endsWith("/api/trpc")
|
|
14
14
|
? config.apiUrl
|
|
15
15
|
: `${config.apiUrl.replace(/\/$/, "")}/api/trpc`;
|
|
16
|
+
if (config.debug) {
|
|
17
|
+
console.error(`[better-i18n] tRPC endpoint: ${url}`);
|
|
18
|
+
}
|
|
19
|
+
// Track logged requests to avoid duplicate logs (tRPC batching can call headers multiple times)
|
|
20
|
+
let lastLoggedUrl = "";
|
|
16
21
|
return createTRPCClient({
|
|
17
22
|
links: [
|
|
18
23
|
httpBatchLink({
|
|
19
24
|
url,
|
|
20
25
|
headers: () => {
|
|
21
26
|
const headers = {
|
|
22
|
-
// Better Auth expects API key in x-api-key header
|
|
23
27
|
"x-api-key": config.apiKey,
|
|
24
28
|
};
|
|
25
29
|
if (config.organizationId) {
|
|
@@ -27,6 +31,39 @@ export function createParisClient(config) {
|
|
|
27
31
|
}
|
|
28
32
|
return headers;
|
|
29
33
|
},
|
|
34
|
+
fetch: async (input, init) => {
|
|
35
|
+
const inputUrl = String(input);
|
|
36
|
+
// Only log if this is a different request (avoid duplicate logs from tRPC batching)
|
|
37
|
+
if (config.debug && inputUrl !== lastLoggedUrl) {
|
|
38
|
+
lastLoggedUrl = inputUrl;
|
|
39
|
+
// Parse the URL to show a cleaner log
|
|
40
|
+
try {
|
|
41
|
+
const parsedUrl = new URL(inputUrl);
|
|
42
|
+
const procedure = parsedUrl.pathname.split("/").pop();
|
|
43
|
+
console.error(`[better-i18n] → ${procedure}`);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
console.error(`[better-i18n] → ${inputUrl}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const response = await fetch(input, init);
|
|
50
|
+
if (config.debug && inputUrl === lastLoggedUrl) {
|
|
51
|
+
if (response.ok) {
|
|
52
|
+
console.error(`[better-i18n] ← ${response.status} OK`);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const clonedResponse = response.clone();
|
|
56
|
+
try {
|
|
57
|
+
const text = await clonedResponse.text();
|
|
58
|
+
console.error(`[better-i18n] ← ${response.status} ERROR: ${text.substring(0, 200)}`);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
console.error(`[better-i18n] ← ${response.status} ERROR`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return response;
|
|
66
|
+
},
|
|
30
67
|
}),
|
|
31
68
|
],
|
|
32
69
|
});
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAY/D;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAkD;IACvF,mDAAmD;IACnD,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC7C,CAAC,CAAC,MAAM,CAAC,MAAM;QACf,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC;IAEnD,IAAI,MAAM,CAAC,KAA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AAE,CAAC;wBAC/C,IAAI,QAAQ,CAAC,EAAE,EAAE,CAAC;4BAChB,OAAO,CAAC,KAAK,CAAC,mBAAmB,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC;wBACzD,CAAC;6BAAM,CAAC;4BACN,MAAM,cAAc,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC;4BACxC,IAAI,CAAC;gCACH,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,CAAC;gCACzC,OAAO,CAAC,KAAK,CAAC,mBAAmB,QAAQ,CAAC,MAAM,WAAW,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;4BACvF,CAAC;4BAAC,MAAM,CAAC;gCACP,OAAO,CAAC,KAAK,CAAC,mBAAmB,QAAQ,CAAC,MAAM,QAAQ,CAAC,CAAC;4BAC5D,CAAC;wBACH,CAAC;oBACH,CAAC;oBAED,OAAO,QAAQ,CAAC;gBAClB,CAAC;aACF,CAAC;SACH;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,GAAE,MAAsB,GAC/B,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CA0BhC"}
|
package/dist/context.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Automatically detects Better i18n project configuration by searching for
|
|
5
5
|
* createI18n usage from @better-i18n/next or @better-i18n/core in the workspace.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
8
8
|
import { dirname, join } from "node:path";
|
|
9
9
|
/**
|
|
10
10
|
* Find and parse createI18n configuration in workspace
|
|
@@ -95,7 +95,7 @@ function findCreateI18nFile(workspaceRoot) {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
catch
|
|
98
|
+
catch {
|
|
99
99
|
// Ignore permission errors
|
|
100
100
|
}
|
|
101
101
|
}
|
|
@@ -119,22 +119,34 @@ function findCreateI18nFile(workspaceRoot) {
|
|
|
119
119
|
/**
|
|
120
120
|
* Parse file to extract createI18n configuration
|
|
121
121
|
*
|
|
122
|
-
*
|
|
123
|
-
* from the createI18n call.
|
|
122
|
+
* Supports both old format (workspaceId + projectSlug) and new format (project: "org/slug")
|
|
124
123
|
*/
|
|
125
124
|
function parseI18nConfig(filePath) {
|
|
126
125
|
const content = readFileSync(filePath, "utf-8");
|
|
127
|
-
//
|
|
126
|
+
// Try new format first: project: "org/slug"
|
|
127
|
+
const projectMatch = content.match(/project:\s*['"]([^'"]+\/[^'"]+)['"]/);
|
|
128
|
+
if (projectMatch) {
|
|
129
|
+
const [workspaceId, projectSlug] = projectMatch[1].split("/");
|
|
130
|
+
const localeMatch = content.match(/defaultLocale:\s*['"]([^'"]+)['"]/);
|
|
131
|
+
const cdnMatch = content.match(/cdnBaseUrl:\s*['"]([^'"]+)['"]/);
|
|
132
|
+
return {
|
|
133
|
+
workspaceId,
|
|
134
|
+
projectSlug,
|
|
135
|
+
defaultLocale: localeMatch?.[1] || "en",
|
|
136
|
+
cdnBaseUrl: cdnMatch?.[1],
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
// Fall back to old format: workspaceId + projectSlug (for backward compatibility)
|
|
128
140
|
const workspaceMatch = content.match(/workspaceId:\s*['"]([^'"]+)['"]/);
|
|
129
|
-
const
|
|
141
|
+
const projectSlugMatch = content.match(/projectSlug:\s*['"]([^'"]+)['"]/);
|
|
130
142
|
const localeMatch = content.match(/defaultLocale:\s*['"]([^'"]+)['"]/);
|
|
131
143
|
const cdnMatch = content.match(/cdnBaseUrl:\s*['"]([^'"]+)['"]/);
|
|
132
|
-
if (!workspaceMatch || !
|
|
133
|
-
throw new Error(`Invalid createI18n config in ${filePath}: missing
|
|
144
|
+
if (!workspaceMatch || !projectSlugMatch) {
|
|
145
|
+
throw new Error(`Invalid createI18n config in ${filePath}: missing project or workspaceId/projectSlug`);
|
|
134
146
|
}
|
|
135
147
|
return {
|
|
136
148
|
workspaceId: workspaceMatch[1],
|
|
137
|
-
projectSlug:
|
|
149
|
+
projectSlug: projectSlugMatch[1],
|
|
138
150
|
defaultLocale: localeMatch?.[1] || "en",
|
|
139
151
|
cdnBaseUrl: cdnMatch?.[1],
|
|
140
152
|
};
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAS1C;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,WAAmB,OAAO,CAAC,GAAG,EAAE;IAEhC,IAAI,CAAC;QACH,sBAAsB;QACtB,MAAM,aAAa,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QAElD,OAAO,CAAC,KAAK,CAAC,6CAA6C,aAAa,KAAK,CAAC,CAAC;QAE/E,0CAA0C;QAC1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OAAO,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvE,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;IAEjE,IAAI,CAAC,cAAc,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CACb,gCAAgC,QAAQ,8CAA8C,CACvF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;QAC9B,WAAW,EAAE,gBAAgB,CAAC,CAAC,CAAC;QAChC,aAAa,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI;QACvC,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;KAC1B,CAAC;AACJ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
10
10
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
11
11
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
12
|
-
import {
|
|
12
|
+
import { createBetterI18nClient } from "./client.js";
|
|
13
13
|
import { detectProjectContext } from "./context.js";
|
|
14
14
|
import { bulkCreateKeys } from "./tools/bulkCreateKeys.js";
|
|
15
15
|
import { bulkUpdateTranslations } from "./tools/bulkUpdateTranslations.js";
|
|
@@ -17,9 +17,9 @@ import { createTranslationKey } from "./tools/createTranslationKey.js";
|
|
|
17
17
|
import { getProjectInfo } from "./tools/getProjectInfo.js";
|
|
18
18
|
import { listKeys } from "./tools/listKeys.js";
|
|
19
19
|
import { updateTranslation } from "./tools/updateTranslation.js";
|
|
20
|
-
class
|
|
20
|
+
class BetterI18nServer {
|
|
21
21
|
server;
|
|
22
|
-
|
|
22
|
+
apiClient;
|
|
23
23
|
context;
|
|
24
24
|
constructor() {
|
|
25
25
|
this.server = new Server({
|
|
@@ -31,16 +31,27 @@ class ParisI18nServer {
|
|
|
31
31
|
},
|
|
32
32
|
});
|
|
33
33
|
// Will be initialized in init()
|
|
34
|
-
this.
|
|
34
|
+
this.apiClient = null;
|
|
35
35
|
this.context = {
|
|
36
36
|
projectContext: null,
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
async init() {
|
|
40
|
-
//
|
|
41
|
-
|
|
40
|
+
// Auto-detect if running from source (local dev) vs npm package (production)
|
|
41
|
+
// If script path contains 'packages/mcp-server/src', we're in local development
|
|
42
|
+
const scriptPath = process.argv[1] || "";
|
|
43
|
+
const isLocalDev = scriptPath.includes("packages/mcp-server/src") ||
|
|
44
|
+
scriptPath.includes("better-i18n/packages/mcp-server");
|
|
45
|
+
// Read configuration from environment, with smart defaults
|
|
46
|
+
const apiUrl = process.env.BETTER_I18N_API_URL ||
|
|
47
|
+
(isLocalDev ? "http://localhost:8787" : "https://dash.better-i18n.com");
|
|
42
48
|
const apiKey = process.env.BETTER_I18N_API_KEY;
|
|
43
49
|
const envOrgId = process.env.BETTER_I18N_ORG_ID;
|
|
50
|
+
const debug = process.env.BETTER_I18N_DEBUG === "true" || isLocalDev;
|
|
51
|
+
console.error(`[better-i18n] Mode: ${isLocalDev ? "LOCAL DEV" : "PRODUCTION"}`);
|
|
52
|
+
console.error(`[better-i18n] API URL: ${apiUrl}`);
|
|
53
|
+
if (debug)
|
|
54
|
+
console.error(`[better-i18n] Debug mode: enabled`);
|
|
44
55
|
if (!apiKey) {
|
|
45
56
|
console.error("[better-i18n] ERROR: BETTER_I18N_API_KEY environment variable is required");
|
|
46
57
|
console.error("[better-i18n] Get your API key from: https://better-i18n.com/settings/api-keys");
|
|
@@ -70,8 +81,8 @@ class ParisI18nServer {
|
|
|
70
81
|
console.error("[better-i18n] Warning: Could not lookup organization ID:", err);
|
|
71
82
|
}
|
|
72
83
|
}
|
|
73
|
-
// Create
|
|
74
|
-
this.
|
|
84
|
+
// Create Better i18n API client with organization context
|
|
85
|
+
this.apiClient = createBetterI18nClient({ apiUrl, apiKey, organizationId, debug });
|
|
75
86
|
if (this.context.projectContext) {
|
|
76
87
|
console.error(`[better-i18n] Detected project: ${this.context.projectContext.workspaceId}/${this.context.projectContext.projectSlug}`);
|
|
77
88
|
}
|
|
@@ -99,22 +110,22 @@ class ParisI18nServer {
|
|
|
99
110
|
let result;
|
|
100
111
|
switch (name) {
|
|
101
112
|
case "getProjectInfo":
|
|
102
|
-
result = await getProjectInfo.execute(this.
|
|
113
|
+
result = await getProjectInfo.execute(this.apiClient, args, this.context);
|
|
103
114
|
break;
|
|
104
115
|
case "createTranslationKey":
|
|
105
|
-
result = await createTranslationKey.execute(this.
|
|
116
|
+
result = await createTranslationKey.execute(this.apiClient, args, this.context);
|
|
106
117
|
break;
|
|
107
118
|
case "updateTranslation":
|
|
108
|
-
result = await updateTranslation.execute(this.
|
|
119
|
+
result = await updateTranslation.execute(this.apiClient, args, this.context);
|
|
109
120
|
break;
|
|
110
121
|
case "listKeys":
|
|
111
|
-
result = await listKeys.execute(this.
|
|
122
|
+
result = await listKeys.execute(this.apiClient, args, this.context);
|
|
112
123
|
break;
|
|
113
124
|
case "bulkCreateKeys":
|
|
114
|
-
result = await bulkCreateKeys.execute(this.
|
|
125
|
+
result = await bulkCreateKeys.execute(this.apiClient, args, this.context);
|
|
115
126
|
break;
|
|
116
127
|
case "bulkUpdateTranslations":
|
|
117
|
-
result = await bulkUpdateTranslations.execute(this.
|
|
128
|
+
result = await bulkUpdateTranslations.execute(this.apiClient, args, this.context);
|
|
118
129
|
break;
|
|
119
130
|
default:
|
|
120
131
|
throw new Error(`Unknown tool: ${name}`);
|
|
@@ -141,7 +152,7 @@ class ParisI18nServer {
|
|
|
141
152
|
}
|
|
142
153
|
}
|
|
143
154
|
// Start the server
|
|
144
|
-
const server = new
|
|
155
|
+
const server = new BetterI18nServer();
|
|
145
156
|
server.init().then(() => server.run()).catch((error) => {
|
|
146
157
|
console.error("[better-i18n] Fatal error:", error);
|
|
147
158
|
process.exit(1);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,MAAM,gBAAgB;IACZ,MAAM,CAAS;IACf,SAAS,CAAM;IACf,OAAO,CAAc;IAE7B;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CACtB;YACE,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,OAAO;SACjB,EACD;YACE,YAAY,EAAE;gBACZ,KAAK,EAAE,EAAE;aACV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IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrD,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;IACnD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulkCreateKeys.d.ts","sourceRoot":"","sources":["../../src/tools/bulkCreateKeys.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"bulkCreateKeys.d.ts","sourceRoot":"","sources":["../../src/tools/bulkCreateKeys.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAc9C,eAAO,MAAM,cAAc,EAAE,IA6G5B,CAAC"}
|
|
@@ -17,7 +17,7 @@ const inputSchema = z.object({
|
|
|
17
17
|
export const bulkCreateKeys = {
|
|
18
18
|
definition: {
|
|
19
19
|
name: "bulkCreateKeys",
|
|
20
|
-
description: "Create multiple translation keys with their translations in a single request. Use this when adding translations for an entire component or page. Each key can have sourceText (English) and translations for other languages.",
|
|
20
|
+
description: "Create multiple translation keys with their translations in a single request. Use this when adding translations for an entire component or page. Each key can have sourceText (English) and translations for other languages. IMPORTANT: If namespace is provided, the key should NOT include the namespace prefix (e.g., namespace: 'nav', key: 'features' NOT 'nav.features').",
|
|
21
21
|
inputSchema: {
|
|
22
22
|
type: "object",
|
|
23
23
|
properties: {
|
|
@@ -33,11 +33,11 @@ export const bulkCreateKeys = {
|
|
|
33
33
|
properties: {
|
|
34
34
|
key: {
|
|
35
35
|
type: "string",
|
|
36
|
-
description: "Translation key (e.g., 'nav.features')",
|
|
36
|
+
description: "Translation key WITHOUT namespace prefix when namespace is provided (e.g., 'features' when namespace is 'nav', NOT 'nav.features'). Only include full path if namespace is not provided.",
|
|
37
37
|
},
|
|
38
38
|
namespace: {
|
|
39
39
|
type: "string",
|
|
40
|
-
description: "Namespace (e.g., 'nav', 'home'). Defaults to 'default'",
|
|
40
|
+
description: "Namespace for the key (e.g., 'nav', 'home', 'cta'). When provided, the key should NOT include this namespace prefix. Defaults to 'default' if not provided.",
|
|
41
41
|
},
|
|
42
42
|
sourceText: {
|
|
43
43
|
type: "string",
|
|
@@ -72,7 +72,7 @@ export const bulkCreateKeys = {
|
|
|
72
72
|
}
|
|
73
73
|
try {
|
|
74
74
|
// Format keys with default namespace
|
|
75
|
-
const formattedKeys = input.keys.map(k => ({
|
|
75
|
+
const formattedKeys = input.keys.map((k) => ({
|
|
76
76
|
key: k.key,
|
|
77
77
|
namespace: k.namespace || "default",
|
|
78
78
|
sourceText: k.sourceText,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulkCreateKeys.js","sourceRoot":"","sources":["../../src/tools/bulkCreateKeys.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,IAAI,EAAE,CAAC,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"bulkCreateKeys.js","sourceRoot":"","sources":["../../src/tools/bulkCreateKeys.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,IAAI,EAAE,CAAC,CAAC,KAAK,CACX,CAAC,CAAC,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,IAAI,EAAE,oCAAoC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;qBACnG;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTranslationKey.d.ts","sourceRoot":"","sources":["../../src/tools/createTranslationKey.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAS9C,eAAO,MAAM,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"createTranslationKey.d.ts","sourceRoot":"","sources":["../../src/tools/createTranslationKey.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAS9C,eAAO,MAAM,oBAAoB,EAAE,IA4FlC,CAAC"}
|
|
@@ -14,7 +14,7 @@ const inputSchema = z.object({
|
|
|
14
14
|
export const createTranslationKey = {
|
|
15
15
|
definition: {
|
|
16
16
|
name: "createTranslationKey",
|
|
17
|
-
description: "Create a new translation key with source text.
|
|
17
|
+
description: "Create a new translation key with source text. If namespace is provided, the key should NOT include the namespace prefix (e.g., namespace: 'auth', key: 'login.title' NOT 'auth.login.title'). If namespace is not provided, it will be auto-extracted from the key if it contains dots. If projectSlug is not provided, uses the project from i18n.config.ts in the workspace.",
|
|
18
18
|
inputSchema: {
|
|
19
19
|
type: "object",
|
|
20
20
|
properties: {
|
|
@@ -24,7 +24,7 @@ export const createTranslationKey = {
|
|
|
24
24
|
},
|
|
25
25
|
key: {
|
|
26
26
|
type: "string",
|
|
27
|
-
description: "Translation key (e.g., '
|
|
27
|
+
description: "Translation key WITHOUT namespace prefix when namespace is provided (e.g., 'login.title' when namespace is 'auth'). Include namespace in key only if namespace parameter is not provided (e.g., 'auth.login.title').",
|
|
28
28
|
},
|
|
29
29
|
sourceValue: {
|
|
30
30
|
type: "string",
|
|
@@ -32,7 +32,7 @@ export const createTranslationKey = {
|
|
|
32
32
|
},
|
|
33
33
|
namespace: {
|
|
34
34
|
type: "string",
|
|
35
|
-
description: "
|
|
35
|
+
description: "Namespace for the key (e.g., 'auth', 'home', 'cta'). When provided, the key should NOT include this namespace prefix.",
|
|
36
36
|
},
|
|
37
37
|
},
|
|
38
38
|
required: ["key", "sourceValue"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTranslationKey.js","sourceRoot":"","sources":["../../src/tools/createTranslationKey.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACtB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACjC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAS;IACxC,UAAU,EAAE;QACV,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EACT,
|
|
1
|
+
{"version":3,"file":"createTranslationKey.js","sourceRoot":"","sources":["../../src/tools/createTranslationKey.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE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H,mDAAmD;YACnD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC;gBAC/C,OAAO;gBACP,WAAW;gBACX,GAAG,EAAE,KAAK,CAAC,GAAG;gBACd,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,SAAS;gBACvC,UAAU,EAAE,KAAK,CAAC,WAAW;aAC9B,CAAC,CAAC;YAEH,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;4BACE,OAAO,EAAE,IAAI;4BACb,KAAK,EAAE,MAAM,CAAC,KAAK;4BACnB,GAAG,EAAE,KAAK,CAAC,GAAG;4BACd,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,SAAS;4BACvC,UAAU,EAAE,KAAK,CAAC,WAAW;4BAC7B,OAAO,EAAE,GAAG,OAAO,IAAI,WAAW,EAAE;yBACrC,EACD,IAAI,EACJ,CAAC,CACF;qBACF;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,mCAAmC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;qBAClG;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
|
package/dist/tools/listKeys.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* listKeys MCP Tool
|
|
3
3
|
*
|
|
4
|
-
* Lists translation keys in a project with
|
|
5
|
-
* Uses the MCP-specific
|
|
4
|
+
* Lists ALL translation keys in a project with their source text and translations.
|
|
5
|
+
* Uses the MCP-specific getAllTranslations endpoint - no pagination needed.
|
|
6
6
|
*/
|
|
7
7
|
import type { Tool } from "../types/index.js";
|
|
8
8
|
export declare const listKeys: Tool;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listKeys.d.ts","sourceRoot":"","sources":["../../src/tools/listKeys.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"listKeys.d.ts","sourceRoot":"","sources":["../../src/tools/listKeys.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAQ9C,eAAO,MAAM,QAAQ,EAAE,IA0EtB,CAAC"}
|
package/dist/tools/listKeys.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* listKeys MCP Tool
|
|
3
3
|
*
|
|
4
|
-
* Lists translation keys in a project with
|
|
5
|
-
* Uses the MCP-specific
|
|
4
|
+
* Lists ALL translation keys in a project with their source text and translations.
|
|
5
|
+
* Uses the MCP-specific getAllTranslations endpoint - no pagination needed.
|
|
6
6
|
*/
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
const inputSchema = z.object({
|
|
9
9
|
projectSlug: z.string().optional(),
|
|
10
10
|
search: z.string().optional(),
|
|
11
11
|
namespaces: z.array(z.string()).optional(),
|
|
12
|
-
missingLanguage: z.string().optional(),
|
|
13
|
-
page: z.number().min(1).default(1),
|
|
14
|
-
limit: z.number().min(1).max(100).default(50),
|
|
15
12
|
});
|
|
16
13
|
export const listKeys = {
|
|
17
14
|
definition: {
|
|
18
15
|
name: "listKeys",
|
|
19
|
-
description: "
|
|
16
|
+
description: "Get all translation keys with their source text and translations. Returns ALL keys in a single response - no pagination. Use 'search' to filter by key name or 'namespaces' to filter by namespace.",
|
|
20
17
|
inputSchema: {
|
|
21
18
|
type: "object",
|
|
22
19
|
properties: {
|
|
@@ -33,18 +30,6 @@ export const listKeys = {
|
|
|
33
30
|
items: { type: "string" },
|
|
34
31
|
description: "Filter by specific namespaces (e.g., ['nav', 'home'])",
|
|
35
32
|
},
|
|
36
|
-
missingLanguage: {
|
|
37
|
-
type: "string",
|
|
38
|
-
description: "Find keys that don't have a translation for this language code (e.g., 'tr' to find keys missing Turkish)",
|
|
39
|
-
},
|
|
40
|
-
page: {
|
|
41
|
-
type: "number",
|
|
42
|
-
description: "Page number (default: 1)",
|
|
43
|
-
},
|
|
44
|
-
limit: {
|
|
45
|
-
type: "number",
|
|
46
|
-
description: "Results per page (default: 50, max: 100)",
|
|
47
|
-
},
|
|
48
33
|
},
|
|
49
34
|
},
|
|
50
35
|
},
|
|
@@ -65,34 +50,18 @@ export const listKeys = {
|
|
|
65
50
|
};
|
|
66
51
|
}
|
|
67
52
|
try {
|
|
68
|
-
// Use
|
|
69
|
-
const result = await client.mcp.
|
|
53
|
+
// Use getAllTranslations endpoint - no pagination, single request
|
|
54
|
+
const result = await client.mcp.getAllTranslations.query({
|
|
70
55
|
orgSlug,
|
|
71
56
|
projectSlug,
|
|
72
57
|
search: input.search,
|
|
73
58
|
namespaces: input.namespaces,
|
|
74
|
-
missingLanguage: input.missingLanguage,
|
|
75
|
-
page: input.page,
|
|
76
|
-
limit: input.limit,
|
|
77
59
|
});
|
|
78
|
-
// Format the response
|
|
79
|
-
const summary = {
|
|
80
|
-
project: `${orgSlug}/${projectSlug}`,
|
|
81
|
-
page: input.page,
|
|
82
|
-
limit: input.limit,
|
|
83
|
-
total: result.total,
|
|
84
|
-
totalPages: Math.ceil(result.total / input.limit),
|
|
85
|
-
keysCount: result.keys.length,
|
|
86
|
-
...(input.missingLanguage && { missingLanguage: input.missingLanguage }),
|
|
87
|
-
};
|
|
88
60
|
return {
|
|
89
61
|
content: [
|
|
90
62
|
{
|
|
91
63
|
type: "text",
|
|
92
|
-
text: JSON.stringify(
|
|
93
|
-
summary,
|
|
94
|
-
keys: result.keys,
|
|
95
|
-
}, null, 2),
|
|
64
|
+
text: JSON.stringify(result, null, 2),
|
|
96
65
|
},
|
|
97
66
|
],
|
|
98
67
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listKeys.js","sourceRoot":"","sources":["../../src/tools/listKeys.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"listKeys.js","sourceRoot":"","sources":["../../src/tools/listKeys.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CAC3C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAS;IAC5B,UAAU,EAAE;QACV,IAAI,EAAE,UAAU;QAChB,WAAW,EACT,qMAAqM;QACvM,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,kDAAkD;iBAChE;gBACD,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,WAAW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AC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;qBACtF;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-i18n/mcp-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "MCP server for Better i18n translation management - AI-powered translation workflow for Cursor, Claude, and other AI assistants",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|