@intlayer/mcp 5.5.12 → 5.7.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 +107 -78
  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 +32 -23
  45. package/dist/cjs/index.cjs +0 -358
  46. package/dist/cjs/index.cjs.map +0 -1
  47. package/dist/esm/index.mjs +0 -323
  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
@@ -51,31 +51,58 @@
51
51
 
52
52
  # @intlayer/mcp: Intlayer MCP Server (Model Context Protocol)
53
53
 
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.
54
+ The **Intlayer MCP (Model Context Protocol) Server** provides AI-powered IDE assistance tailored for the Intlayer ecosystem.
55
+
56
+ ## Where can I use it?
57
+
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.
55
60
 
56
61
  ## Why Use the Intlayer MCP Server?
57
62
 
58
63
  By enabling the Intlayer MCP Server in your IDE, you unlock:
59
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
+
60
69
  - **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).
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.
62
71
 
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.
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.
65
84
 
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.
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.
68
86
 
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.
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.
71
94
 
72
95
  ---
73
96
 
74
- ## Setup Cursor
97
+ ## Setup in Cursor
98
+
99
+ Follow the [official documentation](https://docs.cursor.com/context/mcp) to configure the MCP server in Cursor.
75
100
 
76
101
  In your project root, add the following `.cursor/mcp.json` configuration file:
77
102
 
78
- ```json
103
+ ### Local server (stdio) (recommended)
104
+
105
+ ```json fileName=".cursor/mcp.json"
79
106
  {
80
107
  "mcpServers": {
81
108
  "intlayer": {
@@ -86,19 +113,36 @@ In your project root, add the following `.cursor/mcp.json` configuration file:
86
113
  }
87
114
  ```
88
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
+
89
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.
90
132
 
91
133
  ---
92
134
 
93
- ## Setup VS Code
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.
94
138
 
95
139
  To use the Intlayer MCP Server with VS Code, you need to configure it in your workspace or user settings.
96
140
 
97
- ### Workspace Configuration
141
+ ### Local server (stdio) (recommended)
98
142
 
99
143
  Create a `.vscode/mcp.json` file in your project root:
100
144
 
101
- ```json
145
+ ```json fileName=".vscode/mcp.json"
102
146
  {
103
147
  "servers": {
104
148
  "intlayer": {
@@ -110,92 +154,77 @@ Create a `.vscode/mcp.json` file in your project root:
110
154
  }
111
155
  ```
112
156
 
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.
157
+ ### Remote server (SSE)
118
158
 
119
- 3. **Direct Tool Reference**: Reference tools directly in your prompts by typing `#` followed by the tool name.
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.
120
160
 
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).
161
+ ```json fileName=".vscode/mcp.json"
162
+ {
163
+ "servers": {
164
+ "intlayer": {
165
+ "url": "https://mcp.intlayer.org",
166
+ "type": "sse"
167
+ }
168
+ }
169
+ }
170
+ ```
130
171
 
131
172
  ---
132
173
 
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
174
+ ## Set Up in ChatGPT
144
175
 
145
- # Or use directly with npx (recommended)
146
- npx @intlayer/mcp
147
- ```
176
+ ### Remote server (SSE)
148
177
 
149
- ### Start the Server
178
+ Follow the [official documentation](https://platform.openai.com/docs/mcp#test-and-connect-your-mcp-server) to configure the MCP server in ChatGPT.
150
179
 
151
- To start the MCP server with the inspector for debugging and testing:
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:
152
186
 
153
- ```bash
154
- # Using the built-in start command
155
- npm run start
187
+ - URL: https://mcp.intlayer.org
188
+ - Label: Intlayer MCP Server
189
+ - Name: intlayer-mcp-server
190
+ - Authentication: None
156
191
 
157
- # Or directly with npx
158
- npx @modelcontextprotocol/inspector npx @intlayer/mcp
159
- ```
192
+ 7 - Click on "Save"
160
193
 
161
- This will launch the MCP server with an inspector interface that allows you to:
194
+ ---
162
195
 
163
- - Test MCP protocol communications
164
- - Debug server responses
165
- - Validate tool and resource implementations
166
- - Monitor server performance
196
+ ## Set Up in Claude Desktop
167
197
 
168
- ### Development Usage
198
+ Follow the [official documentation](https://modelcontextprotocol.io/quickstart/user#2-add-the-filesystem-mcp-server) to configure the MCP server in Claude Desktop.
169
199
 
170
- For development and testing purposes, you can run the server in various modes:
200
+ Path of the config file:
171
201
 
172
- ```bash
173
- # Build and start in development mode
174
- npm run dev
202
+ - macOS: `~/Library/Application\ Support/Claude/claude_desktop_config.json`
203
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
175
204
 
176
- # Run with custom configuration
177
- node dist/cjs/index.cjs
205
+ ### Local server (stdio) (recommended)
178
206
 
179
- # Test the server functionality
180
- npm test
207
+ ```json fileName="claude_desktop_config.json"
208
+ {
209
+ "mcpServers": {
210
+ "intlayer": {
211
+ "command": "npx",
212
+ "args": ["-y", "@intlayer/mcp"]
213
+ }
214
+ }
215
+ }
181
216
  ```
182
217
 
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
218
  ---
186
219
 
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 |
220
+ ## Using the MCP Server via CLI
195
221
 
196
- ---
222
+ You can also run the Intlayer MCP server directly from the command line for testing, debugging, or integration with other tools.
197
223
 
198
- ##Useful Links
224
+ ```bash
225
+ # Install globally
226
+ npm install -g @intlayer/mcp
199
227
 
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)
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":[]}