@intlayer/mcp 5.5.11 → 5.6.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.
Files changed (50) hide show
  1. package/README.md +167 -17
  2. package/dist/cjs/client/client.cjs +44 -0
  3. package/dist/cjs/client/client.cjs.map +1 -0
  4. package/dist/cjs/client/sse.cjs +61 -0
  5. package/dist/cjs/client/sse.cjs.map +1 -0
  6. package/dist/cjs/server/server.cjs +56 -0
  7. package/dist/cjs/server/server.cjs.map +1 -0
  8. package/dist/cjs/server/sse.cjs +123 -0
  9. package/dist/cjs/server/sse.cjs.map +1 -0
  10. package/dist/cjs/server/stdio.cjs +15 -0
  11. package/dist/cjs/server/stdio.cjs.map +1 -0
  12. package/dist/cjs/tools/cli.cjs +188 -0
  13. package/dist/cjs/tools/cli.cjs.map +1 -0
  14. package/dist/cjs/tools/docs.cjs +148 -0
  15. package/dist/cjs/tools/docs.cjs.map +1 -0
  16. package/dist/esm/client/client.mjs +18 -0
  17. package/dist/esm/client/client.mjs.map +1 -0
  18. package/dist/esm/client/sse.mjs +60 -0
  19. package/dist/esm/client/sse.mjs.map +1 -0
  20. package/dist/esm/server/server.mjs +30 -0
  21. package/dist/esm/server/server.mjs.map +1 -0
  22. package/dist/esm/server/sse.mjs +100 -0
  23. package/dist/esm/server/sse.mjs.map +1 -0
  24. package/dist/esm/server/stdio.mjs +14 -0
  25. package/dist/esm/server/stdio.mjs.map +1 -0
  26. package/dist/esm/tools/cli.mjs +154 -0
  27. package/dist/esm/tools/cli.mjs.map +1 -0
  28. package/dist/esm/tools/docs.mjs +114 -0
  29. package/dist/esm/tools/docs.mjs.map +1 -0
  30. package/dist/types/client/client.d.ts +26 -0
  31. package/dist/types/client/client.d.ts.map +1 -0
  32. package/dist/types/client/sse.d.ts +2 -0
  33. package/dist/types/client/sse.d.ts.map +1 -0
  34. package/dist/types/server/server.d.ts +4 -0
  35. package/dist/types/server/server.d.ts.map +1 -0
  36. package/dist/types/server/sse.d.ts +3 -0
  37. package/dist/types/server/sse.d.ts.map +1 -0
  38. package/dist/types/server/stdio.d.ts +3 -0
  39. package/dist/types/server/stdio.d.ts.map +1 -0
  40. package/dist/types/tools/cli.d.ts +3 -0
  41. package/dist/types/tools/cli.d.ts.map +1 -0
  42. package/dist/types/tools/docs.d.ts +3 -0
  43. package/dist/types/tools/docs.d.ts.map +1 -0
  44. package/package.json +39 -22
  45. package/dist/cjs/index.cjs +0 -314
  46. package/dist/cjs/index.cjs.map +0 -1
  47. package/dist/esm/index.mjs +0 -289
  48. package/dist/esm/index.mjs.map +0 -1
  49. package/dist/types/index.d.ts +0 -3
  50. package/dist/types/index.d.ts.map +0 -1
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,182 @@
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.
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
+ ## Where can I use it?
57
57
 
58
- ## Installation
58
+ - On modern developer environments like **Cursor**, **VS Code**, and any IDE supporting the MCP protocol.
59
+ - On your favorite AI assistant like **Claude Desktop**, **Gemini**, **ChatGPT**, etc.
59
60
 
60
- Install the necessary package using your preferred package manager:
61
+ ## Why Use the Intlayer MCP Server?
61
62
 
62
- ```bash packageManager="npm"
63
- npm install @intlayer/dictionary-entry
63
+ By enabling the Intlayer MCP Server in your IDE, you unlock:
64
+
65
+ - **Context-Aware Documentation**
66
+ The MCP server loads and exposes the documentation of Intlayer. To speed up your set up, your migrations, etc.
67
+ This ensures that code suggestions, command options, and explanations are always up to date and relevant.
68
+
69
+ - **Smart CLI Integration**
70
+ Access and run Intlayer CLI commands directly from your IDE interface. Using the MCP server, you can let your AI assistant run commands like `intlayer dictionaries build` to update your dictionaries, or `intlayer dictionaries fill` to fill your missing translations.
71
+
72
+ > View the full list of commands and options in the [Intlayer CLI documentation](https://intlayer.org/doc/concept/cli).
73
+
74
+ ## Local server (stdio) vs Remote server (SSE)
75
+
76
+ The MCP server can be used in two ways:
77
+
78
+ - Local server (stdio)
79
+ - Remote server (SSE)
80
+
81
+ ### Local server (stdio) (recommended)
82
+
83
+ Intlayer provides a NPM package that can be installed locally on your machine. It can be installed in your favorite IDE, as VS Code, Cursor, as well as your locale assistant application, as ChatGPT, Claude Desktop, etc.
84
+
85
+ This server is the recommended way to use the MCP server. As it integrates all the features of the MCP server, including the CLI tools.
86
+
87
+ ### Remote server (SSE)
88
+
89
+ The MCP server can also be used remotely, using the SSE transport method. This server is hosted by Intlayer, and is available at https://mcp.intlayer.org. This server can be accessed publicly, without any authentication, and is free to use.
90
+
91
+ Note that the remote server does not integrate CLI tools, AI autocompletion, etc. The distant server is only for interaction with the documentation to help your AI assistant with the Intlayer ecosystem.
92
+
93
+ > Due to server hosting costs, the availability of the remote server cannot be guaranteed. We limit the number of simultaneous connections. We recommend using the local server (stdio) transport method for the most reliable experience.
94
+
95
+ ---
96
+
97
+ ## Setup in Cursor
98
+
99
+ Follow the [official documentation](https://docs.cursor.com/context/mcp) to configure the MCP server in Cursor.
100
+
101
+ In your project root, add the following `.cursor/mcp.json` configuration file:
102
+
103
+ ### Local server (stdio) (recommended)
104
+
105
+ ```json fileName=".cursor/mcp.json"
106
+ {
107
+ "mcpServers": {
108
+ "intlayer": {
109
+ "command": "npx",
110
+ "args": ["-y", "@intlayer/mcp"]
111
+ }
112
+ }
113
+ }
114
+ ```
115
+
116
+ ### Remote server (SSE)
117
+
118
+ For connecting to a remote Intlayer MCP server using Server-Sent Events (SSE), you can configure your MCP client to connect to the hosted service.
119
+
120
+ ```json fileName=".cursor/mcp.json"
121
+ {
122
+ "mcpServers": {
123
+ "intlayer": {
124
+ "url": "https://mcp.intlayer.org",
125
+ "transport": "sse"
126
+ }
127
+ }
128
+ }
129
+ ```
130
+
131
+ This tells your IDE to launch the Intlayer MCP server using `npx`, ensuring it always uses the latest available version unless you pin it.
132
+
133
+ ---
134
+
135
+ ## Setup in VS Code
136
+
137
+ Follow the [official documentation](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) to configure the MCP server in VS Code.
138
+
139
+ To use the Intlayer MCP Server with VS Code, you need to configure it in your workspace or user settings.
140
+
141
+ ### Local server (stdio) (recommended)
142
+
143
+ Create a `.vscode/mcp.json` file in your project root:
144
+
145
+ ```json fileName=".vscode/mcp.json"
146
+ {
147
+ "servers": {
148
+ "intlayer": {
149
+ "type": "stdio",
150
+ "command": "npx",
151
+ "args": ["-y", "@intlayer/mcp"]
152
+ }
153
+ }
154
+ }
64
155
  ```
65
156
 
66
- ```bash packageManager="pnpm"
67
- pnpm add @intlayer/dictionary-entry
157
+ ### Remote server (SSE)
158
+
159
+ For connecting to a remote Intlayer MCP server using Server-Sent Events (SSE), you can configure your MCP client to connect to the hosted service.
160
+
161
+ ```json fileName=".vscode/mcp.json"
162
+ {
163
+ "servers": {
164
+ "intlayer": {
165
+ "url": "https://mcp.intlayer.org",
166
+ "type": "sse"
167
+ }
168
+ }
169
+ }
68
170
  ```
69
171
 
70
- ```bash packageManager="yarn"
71
- yarn add @intlayer/dictionary-entry
172
+ ---
173
+
174
+ ## Set Up in ChatGPT
175
+
176
+ ### Remote server (SSE)
177
+
178
+ Follow the [official documentation](https://platform.openai.com/docs/mcp#test-and-connect-your-mcp-server) to configure the MCP server in ChatGPT.
179
+
180
+ 1 - Go to the [promt dashboard](https://platform.openai.com/prompts)
181
+ 2 - Click on "+ Create"
182
+ 3 - Click on "Tools (Create or +)"
183
+ 4 - Select "MCP Server"
184
+ 5 - Click on "Add new"
185
+ 6 - Fill the following fields:
186
+
187
+ - URL: https://mcp.intlayer.org
188
+ - Label: Intlayer MCP Server
189
+ - Name: intlayer-mcp-server
190
+ - Authentication: None
191
+
192
+ 7 - Click on "Save"
193
+
194
+ ---
195
+
196
+ ## Set Up in Claude Desktop
197
+
198
+ Follow the [official documentation](https://modelcontextprotocol.io/quickstart/user#2-add-the-filesystem-mcp-server) to configure the MCP server in Claude Desktop.
199
+
200
+ Path of the config file:
201
+
202
+ - macOS: `~/Library/Application\ Support/Claude/claude_desktop_config.json`
203
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
204
+
205
+ ### Local server (stdio) (recommended)
206
+
207
+ ```json fileName="claude_desktop_config.json"
208
+ {
209
+ "mcpServers": {
210
+ "intlayer": {
211
+ "command": "npx",
212
+ "args": ["-y", "@intlayer/mcp"]
213
+ }
214
+ }
215
+ }
72
216
  ```
73
217
 
74
- ## Read about Intlayer
218
+ ---
75
219
 
76
- - [Intlayer Website](https://intlayer.org)
77
- - [Intlayer Documentation](https://intlayer.org/doc)
78
- - [Intlayer GitHub](https://github.com/aymericzip/intlayer)
220
+ ## Using the MCP Server via CLI
79
221
 
80
- - [Ask your questions to our smart documentation](https://intlayer.org/docchat)
222
+ You can also run the Intlayer MCP server directly from the command line for testing, debugging, or integration with other tools.
223
+
224
+ ```bash
225
+ # Install globally
226
+ npm install -g @intlayer/mcp
227
+
228
+ # Or use directly with npx (recommended)
229
+ npx @intlayer/mcp
230
+ ```
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var client_exports = {};
20
+ __export(client_exports, {
21
+ dirname: () => dirname,
22
+ loadClient: () => loadClient
23
+ });
24
+ module.exports = __toCommonJS(client_exports);
25
+ var import_config = require("@intlayer/config");
26
+ var import_client = require("@modelcontextprotocol/sdk/client/index.js");
27
+ var import_fs = require("fs");
28
+ var import_path = require("path");
29
+ var import_url = require("url");
30
+ const import_meta = {};
31
+ const dirname = import_config.isESModule ? (0, import_path.dirname)((0, import_url.fileURLToPath)(import_meta.url)) : __dirname;
32
+ const packageJson = JSON.parse(
33
+ (0, import_fs.readFileSync)((0, import_path.resolve)(dirname, "../../../package.json"), "utf8")
34
+ );
35
+ const loadClient = () => new import_client.Client({
36
+ name: `mcp-client-for-intlayer-mcp-server`,
37
+ version: packageJson.version
38
+ });
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ dirname,
42
+ loadClient
43
+ });
44
+ //# sourceMappingURL=client.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/client.ts"],"sourcesContent":["import { isESModule } from '@intlayer/config';\nimport { Client } from '@modelcontextprotocol/sdk/client/index.js';\nimport { readFileSync } from 'fs';\nimport { dirname as pathDirname, resolve } from 'path';\nimport { fileURLToPath } from 'url';\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\nexport const loadClient = () =>\n new Client({\n name: `mcp-client-for-intlayer-mcp-server`,\n version: packageJson.version,\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAC3B,oBAAuB;AACvB,gBAA6B;AAC7B,kBAAgD;AAChD,iBAA8B;AAJ9B;AAMO,MAAM,UAAU,+BACnB,YAAAA,aAAY,0BAAc,YAAY,GAAG,CAAC,IAC1C;AAEJ,MAAM,cAAc,KAAK;AAAA,MACvB,4BAAa,qBAAQ,SAAS,uBAAuB,GAAG,MAAM;AAChE;AAEO,MAAM,aAAa,MACxB,IAAI,qBAAO;AAAA,EACT,MAAM;AAAA,EACN,SAAS,YAAY;AACvB,CAAC;","names":["pathDirname"]}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var import_sse = require("@modelcontextprotocol/sdk/client/sse.js");
3
+ var import_url = require("url");
4
+ var import_client2 = require('./client.cjs');
5
+ class SSEClient {
6
+ client;
7
+ transport = null;
8
+ isCompleted = false;
9
+ constructor() {
10
+ this.client = (0, import_client2.loadClient)();
11
+ }
12
+ async connectToServer() {
13
+ const mcpServerURL = process.env.MCP_SERVER_URL ?? "https://mcp.intlayer.org";
14
+ const url = new import_url.URL(mcpServerURL);
15
+ try {
16
+ console.info(`Connecting to server - ${mcpServerURL}`);
17
+ this.transport = new import_sse.SSEClientTransport(url);
18
+ await this.client.connect(this.transport);
19
+ console.info("Connected to MCP server");
20
+ this.setUpTransport();
21
+ } catch (e) {
22
+ console.info("Failed to connect to MCP server: ", e);
23
+ throw e;
24
+ }
25
+ }
26
+ setUpTransport() {
27
+ if (this.transport === null) {
28
+ return;
29
+ }
30
+ this.transport.onclose = () => {
31
+ console.info("SSE transport closed.");
32
+ this.isCompleted = true;
33
+ };
34
+ this.transport.onerror = async (error) => {
35
+ console.info("SSE transport error: ", error);
36
+ await this.cleanup();
37
+ };
38
+ this.transport.onmessage = (message) => {
39
+ console.info("message received: ", message);
40
+ };
41
+ }
42
+ async waitForCompletion() {
43
+ while (!this.isCompleted) {
44
+ await new Promise((resolve) => setTimeout(resolve, 100));
45
+ }
46
+ }
47
+ async cleanup() {
48
+ await this.client.close();
49
+ }
50
+ }
51
+ const main = async () => {
52
+ const client = new SSEClient();
53
+ try {
54
+ await client.connectToServer();
55
+ await client.waitForCompletion();
56
+ } finally {
57
+ await client.cleanup();
58
+ }
59
+ };
60
+ main();
61
+ //# sourceMappingURL=sse.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/sse.ts"],"sourcesContent":["import { Client } from '@modelcontextprotocol/sdk/client/index.js';\nimport { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';\nimport { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';\nimport { URL } from 'url';\nimport { loadClient } from './client';\n\nclass SSEClient {\n private client: Client;\n private transport: Transport | null = null;\n private isCompleted = false;\n\n constructor() {\n this.client = loadClient();\n }\n\n async connectToServer() {\n const mcpServerURL =\n process.env.MCP_SERVER_URL ?? 'https://mcp.intlayer.org';\n\n const url = new URL(mcpServerURL);\n try {\n console.info(`Connecting to server - ${mcpServerURL}`);\n this.transport = new SSEClientTransport(url);\n await this.client.connect(this.transport);\n console.info('Connected to MCP server');\n\n this.setUpTransport();\n } catch (e) {\n console.info('Failed to connect to MCP server: ', e);\n throw e;\n }\n }\n\n private setUpTransport() {\n if (this.transport === null) {\n return;\n }\n this.transport.onclose = () => {\n console.info('SSE transport closed.');\n this.isCompleted = true;\n };\n\n this.transport.onerror = async (error) => {\n console.info('SSE transport error: ', error);\n await this.cleanup();\n };\n\n this.transport.onmessage = (message) => {\n console.info('message received: ', message);\n };\n }\n\n async waitForCompletion() {\n while (!this.isCompleted) {\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n }\n\n async cleanup() {\n await this.client.close();\n }\n}\n\nconst main = async () => {\n const client = new SSEClient();\n\n try {\n await client.connectToServer();\n await client.waitForCompletion();\n } finally {\n await client.cleanup();\n }\n};\n\nmain();\n"],"mappings":";AACA,iBAAmC;AAEnC,iBAAoB;AACpB,IAAAA,iBAA2B;AAE3B,MAAM,UAAU;AAAA,EACN;AAAA,EACA,YAA8B;AAAA,EAC9B,cAAc;AAAA,EAEtB,cAAc;AACZ,SAAK,aAAS,2BAAW;AAAA,EAC3B;AAAA,EAEA,MAAM,kBAAkB;AACtB,UAAM,eACJ,QAAQ,IAAI,kBAAkB;AAEhC,UAAM,MAAM,IAAI,eAAI,YAAY;AAChC,QAAI;AACF,cAAQ,KAAK,0BAA0B,YAAY,EAAE;AACrD,WAAK,YAAY,IAAI,8BAAmB,GAAG;AAC3C,YAAM,KAAK,OAAO,QAAQ,KAAK,SAAS;AACxC,cAAQ,KAAK,yBAAyB;AAEtC,WAAK,eAAe;AAAA,IACtB,SAAS,GAAG;AACV,cAAQ,KAAK,qCAAqC,CAAC;AACnD,YAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEQ,iBAAiB;AACvB,QAAI,KAAK,cAAc,MAAM;AAC3B;AAAA,IACF;AACA,SAAK,UAAU,UAAU,MAAM;AAC7B,cAAQ,KAAK,uBAAuB;AACpC,WAAK,cAAc;AAAA,IACrB;AAEA,SAAK,UAAU,UAAU,OAAO,UAAU;AACxC,cAAQ,KAAK,yBAAyB,KAAK;AAC3C,YAAM,KAAK,QAAQ;AAAA,IACrB;AAEA,SAAK,UAAU,YAAY,CAAC,YAAY;AACtC,cAAQ,KAAK,sBAAsB,OAAO;AAAA,IAC5C;AAAA,EACF;AAAA,EAEA,MAAM,oBAAoB;AACxB,WAAO,CAAC,KAAK,aAAa;AACxB,YAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,GAAG,CAAC;AAAA,IACzD;AAAA,EACF;AAAA,EAEA,MAAM,UAAU;AACd,UAAM,KAAK,OAAO,MAAM;AAAA,EAC1B;AACF;AAEA,MAAM,OAAO,YAAY;AACvB,QAAM,SAAS,IAAI,UAAU;AAE7B,MAAI;AACF,UAAM,OAAO,gBAAgB;AAC7B,UAAM,OAAO,kBAAkB;AAAA,EACjC,UAAE;AACA,UAAM,OAAO,QAAQ;AAAA,EACvB;AACF;AAEA,KAAK;","names":["import_client"]}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var server_exports = {};
20
+ __export(server_exports, {
21
+ dirname: () => dirname,
22
+ loadServer: () => loadServer
23
+ });
24
+ module.exports = __toCommonJS(server_exports);
25
+ var import_config = require("@intlayer/config");
26
+ var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
27
+ var import_fs = require("fs");
28
+ var import_path = require("path");
29
+ var import_url = require("url");
30
+ var import_cli = require('../tools/cli.cjs');
31
+ var import_docs = require('../tools/docs.cjs');
32
+ const import_meta = {};
33
+ const dirname = import_config.isESModule ? (0, import_path.dirname)((0, import_url.fileURLToPath)(import_meta.url)) : __dirname;
34
+ const packageJson = JSON.parse(
35
+ (0, import_fs.readFileSync)((0, import_path.resolve)(dirname, "../../../package.json"), "utf8")
36
+ );
37
+ const loadServer = (isLocal) => {
38
+ const server = new import_mcp.McpServer({
39
+ name: "intlayer",
40
+ version: packageJson.version,
41
+ capabilities: {
42
+ resources: {}
43
+ }
44
+ });
45
+ if (!isLocal) {
46
+ (0, import_cli.loadCLITools)(server);
47
+ }
48
+ (0, import_docs.loadDocsTools)(server);
49
+ return server;
50
+ };
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ dirname,
54
+ loadServer
55
+ });
56
+ //# sourceMappingURL=server.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/server/server.ts"],"sourcesContent":["import { isESModule } from '@intlayer/config';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { readFileSync } from 'fs';\nimport { dirname as pathDirname, resolve } from 'path';\nimport { fileURLToPath } from 'url';\nimport { loadCLITools } from '../tools/cli';\nimport { loadDocsTools } from '../tools/docs';\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\nexport const loadServer = (isLocal: boolean): McpServer => {\n const server = new McpServer({\n name: 'intlayer',\n version: packageJson.version,\n capabilities: {\n resources: {},\n },\n });\n\n if (!isLocal) {\n loadCLITools(server);\n }\n\n loadDocsTools(server);\n\n return server;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAC3B,iBAA0B;AAC1B,gBAA6B;AAC7B,kBAAgD;AAChD,iBAA8B;AAC9B,iBAA6B;AAC7B,kBAA8B;AAN9B;AAQO,MAAM,UAAU,+BACnB,YAAAA,aAAY,0BAAc,YAAY,GAAG,CAAC,IAC1C;AAEJ,MAAM,cAAc,KAAK;AAAA,MACvB,4BAAa,qBAAQ,SAAS,uBAAuB,GAAG,MAAM;AAChE;AAEO,MAAM,aAAa,CAAC,YAAgC;AACzD,QAAM,SAAS,IAAI,qBAAU;AAAA,IAC3B,MAAM;AAAA,IACN,SAAS,YAAY;AAAA,IACrB,cAAc;AAAA,MACZ,WAAW,CAAC;AAAA,IACd;AAAA,EACF,CAAC;AAED,MAAI,CAAC,SAAS;AACZ,iCAAa,MAAM;AAAA,EACrB;AAEA,iCAAc,MAAM;AAEpB,SAAO;AACT;","names":["pathDirname"]}
@@ -0,0 +1,123 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+ var import_sse = require("@modelcontextprotocol/sdk/server/sse.js");
26
+ var import_dotenv = __toESM(require("dotenv"));
27
+ var import_express = __toESM(require("express"));
28
+ var import_server = require('./server.cjs');
29
+ const server = (0, import_server.loadServer)(false);
30
+ const app = (0, import_express.default)();
31
+ const env = app.get("env");
32
+ import_dotenv.default.config({
33
+ path: [`.env.${env}.local`, `.env.${env}`, ".env.local", ".env"]
34
+ });
35
+ app.use((req, res, next) => {
36
+ res.header("Access-Control-Allow-Origin", "*");
37
+ res.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
38
+ res.header("Access-Control-Allow-Headers", "Content-Type");
39
+ if (req.method === "OPTIONS") {
40
+ res.sendStatus(200);
41
+ return;
42
+ }
43
+ next();
44
+ });
45
+ app.use(import_express.default.json());
46
+ const router = import_express.default.Router();
47
+ const transports = {};
48
+ const POST_ENDPOINT = "/messages";
49
+ router.post(POST_ENDPOINT, async (req, res) => {
50
+ console.info("message request received: ", req.body);
51
+ const sessionId = req.query.sessionId;
52
+ if (typeof sessionId != "string") {
53
+ res.status(400).send({ messages: "Bad session id." });
54
+ return;
55
+ }
56
+ const transport = transports[sessionId];
57
+ if (!transport) {
58
+ res.status(400).send({ messages: "No transport found for sessionId." });
59
+ return;
60
+ }
61
+ await transport.handlePostMessage(req, res, req.body);
62
+ return;
63
+ });
64
+ router.get("/", async (_req, res) => {
65
+ console.info("connection request received");
66
+ const transport = new import_sse.SSEServerTransport(POST_ENDPOINT, res);
67
+ console.info("new transport created with session id: ", transport.sessionId);
68
+ transports[transport.sessionId] = transport;
69
+ console.info(`${Object.keys(transports).length} sessions active`);
70
+ res.on("close", () => {
71
+ console.info("SSE connection closed");
72
+ delete transports[transport.sessionId];
73
+ });
74
+ await server.connect(transport);
75
+ await sendMessages(transport);
76
+ return;
77
+ });
78
+ const sendMessages = async (transport) => {
79
+ try {
80
+ await transport.send({
81
+ jsonrpc: "2.0",
82
+ method: "sse/connection",
83
+ params: { message: "Stream started" }
84
+ });
85
+ console.info("Stream started");
86
+ let messageCount = 0;
87
+ const interval = setInterval(async () => {
88
+ messageCount++;
89
+ const message = `Message ${messageCount} at ${(/* @__PURE__ */ new Date()).toISOString()}`;
90
+ try {
91
+ await transport.send({
92
+ jsonrpc: "2.0",
93
+ method: "sse/message",
94
+ params: { data: message }
95
+ });
96
+ console.info(`Sent: ${message}`);
97
+ if (messageCount === 2) {
98
+ clearInterval(interval);
99
+ await transport.send({
100
+ jsonrpc: "2.0",
101
+ method: "sse/complete",
102
+ params: { message: "Stream completed" }
103
+ });
104
+ console.info("Stream completed");
105
+ }
106
+ } catch (error) {
107
+ console.error("Error sending message:", error);
108
+ clearInterval(interval);
109
+ }
110
+ }, 1e3);
111
+ } catch (error) {
112
+ console.error("Error in startSending:", error);
113
+ }
114
+ };
115
+ app.use("/", router);
116
+ app.use("/health", (_req, res) => {
117
+ res.send("OK");
118
+ });
119
+ const PORT = process.env.PORT ?? 3e3;
120
+ app.listen(PORT, () => {
121
+ console.info(`MCP Streamable HTTP Server listening on port ${PORT}`);
122
+ });
123
+ //# sourceMappingURL=sse.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/server/sse.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';\nimport dotenv from 'dotenv';\nimport express, { type Request, type Response } from 'express';\nimport { loadServer } from './server';\n\n/*******************************/\n/******* Server Set Up *******/\n/*******************************/\n\nconst server = loadServer(false);\n\n/*******************************/\n/******* Express App Set Up *******/\n/*******************************/\n\nconst app = express();\n\n// Environment variables\nconst env = app.get('env');\n\ndotenv.config({\n path: [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'],\n});\n\n// Enable CORS for development\napp.use((req, res, next) => {\n res.header('Access-Control-Allow-Origin', '*');\n res.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');\n res.header('Access-Control-Allow-Headers', 'Content-Type');\n\n if (req.method === 'OPTIONS') {\n res.sendStatus(200);\n return;\n }\n\n next();\n});\n\napp.use(express.json());\nconst router = express.Router();\n\n// to support multiple simultaneous connections we have a lookup object from\n// sessionId to transport\nconst transports: { [sessionId: string]: SSEServerTransport } = {};\n\n// endpoint for the client to use for sending messages\nconst POST_ENDPOINT = '/messages';\n\nrouter.post(POST_ENDPOINT, async (req: Request, res: Response) => {\n console.info('message request received: ', req.body);\n // when client sends messages with `SSEClientTransport`,\n // the sessionId will be atomically set as query parameter.\n const sessionId = req.query.sessionId;\n\n if (typeof sessionId != 'string') {\n res.status(400).send({ messages: 'Bad session id.' });\n return;\n }\n const transport = transports[sessionId];\n if (!transport) {\n res.status(400).send({ messages: 'No transport found for sessionId.' });\n return;\n }\n\n // IMPORTANT!\n // using `await transport.handlePostMessage(req, res)` will cause\n // `SSE transport error: Error: Error POSTing to endpoint (HTTP 400): InternalServerError: stream is not readable`\n // on the client side\n await transport.handlePostMessage(req, res, req.body);\n\n return;\n});\n\n// initialization:\n// create a new transport to connect and\n// send an endpoint event containing a URI for the client to use for sending messages\nrouter.get('/', async (_req: Request, res: Response) => {\n console.info('connection request received');\n // tells the client to send messages to the `POST_ENDPOINT`\n const transport = new SSEServerTransport(POST_ENDPOINT, res);\n console.info('new transport created with session id: ', transport.sessionId);\n\n transports[transport.sessionId] = transport;\n\n console.info(`${Object.keys(transports).length} sessions active`);\n\n res.on('close', () => {\n console.info('SSE connection closed');\n delete transports[transport.sessionId];\n });\n\n await server.connect(transport);\n\n // an exmaple of a server-sent-event (message) to client\n await sendMessages(transport);\n\n return;\n});\n\nconst sendMessages = async (transport: SSEServerTransport) => {\n try {\n // some messages will proabaly not be able to observed on the client side\n // becasue an open SSE Stream is not yet established\n // by receving the `initialize` POST request and the `notifications/initialized` POST request\n await transport.send({\n jsonrpc: '2.0',\n method: 'sse/connection',\n params: { message: 'Stream started' },\n });\n console.info('Stream started');\n\n let messageCount = 0;\n const interval = setInterval(async () => {\n messageCount++;\n\n const message = `Message ${messageCount} at ${new Date().toISOString()}`;\n\n try {\n await transport.send({\n jsonrpc: '2.0',\n method: 'sse/message',\n params: { data: message },\n });\n\n console.info(`Sent: ${message}`);\n\n if (messageCount === 2) {\n clearInterval(interval);\n await transport.send({\n jsonrpc: '2.0',\n method: 'sse/complete',\n params: { message: 'Stream completed' },\n });\n console.info('Stream completed');\n }\n } catch (error) {\n console.error('Error sending message:', error);\n clearInterval(interval);\n }\n }, 1000);\n } catch (error) {\n console.error('Error in startSending:', error);\n }\n};\n\napp.use('/', router);\n\napp.use('/health', (_req: Request, res: Response) => {\n res.send('OK');\n});\n\nconst PORT = process.env.PORT ?? 3000;\n\napp.listen(PORT, () => {\n console.info(`MCP Streamable HTTP Server listening on port ${PORT}`);\n});\n"],"mappings":"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","names":["express","dotenv"]}
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
4
+ var import_server = require('./server.cjs');
5
+ const server = (0, import_server.loadServer)(true);
6
+ const main = async () => {
7
+ const transport = new import_stdio.StdioServerTransport();
8
+ await server.connect(transport);
9
+ console.error("Intlayer MCP Server running on stdio");
10
+ };
11
+ main().catch((error) => {
12
+ console.error("Fatal error in main():", error);
13
+ process.exit(1);
14
+ });
15
+ //# sourceMappingURL=stdio.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/server/stdio.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { loadServer } from './server';\n\nconst server = loadServer(true);\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,mBAAqC;AACrC,oBAA2B;AAE3B,MAAM,aAAS,0BAAW,IAAI;AAE9B,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":[]}