@intlayer/mcp 5.5.11 → 5.5.12

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
@@ -33,7 +33,7 @@
33
33
  <a href="https://www.facebook.com/intlayer" target="blank"><img align="center"
34
34
  src="https://img.shields.io/badge/facebook-4267B2.svg?style=for-the-badge&logo=facebook&logoColor=white"
35
35
  alt="Intlayer Facebook" height="30"/></a>
36
- <a href="https://www.instagram.com/intlayer_org/" target="blank"><img align="center"
36
+ <a href="https://www.instagram.com/intlayer/" target="blank"><img align="center"
37
37
  src="https://img.shields.io/badge/instagram-%23E4405F.svg?style=for-the-badge&logo=Instagram&logoColor=white"
38
38
  alt="Intlayer Instagram" height="30"/></a>
39
39
  <a href="https://x.com/Intlayer183096" target="blank"><img align="center"
@@ -49,32 +49,153 @@
49
49
  </p>
50
50
  </div>
51
51
 
52
- # @intlayer/dictionary-entry: Retrieve Intlayer dictionaries
52
+ # @intlayer/mcp: Intlayer MCP Server (Model Context Protocol)
53
53
 
54
- **Intlayer** is a suite of packages designed specifically for JavaScript developers. It is compatible with frameworks like React, React, and Express.js.
54
+ The **Intlayer MCP (Model Context Protocol) Server** provides AI-powered IDE assistance tailored for the Intlayer ecosystem. Designed for modern developer environments like **Cursor**, **GitHub Copilot workspace**, and any IDE supporting the MCP protocol, this server gives you contextual, real-time support based on your project's setup.
55
55
 
56
- The **`@intlayer/dictionary-entry`** package is a NPM package that only returns the entry path of the intlayer dictionaries. Since the filesystem search is impossible from the browser, using bundlers like Webpack or Rollup to retrieve the entry path of the dictionaries is not possible. This package aims to be aliased.
56
+ ## Why Use the Intlayer MCP Server?
57
57
 
58
- ## Installation
58
+ By enabling the Intlayer MCP Server in your IDE, you unlock:
59
59
 
60
- Install the necessary package using your preferred package manager:
60
+ - **Smart CLI Integration**
61
+ Access and run Intlayer CLI commands directly from your IDE interface. View the full list of commands and options in the [Intlayer CLI documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_cli.md).
61
62
 
62
- ```bash packageManager="npm"
63
- npm install @intlayer/dictionary-entry
63
+ - **Context-Aware Documentation**
64
+ The MCP server loads and exposes the documentation that corresponds to the version of Intlayer you're using in your project. This ensures that code suggestions, command options, and explanations are always up to date and relevant.
65
+
66
+ - **AI-Assisted Development**
67
+ With project-aware suggestions and autocomplete, the AI assistant can explain your code, recommend CLI usage, or suggest how to use specific features of Intlayer based on your current files.
68
+
69
+ - **Lightweight & Instant Setup**
70
+ No server maintenance or heavy install required. Just configure your `.cursor/mcp.json` or equivalent MCP config and you're ready to go.
71
+
72
+ ---
73
+
74
+ ## Setup Cursor
75
+
76
+ In your project root, add the following `.cursor/mcp.json` configuration file:
77
+
78
+ ```json
79
+ {
80
+ "mcpServers": {
81
+ "intlayer": {
82
+ "command": "npx",
83
+ "args": ["-y", "@intlayer/mcp"]
84
+ }
85
+ }
86
+ }
64
87
  ```
65
88
 
66
- ```bash packageManager="pnpm"
67
- pnpm add @intlayer/dictionary-entry
89
+ This tells your IDE to launch the Intlayer MCP server using `npx`, ensuring it always uses the latest available version unless you pin it.
90
+
91
+ ---
92
+
93
+ ## Setup VS Code
94
+
95
+ To use the Intlayer MCP Server with VS Code, you need to configure it in your workspace or user settings.
96
+
97
+ ### Workspace Configuration
98
+
99
+ Create a `.vscode/mcp.json` file in your project root:
100
+
101
+ ```json
102
+ {
103
+ "servers": {
104
+ "intlayer": {
105
+ "type": "stdio",
106
+ "command": "npx",
107
+ "args": ["-y", "@intlayer/mcp"]
108
+ }
109
+ }
110
+ }
68
111
  ```
69
112
 
70
- ```bash packageManager="yarn"
71
- yarn add @intlayer/dictionary-entry
113
+ ### Using the MCP Server in VS Code
114
+
115
+ 1. **Enable Agent Mode**: Open the Chat view (⌃⌘I on Mac, Ctrl+Alt+I on Windows/Linux) and select **Agent** mode from the dropdown.
116
+
117
+ 2. **Access Tools**: Click the **Tools** button to view available Intlayer tools. You can select/deselect specific tools as needed.
118
+
119
+ 3. **Direct Tool Reference**: Reference tools directly in your prompts by typing `#` followed by the tool name.
120
+
121
+ 4. **Tool Confirmation**: By default, VS Code will ask for confirmation before running tools. Use the **Continue** button options to automatically confirm tools for the current session, workspace, or all future invocations.
122
+
123
+ ### Managing the Server
124
+
125
+ - Run **MCP: List Servers** from the Command Palette to view configured servers
126
+ - Start, stop, or restart the Intlayer MCP server as needed
127
+ - View server logs for troubleshooting by selecting the server and choosing **Show Output**
128
+
129
+ For more detailed information about VS Code MCP integration, see the [official VS Code MCP documentation](https://code.visualstudio.com/docs/copilot/chat/mcp-servers).
130
+
131
+ ---
132
+
133
+ ## Using the MCP Server via CLI
134
+
135
+ You can also run the Intlayer MCP server directly from the command line for testing, debugging, or integration with other tools.
136
+
137
+ ### Install the MCP Server
138
+
139
+ First, install the MCP server package globally or use it via npx:
140
+
141
+ ```bash
142
+ # Install globally
143
+ npm install -g @intlayer/mcp
144
+
145
+ # Or use directly with npx (recommended)
146
+ npx @intlayer/mcp
72
147
  ```
73
148
 
74
- ## Read about Intlayer
149
+ ### Start the Server
150
+
151
+ To start the MCP server with the inspector for debugging and testing:
152
+
153
+ ```bash
154
+ # Using the built-in start command
155
+ npm run start
156
+
157
+ # Or directly with npx
158
+ npx @modelcontextprotocol/inspector npx @intlayer/mcp
159
+ ```
160
+
161
+ This will launch the MCP server with an inspector interface that allows you to:
162
+
163
+ - Test MCP protocol communications
164
+ - Debug server responses
165
+ - Validate tool and resource implementations
166
+ - Monitor server performance
167
+
168
+ ### Development Usage
169
+
170
+ For development and testing purposes, you can run the server in various modes:
171
+
172
+ ```bash
173
+ # Build and start in development mode
174
+ npm run dev
175
+
176
+ # Run with custom configuration
177
+ node dist/cjs/index.cjs
178
+
179
+ # Test the server functionality
180
+ npm test
181
+ ```
182
+
183
+ The server will expose Intlayer-specific tools and resources that can be consumed by any MCP-compatible client, not just Cursor or other IDEs.
184
+
185
+ ---
186
+
187
+ ## Features Overview
188
+
189
+ | Feature | Description |
190
+ | -------------- | ---------------------------------------------------------------------------- |
191
+ | CLI Support | Run `intlayer` commands, get usage hints and arguments inline |
192
+ | Versioned Docs | Auto-detect and load documentation matching your current version of Intlayer |
193
+ | Autocompletion | Intelligent command and config suggestions as you type |
194
+ | Plugin-Ready | Compatible with IDEs and tools that support the MCP standard |
195
+
196
+ ---
75
197
 
76
- - [Intlayer Website](https://intlayer.org)
77
- - [Intlayer Documentation](https://intlayer.org/doc)
78
- - [Intlayer GitHub](https://github.com/aymericzip/intlayer)
198
+ ##Useful Links
79
199
 
80
- - [Ask your questions to our smart documentation](https://intlayer.org/docchat)
200
+ - [Intlayer CLI Documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_cli.md)
201
+ - [Intlayer GitHub Repository](https://github.com/aymericzip/intlayer)
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var index_exports = {};
21
31
  __export(index_exports, {
@@ -26,7 +36,9 @@ var import_cli = require("@intlayer/cli");
26
36
  var import_config = require("@intlayer/config");
27
37
  var import_docs = require("@intlayer/docs");
28
38
  var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
39
+ var import_sse = require("@modelcontextprotocol/sdk/server/sse.js");
29
40
  var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
41
+ var import_express = __toESM(require("express"));
30
42
  var import_fs = require("fs");
31
43
  var import_path = require("path");
32
44
  var import_url = require("url");
@@ -95,10 +107,8 @@ const server = new import_mcp.McpServer({
95
107
  });
96
108
  server.tool(
97
109
  "intlayer-build",
98
- {
99
- description: "Build the dictionaries",
100
- ...buildToolSchema
101
- },
110
+ "Build the dictionaries. List all content declarations files `.content.{ts,tsx,js,json,...}` to update the content callable using the `useIntlayer` hook.",
111
+ buildToolSchema,
102
112
  async ({ watch, baseDir, env, envFile, verbose, prefix }) => {
103
113
  try {
104
114
  const log = {};
@@ -142,10 +152,8 @@ server.tool(
142
152
  );
143
153
  server.tool(
144
154
  "intlayer-fill",
145
- {
146
- description: "Fill the dictionaries with missing translations",
147
- ...fillToolSchema
148
- },
155
+ "Fill the dictionaries with missing translations / review translations using Intlayer servers",
156
+ fillToolSchema,
149
157
  async (props) => {
150
158
  try {
151
159
  const { gitOptions, ...rest } = props;
@@ -183,10 +191,8 @@ server.tool(
183
191
  );
184
192
  server.tool(
185
193
  "intlayer-push",
186
- {
187
- description: "Push dictionaries to the server",
188
- ...pushToolSchema
189
- },
194
+ "Push locale dictionaries to the server",
195
+ pushToolSchema,
190
196
  async (props) => {
191
197
  try {
192
198
  const { gitOptions, ...rest } = props;
@@ -224,10 +230,8 @@ server.tool(
224
230
  );
225
231
  server.tool(
226
232
  "intlayer-pull",
227
- {
228
- description: "Pull dictionaries from the server",
229
- ...pullToolSchema
230
- },
233
+ "Pull dictionaries from the CMS",
234
+ pullToolSchema,
231
235
  async (props) => {
232
236
  try {
233
237
  await (0, import_cli.pull)(props);
@@ -254,12 +258,12 @@ server.tool(
254
258
  );
255
259
  server.tool(
256
260
  "get-doc-list",
261
+ "Get the list of docs names and their metadata to get more details about what doc to retrieve",
257
262
  {
258
- lang: import_zod.z.nativeEnum(import_config.Locales),
259
- description: "Get the list of docs and their metadata to get more details about what doc to"
263
+ lang: import_zod.z.nativeEnum(import_config.Locales).optional().describe("Language of the docs")
260
264
  },
261
- async ({}) => {
262
- const docsMetadataRecord = await (0, import_docs.getDocMetadataRecord)();
265
+ async ({ lang }) => {
266
+ const docsMetadataRecord = await (0, import_docs.getDocMetadataRecord)(lang);
263
267
  return {
264
268
  content: [
265
269
  {
@@ -272,10 +276,10 @@ server.tool(
272
276
  );
273
277
  server.tool(
274
278
  "get-doc",
279
+ "Get a doc by his key. Example: `./docs/en/getting-started.md`. List all docs metadata first to get more details about what doc key to retrieve.",
275
280
  {
276
281
  docKey: import_zod.z.string(),
277
- lang: import_zod.z.nativeEnum(import_config.Locales),
278
- description: "Get a doc by his key"
282
+ lang: import_zod.z.nativeEnum(import_config.Locales).optional().describe("Language of the docs")
279
283
  },
280
284
  async ({ docKey, lang }) => {
281
285
  const doc = await (0, import_docs.getDoc)(docKey, lang);
@@ -286,22 +290,62 @@ server.tool(
286
290
  );
287
291
  server.tool(
288
292
  "get-doc-by-slug",
293
+ "Get an array of docs by their slugs. If not slug is provided, return all docs (1.2Mb). List all docs metadata first to get more details about what doc to retrieve.",
289
294
  {
290
- slug: import_zod.z.union([import_zod.z.string(), import_zod.z.array(import_zod.z.string())]),
291
- lang: import_zod.z.nativeEnum(import_config.Locales),
295
+ slug: import_zod.z.union([import_zod.z.string(), import_zod.z.array(import_zod.z.string())]).optional().describe(
296
+ "Slug of the docs. If not provided, return all docs. If not provided, return all docs."
297
+ ),
298
+ lang: import_zod.z.nativeEnum(import_config.Locales).optional().describe("Language of the docs"),
299
+ strict: import_zod.z.boolean().optional().describe(
300
+ "Strict mode - only return docs that match all slugs, by excluding additional slugs"
301
+ ),
292
302
  description: "Get an array of docs by their slugs"
293
303
  },
294
- async ({ slug, lang }) => {
295
- const doc = await (0, import_docs.getDocBySlug)(slug, lang);
304
+ async ({ slug, lang, strict }) => {
305
+ const doc = await (0, import_docs.getDocBySlug)(slug, lang, strict);
296
306
  return {
297
307
  content: doc.map((d) => ({ type: "text", text: d }))
298
308
  };
299
309
  }
300
310
  );
301
311
  const main = async () => {
302
- const transport = new import_stdio.StdioServerTransport();
303
- await server.connect(transport);
304
- console.error("Intlayer MCP Server running on stdio");
312
+ const args = process.argv.slice(2);
313
+ const useHttp = args.includes("--http") ?? process.env.MCP_TRANSPORT === "http";
314
+ const port = parseInt(process.env.MCP_PORT ?? "6274");
315
+ if (useHttp) {
316
+ const app = (0, import_express.default)();
317
+ app.use(import_express.default.json());
318
+ const transports = {};
319
+ app.get("/mcp", async (req, res) => {
320
+ console.error("SSE connection request received");
321
+ const transport = new import_sse.SSEServerTransport("/messages", res);
322
+ transports[transport.sessionId] = transport;
323
+ res.on("close", () => {
324
+ console.error("SSE connection closed");
325
+ delete transports[transport.sessionId];
326
+ });
327
+ await server.connect(transport);
328
+ });
329
+ app.post("/messages", async (req, res) => {
330
+ const sessionId = req.query.sessionId;
331
+ if (!sessionId || !transports[sessionId]) {
332
+ res.status(400).json({ error: "Invalid session ID" });
333
+ return;
334
+ }
335
+ const transport = transports[sessionId];
336
+ await transport.handlePostMessage(req, res, req.body);
337
+ });
338
+ app.get("/health", (req, res) => {
339
+ res.json({ status: "ok", transport: "http" });
340
+ });
341
+ app.listen(port, () => {
342
+ console.error(`Intlayer MCP Server running on HTTP port ${port}`);
343
+ });
344
+ } else {
345
+ const transport = new import_stdio.StdioServerTransport();
346
+ await server.connect(transport);
347
+ console.error("Intlayer MCP Server running on stdio");
348
+ }
305
349
  };
306
350
  main().catch((error) => {
307
351
  console.error("Fatal error in main():", error);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { build, fill, pull, push } from '@intlayer/cli';\nimport { isESModule, Locales, type LogConfig } from '@intlayer/config';\nimport { getDoc, getDocBySlug, getDocMetadataRecord } from '@intlayer/docs';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { readFileSync } from 'fs';\nimport { dirname as pathDirname, resolve } from 'path';\nimport { fileURLToPath } from 'url';\nimport { z } from 'zod';\n\nexport const dirname = isESModule\n ? pathDirname(fileURLToPath(import.meta.url))\n : __dirname;\n\nconst packageJson = JSON.parse(\n readFileSync(resolve(dirname, '../../package.json'), 'utf8')\n);\n\nconst buildToolSchema = {\n watch: z.boolean().optional().describe('Watch for changes'),\n baseDir: z.string().optional().describe('Base directory'),\n env: z.string().optional().describe('Environment'),\n envFile: z.string().optional().describe('Environment file'),\n verbose: z.boolean().optional().describe('Verbose output'),\n prefix: z.string().optional().describe('Log prefix'),\n};\n\ntype BuildToolProps = z.infer<z.ZodObject<typeof buildToolSchema>>;\n\nconst fillToolSchema = {\n sourceLocale: z.nativeEnum(Locales).optional().describe('Source locale'),\n outputLocales: z\n .union([z.nativeEnum(Locales), z.array(z.nativeEnum(Locales))])\n .optional()\n .describe('Output locales'),\n file: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('File path'),\n mode: z.enum(['complete', 'review']).optional().describe('Fill mode'),\n keys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to include'),\n excludedKeys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to exclude'),\n pathFilter: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Path filter'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n aiOptions: z\n .object({\n provider: z.string().optional(),\n temperature: z.number().optional(),\n model: z.string().optional(),\n apiKey: z.string().optional(),\n customPrompt: z.string().optional(),\n applicationContext: z.string().optional(),\n })\n .optional()\n .describe('AI options'),\n};\n\ntype FillToolProps = z.infer<z.ZodObject<typeof fillToolSchema>>;\n\nconst pushToolSchema = {\n deleteLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Delete local dictionary after push'),\n keepLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Keep local dictionary after push'),\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to push'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n};\n\ntype PushToolProps = z.infer<z.ZodObject<typeof pushToolSchema>>;\n\nconst pullToolSchema = {\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to pull'),\n newDictionariesPath: z\n .string()\n .optional()\n .describe('Path to save new dictionaries'),\n};\n\ntype PullToolProps = z.infer<z.ZodObject<typeof pullToolSchema>>;\n\nconst server = new McpServer({\n name: 'intlayer',\n version: packageJson.version,\n capabilities: {\n resources: {},\n },\n});\n\nserver.tool(\n 'intlayer-build',\n {\n description: 'Build the dictionaries',\n ...buildToolSchema,\n },\n async ({ watch, baseDir, env, envFile, verbose, prefix }: BuildToolProps) => {\n try {\n const log: Partial<LogConfig> = {};\n if (verbose) {\n log.mode = 'verbose';\n }\n if (prefix) {\n log.prefix = prefix;\n }\n\n await build({\n watch,\n configOptions: {\n baseDir,\n env,\n envFile,\n override: {\n log,\n },\n },\n });\n\n return {\n content: [\n {\n type: 'text',\n text: 'Build successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Build failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n);\n\nserver.tool(\n 'intlayer-fill',\n {\n description: 'Fill the dictionaries with missing translations',\n ...fillToolSchema,\n },\n async (props: FillToolProps) => {\n try {\n const { gitOptions, ...rest } = props;\n const fillOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n fillOptions.gitOptions = { ...restGit, mode };\n }\n\n await fill(fillOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Fill successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Fill failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n);\n\nserver.tool(\n 'intlayer-push',\n {\n description: 'Push dictionaries to the server',\n ...pushToolSchema,\n },\n async (props: PushToolProps) => {\n try {\n const { gitOptions, ...rest } = props;\n const pushOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n pushOptions.gitOptions = { ...restGit, mode };\n }\n\n await push(pushOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Push successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Push failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n);\n\nserver.tool(\n 'intlayer-pull',\n {\n description: 'Pull dictionaries from the server',\n ...pullToolSchema,\n },\n async (props: PullToolProps) => {\n try {\n await pull(props);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Pull successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Pull failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n);\n\nserver.tool(\n 'get-doc-list',\n {\n lang: z.nativeEnum(Locales),\n description:\n 'Get the list of docs and their metadata to get more details about what doc to',\n },\n async ({}) => {\n const docsMetadataRecord = await getDocMetadataRecord();\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(docsMetadataRecord, null, 2),\n },\n ],\n };\n }\n);\n\nserver.tool(\n 'get-doc',\n {\n docKey: z.string(),\n lang: z.nativeEnum(Locales),\n description: 'Get a doc by his key',\n },\n async ({ docKey, lang }) => {\n const doc = await getDoc(docKey as any, lang);\n return {\n content: [{ type: 'text', text: doc }],\n };\n }\n);\n\nserver.tool(\n 'get-doc-by-slug',\n {\n slug: z.union([z.string(), z.array(z.string())]),\n lang: z.nativeEnum(Locales),\n description: 'Get an array of docs by their slugs',\n },\n async ({ slug, lang }) => {\n const doc = await getDocBySlug(slug, lang);\n return {\n content: doc.map((d) => ({ type: 'text', text: d })),\n };\n }\n);\n\nconst main = async () => {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n console.error('Intlayer MCP Server running on stdio');\n};\n\nmain().catch((error) => {\n console.error('Fatal error in main():', error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAwC;AACxC,oBAAoD;AACpD,kBAA2D;AAC3D,iBAA0B;AAC1B,mBAAqC;AACrC,gBAA6B;AAC7B,kBAAgD;AAChD,iBAA8B;AAC9B,iBAAkB;AAVlB;AAYO,MAAM,UAAU,+BACnB,YAAAA,aAAY,0BAAc,YAAY,GAAG,CAAC,IAC1C;AAEJ,MAAM,cAAc,KAAK;AAAA,MACvB,4BAAa,qBAAQ,SAAS,oBAAoB,GAAG,MAAM;AAC7D;AAEA,MAAM,kBAAkB;AAAA,EACtB,OAAO,aAAE,QAAQ,EAAE,SAAS,EAAE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,QAAe,IAAI;AAC5C,WAAO;AAAA,MACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,IAAI,CAAC;AAAA,IACvC;AAAA,EACF;AACF;AAEA,OAAO;AAAA,EACL;AAAA,EACA;AAAA,IACE,MAAM,aAAE,MAAM,CAAC,aAAE,OAAO,GAAG,aAAE,MAAM,aAAE,OAAO,CAAC,CAAC,CAAC;AAAA,IAC/C,MAAM,aAAE,WAAW,qBAAO;AAAA,IAC1B,aAAa;AAAA,EACf;AAAA,EACA,OAAO,EAAE,MAAM,KAAK,MAAM;AACxB,UAAM,MAAM,UAAM,0BAAa,MAAM,IAAI;AACzC,WAAO;AAAA,MACL,SAAS,IAAI,IAAI,CAAC,OAAO,EAAE,MAAM,QAAQ,MAAM,EAAE,EAAE;AAAA,IACrD;AAAA,EACF;AACF;AAEA,MAAM,OAAO,YAAY;AACvB,QAAM,YAAY,IAAI,kCAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAC9B,UAAQ,MAAM,sCAAsC;AACtD;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,0BAA0B,KAAK;AAC7C,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["pathDirname"]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { build, fill, pull, push } from '@intlayer/cli';\nimport { isESModule, Locales, type LogConfig } from '@intlayer/config';\nimport { getDoc, getDocBySlug, getDocMetadataRecord } from '@intlayer/docs';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport express, { Request, Response } from 'express';\nimport { readFileSync } from 'fs';\nimport { dirname as pathDirname, resolve } from 'path';\nimport { fileURLToPath } from 'url';\nimport { z } from 'zod';\n\nexport const dirname = isESModule\n ? pathDirname(fileURLToPath(import.meta.url))\n : __dirname;\n\nconst packageJson = JSON.parse(\n readFileSync(resolve(dirname, '../../package.json'), 'utf8')\n);\n\nconst buildToolSchema = {\n watch: z.boolean().optional().describe('Watch for changes'),\n baseDir: z.string().optional().describe('Base directory'),\n env: z.string().optional().describe('Environment'),\n envFile: z.string().optional().describe('Environment file'),\n verbose: z.boolean().optional().describe('Verbose output'),\n prefix: z.string().optional().describe('Log prefix'),\n};\n\ntype BuildToolProps = z.infer<z.ZodObject<typeof buildToolSchema>>;\n\nconst fillToolSchema = {\n sourceLocale: z.nativeEnum(Locales).optional().describe('Source locale'),\n outputLocales: z\n .union([z.nativeEnum(Locales), z.array(z.nativeEnum(Locales))])\n .optional()\n .describe('Output locales'),\n file: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('File path'),\n mode: z.enum(['complete', 'review']).optional().describe('Fill mode'),\n keys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to include'),\n excludedKeys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to exclude'),\n pathFilter: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Path filter'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n aiOptions: z\n .object({\n provider: z.string().optional(),\n temperature: z.number().optional(),\n model: z.string().optional(),\n apiKey: z.string().optional(),\n customPrompt: z.string().optional(),\n applicationContext: z.string().optional(),\n })\n .optional()\n .describe('AI options'),\n};\n\ntype FillToolProps = z.infer<z.ZodObject<typeof fillToolSchema>>;\n\nconst pushToolSchema = {\n deleteLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Delete local dictionary after push'),\n keepLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Keep local dictionary after push'),\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to push'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n};\n\ntype PushToolProps = z.infer<z.ZodObject<typeof pushToolSchema>>;\n\nconst pullToolSchema = {\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to pull'),\n newDictionariesPath: z\n .string()\n .optional()\n .describe('Path to save new dictionaries'),\n};\n\ntype PullToolProps = z.infer<z.ZodObject<typeof pullToolSchema>>;\n\nconst server = new McpServer({\n name: 'intlayer',\n version: packageJson.version,\n capabilities: {\n resources: {},\n },\n});\n\nserver.tool(\n 'intlayer-build',\n 'Build the dictionaries. List all content declarations files `.content.{ts,tsx,js,json,...}` to update the content callable using the `useIntlayer` hook.',\n buildToolSchema,\n async ({ watch, baseDir, env, envFile, verbose, prefix }: BuildToolProps) => {\n try {\n const log: Partial<LogConfig> = {};\n if (verbose) {\n log.mode = 'verbose';\n }\n if (prefix) {\n log.prefix = prefix;\n }\n\n await build({\n watch,\n configOptions: {\n baseDir,\n env,\n envFile,\n override: {\n log,\n },\n },\n });\n\n return {\n content: [\n {\n type: 'text',\n text: 'Build successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Build failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n);\n\nserver.tool(\n 'intlayer-fill',\n 'Fill the dictionaries with missing translations / review translations using Intlayer servers',\n fillToolSchema,\n async (props: FillToolProps) => {\n try {\n const { gitOptions, ...rest } = props;\n const fillOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n fillOptions.gitOptions = { ...restGit, mode };\n }\n\n await fill(fillOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Fill successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Fill failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n);\n\nserver.tool(\n 'intlayer-push',\n 'Push locale dictionaries to the server',\n pushToolSchema,\n async (props: PushToolProps) => {\n try {\n const { gitOptions, ...rest } = props;\n const pushOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n pushOptions.gitOptions = { ...restGit, mode };\n }\n\n await push(pushOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Push successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Push failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n);\n\nserver.tool(\n 'intlayer-pull',\n 'Pull dictionaries from the CMS',\n pullToolSchema,\n async (props: PullToolProps) => {\n try {\n await pull(props);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Pull successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Pull failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n);\n\nserver.tool(\n 'get-doc-list',\n 'Get the list of docs names and their metadata to get more details about what doc to retrieve',\n {\n lang: z.nativeEnum(Locales).optional().describe('Language of the docs'),\n },\n async ({ lang }) => {\n const docsMetadataRecord = await getDocMetadataRecord(lang);\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(docsMetadataRecord, null, 2),\n },\n ],\n };\n }\n);\n\nserver.tool(\n 'get-doc',\n 'Get a doc by his key. Example: `./docs/en/getting-started.md`. List all docs metadata first to get more details about what doc key to retrieve.',\n {\n docKey: z.string(),\n lang: z.nativeEnum(Locales).optional().describe('Language of the docs'),\n },\n async ({ docKey, lang }) => {\n const doc = await getDoc(docKey as any, lang);\n return {\n content: [{ type: 'text', text: doc }],\n };\n }\n);\n\nserver.tool(\n 'get-doc-by-slug',\n 'Get an array of docs by their slugs. If not slug is provided, return all docs (1.2Mb). List all docs metadata first to get more details about what doc to retrieve.',\n {\n slug: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe(\n 'Slug of the docs. If not provided, return all docs. If not provided, return all docs.'\n ),\n lang: z.nativeEnum(Locales).optional().describe('Language of the docs'),\n strict: z\n .boolean()\n .optional()\n .describe(\n 'Strict mode - only return docs that match all slugs, by excluding additional slugs'\n ),\n description: 'Get an array of docs by their slugs',\n },\n async ({ slug, lang, strict }) => {\n const doc = await getDocBySlug(slug, lang, strict);\n return {\n content: doc.map((d) => ({ type: 'text', text: d })),\n };\n }\n);\n\nconst main = async () => {\n const args = process.argv.slice(2);\n const useHttp =\n args.includes('--http') ?? process.env.MCP_TRANSPORT === 'http';\n const port = parseInt(process.env.MCP_PORT ?? '6274');\n\n if (useHttp) {\n // HTTP/SSE transport for Docker/remote usage\n const app = express();\n app.use(express.json());\n\n const transports: { [sessionId: string]: SSEServerTransport } = {};\n\n // SSE connection endpoint\n app.get('/mcp', async (req: Request, res: Response) => {\n console.error('SSE connection request received');\n\n const transport = new SSEServerTransport('/messages', res);\n transports[transport.sessionId] = transport;\n\n res.on('close', () => {\n console.error('SSE connection closed');\n delete transports[transport.sessionId];\n });\n\n await server.connect(transport);\n });\n\n // Message handling endpoint\n app.post('/messages', async (req: Request, res: Response) => {\n const sessionId = req.query.sessionId as string;\n\n if (!sessionId || !transports[sessionId]) {\n res.status(400).json({ error: 'Invalid session ID' });\n return;\n }\n\n const transport = transports[sessionId];\n await transport.handlePostMessage(req, res, req.body);\n });\n\n // Health check endpoint\n app.get('/health', (req: Request, res: Response) => {\n res.json({ status: 'ok', transport: 'http' });\n });\n\n app.listen(port, () => {\n console.error(`Intlayer MCP Server running on HTTP port ${port}`);\n });\n } else {\n // Original stdio transport for local usage\n const transport = new StdioServerTransport();\n await server.connect(transport);\n console.error('Intlayer MCP Server running on stdio');\n }\n};\n\nmain().catch((error) => {\n console.error('Fatal error in main():', error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAwC;AACxC,oBAAoD;AACpD,kBAA2D;AAC3D,iBAA0B;AAC1B,iBAAmC;AACnC,mBAAqC;AACrC,qBAA2C;AAC3C,gBAA6B;AAC7B,kBAAgD;AAChD,iBAA8B;AAC9B,iBAAkB;AAZlB;AAcO,MAAM,UAAU,+BACnB,YAAAA,aAAY,0BAAc,YAAY,GAAG,CAAC,IAC1C;AAEJ,MAAM,cAAc,KAAK;AAAA,MACvB,4BAAa,qBAAQ,SAAS,oBAAoB,GAAG,MAAM;AAC7D;AAEA,MAAM,kBAAkB;AAAA,EACtB,OAAO,aAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,mBAAmB;AAAA,EAC1D,SAAS,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,gBAAgB;AAAA,EACxD,KAAK,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,aAAa;AAAA,EACjD,SAAS,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,kBAAkB;AAAA,EAC1D,SAAS,aAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,gBAAgB;AAAA,EACzD,QAAQ,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,YAAY;AACrD;AAIA,MAAM,iBAAiB;AAAA,EACrB,cAAc,aAAE,WAAW,qBAAO,EAAE,SAAS,EAAE,SAAS,eA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,MAAM;AACrB,cAAQ,MAAM,4CAA4C,IAAI,EAAE;AAAA,IAClE,CAAC;AAAA,EACH,OAAO;AAEL,UAAM,YAAY,IAAI,kCAAqB;AAC3C,UAAM,OAAO,QAAQ,SAAS;AAC9B,YAAQ,MAAM,sCAAsC;AAAA,EACtD;AACF;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,0BAA0B,KAAK;AAC7C,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["pathDirname","express"]}
@@ -3,7 +3,9 @@ import { build, fill, pull, push } from "@intlayer/cli";
3
3
  import { isESModule, Locales } from "@intlayer/config";
4
4
  import { getDoc, getDocBySlug, getDocMetadataRecord } from "@intlayer/docs";
5
5
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
6
+ import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
6
7
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
8
+ import express from "express";
7
9
  import { readFileSync } from "fs";
8
10
  import { dirname as pathDirname, resolve } from "path";
9
11
  import { fileURLToPath } from "url";
@@ -71,10 +73,8 @@ const server = new McpServer({
71
73
  });
72
74
  server.tool(
73
75
  "intlayer-build",
74
- {
75
- description: "Build the dictionaries",
76
- ...buildToolSchema
77
- },
76
+ "Build the dictionaries. List all content declarations files `.content.{ts,tsx,js,json,...}` to update the content callable using the `useIntlayer` hook.",
77
+ buildToolSchema,
78
78
  async ({ watch, baseDir, env, envFile, verbose, prefix }) => {
79
79
  try {
80
80
  const log = {};
@@ -118,10 +118,8 @@ server.tool(
118
118
  );
119
119
  server.tool(
120
120
  "intlayer-fill",
121
- {
122
- description: "Fill the dictionaries with missing translations",
123
- ...fillToolSchema
124
- },
121
+ "Fill the dictionaries with missing translations / review translations using Intlayer servers",
122
+ fillToolSchema,
125
123
  async (props) => {
126
124
  try {
127
125
  const { gitOptions, ...rest } = props;
@@ -159,10 +157,8 @@ server.tool(
159
157
  );
160
158
  server.tool(
161
159
  "intlayer-push",
162
- {
163
- description: "Push dictionaries to the server",
164
- ...pushToolSchema
165
- },
160
+ "Push locale dictionaries to the server",
161
+ pushToolSchema,
166
162
  async (props) => {
167
163
  try {
168
164
  const { gitOptions, ...rest } = props;
@@ -200,10 +196,8 @@ server.tool(
200
196
  );
201
197
  server.tool(
202
198
  "intlayer-pull",
203
- {
204
- description: "Pull dictionaries from the server",
205
- ...pullToolSchema
206
- },
199
+ "Pull dictionaries from the CMS",
200
+ pullToolSchema,
207
201
  async (props) => {
208
202
  try {
209
203
  await pull(props);
@@ -230,12 +224,12 @@ server.tool(
230
224
  );
231
225
  server.tool(
232
226
  "get-doc-list",
227
+ "Get the list of docs names and their metadata to get more details about what doc to retrieve",
233
228
  {
234
- lang: z.nativeEnum(Locales),
235
- description: "Get the list of docs and their metadata to get more details about what doc to"
229
+ lang: z.nativeEnum(Locales).optional().describe("Language of the docs")
236
230
  },
237
- async ({}) => {
238
- const docsMetadataRecord = await getDocMetadataRecord();
231
+ async ({ lang }) => {
232
+ const docsMetadataRecord = await getDocMetadataRecord(lang);
239
233
  return {
240
234
  content: [
241
235
  {
@@ -248,10 +242,10 @@ server.tool(
248
242
  );
249
243
  server.tool(
250
244
  "get-doc",
245
+ "Get a doc by his key. Example: `./docs/en/getting-started.md`. List all docs metadata first to get more details about what doc key to retrieve.",
251
246
  {
252
247
  docKey: z.string(),
253
- lang: z.nativeEnum(Locales),
254
- description: "Get a doc by his key"
248
+ lang: z.nativeEnum(Locales).optional().describe("Language of the docs")
255
249
  },
256
250
  async ({ docKey, lang }) => {
257
251
  const doc = await getDoc(docKey, lang);
@@ -262,22 +256,62 @@ server.tool(
262
256
  );
263
257
  server.tool(
264
258
  "get-doc-by-slug",
259
+ "Get an array of docs by their slugs. If not slug is provided, return all docs (1.2Mb). List all docs metadata first to get more details about what doc to retrieve.",
265
260
  {
266
- slug: z.union([z.string(), z.array(z.string())]),
267
- lang: z.nativeEnum(Locales),
261
+ slug: z.union([z.string(), z.array(z.string())]).optional().describe(
262
+ "Slug of the docs. If not provided, return all docs. If not provided, return all docs."
263
+ ),
264
+ lang: z.nativeEnum(Locales).optional().describe("Language of the docs"),
265
+ strict: z.boolean().optional().describe(
266
+ "Strict mode - only return docs that match all slugs, by excluding additional slugs"
267
+ ),
268
268
  description: "Get an array of docs by their slugs"
269
269
  },
270
- async ({ slug, lang }) => {
271
- const doc = await getDocBySlug(slug, lang);
270
+ async ({ slug, lang, strict }) => {
271
+ const doc = await getDocBySlug(slug, lang, strict);
272
272
  return {
273
273
  content: doc.map((d) => ({ type: "text", text: d }))
274
274
  };
275
275
  }
276
276
  );
277
277
  const main = async () => {
278
- const transport = new StdioServerTransport();
279
- await server.connect(transport);
280
- console.error("Intlayer MCP Server running on stdio");
278
+ const args = process.argv.slice(2);
279
+ const useHttp = args.includes("--http") ?? process.env.MCP_TRANSPORT === "http";
280
+ const port = parseInt(process.env.MCP_PORT ?? "6274");
281
+ if (useHttp) {
282
+ const app = express();
283
+ app.use(express.json());
284
+ const transports = {};
285
+ app.get("/mcp", async (req, res) => {
286
+ console.error("SSE connection request received");
287
+ const transport = new SSEServerTransport("/messages", res);
288
+ transports[transport.sessionId] = transport;
289
+ res.on("close", () => {
290
+ console.error("SSE connection closed");
291
+ delete transports[transport.sessionId];
292
+ });
293
+ await server.connect(transport);
294
+ });
295
+ app.post("/messages", async (req, res) => {
296
+ const sessionId = req.query.sessionId;
297
+ if (!sessionId || !transports[sessionId]) {
298
+ res.status(400).json({ error: "Invalid session ID" });
299
+ return;
300
+ }
301
+ const transport = transports[sessionId];
302
+ await transport.handlePostMessage(req, res, req.body);
303
+ });
304
+ app.get("/health", (req, res) => {
305
+ res.json({ status: "ok", transport: "http" });
306
+ });
307
+ app.listen(port, () => {
308
+ console.error(`Intlayer MCP Server running on HTTP port ${port}`);
309
+ });
310
+ } else {
311
+ const transport = new StdioServerTransport();
312
+ await server.connect(transport);
313
+ console.error("Intlayer MCP Server running on stdio");
314
+ }
281
315
  };
282
316
  main().catch((error) => {
283
317
  console.error("Fatal error in main():", error);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { build, fill, pull, push } from '@intlayer/cli';\nimport { isESModule, Locales, type LogConfig } from '@intlayer/config';\nimport { getDoc, getDocBySlug, getDocMetadataRecord } from '@intlayer/docs';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { readFileSync } from 'fs';\nimport { dirname as pathDirname, resolve } from 'path';\nimport { fileURLToPath } from 'url';\nimport { z } from 'zod';\n\nexport const dirname = isESModule\n ? pathDirname(fileURLToPath(import.meta.url))\n : __dirname;\n\nconst packageJson = JSON.parse(\n readFileSync(resolve(dirname, '../../package.json'), 'utf8')\n);\n\nconst buildToolSchema = {\n watch: z.boolean().optional().describe('Watch for changes'),\n baseDir: z.string().optional().describe('Base directory'),\n env: z.string().optional().describe('Environment'),\n envFile: z.string().optional().describe('Environment file'),\n verbose: z.boolean().optional().describe('Verbose output'),\n prefix: z.string().optional().describe('Log prefix'),\n};\n\ntype BuildToolProps = z.infer<z.ZodObject<typeof buildToolSchema>>;\n\nconst fillToolSchema = {\n sourceLocale: z.nativeEnum(Locales).optional().describe('Source locale'),\n outputLocales: z\n .union([z.nativeEnum(Locales), z.array(z.nativeEnum(Locales))])\n .optional()\n .describe('Output locales'),\n file: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('File path'),\n mode: z.enum(['complete', 'review']).optional().describe('Fill mode'),\n keys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to include'),\n excludedKeys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to exclude'),\n pathFilter: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Path filter'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n aiOptions: z\n .object({\n provider: z.string().optional(),\n temperature: z.number().optional(),\n model: z.string().optional(),\n apiKey: z.string().optional(),\n customPrompt: z.string().optional(),\n applicationContext: z.string().optional(),\n })\n .optional()\n .describe('AI options'),\n};\n\ntype FillToolProps = z.infer<z.ZodObject<typeof fillToolSchema>>;\n\nconst pushToolSchema = {\n deleteLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Delete local dictionary after push'),\n keepLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Keep local dictionary after push'),\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to push'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n};\n\ntype PushToolProps = z.infer<z.ZodObject<typeof pushToolSchema>>;\n\nconst pullToolSchema = {\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to pull'),\n newDictionariesPath: z\n .string()\n .optional()\n .describe('Path to save new dictionaries'),\n};\n\ntype PullToolProps = z.infer<z.ZodObject<typeof pullToolSchema>>;\n\nconst server = new McpServer({\n name: 'intlayer',\n version: packageJson.version,\n capabilities: {\n resources: {},\n },\n});\n\nserver.tool(\n 'intlayer-build',\n {\n description: 'Build the dictionaries',\n ...buildToolSchema,\n },\n async ({ watch, baseDir, env, envFile, verbose, prefix }: BuildToolProps) => {\n try {\n const log: Partial<LogConfig> = {};\n if (verbose) {\n log.mode = 'verbose';\n }\n if (prefix) {\n log.prefix = prefix;\n }\n\n await build({\n watch,\n configOptions: {\n baseDir,\n env,\n envFile,\n override: {\n log,\n },\n },\n });\n\n return {\n content: [\n {\n type: 'text',\n text: 'Build successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Build failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n);\n\nserver.tool(\n 'intlayer-fill',\n {\n description: 'Fill the dictionaries with missing translations',\n ...fillToolSchema,\n },\n async (props: FillToolProps) => {\n try {\n const { gitOptions, ...rest } = props;\n const fillOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n fillOptions.gitOptions = { ...restGit, mode };\n }\n\n await fill(fillOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Fill successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Fill failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n);\n\nserver.tool(\n 'intlayer-push',\n {\n description: 'Push dictionaries to the server',\n ...pushToolSchema,\n },\n async (props: PushToolProps) => {\n try {\n const { gitOptions, ...rest } = props;\n const pushOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n pushOptions.gitOptions = { ...restGit, mode };\n }\n\n await push(pushOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Push successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Push failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n);\n\nserver.tool(\n 'intlayer-pull',\n {\n description: 'Pull dictionaries from the server',\n ...pullToolSchema,\n },\n async (props: PullToolProps) => {\n try {\n await pull(props);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Pull successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Pull failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n);\n\nserver.tool(\n 'get-doc-list',\n {\n lang: z.nativeEnum(Locales),\n description:\n 'Get the list of docs and their metadata to get more details about what doc to',\n },\n async ({}) => {\n const docsMetadataRecord = await getDocMetadataRecord();\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(docsMetadataRecord, null, 2),\n },\n ],\n };\n }\n);\n\nserver.tool(\n 'get-doc',\n {\n docKey: z.string(),\n lang: z.nativeEnum(Locales),\n description: 'Get a doc by his key',\n },\n async ({ docKey, lang }) => {\n const doc = await getDoc(docKey as any, lang);\n return {\n content: [{ type: 'text', text: doc }],\n };\n }\n);\n\nserver.tool(\n 'get-doc-by-slug',\n {\n slug: z.union([z.string(), z.array(z.string())]),\n lang: z.nativeEnum(Locales),\n description: 'Get an array of docs by their slugs',\n },\n async ({ slug, lang }) => {\n const doc = await getDocBySlug(slug, lang);\n return {\n content: doc.map((d) => ({ type: 'text', text: d })),\n };\n }\n);\n\nconst main = async () => {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n console.error('Intlayer MCP Server running on stdio');\n};\n\nmain().catch((error) => {\n console.error('Fatal error in main():', error);\n process.exit(1);\n});\n"],"mappings":";AAEA,SAAS,OAAO,MAAM,MAAM,YAAY;AACxC,SAAS,YAAY,eAA+B;AACpD,SAAS,QAAQ,cAAc,4BAA4B;AAC3D,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,WAAW,aAAa,eAAe;AAChD,SAAS,qBAAqB;AAC9B,SAAS,SAAS;AAEX,MAAM,UAAU,aACnB,YA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;AAAA,IACE,QAAQ,EAAE,OAAO;AAAA,IACjB,MAAM,EAAE,WAAW,OAAO;AAAA,IAC1B,aAAa;AAAA,EACf;AAAA,EACA,OAAO,EAAE,QAAQ,KAAK,MAAM;AAC1B,UAAM,MAAM,MAAM,OAAO,QAAe,IAAI;AAC5C,WAAO;AAAA,MACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,IAAI,CAAC;AAAA,IACvC;AAAA,EACF;AACF;AAEA,OAAO;AAAA,EACL;AAAA,EACA;AAAA,IACE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAAA,IAC/C,MAAM,EAAE,WAAW,OAAO;AAAA,IAC1B,aAAa;AAAA,EACf;AAAA,EACA,OAAO,EAAE,MAAM,KAAK,MAAM;AACxB,UAAM,MAAM,MAAM,aAAa,MAAM,IAAI;AACzC,WAAO;AAAA,MACL,SAAS,IAAI,IAAI,CAAC,OAAO,EAAE,MAAM,QAAQ,MAAM,EAAE,EAAE;AAAA,IACrD;AAAA,EACF;AACF;AAEA,MAAM,OAAO,YAAY;AACvB,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAC9B,UAAQ,MAAM,sCAAsC;AACtD;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,0BAA0B,KAAK;AAC7C,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { build, fill, pull, push } from '@intlayer/cli';\nimport { isESModule, Locales, type LogConfig } from '@intlayer/config';\nimport { getDoc, getDocBySlug, getDocMetadataRecord } from '@intlayer/docs';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport express, { Request, Response } from 'express';\nimport { readFileSync } from 'fs';\nimport { dirname as pathDirname, resolve } from 'path';\nimport { fileURLToPath } from 'url';\nimport { z } from 'zod';\n\nexport const dirname = isESModule\n ? pathDirname(fileURLToPath(import.meta.url))\n : __dirname;\n\nconst packageJson = JSON.parse(\n readFileSync(resolve(dirname, '../../package.json'), 'utf8')\n);\n\nconst buildToolSchema = {\n watch: z.boolean().optional().describe('Watch for changes'),\n baseDir: z.string().optional().describe('Base directory'),\n env: z.string().optional().describe('Environment'),\n envFile: z.string().optional().describe('Environment file'),\n verbose: z.boolean().optional().describe('Verbose output'),\n prefix: z.string().optional().describe('Log prefix'),\n};\n\ntype BuildToolProps = z.infer<z.ZodObject<typeof buildToolSchema>>;\n\nconst fillToolSchema = {\n sourceLocale: z.nativeEnum(Locales).optional().describe('Source locale'),\n outputLocales: z\n .union([z.nativeEnum(Locales), z.array(z.nativeEnum(Locales))])\n .optional()\n .describe('Output locales'),\n file: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('File path'),\n mode: z.enum(['complete', 'review']).optional().describe('Fill mode'),\n keys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to include'),\n excludedKeys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to exclude'),\n pathFilter: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Path filter'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n aiOptions: z\n .object({\n provider: z.string().optional(),\n temperature: z.number().optional(),\n model: z.string().optional(),\n apiKey: z.string().optional(),\n customPrompt: z.string().optional(),\n applicationContext: z.string().optional(),\n })\n .optional()\n .describe('AI options'),\n};\n\ntype FillToolProps = z.infer<z.ZodObject<typeof fillToolSchema>>;\n\nconst pushToolSchema = {\n deleteLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Delete local dictionary after push'),\n keepLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Keep local dictionary after push'),\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to push'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n};\n\ntype PushToolProps = z.infer<z.ZodObject<typeof pushToolSchema>>;\n\nconst pullToolSchema = {\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to pull'),\n newDictionariesPath: z\n .string()\n .optional()\n .describe('Path to save new dictionaries'),\n};\n\ntype PullToolProps = z.infer<z.ZodObject<typeof pullToolSchema>>;\n\nconst server = new McpServer({\n name: 'intlayer',\n version: packageJson.version,\n capabilities: {\n resources: {},\n },\n});\n\nserver.tool(\n 'intlayer-build',\n 'Build the dictionaries. List all content declarations files `.content.{ts,tsx,js,json,...}` to update the content callable using the `useIntlayer` hook.',\n buildToolSchema,\n async ({ watch, baseDir, env, envFile, verbose, prefix }: BuildToolProps) => {\n try {\n const log: Partial<LogConfig> = {};\n if (verbose) {\n log.mode = 'verbose';\n }\n if (prefix) {\n log.prefix = prefix;\n }\n\n await build({\n watch,\n configOptions: {\n baseDir,\n env,\n envFile,\n override: {\n log,\n },\n },\n });\n\n return {\n content: [\n {\n type: 'text',\n text: 'Build successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Build failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n);\n\nserver.tool(\n 'intlayer-fill',\n 'Fill the dictionaries with missing translations / review translations using Intlayer servers',\n fillToolSchema,\n async (props: FillToolProps) => {\n try {\n const { gitOptions, ...rest } = props;\n const fillOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n fillOptions.gitOptions = { ...restGit, mode };\n }\n\n await fill(fillOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Fill successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Fill failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n);\n\nserver.tool(\n 'intlayer-push',\n 'Push locale dictionaries to the server',\n pushToolSchema,\n async (props: PushToolProps) => {\n try {\n const { gitOptions, ...rest } = props;\n const pushOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n pushOptions.gitOptions = { ...restGit, mode };\n }\n\n await push(pushOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Push successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Push failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n);\n\nserver.tool(\n 'intlayer-pull',\n 'Pull dictionaries from the CMS',\n pullToolSchema,\n async (props: PullToolProps) => {\n try {\n await pull(props);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Pull successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Pull failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n);\n\nserver.tool(\n 'get-doc-list',\n 'Get the list of docs names and their metadata to get more details about what doc to retrieve',\n {\n lang: z.nativeEnum(Locales).optional().describe('Language of the docs'),\n },\n async ({ lang }) => {\n const docsMetadataRecord = await getDocMetadataRecord(lang);\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(docsMetadataRecord, null, 2),\n },\n ],\n };\n }\n);\n\nserver.tool(\n 'get-doc',\n 'Get a doc by his key. Example: `./docs/en/getting-started.md`. List all docs metadata first to get more details about what doc key to retrieve.',\n {\n docKey: z.string(),\n lang: z.nativeEnum(Locales).optional().describe('Language of the docs'),\n },\n async ({ docKey, lang }) => {\n const doc = await getDoc(docKey as any, lang);\n return {\n content: [{ type: 'text', text: doc }],\n };\n }\n);\n\nserver.tool(\n 'get-doc-by-slug',\n 'Get an array of docs by their slugs. If not slug is provided, return all docs (1.2Mb). List all docs metadata first to get more details about what doc to retrieve.',\n {\n slug: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe(\n 'Slug of the docs. If not provided, return all docs. If not provided, return all docs.'\n ),\n lang: z.nativeEnum(Locales).optional().describe('Language of the docs'),\n strict: z\n .boolean()\n .optional()\n .describe(\n 'Strict mode - only return docs that match all slugs, by excluding additional slugs'\n ),\n description: 'Get an array of docs by their slugs',\n },\n async ({ slug, lang, strict }) => {\n const doc = await getDocBySlug(slug, lang, strict);\n return {\n content: doc.map((d) => ({ type: 'text', text: d })),\n };\n }\n);\n\nconst main = async () => {\n const args = process.argv.slice(2);\n const useHttp =\n args.includes('--http') ?? process.env.MCP_TRANSPORT === 'http';\n const port = parseInt(process.env.MCP_PORT ?? '6274');\n\n if (useHttp) {\n // HTTP/SSE transport for Docker/remote usage\n const app = express();\n app.use(express.json());\n\n const transports: { [sessionId: string]: SSEServerTransport } = {};\n\n // SSE connection endpoint\n app.get('/mcp', async (req: Request, res: Response) => {\n console.error('SSE connection request received');\n\n const transport = new SSEServerTransport('/messages', res);\n transports[transport.sessionId] = transport;\n\n res.on('close', () => {\n console.error('SSE connection closed');\n delete transports[transport.sessionId];\n });\n\n await server.connect(transport);\n });\n\n // Message handling endpoint\n app.post('/messages', async (req: Request, res: Response) => {\n const sessionId = req.query.sessionId as string;\n\n if (!sessionId || !transports[sessionId]) {\n res.status(400).json({ error: 'Invalid session ID' });\n return;\n }\n\n const transport = transports[sessionId];\n await transport.handlePostMessage(req, res, req.body);\n });\n\n // Health check endpoint\n app.get('/health', (req: Request, res: Response) => {\n res.json({ status: 'ok', transport: 'http' });\n });\n\n app.listen(port, () => {\n console.error(`Intlayer MCP Server running on HTTP port ${port}`);\n });\n } else {\n // Original stdio transport for local usage\n const transport = new StdioServerTransport();\n await server.connect(transport);\n console.error('Intlayer MCP Server running on stdio');\n }\n};\n\nmain().catch((error) => {\n console.error('Fatal error in main():', error);\n process.exit(1);\n});\n"],"mappings":";AAEA,SAAS,OAAO,MAAM,MAAM,YAAY;AACxC,SAAS,YAAY,eAA+B;AACpD,SAAS,QAAQ,cAAc,4BAA4B;AAC3D,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,OAAO,aAAoC;AAC3C,SAAS,oBAAoB;AAC7B,SAAS,WAAW,aAAa,eAAe;AAChD,SAAS,qBAAqB;AAC9B,SAAS,SAAS;AAEX,MAAM,UAAU,aACnB,YAAY,cAAc,YAAY,GAAG,CAAC,IAC1C;AAEJ,MAAM,cAAc,KAAK;AAAA,EACvB,aAAa,QAAQ,SAAS,oBAAoB,GAAG,MAAM;AAC7D;AAEA,MAAM,kBAAkB;AAAA,EACtB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,mBAAmB;AAAA,EAC1D,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,gBAAgB;AAAA,EACxD,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,aAAa;AAAA,EACjD,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,kBAAkB;AAAA,EAC1D,SAAS,EAAE,QAAQ,E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D,CAAC;AAGD,QAAI,IAAI,WAAW,CAAC,KAAc,QAAkB;AAClD,UAAI,KAAK,EAAE,QAAQ,MAAM,WAAW,OAAO,CAAC;AAAA,IAC9C,CAAC;AAED,QAAI,OAAO,MAAM,MAAM;AACrB,cAAQ,MAAM,4CAA4C,IAAI,EAAE;AAAA,IAClE,CAAC;AAAA,EACH,OAAO;AAEL,UAAM,YAAY,IAAI,qBAAqB;AAC3C,UAAM,OAAO,QAAQ,SAAS;AAC9B,YAAQ,MAAM,sCAAsC;AAAA,EACtD;AACF;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,0BAA0B,KAAK;AAC7C,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAYA,eAAO,MAAM,OAAO,QAEP,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAcA,eAAO,MAAM,OAAO,QAEP,CAAC"}
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "@intlayer/mcp",
3
- "version": "5.5.11",
3
+ "version": "5.5.12",
4
4
  "private": false,
5
5
  "description": "Intlayer MCP server. Handle MCP to help IDE to use Intlayer. It build, fill, pull, push, dictionaries",
6
6
  "keywords": [
7
7
  "intlayer",
8
- "alias",
9
- "dictionaries",
10
- "entry"
8
+ "mcp",
9
+ "mcp-server",
10
+ "mcp-proxy",
11
+ "documentation",
12
+ "cli"
11
13
  ],
12
14
  "homepage": "https://intlayer.org",
13
15
  "bugs": {
@@ -54,14 +56,17 @@
54
56
  "./package.json"
55
57
  ],
56
58
  "dependencies": {
57
- "@modelcontextprotocol/sdk": "^1.9.0",
59
+ "@modelcontextprotocol/sdk": "^1.15.0",
60
+ "express": "^5.1.0",
61
+ "mcp-proxy": "^5.3.0",
58
62
  "zod": "^3.25.56",
59
- "@intlayer/config": "5.5.11",
63
+ "@intlayer/docs": "5.5.12",
60
64
  "@intlayer/cli": "5.5.11",
61
- "@intlayer/docs": "5.5.11"
65
+ "@intlayer/config": "5.5.11"
62
66
  },
63
67
  "devDependencies": {
64
- "@modelcontextprotocol/inspector": "^0.14.0",
68
+ "@modelcontextprotocol/inspector": "^0.16.0",
69
+ "@types/express": "^5.0.2",
65
70
  "@types/node": "^22.15.30",
66
71
  "@typescript-eslint/parser": "^8.33.1",
67
72
  "concurrently": "^9.1.2",
@@ -74,13 +79,13 @@
74
79
  "vitest": "^3.2.2",
75
80
  "@utils/eslint-config": "1.0.4",
76
81
  "@utils/ts-config": "1.0.4",
77
- "@utils/ts-config-types": "1.0.4",
78
- "@utils/tsup-config": "1.0.4"
82
+ "@utils/tsup-config": "1.0.4",
83
+ "@utils/ts-config-types": "1.0.4"
79
84
  },
80
85
  "peerDependencies": {
81
86
  "@intlayer/cli": "5.5.11",
82
87
  "@intlayer/config": "5.5.11",
83
- "@intlayer/docs": "5.5.11"
88
+ "@intlayer/docs": "5.5.12"
84
89
  },
85
90
  "engines": {
86
91
  "node": ">=14.18"
@@ -103,7 +108,10 @@
103
108
  "prettier:fix": "prettier . --write",
104
109
  "process-files": "ts-node src/transpiler/processFilesCLI.ts --dir $npm_config_dir --extension $npm_config_extension --no-node-snapshot",
105
110
  "reset": "pnpm clean & pnpm build",
106
- "start": "npx @modelcontextprotocol/inspector node dist/cjs/index.cjs",
111
+ "start": "npx node dist/cjs/index.cjs",
112
+ "start:http": "npx mcp-proxy --port 6274 --shell node dist/cjs/index.cjs",
113
+ "start:http-native": "MCP_TRANSPORT=http MCP_PORT=6274 node dist/cjs/index.cjs",
114
+ "start:inspector": "npx @modelcontextprotocol/inspector node dist/cjs/index.cjs",
107
115
  "test": "vitest run",
108
116
  "test:watch": "vitest",
109
117
  "typecheck": "tsup --project ./tsconfig.json --noEmit"