@better-i18n/mcp-server 0.1.0
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 +158 -0
- package/dist/client.d.ts +17 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +34 -0
- package/dist/client.js.map +1 -0
- package/dist/context.d.ts +23 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +142 -0
- package/dist/context.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +149 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/bulkCreateKeys.d.ts +9 -0
- package/dist/tools/bulkCreateKeys.d.ts.map +1 -0
- package/dist/tools/bulkCreateKeys.js +113 -0
- package/dist/tools/bulkCreateKeys.js.map +1 -0
- package/dist/tools/bulkUpdateTranslations.d.ts +9 -0
- package/dist/tools/bulkUpdateTranslations.d.ts.map +1 -0
- package/dist/tools/bulkUpdateTranslations.js +107 -0
- package/dist/tools/bulkUpdateTranslations.js.map +1 -0
- package/dist/tools/createTranslationKey.d.ts +9 -0
- package/dist/tools/createTranslationKey.d.ts.map +1 -0
- package/dist/tools/createTranslationKey.js +95 -0
- package/dist/tools/createTranslationKey.js.map +1 -0
- package/dist/tools/getProjectInfo.d.ts +9 -0
- package/dist/tools/getProjectInfo.d.ts.map +1 -0
- package/dist/tools/getProjectInfo.js +67 -0
- package/dist/tools/getProjectInfo.js.map +1 -0
- package/dist/tools/listKeys.d.ts +9 -0
- package/dist/tools/listKeys.d.ts.map +1 -0
- package/dist/tools/listKeys.js +113 -0
- package/dist/tools/listKeys.js.map +1 -0
- package/dist/tools/updateTranslation.d.ts +9 -0
- package/dist/tools/updateTranslation.d.ts.map +1 -0
- package/dist/tools/updateTranslation.js +101 -0
- package/dist/tools/updateTranslation.js.map +1 -0
- package/dist/types/index.d.ts +44 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* updateTranslation MCP Tool
|
|
3
|
+
*
|
|
4
|
+
* Updates or creates a translation for a specific language.
|
|
5
|
+
* Uses the MCP-specific API that works with org/project slugs.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
const inputSchema = z.object({
|
|
9
|
+
projectSlug: z.string().optional(),
|
|
10
|
+
key: z.string().min(1),
|
|
11
|
+
languageCode: z.string().min(2).max(10),
|
|
12
|
+
value: z.string(),
|
|
13
|
+
namespace: z.string().optional(),
|
|
14
|
+
});
|
|
15
|
+
export const updateTranslation = {
|
|
16
|
+
definition: {
|
|
17
|
+
name: "updateTranslation",
|
|
18
|
+
description: "Update or create a translation for a specific language. If the translation doesn't exist, it will be created.",
|
|
19
|
+
inputSchema: {
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: {
|
|
22
|
+
projectSlug: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "Project slug (optional if i18n.config.ts exists)",
|
|
25
|
+
},
|
|
26
|
+
key: {
|
|
27
|
+
type: "string",
|
|
28
|
+
description: "Translation key to update",
|
|
29
|
+
},
|
|
30
|
+
languageCode: {
|
|
31
|
+
type: "string",
|
|
32
|
+
description: "Language code (e.g., 'en', 'tr', 'de', 'fr')",
|
|
33
|
+
},
|
|
34
|
+
value: {
|
|
35
|
+
type: "string",
|
|
36
|
+
description: "Translation text",
|
|
37
|
+
},
|
|
38
|
+
namespace: {
|
|
39
|
+
type: "string",
|
|
40
|
+
description: "Namespace (default: 'default')",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
required: ["key", "languageCode", "value"],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
async execute(client, args, context) {
|
|
47
|
+
const input = inputSchema.parse(args);
|
|
48
|
+
// Get project slug from args or context
|
|
49
|
+
const projectSlug = input.projectSlug || context.projectContext?.projectSlug;
|
|
50
|
+
const orgSlug = context.projectContext?.workspaceId;
|
|
51
|
+
if (!projectSlug || !orgSlug) {
|
|
52
|
+
return {
|
|
53
|
+
content: [
|
|
54
|
+
{
|
|
55
|
+
type: "text",
|
|
56
|
+
text: "Error: Project not specified and no i18n.config.ts found in workspace",
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
isError: true,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
// Use MCP-specific endpoint with slug-based lookup
|
|
64
|
+
await client.mcp.updateTranslation.mutate({
|
|
65
|
+
orgSlug,
|
|
66
|
+
projectSlug,
|
|
67
|
+
key: input.key,
|
|
68
|
+
namespace: input.namespace || "default",
|
|
69
|
+
languageCode: input.languageCode,
|
|
70
|
+
value: input.value,
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
content: [
|
|
74
|
+
{
|
|
75
|
+
type: "text",
|
|
76
|
+
text: JSON.stringify({
|
|
77
|
+
success: true,
|
|
78
|
+
key: input.key,
|
|
79
|
+
namespace: input.namespace || "default",
|
|
80
|
+
languageCode: input.languageCode,
|
|
81
|
+
value: input.value,
|
|
82
|
+
project: `${orgSlug}/${projectSlug}`,
|
|
83
|
+
}, null, 2),
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
return {
|
|
90
|
+
content: [
|
|
91
|
+
{
|
|
92
|
+
type: "text",
|
|
93
|
+
text: `Error updating translation: ${error instanceof Error ? error.message : String(error)}`,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
isError: true,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=updateTranslation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateTranslation.js","sourceRoot":"","sources":["../../src/tools/updateTranslation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO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AAC,KAAK,CAAC,EAAE;qBAC9F;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for MCP server
|
|
3
|
+
*/
|
|
4
|
+
import type { ProjectContext } from "../context.js";
|
|
5
|
+
/**
|
|
6
|
+
* MCP Tool definition
|
|
7
|
+
*/
|
|
8
|
+
export interface ToolDefinition {
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: "object";
|
|
13
|
+
properties: Record<string, any>;
|
|
14
|
+
required?: string[];
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* MCP Tool execution result - compatible with @modelcontextprotocol/sdk
|
|
19
|
+
*/
|
|
20
|
+
export interface ToolResult {
|
|
21
|
+
content: Array<{
|
|
22
|
+
type: "text" | "image" | "resource";
|
|
23
|
+
text?: string;
|
|
24
|
+
data?: string;
|
|
25
|
+
uri?: string;
|
|
26
|
+
mimeType?: string;
|
|
27
|
+
}>;
|
|
28
|
+
isError?: boolean;
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* MCP Tool implementation
|
|
33
|
+
*/
|
|
34
|
+
export interface Tool {
|
|
35
|
+
definition: ToolDefinition;
|
|
36
|
+
execute: (client: any, args: unknown, context: ToolContext) => Promise<ToolResult>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Context passed to tool execution
|
|
40
|
+
*/
|
|
41
|
+
export interface ToolContext {
|
|
42
|
+
projectContext: ProjectContext | null;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAChC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;QACpC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,UAAU,EAAE,cAAc,CAAC;IAC3B,OAAO,EAAE,CACP,MAAM,EAAE,GAAG,EACX,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,WAAW,KACjB,OAAO,CAAC,UAAU,CAAC,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,cAAc,EAAE,cAAc,GAAG,IAAI,CAAC;CACvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@better-i18n/mcp-server",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server for Better i18n translation management - AI-powered translation workflow for Cursor, Claude, and other AI assistants",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"bin": {
|
|
10
|
+
"better-i18n-mcp": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"package.json",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/better-i18n/better-i18n.git",
|
|
23
|
+
"directory": "packages/mcp-server"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://better-i18n.com",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/better-i18n/better-i18n/issues"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"mcp",
|
|
31
|
+
"model-context-protocol",
|
|
32
|
+
"i18n",
|
|
33
|
+
"internationalization",
|
|
34
|
+
"translation",
|
|
35
|
+
"better-i18n",
|
|
36
|
+
"cursor",
|
|
37
|
+
"claude",
|
|
38
|
+
"ai",
|
|
39
|
+
"localization"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsc",
|
|
43
|
+
"start": "node ./dist/index.js",
|
|
44
|
+
"dev": "bun run src/index.ts",
|
|
45
|
+
"typecheck": "tsc --noEmit",
|
|
46
|
+
"clean": "rm -rf dist",
|
|
47
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@modelcontextprotocol/sdk": "^1.0.4",
|
|
51
|
+
"@trpc/client": "^11.0.0",
|
|
52
|
+
"zod": "^3.25.1"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/node": "^20.0.0",
|
|
56
|
+
"typescript": "~5.9.2"
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=18.0.0"
|
|
60
|
+
}
|
|
61
|
+
}
|