@intlayer/mcp 7.5.0-canary.1 → 7.5.1
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/dist/cjs/client/client.cjs +4 -4
- package/dist/cjs/client/client.cjs.map +1 -1
- package/dist/cjs/client/sse.cjs +2 -2
- package/dist/cjs/client/sse.cjs.map +1 -1
- package/dist/cjs/server/server.cjs +4 -4
- package/dist/cjs/server/server.cjs.map +1 -1
- package/dist/cjs/server/sse.cjs +2 -2
- package/dist/cjs/server/sse.cjs.map +1 -1
- package/dist/cjs/server/stdio.cjs +2 -2
- package/dist/cjs/server/stdio.cjs.map +1 -1
- package/dist/cjs/tools/cli.cjs +11 -11
- package/dist/cjs/tools/cli.cjs.map +1 -1
- package/dist/cjs/tools/docs.cjs +5 -5
- package/dist/cjs/tools/docs.cjs.map +1 -1
- package/package.json +8 -8
|
@@ -2,13 +2,13 @@ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
|
2
2
|
let node_fs = require("node:fs");
|
|
3
3
|
let node_path = require("node:path");
|
|
4
4
|
let node_url = require("node:url");
|
|
5
|
-
let
|
|
6
|
-
let
|
|
5
|
+
let _intlayer_config = require("@intlayer/config");
|
|
6
|
+
let _modelcontextprotocol_sdk_client_index_js = require("@modelcontextprotocol/sdk/client/index.js");
|
|
7
7
|
|
|
8
8
|
//#region src/client/client.ts
|
|
9
|
-
const dirname =
|
|
9
|
+
const dirname = _intlayer_config.isESModule ? (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href)) : __dirname;
|
|
10
10
|
const packageJson = JSON.parse((0, node_fs.readFileSync)((0, node_path.resolve)(dirname, "../../../package.json"), "utf8"));
|
|
11
|
-
const loadClient = () => new
|
|
11
|
+
const loadClient = () => new _modelcontextprotocol_sdk_client_index_js.Client({
|
|
12
12
|
name: `mcp-client-for-intlayer-mcp-server`,
|
|
13
13
|
version: packageJson.version
|
|
14
14
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.cjs","names":["dirname: string","isESModule","packageJson: Record<string, any>","loadClient: LoadClient","Client"],"sources":["../../../src/client/client.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { dirname as pathDirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { isESModule } from '@intlayer/config';\nimport { Client } from '@modelcontextprotocol/sdk/client/index.js';\n\nexport const dirname: string = isESModule\n ? pathDirname(fileURLToPath(import.meta.url))\n : __dirname;\n\nconst packageJson: Record<string, any> = JSON.parse(\n readFileSync(resolve(dirname, '../../../package.json'), 'utf8')\n);\n\ntype LoadClient = () => Client;\n\nexport const loadClient: LoadClient = () =>\n new Client({\n name: `mcp-client-for-intlayer-mcp-server`,\n version: packageJson.version,\n });\n"],"mappings":";;;;;;;;AAMA,MAAaA,UAAkBC,
|
|
1
|
+
{"version":3,"file":"client.cjs","names":["dirname: string","isESModule","packageJson: Record<string, any>","loadClient: LoadClient","Client"],"sources":["../../../src/client/client.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { dirname as pathDirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { isESModule } from '@intlayer/config';\nimport { Client } from '@modelcontextprotocol/sdk/client/index.js';\n\nexport const dirname: string = isESModule\n ? pathDirname(fileURLToPath(import.meta.url))\n : __dirname;\n\nconst packageJson: Record<string, any> = JSON.parse(\n readFileSync(resolve(dirname, '../../../package.json'), 'utf8')\n);\n\ntype LoadClient = () => Client;\n\nexport const loadClient: LoadClient = () =>\n new Client({\n name: `mcp-client-for-intlayer-mcp-server`,\n version: packageJson.version,\n });\n"],"mappings":";;;;;;;;AAMA,MAAaA,UAAkBC,+HACe,CAAC,GAC3C;AAEJ,MAAMC,cAAmC,KAAK,uDACvB,SAAS,wBAAwB,EAAE,OAAO,CAChE;AAID,MAAaC,mBACX,IAAIC,iDAAO;CACT,MAAM;CACN,SAAS,YAAY;CACtB,CAAC"}
|
package/dist/cjs/client/sse.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_client_client = require('./client.cjs');
|
|
3
3
|
let node_url = require("node:url");
|
|
4
|
-
let
|
|
4
|
+
let _modelcontextprotocol_sdk_client_sse_js = require("@modelcontextprotocol/sdk/client/sse.js");
|
|
5
5
|
|
|
6
6
|
//#region src/client/sse.ts
|
|
7
7
|
var SSEClient = class {
|
|
@@ -16,7 +16,7 @@ var SSEClient = class {
|
|
|
16
16
|
const url = new node_url.URL(mcpServerURL);
|
|
17
17
|
try {
|
|
18
18
|
console.info(`Connecting to server - ${mcpServerURL}`);
|
|
19
|
-
this.transport = new
|
|
19
|
+
this.transport = new _modelcontextprotocol_sdk_client_sse_js.SSEClientTransport(url);
|
|
20
20
|
await this.client.connect(this.transport);
|
|
21
21
|
console.info("Connected to MCP server");
|
|
22
22
|
this.setUpTransport();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.cjs","names":["loadClient","URL","SSEClientTransport"],"sources":["../../../src/client/sse.ts"],"sourcesContent":["import { URL } from 'node:url';\nimport type { Client } from '@modelcontextprotocol/sdk/client/index.js';\nimport { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';\nimport type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';\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":";;;;;;AAMA,IAAM,YAAN,MAAgB;CACd,AAAQ;CACR,AAAQ,YAA8B;CACtC,AAAQ,cAAc;CAEtB,cAAc;AACZ,OAAK,SAASA,kCAAY;;CAG5B,MAAM,kBAAkB;EACtB,MAAM,eACJ,QAAQ,IAAI,kBAAkB;EAEhC,MAAM,MAAM,IAAIC,aAAI,aAAa;AACjC,MAAI;AACF,WAAQ,KAAK,0BAA0B,eAAe;AACtD,QAAK,YAAY,IAAIC,
|
|
1
|
+
{"version":3,"file":"sse.cjs","names":["loadClient","URL","SSEClientTransport"],"sources":["../../../src/client/sse.ts"],"sourcesContent":["import { URL } from 'node:url';\nimport type { Client } from '@modelcontextprotocol/sdk/client/index.js';\nimport { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';\nimport type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';\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":";;;;;;AAMA,IAAM,YAAN,MAAgB;CACd,AAAQ;CACR,AAAQ,YAA8B;CACtC,AAAQ,cAAc;CAEtB,cAAc;AACZ,OAAK,SAASA,kCAAY;;CAG5B,MAAM,kBAAkB;EACtB,MAAM,eACJ,QAAQ,IAAI,kBAAkB;EAEhC,MAAM,MAAM,IAAIC,aAAI,aAAa;AACjC,MAAI;AACF,WAAQ,KAAK,0BAA0B,eAAe;AACtD,QAAK,YAAY,IAAIC,2DAAmB,IAAI;AAC5C,SAAM,KAAK,OAAO,QAAQ,KAAK,UAAU;AACzC,WAAQ,KAAK,0BAA0B;AAEvC,QAAK,gBAAgB;WACd,GAAG;AACV,WAAQ,KAAK,qCAAqC,EAAE;AACpD,SAAM;;;CAIV,AAAQ,iBAAiB;AACvB,MAAI,KAAK,cAAc,KACrB;AAEF,OAAK,UAAU,gBAAgB;AAC7B,WAAQ,KAAK,wBAAwB;AACrC,QAAK,cAAc;;AAGrB,OAAK,UAAU,UAAU,OAAO,UAAU;AACxC,WAAQ,KAAK,yBAAyB,MAAM;AAC5C,SAAM,KAAK,SAAS;;AAGtB,OAAK,UAAU,aAAa,YAAY;AACtC,WAAQ,KAAK,sBAAsB,QAAQ;;;CAI/C,MAAM,oBAAoB;AACxB,SAAO,CAAC,KAAK,YACX,OAAM,IAAI,SAAS,YAAY,WAAW,SAAS,IAAI,CAAC;;CAI5D,MAAM,UAAU;AACd,QAAM,KAAK,OAAO,OAAO;;;AAI7B,MAAM,OAAO,YAAY;CACvB,MAAM,SAAS,IAAI,WAAW;AAE9B,KAAI;AACF,QAAM,OAAO,iBAAiB;AAC9B,QAAM,OAAO,mBAAmB;WACxB;AACR,QAAM,OAAO,SAAS;;;AAI1B,MAAM"}
|
|
@@ -4,14 +4,14 @@ const require_tools_docs = require('../tools/docs.cjs');
|
|
|
4
4
|
let node_fs = require("node:fs");
|
|
5
5
|
let node_path = require("node:path");
|
|
6
6
|
let node_url = require("node:url");
|
|
7
|
-
let
|
|
8
|
-
let
|
|
7
|
+
let _intlayer_config = require("@intlayer/config");
|
|
8
|
+
let _modelcontextprotocol_sdk_server_mcp_js = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
9
9
|
|
|
10
10
|
//#region src/server/server.ts
|
|
11
|
-
const dirname =
|
|
11
|
+
const dirname = _intlayer_config.isESModule ? (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href)) : __dirname;
|
|
12
12
|
const packageJson = JSON.parse((0, node_fs.readFileSync)((0, node_path.resolve)(dirname, "../../../package.json"), "utf8"));
|
|
13
13
|
const loadServer = ({ isLocal }) => {
|
|
14
|
-
const server = new
|
|
14
|
+
const server = new _modelcontextprotocol_sdk_server_mcp_js.McpServer({
|
|
15
15
|
name: "intlayer",
|
|
16
16
|
version: packageJson.version,
|
|
17
17
|
capabilities: { resources: {} }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.cjs","names":["dirname: string","isESModule","packageJson: Record<string, any>","loadServer: LoadServer","McpServer"],"sources":["../../../src/server/server.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { dirname as pathDirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { isESModule } from '@intlayer/config';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { loadCLITools } from '../tools/cli';\nimport { loadDocsTools } from '../tools/docs';\n\nexport const dirname: string = isESModule\n ? pathDirname(fileURLToPath(import.meta.url))\n : __dirname;\n\nconst packageJson: Record<string, any> = JSON.parse(\n readFileSync(resolve(dirname, '../../../package.json'), 'utf8')\n);\n\ntype LoadServer = (options: { isLocal: boolean }) => McpServer;\n\nexport const loadServer: LoadServer = ({ isLocal }) => {\n const server = new McpServer({\n name: 'intlayer',\n version: packageJson.version,\n capabilities: {\n resources: {},\n },\n });\n\n if (isLocal) {\n try {\n loadCLITools(server);\n } catch (error) {\n console.error('Error loading CLI tools:', error);\n }\n }\n\n try {\n loadDocsTools(server);\n } catch (error) {\n console.error('Error loading docs tools:', error);\n }\n\n return server;\n};\n"],"mappings":";;;;;;;;;;AAQA,MAAaA,UAAkBC,
|
|
1
|
+
{"version":3,"file":"server.cjs","names":["dirname: string","isESModule","packageJson: Record<string, any>","loadServer: LoadServer","McpServer"],"sources":["../../../src/server/server.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { dirname as pathDirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { isESModule } from '@intlayer/config';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { loadCLITools } from '../tools/cli';\nimport { loadDocsTools } from '../tools/docs';\n\nexport const dirname: string = isESModule\n ? pathDirname(fileURLToPath(import.meta.url))\n : __dirname;\n\nconst packageJson: Record<string, any> = JSON.parse(\n readFileSync(resolve(dirname, '../../../package.json'), 'utf8')\n);\n\ntype LoadServer = (options: { isLocal: boolean }) => McpServer;\n\nexport const loadServer: LoadServer = ({ isLocal }) => {\n const server = new McpServer({\n name: 'intlayer',\n version: packageJson.version,\n capabilities: {\n resources: {},\n },\n });\n\n if (isLocal) {\n try {\n loadCLITools(server);\n } catch (error) {\n console.error('Error loading CLI tools:', error);\n }\n }\n\n try {\n loadDocsTools(server);\n } catch (error) {\n console.error('Error loading docs tools:', error);\n }\n\n return server;\n};\n"],"mappings":";;;;;;;;;;AAQA,MAAaA,UAAkBC,+HACe,CAAC,GAC3C;AAEJ,MAAMC,cAAmC,KAAK,uDACvB,SAAS,wBAAwB,EAAE,OAAO,CAChE;AAID,MAAaC,cAA0B,EAAE,cAAc;CACrD,MAAM,SAAS,IAAIC,kDAAU;EAC3B,MAAM;EACN,SAAS,YAAY;EACrB,cAAc,EACZ,WAAW,EAAE,EACd;EACF,CAAC;AAEF,KAAI,QACF,KAAI;AACF,iCAAa,OAAO;UACb,OAAO;AACd,UAAQ,MAAM,4BAA4B,MAAM;;AAIpD,KAAI;AACF,mCAAc,OAAO;UACd,OAAO;AACd,UAAQ,MAAM,6BAA6B,MAAM;;AAGnD,QAAO"}
|
package/dist/cjs/server/sse.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
3
3
|
const require_server_server = require('./server.cjs');
|
|
4
|
-
let
|
|
4
|
+
let _modelcontextprotocol_sdk_server_sse_js = require("@modelcontextprotocol/sdk/server/sse.js");
|
|
5
5
|
let dotenv = require("dotenv");
|
|
6
6
|
dotenv = require_rolldown_runtime.__toESM(dotenv);
|
|
7
7
|
let express = require("express");
|
|
@@ -49,7 +49,7 @@ router.post(POST_ENDPOINT, async (req, res) => {
|
|
|
49
49
|
});
|
|
50
50
|
router.get("/", async (_req, res) => {
|
|
51
51
|
console.info("connection request received");
|
|
52
|
-
const transport = new
|
|
52
|
+
const transport = new _modelcontextprotocol_sdk_server_sse_js.SSEServerTransport(POST_ENDPOINT, res);
|
|
53
53
|
console.info("new transport created with session id: ", transport.sessionId);
|
|
54
54
|
transports[transport.sessionId] = transport;
|
|
55
55
|
console.info(`${Object.keys(transports).length} sessions active`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.cjs","names":["loadServer","transports: { [sessionId: string]: SSEServerTransport }","SSEServerTransport"],"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({ isLocal: 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":";;;;;;;;;;;AAWA,MAAM,SAASA,iCAAW,EAAE,SAAS,OAAO,CAAC;;AAM7C,MAAM,4BAAe;AAGrB,MAAM,MAAM,IAAI,IAAI,MAAM;AAE1B,eAAO,OAAO,EACZ,MAAM;CAAC,QAAQ,IAAI;CAAS,QAAQ;CAAO;CAAc;CAAO,EACjE,CAAC;AAGF,IAAI,KAAK,KAAK,KAAK,SAAS;AAC1B,KAAI,OAAO,+BAA+B,IAAI;AAC9C,KAAI,OAAO,gCAAgC,qBAAqB;AAChE,KAAI,OAAO,gCAAgC,eAAe;AAE1D,KAAI,IAAI,WAAW,WAAW;AAC5B,MAAI,WAAW,IAAI;AACnB;;AAGF,OAAM;EACN;AAEF,IAAI,IAAI,gBAAQ,MAAM,CAAC;AACvB,MAAM,SAAS,gBAAQ,QAAQ;AAI/B,MAAMC,aAA0D,EAAE;AAGlE,MAAM,gBAAgB;AAEtB,OAAO,KAAK,eAAe,OAAO,KAAc,QAAkB;AAChE,SAAQ,KAAK,8BAA8B,IAAI,KAAK;CAGpD,MAAM,YAAY,IAAI,MAAM;AAE5B,KAAI,OAAO,cAAc,UAAU;AACjC,MAAI,OAAO,IAAI,CAAC,KAAK,EAAE,UAAU,mBAAmB,CAAC;AACrD;;CAEF,MAAM,YAAY,WAAW;AAC7B,KAAI,CAAC,WAAW;AACd,MAAI,OAAO,IAAI,CAAC,KAAK,EAAE,UAAU,qCAAqC,CAAC;AACvE;;AAOF,OAAM,UAAU,kBAAkB,KAAK,KAAK,IAAI,KAAK;EAGrD;AAKF,OAAO,IAAI,KAAK,OAAO,MAAe,QAAkB;AACtD,SAAQ,KAAK,8BAA8B;CAE3C,MAAM,YAAY,IAAIC,
|
|
1
|
+
{"version":3,"file":"sse.cjs","names":["loadServer","transports: { [sessionId: string]: SSEServerTransport }","SSEServerTransport"],"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({ isLocal: 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":";;;;;;;;;;;AAWA,MAAM,SAASA,iCAAW,EAAE,SAAS,OAAO,CAAC;;AAM7C,MAAM,4BAAe;AAGrB,MAAM,MAAM,IAAI,IAAI,MAAM;AAE1B,eAAO,OAAO,EACZ,MAAM;CAAC,QAAQ,IAAI;CAAS,QAAQ;CAAO;CAAc;CAAO,EACjE,CAAC;AAGF,IAAI,KAAK,KAAK,KAAK,SAAS;AAC1B,KAAI,OAAO,+BAA+B,IAAI;AAC9C,KAAI,OAAO,gCAAgC,qBAAqB;AAChE,KAAI,OAAO,gCAAgC,eAAe;AAE1D,KAAI,IAAI,WAAW,WAAW;AAC5B,MAAI,WAAW,IAAI;AACnB;;AAGF,OAAM;EACN;AAEF,IAAI,IAAI,gBAAQ,MAAM,CAAC;AACvB,MAAM,SAAS,gBAAQ,QAAQ;AAI/B,MAAMC,aAA0D,EAAE;AAGlE,MAAM,gBAAgB;AAEtB,OAAO,KAAK,eAAe,OAA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,UAAU,KAAK;MACnB,SAAS;MACT,QAAQ;MACR,QAAQ,EAAE,SAAS,oBAAoB;MACxC,CAAC;AACF,aAAQ,KAAK,mBAAmB;;YAE3B,OAAO;AACd,YAAQ,MAAM,0BAA0B,MAAM;AAC9C,kBAAc,SAAS;;KAExB,IAAK;UACD,OAAO;AACd,UAAQ,MAAM,0BAA0B,MAAM;;;AAIlD,IAAI,IAAI,KAAK,OAAO;AAEpB,IAAI,IAAI,YAAY,MAAe,QAAkB;AACnD,KAAI,KAAK,KAAK;EACd;AAEF,MAAM,OAAO,QAAQ,IAAI,QAAQ;AAEjC,IAAI,OAAO,YAAY;AACrB,SAAQ,KAAK,gDAAgD,OAAO;EACpE"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
3
3
|
const require_server_server = require('./server.cjs');
|
|
4
|
-
let
|
|
4
|
+
let _modelcontextprotocol_sdk_server_stdio_js = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
5
5
|
|
|
6
6
|
//#region src/server/stdio.ts
|
|
7
7
|
const server = require_server_server.loadServer({ isLocal: true });
|
|
8
8
|
const main = async () => {
|
|
9
|
-
const transport = new
|
|
9
|
+
const transport = new _modelcontextprotocol_sdk_server_stdio_js.StdioServerTransport();
|
|
10
10
|
await server.connect(transport);
|
|
11
11
|
console.error("Intlayer MCP Server running on stdio");
|
|
12
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.cjs","names":["loadServer","StdioServerTransport"],"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({ isLocal: true });\n\nconst main = async () => {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n\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":";;;;;;AAKA,MAAM,SAASA,iCAAW,EAAE,SAAS,MAAM,CAAC;AAE5C,MAAM,OAAO,YAAY;CACvB,MAAM,YAAY,IAAIC,
|
|
1
|
+
{"version":3,"file":"stdio.cjs","names":["loadServer","StdioServerTransport"],"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({ isLocal: true });\n\nconst main = async () => {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n\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":";;;;;;AAKA,MAAM,SAASA,iCAAW,EAAE,SAAS,MAAM,CAAC;AAE5C,MAAM,OAAO,YAAY;CACvB,MAAM,YAAY,IAAIC,gEAAsB;AAC5C,OAAM,OAAO,QAAQ,UAAU;AAE/B,SAAQ,MAAM,uCAAuC;;AAGvD,MAAM,CAAC,OAAO,UAAU;AACtB,SAAQ,MAAM,0BAA0B,MAAM;AAC9C,SAAQ,KAAK,EAAE;EACf"}
|
package/dist/cjs/tools/cli.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let
|
|
3
|
-
let
|
|
2
|
+
let _intlayer_cli = require("@intlayer/cli");
|
|
3
|
+
let _intlayer_types = require("@intlayer/types");
|
|
4
4
|
let zod_v3 = require("zod/v3");
|
|
5
5
|
zod_v3 = require_rolldown_runtime.__toESM(zod_v3);
|
|
6
6
|
|
|
@@ -21,7 +21,7 @@ const loadCLITools = async (server) => {
|
|
|
21
21
|
const log = {};
|
|
22
22
|
if (verbose) log.mode = "verbose";
|
|
23
23
|
if (prefix) log.prefix = prefix;
|
|
24
|
-
await (0,
|
|
24
|
+
await (0, _intlayer_cli.build)({
|
|
25
25
|
watch,
|
|
26
26
|
configOptions: {
|
|
27
27
|
baseDir,
|
|
@@ -44,8 +44,8 @@ const loadCLITools = async (server) => {
|
|
|
44
44
|
server.registerTool("intlayer-fill", {
|
|
45
45
|
description: "Fill the dictionaries with missing translations / review translations using Intlayer servers",
|
|
46
46
|
inputSchema: {
|
|
47
|
-
sourceLocale: zod_v3.default.nativeEnum(
|
|
48
|
-
outputLocales: zod_v3.default.union([zod_v3.default.nativeEnum(
|
|
47
|
+
sourceLocale: zod_v3.default.nativeEnum(_intlayer_types.Locales.ALL_LOCALES).optional().describe("Source locale"),
|
|
48
|
+
outputLocales: zod_v3.default.union([zod_v3.default.nativeEnum(_intlayer_types.Locales.ALL_LOCALES), zod_v3.default.array(zod_v3.default.nativeEnum(_intlayer_types.Locales.ALL_LOCALES))]).optional().describe("Output locales"),
|
|
49
49
|
file: zod_v3.default.union([zod_v3.default.string(), zod_v3.default.array(zod_v3.default.string())]).optional().describe("File path"),
|
|
50
50
|
mode: zod_v3.default.enum(["complete", "review"]).optional().describe("Fill mode"),
|
|
51
51
|
keys: zod_v3.default.union([zod_v3.default.string(), zod_v3.default.array(zod_v3.default.string())]).optional().describe("Keys to include"),
|
|
@@ -87,7 +87,7 @@ const loadCLITools = async (server) => {
|
|
|
87
87
|
mode
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
|
-
await (0,
|
|
90
|
+
await (0, _intlayer_cli.fill)(fillOptions);
|
|
91
91
|
return { content: [{
|
|
92
92
|
type: "text",
|
|
93
93
|
text: "Fill successful."
|
|
@@ -133,7 +133,7 @@ const loadCLITools = async (server) => {
|
|
|
133
133
|
mode
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
|
-
await (0,
|
|
136
|
+
await (0, _intlayer_cli.push)(pushOptions);
|
|
137
137
|
return { content: [{
|
|
138
138
|
type: "text",
|
|
139
139
|
text: "Push successful."
|
|
@@ -153,7 +153,7 @@ const loadCLITools = async (server) => {
|
|
|
153
153
|
}
|
|
154
154
|
}, async (props) => {
|
|
155
155
|
try {
|
|
156
|
-
await (0,
|
|
156
|
+
await (0, _intlayer_cli.pull)(props);
|
|
157
157
|
return { content: [{
|
|
158
158
|
type: "text",
|
|
159
159
|
text: "Pull successful."
|
|
@@ -178,7 +178,7 @@ const loadCLITools = async (server) => {
|
|
|
178
178
|
}).optional().describe("Configuration options") }
|
|
179
179
|
}, async (props) => {
|
|
180
180
|
try {
|
|
181
|
-
const rows = (0,
|
|
181
|
+
const rows = (0, _intlayer_cli.listContentDeclarationRows)(props);
|
|
182
182
|
return { content: [{
|
|
183
183
|
type: "text",
|
|
184
184
|
text: JSON.stringify(rows, null, 2)
|
|
@@ -203,7 +203,7 @@ const loadCLITools = async (server) => {
|
|
|
203
203
|
}).optional().describe("Configuration options") }
|
|
204
204
|
}, async (props) => {
|
|
205
205
|
try {
|
|
206
|
-
const missingTranslations = (0,
|
|
206
|
+
const missingTranslations = (0, _intlayer_cli.listMissingTranslations)(props?.configOptions);
|
|
207
207
|
return { content: [{
|
|
208
208
|
type: "text",
|
|
209
209
|
text: JSON.stringify(missingTranslations, null, 2)
|
|
@@ -232,7 +232,7 @@ const loadCLITools = async (server) => {
|
|
|
232
232
|
}
|
|
233
233
|
}, async (props) => {
|
|
234
234
|
try {
|
|
235
|
-
await (0,
|
|
235
|
+
await (0, _intlayer_cli.transform)({
|
|
236
236
|
files: Array.isArray(props.file) ? props.file : props.file ? [props.file] : void 0,
|
|
237
237
|
outputContentDeclarations: props.outputContentDeclarations,
|
|
238
238
|
configOptions: props.configOptions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.cjs","names":["loadCLITools: LoadCLITools","z","log: Partial<LogConfig>","Locales","fillOptions: any","pushOptions: any"],"sources":["../../../src/tools/cli.ts"],"sourcesContent":["import {\n build,\n fill,\n listContentDeclarationRows,\n listMissingTranslations,\n pull,\n push,\n transform,\n} from '@intlayer/cli';\nimport { Locales, type LogConfig } from '@intlayer/types';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod/v3';\n\ntype LoadCLITools = (server: McpServer) => Promise<void>;\n\nexport const loadCLITools: LoadCLITools = async (server) => {\n server.registerTool(\n 'intlayer-build',\n {\n description:\n 'Build the dictionaries. List all content declarations files `.content.{ts,tsx,js,json,...}` to update the content callable using the `useIntlayer` hook.',\n inputSchema: {\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 },\n async ({ watch, baseDir, env, envFile, verbose, prefix }) => {\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\n server.registerTool(\n 'intlayer-fill',\n {\n description:\n 'Fill the dictionaries with missing translations / review translations using Intlayer servers',\n inputSchema: {\n sourceLocale: z\n .nativeEnum(Locales.ALL_LOCALES)\n .optional()\n .describe('Source locale'),\n outputLocales: z\n .union([\n z.nativeEnum(Locales.ALL_LOCALES),\n z.array(z.nativeEnum(Locales.ALL_LOCALES)),\n ])\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 },\n async (props) => {\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\n server.registerTool(\n 'intlayer-push',\n {\n description: 'Push local dictionaries to the server',\n inputSchema: {\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 },\n async (props) => {\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\n server.registerTool(\n 'intlayer-pull',\n {\n description: 'Pull dictionaries from the CMS',\n inputSchema: {\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 },\n async (props) => {\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\n server.registerTool(\n 'intlayer-content-list',\n {\n description:\n 'List the content declaration (.content.{ts,tsx,js,json,...}) files present in the project. That files contain the multilingual content of the application and are used to build the dictionaries.',\n inputSchema: {\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n },\n async (props) => {\n try {\n const rows = listContentDeclarationRows(props);\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(rows, null, 2),\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: `Content list failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-content-test',\n {\n description:\n 'Test if there are missing translations in the content declaration files. That files contain the multilingual content of the application and are used to build the dictionaries.',\n inputSchema: {\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n },\n async (props) => {\n try {\n const missingTranslations = listMissingTranslations(\n props?.configOptions\n );\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(missingTranslations, null, 2),\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: `Content test failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-transform',\n {\n description:\n 'Transform an existing component to use Intlayer. Trigger this action to transform an existing component to be multilingual. If the component does not exist, create a normal React component including text in JSX, and then trigger this tool to transform it.',\n inputSchema: {\n file: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('List of files to transform'),\n outputContentDeclarations: z\n .string()\n .optional()\n .describe('Path to output content declaration files'),\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n },\n async (props) => {\n try {\n await transform({\n files: Array.isArray(props.file)\n ? props.file\n : props.file\n ? [props.file]\n : undefined,\n outputContentDeclarations: props.outputContentDeclarations,\n configOptions: props.configOptions,\n });\n\n return {\n content: [\n {\n type: 'text',\n text: 'Transform 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: `Transform failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n};\n"],"mappings":";;;;;;;AAeA,MAAaA,eAA6B,OAAO,WAAW;AAC1D,QAAO,aACL,kBACA;EACE,aACE;EACF,aAAa;GACX,OAAOC,eAAE,SAAS,CAAC,UAAU,CAAC,SAAS,oBAAoB;GAC3D,SAASA,eAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,iBAAiB;GACzD,KAAKA,eAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,cAAc;GAClD,SAASA,eAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,mBAAmB;GAC3D,SAASA,eAAE,SAAS,CAAC,UAAU,CAAC,SAAS,iBAAiB;GAC1D,QAAQA,eAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,aAAa;GACrD;EACF,EACD,OAAO,EAAE,OAAO,SAAS,KAAK,SAAS,SAAS,aAAa;AAC3D,MAAI;GACF,MAAMC,MAA0B,EAAE;AAClC,OAAI,QACF,KAAI,OAAO;AAEb,OAAI,OACF,KAAI,SAAS;AAGf,mCAAY;IACV;IACA,eAAe;KACb;KACA;KACA;KACA,UAAU,EACR,KACD;KACF;IACF,CAAC;AAEF,UAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM;IACP,CACF,EACF;WACM,OAAO;AAGd,UAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,iBALV,iBAAiB,QAAQ,MAAM,UAAU;IAMtC,CACF,EACF;;GAGN;AAED,QAAO,aACL,iBACA;EACE,aACE;EACF,aAAa;GACX,cAAcD,eACX,WAAWE,yBAAQ,YAAY,CAC/B,UAAU,CACV,SAAS,gBAAgB;GAC5B,eAAeF,eACZ,MAAM,CACLA,eAAE,WAAWE,yBAAQ,YAAY,EACjCF,eAAE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6BAA6B;GACzC,2BAA2BA,eACxB,QAAQ,CACR,UAAU,CACV,SAAS,2CAA2C;GACvD,eAAeA,eACZ,OAAO;IACN,SAASA,eAAE,QAAQ,CAAC,UAAU;IAC9B,KAAKA,eAAE,QAAQ,CAAC,UAAU;IAC1B,SAASA,eAAE,QAAQ,CAAC,UAAU;IAC9B,UAAUA,eACP,OAAO,EACN,KAAKA,eACF,OAAO;KACN,QAAQA,eAAE,QAAQ,CAAC,UAAU;KAC7B,SAASA,eAAE,SAAS,CAAC,UAAU;KAChC,CAAC,CACD,UAAU,EACd,CAAC,CACD,UAAU;IACd,CAAC,CACD,UAAU,CACV,SAAS,wBAAwB;GACrC;EACF,EACD,OAAO,UAAU;AACf,MAAI;AACF,uCAAgB;IACd,OAAO,MAAM,QAAQ,MAAM,KAAK,GAC5B,MAAM,OACN,MAAM,OACJ,CAAC,MAAM,KAAK,GACZ;IACN,2BAA2B,MAAM;IACjC,eAAe,MAAM;IACtB,CAAC;AAEF,UAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM;IACP,CACF,EACF;WACM,OAAO;AAGd,UAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,qBALV,iBAAiB,QAAQ,MAAM,UAAU;IAMtC,CACF,EACF;;GAGN"}
|
|
1
|
+
{"version":3,"file":"cli.cjs","names":["loadCLITools: LoadCLITools","z","log: Partial<LogConfig>","Locales","fillOptions: any","pushOptions: any"],"sources":["../../../src/tools/cli.ts"],"sourcesContent":["import {\n build,\n fill,\n listContentDeclarationRows,\n listMissingTranslations,\n pull,\n push,\n transform,\n} from '@intlayer/cli';\nimport { Locales, type LogConfig } from '@intlayer/types';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod/v3';\n\ntype LoadCLITools = (server: McpServer) => Promise<void>;\n\nexport const loadCLITools: LoadCLITools = async (server) => {\n server.registerTool(\n 'intlayer-build',\n {\n description:\n 'Build the dictionaries. List all content declarations files `.content.{ts,tsx,js,json,...}` to update the content callable using the `useIntlayer` hook.',\n inputSchema: {\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 },\n async ({ watch, baseDir, env, envFile, verbose, prefix }) => {\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\n server.registerTool(\n 'intlayer-fill',\n {\n description:\n 'Fill the dictionaries with missing translations / review translations using Intlayer servers',\n inputSchema: {\n sourceLocale: z\n .nativeEnum(Locales.ALL_LOCALES)\n .optional()\n .describe('Source locale'),\n outputLocales: z\n .union([\n z.nativeEnum(Locales.ALL_LOCALES),\n z.array(z.nativeEnum(Locales.ALL_LOCALES)),\n ])\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 },\n async (props) => {\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\n server.registerTool(\n 'intlayer-push',\n {\n description: 'Push local dictionaries to the server',\n inputSchema: {\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 },\n async (props) => {\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\n server.registerTool(\n 'intlayer-pull',\n {\n description: 'Pull dictionaries from the CMS',\n inputSchema: {\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 },\n async (props) => {\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\n server.registerTool(\n 'intlayer-content-list',\n {\n description:\n 'List the content declaration (.content.{ts,tsx,js,json,...}) files present in the project. That files contain the multilingual content of the application and are used to build the dictionaries.',\n inputSchema: {\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n },\n async (props) => {\n try {\n const rows = listContentDeclarationRows(props);\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(rows, null, 2),\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: `Content list failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-content-test',\n {\n description:\n 'Test if there are missing translations in the content declaration files. That files contain the multilingual content of the application and are used to build the dictionaries.',\n inputSchema: {\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n },\n async (props) => {\n try {\n const missingTranslations = listMissingTranslations(\n props?.configOptions\n );\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(missingTranslations, null, 2),\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: `Content test failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-transform',\n {\n description:\n 'Transform an existing component to use Intlayer. Trigger this action to transform an existing component to be multilingual. If the component does not exist, create a normal React component including text in JSX, and then trigger this tool to transform it.',\n inputSchema: {\n file: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('List of files to transform'),\n outputContentDeclarations: z\n .string()\n .optional()\n .describe('Path to output content declaration files'),\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n },\n async (props) => {\n try {\n await transform({\n files: Array.isArray(props.file)\n ? props.file\n : props.file\n ? [props.file]\n : undefined,\n outputContentDeclarations: props.outputContentDeclarations,\n configOptions: props.configOptions,\n });\n\n return {\n content: [\n {\n type: 'text',\n text: 'Transform 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: `Transform failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n};\n"],"mappings":";;;;;;;AAeA,M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9B,UAAUA,eACP,OAAO,EACN,KAAKA,eACF,OAAO;KACN,QAAQA,eAAE,QAAQ,CAAC,UAAU;KAC7B,SAASA,eAAE,SAAS,CAAC,UAAU;KAChC,CAAC,CACD,UAAU,EACd,CAAC,CACD,UAAU;IACd,CAAC,CACD,UAAU,CACV,SAAS,wBAAwB;GACrC;EACF,EACD,OAAO,UAAU;AACf,MAAI;AACF,sCAAgB;IACd,OAAO,MAAM,QAAQ,MAAM,KAAK,GAC5B,MAAM,OACN,MAAM,OACJ,CAAC,MAAM,KAAK,GACZ;IACN,2BAA2B,MAAM;IACjC,eAAe,MAAM;IACtB,CAAC;AAEF,UAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM;IACP,CACF,EACF;WACM,OAAO;AAGd,UAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,qBALV,iBAAiB,QAAQ,MAAM,UAAU;IAMtC,CACF,EACF;;GAGN"}
|
package/dist/cjs/tools/docs.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
let zod_v3 = require("zod/v3");
|
|
3
3
|
zod_v3 = require_rolldown_runtime.__toESM(zod_v3);
|
|
4
|
-
let
|
|
4
|
+
let _intlayer_docs = require("@intlayer/docs");
|
|
5
5
|
|
|
6
6
|
//#region src/tools/docs.ts
|
|
7
7
|
const loadDocsTools = async (server) => {
|
|
8
|
-
const docsKeys = (0,
|
|
8
|
+
const docsKeys = (0, _intlayer_docs.getDocsKeys)();
|
|
9
9
|
server.registerTool("get-doc-list", {
|
|
10
10
|
description: "Get the list of docs names and their metadata to get more details about what doc to retrieve",
|
|
11
11
|
inputSchema: {}
|
|
12
12
|
}, async () => {
|
|
13
13
|
try {
|
|
14
|
-
const docsMetadataRecord = await (0,
|
|
14
|
+
const docsMetadataRecord = await (0, _intlayer_docs.getDocMetadataRecord)();
|
|
15
15
|
return { content: [{
|
|
16
16
|
type: "text",
|
|
17
17
|
text: JSON.stringify(docsMetadataRecord, null, 2)
|
|
@@ -30,7 +30,7 @@ const loadDocsTools = async (server) => {
|
|
|
30
30
|
try {
|
|
31
31
|
return { content: [{
|
|
32
32
|
type: "text",
|
|
33
|
-
text: await (0,
|
|
33
|
+
text: await (0, _intlayer_docs.getDoc)(docKey)
|
|
34
34
|
}] };
|
|
35
35
|
} catch (error) {
|
|
36
36
|
return { content: [{
|
|
@@ -47,7 +47,7 @@ const loadDocsTools = async (server) => {
|
|
|
47
47
|
}
|
|
48
48
|
}, async ({ slug, strict }) => {
|
|
49
49
|
try {
|
|
50
|
-
return { content: (await (0,
|
|
50
|
+
return { content: (await (0, _intlayer_docs.getDocBySlug)(slug, void 0, strict)).map((d) => ({
|
|
51
51
|
type: "text",
|
|
52
52
|
text: d
|
|
53
53
|
})) };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.cjs","names":["loadDocsTools: LoadDocsTools","z"],"sources":["../../../src/tools/docs.ts"],"sourcesContent":["import type { DocKey } from '@intlayer/docs';\nimport {\n getDoc,\n getDocBySlug,\n getDocMetadataRecord,\n getDocsKeys,\n} from '@intlayer/docs';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod/v3';\n\ntype LoadDocsTools = (server: McpServer) => Promise<void>;\n\nexport const loadDocsTools: LoadDocsTools = async (server) => {\n const docsKeys = getDocsKeys();\n\n server.registerTool(\n 'get-doc-list',\n {\n description:\n 'Get the list of docs names and their metadata to get more details about what doc to retrieve',\n inputSchema: {},\n },\n async () => {\n try {\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 } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n { type: 'text', text: `Get doc list failed: ${errorMessage}` },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'get-doc',\n {\n description:\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 inputSchema: {\n docKey: z.enum(docsKeys as [string, ...string[]]),\n },\n },\n async ({ docKey }) => {\n try {\n const doc = await getDoc(docKey as DocKey);\n return {\n content: [{ type: 'text', text: doc }],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [{ type: 'text', text: `Get doc failed: ${errorMessage}` }],\n };\n }\n }\n );\n\n server.registerTool(\n 'get-doc-by-slug',\n {\n description:\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 inputSchema: {\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 strict: z\n .boolean()\n .optional()\n .describe(\n 'Strict mode - only return docs that match all slugs, by excluding additional slugs'\n ),\n },\n },\n async ({ slug, strict }) => {\n try {\n const doc = await getDocBySlug(slug, undefined, strict);\n return {\n content: doc.map((d) => ({ type: 'text', text: d })),\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n { type: 'text', text: `Get doc by slug failed: ${errorMessage}` },\n ],\n };\n }\n }\n );\n};\n"],"mappings":";;;;;;AAYA,MAAaA,gBAA+B,OAAO,WAAW;CAC5D,MAAM,
|
|
1
|
+
{"version":3,"file":"docs.cjs","names":["loadDocsTools: LoadDocsTools","z"],"sources":["../../../src/tools/docs.ts"],"sourcesContent":["import type { DocKey } from '@intlayer/docs';\nimport {\n getDoc,\n getDocBySlug,\n getDocMetadataRecord,\n getDocsKeys,\n} from '@intlayer/docs';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod/v3';\n\ntype LoadDocsTools = (server: McpServer) => Promise<void>;\n\nexport const loadDocsTools: LoadDocsTools = async (server) => {\n const docsKeys = getDocsKeys();\n\n server.registerTool(\n 'get-doc-list',\n {\n description:\n 'Get the list of docs names and their metadata to get more details about what doc to retrieve',\n inputSchema: {},\n },\n async () => {\n try {\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 } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n { type: 'text', text: `Get doc list failed: ${errorMessage}` },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'get-doc',\n {\n description:\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 inputSchema: {\n docKey: z.enum(docsKeys as [string, ...string[]]),\n },\n },\n async ({ docKey }) => {\n try {\n const doc = await getDoc(docKey as DocKey);\n return {\n content: [{ type: 'text', text: doc }],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [{ type: 'text', text: `Get doc failed: ${errorMessage}` }],\n };\n }\n }\n );\n\n server.registerTool(\n 'get-doc-by-slug',\n {\n description:\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 inputSchema: {\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 strict: z\n .boolean()\n .optional()\n .describe(\n 'Strict mode - only return docs that match all slugs, by excluding additional slugs'\n ),\n },\n },\n async ({ slug, strict }) => {\n try {\n const doc = await getDocBySlug(slug, undefined, strict);\n return {\n content: doc.map((d) => ({ type: 'text', text: d })),\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n { type: 'text', text: `Get doc by slug failed: ${errorMessage}` },\n ],\n };\n }\n }\n );\n};\n"],"mappings":";;;;;;AAYA,MAAaA,gBAA+B,OAAO,WAAW;CAC5D,MAAM,4C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|
2
2
|
"name": "@intlayer/mcp",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.1",
|
|
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": [
|
|
@@ -96,25 +96,25 @@
|
|
|
96
96
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
97
97
|
},
|
|
98
98
|
"dependencies": {
|
|
99
|
-
"@intlayer/cli": "7.5.
|
|
100
|
-
"@intlayer/config": "7.5.
|
|
101
|
-
"@intlayer/docs": "7.5.
|
|
102
|
-
"@intlayer/types": "7.5.
|
|
99
|
+
"@intlayer/cli": "7.5.1",
|
|
100
|
+
"@intlayer/config": "7.5.1",
|
|
101
|
+
"@intlayer/docs": "7.5.1",
|
|
102
|
+
"@intlayer/types": "7.5.1",
|
|
103
103
|
"@modelcontextprotocol/sdk": "1.21.1",
|
|
104
104
|
"dotenv": "16.6.1",
|
|
105
105
|
"express": "5.2.1",
|
|
106
106
|
"zod": "3.25.76"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@intlayer/types": "7.5.
|
|
109
|
+
"@intlayer/types": "7.5.1",
|
|
110
110
|
"@modelcontextprotocol/inspector": "0.17.2",
|
|
111
111
|
"@types/express": "5.0.6",
|
|
112
|
-
"@types/node": "25.0.
|
|
112
|
+
"@types/node": "25.0.3",
|
|
113
113
|
"@utils/ts-config": "1.0.4",
|
|
114
114
|
"@utils/ts-config-types": "1.0.4",
|
|
115
115
|
"@utils/tsdown-config": "1.0.4",
|
|
116
116
|
"rimraf": "6.1.2",
|
|
117
|
-
"tsdown": "0.18.
|
|
117
|
+
"tsdown": "0.18.1",
|
|
118
118
|
"typescript": "5.9.3",
|
|
119
119
|
"vitest": "4.0.16"
|
|
120
120
|
},
|