@intlayer/mcp 8.9.2 → 8.9.4-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/client/client.mjs +2 -9
- package/dist/esm/client/client.mjs.map +1 -1
- package/dist/esm/client/sse.mjs +17 -50
- package/dist/esm/client/sse.mjs.map +1 -1
- package/dist/esm/server/server.mjs +9 -3
- package/dist/esm/server/server.mjs.map +1 -1
- package/dist/esm/server/sse.mjs +1 -1
- package/dist/esm/server/sse.mjs.map +1 -1
- package/dist/esm/server/stdio.mjs +1 -1
- package/dist/esm/server/stdio.mjs.map +1 -1
- package/dist/esm/tools/api.mjs +341 -0
- package/dist/esm/tools/api.mjs.map +1 -0
- package/dist/esm/tools/cli.mjs.map +1 -1
- package/dist/esm/tools/docs.mjs.map +1 -1
- package/dist/esm/tools/installSkills.mjs.map +1 -1
- package/dist/types/client/client.d.ts +1 -5
- package/dist/types/client/client.d.ts.map +1 -1
- package/dist/types/server/server.d.ts +1 -1
- package/dist/types/server/server.d.ts.map +1 -1
- package/dist/types/tools/api.d.ts +8 -0
- package/dist/types/tools/api.d.ts.map +1 -0
- package/dist/types/tools/cli.d.ts +1 -1
- package/dist/types/tools/docs.d.ts +1 -1
- package/dist/types/tools/installSkills.d.ts +1 -1
- package/package.json +11 -12
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { dirname as dirname$1, resolve } from "node:path";
|
|
1
|
+
import { dirname as dirname$1 } from "node:path";
|
|
3
2
|
import { fileURLToPath } from "node:url";
|
|
4
3
|
import { isESModule } from "@intlayer/config/utils";
|
|
5
|
-
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
6
4
|
|
|
7
5
|
//#region src/client/client.ts
|
|
8
6
|
const dirname = isESModule ? dirname$1(fileURLToPath(import.meta.url)) : __dirname;
|
|
9
|
-
const packageJson = JSON.parse(readFileSync(resolve(dirname, "../../../package.json"), "utf8"));
|
|
10
|
-
const loadClient = () => new Client({
|
|
11
|
-
name: `mcp-client-for-intlayer-mcp-server`,
|
|
12
|
-
version: packageJson.version
|
|
13
|
-
});
|
|
14
7
|
|
|
15
8
|
//#endregion
|
|
16
|
-
export { dirname
|
|
9
|
+
export { dirname };
|
|
17
10
|
//# sourceMappingURL=client.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.mjs","names":["pathDirname"],"sources":["../../../src/client/client.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"client.mjs","names":["pathDirname"],"sources":["../../../src/client/client.ts"],"sourcesContent":["import { dirname as pathDirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { isESModule } from '@intlayer/config/utils';\n\nexport const dirname: string = isESModule\n ? pathDirname(fileURLToPath(import.meta.url))\n : __dirname;\n"],"mappings":";;;;;AAIA,MAAa,UAAkB,aAC3BA,UAAY,cAAc,OAAO,KAAK,IAAI,CAAC,GAC3C"}
|
package/dist/esm/client/sse.mjs
CHANGED
|
@@ -1,59 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { URL } from "node:url";
|
|
3
|
-
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
1
|
+
import { createMCPClient } from "@ai-sdk/mcp";
|
|
4
2
|
|
|
5
3
|
//#region src/client/sse.ts
|
|
6
|
-
var SSEClient = class {
|
|
7
|
-
client;
|
|
8
|
-
transport = null;
|
|
9
|
-
isCompleted = false;
|
|
10
|
-
constructor() {
|
|
11
|
-
this.client = loadClient();
|
|
12
|
-
}
|
|
13
|
-
async connectToServer() {
|
|
14
|
-
const mcpServerURL = process.env.MCP_SERVER_URL ?? "http://localhost:3000/";
|
|
15
|
-
const url = new URL(mcpServerURL);
|
|
16
|
-
try {
|
|
17
|
-
console.info(`Connecting to server - ${mcpServerURL}`);
|
|
18
|
-
this.transport = new StreamableHTTPClientTransport(url);
|
|
19
|
-
await this.client.connect(this.transport);
|
|
20
|
-
console.info("Connected to MCP server");
|
|
21
|
-
this.setUpTransport();
|
|
22
|
-
} catch (e) {
|
|
23
|
-
console.error("Failed to connect to MCP server: ", e);
|
|
24
|
-
throw e;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
setUpTransport() {
|
|
28
|
-
if (this.transport === null) return;
|
|
29
|
-
this.transport.onclose = () => {
|
|
30
|
-
console.info("Transport closed.");
|
|
31
|
-
this.isCompleted = true;
|
|
32
|
-
};
|
|
33
|
-
this.transport.onerror = async (error) => {
|
|
34
|
-
console.error("Transport error: ", error);
|
|
35
|
-
await this.cleanup();
|
|
36
|
-
};
|
|
37
|
-
this.transport.onmessage = (message) => {
|
|
38
|
-
console.info("Message received: ", message);
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
async waitForCompletion() {
|
|
42
|
-
while (!this.isCompleted) await new Promise((resolve) => setTimeout(resolve, 100));
|
|
43
|
-
}
|
|
44
|
-
async cleanup() {
|
|
45
|
-
if (this.transport) await this.client.close();
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
4
|
const main = async () => {
|
|
49
|
-
const
|
|
5
|
+
const mcpServerURL = process.env.MCP_SERVER_URL ?? "http://localhost:3000/";
|
|
6
|
+
console.info(`Connecting to server - ${mcpServerURL}`);
|
|
7
|
+
let mcpClient;
|
|
50
8
|
try {
|
|
51
|
-
await
|
|
52
|
-
|
|
9
|
+
mcpClient = await createMCPClient({ transport: {
|
|
10
|
+
type: "http",
|
|
11
|
+
url: mcpServerURL
|
|
12
|
+
} });
|
|
13
|
+
console.info("Connected to MCP server");
|
|
14
|
+
await new Promise((resolve) => {
|
|
15
|
+
process.once("SIGINT", resolve);
|
|
16
|
+
process.once("SIGTERM", resolve);
|
|
17
|
+
});
|
|
53
18
|
} catch (error) {
|
|
54
|
-
console.error(error);
|
|
19
|
+
console.error("Failed to connect to MCP server: ", error);
|
|
20
|
+
throw error;
|
|
55
21
|
} finally {
|
|
56
|
-
await
|
|
22
|
+
await mcpClient?.close();
|
|
23
|
+
console.info("Connection closed.");
|
|
57
24
|
}
|
|
58
25
|
};
|
|
59
26
|
main();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.mjs","names":[],"sources":["../../../src/client/sse.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"sse.mjs","names":[],"sources":["../../../src/client/sse.ts"],"sourcesContent":["import { createMCPClient, type MCPClient } from '@ai-sdk/mcp';\n\nconst main = async () => {\n const mcpServerURL = process.env.MCP_SERVER_URL ?? 'http://localhost:3000/';\n\n console.info(`Connecting to server - ${mcpServerURL}`);\n\n let mcpClient: MCPClient | undefined;\n try {\n mcpClient = await createMCPClient({\n transport: {\n type: 'http',\n url: mcpServerURL,\n },\n });\n console.info('Connected to MCP server');\n\n await new Promise<void>((resolve) => {\n process.once('SIGINT', resolve);\n process.once('SIGTERM', resolve);\n });\n } catch (error) {\n console.error('Failed to connect to MCP server: ', error);\n throw error;\n } finally {\n await mcpClient?.close();\n console.info('Connection closed.');\n }\n};\n\nmain();\n"],"mappings":";;;AAEA,MAAM,OAAO,YAAY;CACvB,MAAM,eAAe,QAAQ,IAAI,kBAAkB;CAEnD,QAAQ,KAAK,0BAA0B,eAAe;CAEtD,IAAI;CACJ,IAAI;EACF,YAAY,MAAM,gBAAgB,EAChC,WAAW;GACT,MAAM;GACN,KAAK;GACN,EACF,CAAC;EACF,QAAQ,KAAK,0BAA0B;EAEvC,MAAM,IAAI,SAAe,YAAY;GACnC,QAAQ,KAAK,UAAU,QAAQ;GAC/B,QAAQ,KAAK,WAAW,QAAQ;IAChC;UACK,OAAO;EACd,QAAQ,MAAM,qCAAqC,MAAM;EACzD,MAAM;WACE;EACR,MAAM,WAAW,OAAO;EACxB,QAAQ,KAAK,qBAAqB;;;AAItC,MAAM"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { loadCLITools } from "../tools/cli.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { loadAPITools } from "../tools/api.mjs";
|
|
3
3
|
import { loadInstallSkillsTool } from "../tools/installSkills.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { loadDocsTools } from "../tools/docs.mjs";
|
|
5
5
|
import { dirname as dirname$1, resolve } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { isESModule } from "@intlayer/config/utils";
|
|
8
|
-
import {
|
|
8
|
+
import { readFileSync } from "node:fs";
|
|
9
|
+
import { McpServer } from "/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js";
|
|
9
10
|
|
|
10
11
|
//#region src/server/server.ts
|
|
11
12
|
const dirname = isESModule ? dirname$1(fileURLToPath(import.meta.url)) : __dirname;
|
|
@@ -26,6 +27,11 @@ const loadServer = ({ isLocal }) => {
|
|
|
26
27
|
} catch (error) {
|
|
27
28
|
console.error("Error loading docs tools:", error);
|
|
28
29
|
}
|
|
30
|
+
try {
|
|
31
|
+
loadAPITools(server);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error("Error loading API tools:", error);
|
|
34
|
+
}
|
|
29
35
|
return server;
|
|
30
36
|
};
|
|
31
37
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.mjs","names":["pathDirname"],"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/utils';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { loadCLITools } from '../tools/cli';\nimport { loadDocsTools } from '../tools/docs';\nimport { loadInstallSkillsTool } from '../tools/installSkills';\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 });\n\n if (isLocal) {\n try {\n loadCLITools(server);\n loadInstallSkillsTool(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":"
|
|
1
|
+
{"version":3,"file":"server.mjs","names":["pathDirname"],"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/utils';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { loadAPITools } from '../tools/api';\nimport { loadCLITools } from '../tools/cli';\nimport { loadDocsTools } from '../tools/docs';\nimport { loadInstallSkillsTool } from '../tools/installSkills';\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 });\n\n if (isLocal) {\n try {\n loadCLITools(server);\n loadInstallSkillsTool(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 try {\n loadAPITools(server);\n } catch (error) {\n console.error('Error loading API tools:', error);\n }\n\n return server;\n};\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,UAAkB,aAC3BA,UAAY,cAAc,OAAO,KAAK,IAAI,CAAC,GAC3C;AAEJ,MAAM,cAAmC,KAAK,MAC5C,aAAa,QAAQ,SAAS,wBAAwB,EAAE,OAAO,CAChE;AAID,MAAa,cAA0B,EAAE,cAAc;CACrD,MAAM,SAAS,IAAI,UAAU;EAC3B,MAAM;EACN,SAAS,YAAY;EACtB,CAAC;CAEF,IAAI,SACF,IAAI;EACF,aAAa,OAAO;EACpB,sBAAsB,OAAO;UACtB,OAAO;EACd,QAAQ,MAAM,4BAA4B,MAAM;;CAIpD,IAAI;EACF,cAAc,OAAO;UACd,OAAO;EACd,QAAQ,MAAM,6BAA6B,MAAM;;CAGnD,IAAI;EACF,aAAa,OAAO;UACb,OAAO;EACd,QAAQ,MAAM,4BAA4B,MAAM;;CAGlD,OAAO"}
|
package/dist/esm/server/sse.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { loadServer } from "./server.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
|
-
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
4
|
+
import { StreamableHTTPServerTransport } from "/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/streamableHttp.js";
|
|
5
5
|
import dotenv from "dotenv";
|
|
6
6
|
import express from "express";
|
|
7
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.mjs","names":[],"sources":["../../../src/server/sse.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { randomUUID } from 'node:crypto';\nimport { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';\nimport dotenv from 'dotenv';\nimport express, { type Request, type Response } from 'express';\nimport { loadServer } from './server';\n\nconst app = express();\nconst env = app.get('env');\n\ndotenv.config({\n path: [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'],\n quiet: true,\n});\n\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, mcp-session-id');\n if (req.method === 'OPTIONS') {\n res.sendStatus(200);\n return;\n }\n next();\n});\n\napp.use(express.json());\nconst router = express.Router();\n\nconst transports: { [sessionId: string]: StreamableHTTPServerTransport } = {};\n\nrouter.post('/', async (req: Request, res: Response) => {\n const sessionId = req.headers['mcp-session-id'] as string | undefined;\n\n let transport: StreamableHTTPServerTransport;\n\n if (sessionId && transports[sessionId]) {\n transport = transports[sessionId];\n } else if (!sessionId) {\n transport = new StreamableHTTPServerTransport({\n sessionIdGenerator: () => randomUUID(),\n });\n transport.onclose = () => {\n if (transport.sessionId) {\n delete transports[transport.sessionId];\n }\n };\n const server = loadServer({ isLocal: false });\n await server.connect(transport);\n } else {\n res.status(400).send({ messages: 'Bad session id.' });\n return;\n }\n\n await transport.handleRequest(req, res, req.body);\n\n const newSessionId = transport.sessionId;\n if (newSessionId && !transports[newSessionId]) {\n transports[newSessionId] = transport;\n }\n});\n\nrouter.get('/', async (req: Request, res: Response) => {\n const sessionId = req.headers['mcp-session-id'] as string | undefined;\n\n if (!sessionId || !transports[sessionId]) {\n res.status(400).send({ messages: 'Bad session id.' });\n return;\n }\n\n await transports[sessionId].handleRequest(req, res);\n});\n\nrouter.delete('/', async (req: Request, res: Response) => {\n const sessionId = req.headers['mcp-session-id'] as string | undefined;\n\n if (!sessionId || !transports[sessionId]) {\n res.status(400).send({ messages: 'Bad session id.' });\n return;\n }\n\n await transports[sessionId].handleRequest(req, res);\n});\n\napp.use('/', router);\napp.use('/health', (_req: Request, res: Response) => {\n res.send('OK');\n});\n\nconst PORT = process.env.PORT ?? 3000;\napp.listen(PORT, () => {\n console.info(`MCP Streamable HTTP Server listening on port ${PORT}`);\n});\n"],"mappings":";;;;;;;;AAQA,MAAM,MAAM,SAAS;AACrB,MAAM,MAAM,IAAI,IAAI,MAAM;AAE1B,OAAO,OAAO;CACZ,MAAM;EAAC,QAAQ,IAAI;EAAS,QAAQ;EAAO;EAAc;EAAO;CAChE,OAAO;CACR,CAAC;AAEF,IAAI,KAAK,KAAK,KAAK,SAAS;
|
|
1
|
+
{"version":3,"file":"sse.mjs","names":[],"sources":["../../../src/server/sse.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { randomUUID } from 'node:crypto';\nimport { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';\nimport dotenv from 'dotenv';\nimport express, { type Request, type Response } from 'express';\nimport { loadServer } from './server';\n\nconst app = express();\nconst env = app.get('env');\n\ndotenv.config({\n path: [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'],\n quiet: true,\n});\n\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, mcp-session-id');\n if (req.method === 'OPTIONS') {\n res.sendStatus(200);\n return;\n }\n next();\n});\n\napp.use(express.json());\nconst router = express.Router();\n\nconst transports: { [sessionId: string]: StreamableHTTPServerTransport } = {};\n\nrouter.post('/', async (req: Request, res: Response) => {\n const sessionId = req.headers['mcp-session-id'] as string | undefined;\n\n let transport: StreamableHTTPServerTransport;\n\n if (sessionId && transports[sessionId]) {\n transport = transports[sessionId];\n } else if (!sessionId) {\n transport = new StreamableHTTPServerTransport({\n sessionIdGenerator: () => randomUUID(),\n });\n transport.onclose = () => {\n if (transport.sessionId) {\n delete transports[transport.sessionId];\n }\n };\n const server = loadServer({ isLocal: false });\n await server.connect(transport);\n } else {\n res.status(400).send({ messages: 'Bad session id.' });\n return;\n }\n\n await transport.handleRequest(req, res, req.body);\n\n const newSessionId = transport.sessionId;\n if (newSessionId && !transports[newSessionId]) {\n transports[newSessionId] = transport;\n }\n});\n\nrouter.get('/', async (req: Request, res: Response) => {\n const sessionId = req.headers['mcp-session-id'] as string | undefined;\n\n if (!sessionId || !transports[sessionId]) {\n res.status(400).send({ messages: 'Bad session id.' });\n return;\n }\n\n await transports[sessionId].handleRequest(req, res);\n});\n\nrouter.delete('/', async (req: Request, res: Response) => {\n const sessionId = req.headers['mcp-session-id'] as string | undefined;\n\n if (!sessionId || !transports[sessionId]) {\n res.status(400).send({ messages: 'Bad session id.' });\n return;\n }\n\n await transports[sessionId].handleRequest(req, res);\n});\n\napp.use('/', router);\napp.use('/health', (_req: Request, res: Response) => {\n res.send('OK');\n});\n\nconst PORT = process.env.PORT ?? 3000;\napp.listen(PORT, () => {\n console.info(`MCP Streamable HTTP Server listening on port ${PORT}`);\n});\n"],"mappings":";;;;;;;;AAQA,MAAM,MAAM,SAAS;AACrB,MAAM,MAAM,IAAI,IAAI,MAAM;AAE1B,OAAO,OAAO;CACZ,MAAM;EAAC,QAAQ,IAAI;EAAS,QAAQ;EAAO;EAAc;EAAO;CAChE,OAAO;CACR,CAAC;AAEF,IAAI,KAAK,KAAK,KAAK,SAAS;CAC1B,IAAI,OAAO,+BAA+B,IAAI;CAC9C,IAAI,OAAO,gCAAgC,qBAAqB;CAChE,IAAI,OAAO,gCAAgC,+BAA+B;CAC1E,IAAI,IAAI,WAAW,WAAW;EAC5B,IAAI,WAAW,IAAI;EACnB;;CAEF,MAAM;EACN;AAEF,IAAI,IAAI,QAAQ,MAAM,CAAC;AACvB,MAAM,SAAS,QAAQ,QAAQ;AAE/B,MAAM,aAAqE,EAAE;AAE7E,OAAO,KAAK,KAAK,OAAO,KAAc,QAAkB;CACtD,MAAM,YAAY,IAAI,QAAQ;CAE9B,IAAI;CAEJ,IAAI,aAAa,WAAW,YAC1B,YAAY,WAAW;MAClB,IAAI,CAAC,WAAW;EACrB,YAAY,IAAI,8BAA8B,EAC5C,0BAA0B,YAAY,EACvC,CAAC;EACF,UAAU,gBAAgB;GACxB,IAAI,UAAU,WACZ,OAAO,WAAW,UAAU;;EAIhC,MADe,WAAW,EAAE,SAAS,OAAO,CAChC,CAAC,QAAQ,UAAU;QAC1B;EACL,IAAI,OAAO,IAAI,CAAC,KAAK,EAAE,UAAU,mBAAmB,CAAC;EACrD;;CAGF,MAAM,UAAU,cAAc,KAAK,KAAK,IAAI,KAAK;CAEjD,MAAM,eAAe,UAAU;CAC/B,IAAI,gBAAgB,CAAC,WAAW,eAC9B,WAAW,gBAAgB;EAE7B;AAEF,OAAO,IAAI,KAAK,OAAO,KAAc,QAAkB;CACrD,MAAM,YAAY,IAAI,QAAQ;CAE9B,IAAI,CAAC,aAAa,CAAC,WAAW,YAAY;EACxC,IAAI,OAAO,IAAI,CAAC,KAAK,EAAE,UAAU,mBAAmB,CAAC;EACrD;;CAGF,MAAM,WAAW,WAAW,cAAc,KAAK,IAAI;EACnD;AAEF,OAAO,OAAO,KAAK,OAAO,KAAc,QAAkB;CACxD,MAAM,YAAY,IAAI,QAAQ;CAE9B,IAAI,CAAC,aAAa,CAAC,WAAW,YAAY;EACxC,IAAI,OAAO,IAAI,CAAC,KAAK,EAAE,UAAU,mBAAmB,CAAC;EACrD;;CAGF,MAAM,WAAW,WAAW,cAAc,KAAK,IAAI;EACnD;AAEF,IAAI,IAAI,KAAK,OAAO;AACpB,IAAI,IAAI,YAAY,MAAe,QAAkB;CACnD,IAAI,KAAK,KAAK;EACd;AAEF,MAAM,OAAO,QAAQ,IAAI,QAAQ;AACjC,IAAI,OAAO,YAAY;CACrB,QAAQ,KAAK,gDAAgD,OAAO;EACpE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { loadServer } from "./server.mjs";
|
|
3
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { StdioServerTransport } from "/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js";
|
|
4
4
|
|
|
5
5
|
//#region src/server/stdio.ts
|
|
6
6
|
const server = loadServer({ isLocal: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.mjs","names":[],"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,SAAS,WAAW,EAAE,SAAS,MAAM,CAAC;AAE5C,MAAM,OAAO,YAAY;CACvB,MAAM,YAAY,IAAI,sBAAsB;
|
|
1
|
+
{"version":3,"file":"stdio.mjs","names":[],"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,SAAS,WAAW,EAAE,SAAS,MAAM,CAAC;AAE5C,MAAM,OAAO,YAAY;CACvB,MAAM,YAAY,IAAI,sBAAsB;CAC5C,MAAM,OAAO,QAAQ,UAAU;CAE/B,QAAQ,MAAM,uCAAuC;;AAGvD,MAAM,CAAC,OAAO,UAAU;CACtB,QAAQ,MAAM,0BAA0B,MAAM;CAC9C,QAAQ,KAAK,EAAE;EACf"}
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { getConfiguration } from "@intlayer/config";
|
|
3
|
+
import { getIntlayerAPI } from "@intlayer/api";
|
|
4
|
+
|
|
5
|
+
//#region src/tools/api.ts
|
|
6
|
+
const authSchema = {
|
|
7
|
+
clientId: z.string().optional().describe("Intlayer OAuth2 client ID (access key). Falls back to INTLAYER_CLIENT_ID env var."),
|
|
8
|
+
clientSecret: z.string().optional().describe("Intlayer OAuth2 client secret. Falls back to INTLAYER_CLIENT_SECRET env var.")
|
|
9
|
+
};
|
|
10
|
+
const getAPI = async (clientId, clientSecret) => {
|
|
11
|
+
const config = getConfiguration();
|
|
12
|
+
const resolvedClientId = clientId ?? config.editor.clientId;
|
|
13
|
+
const resolvedClientSecret = clientSecret ?? config.editor.clientSecret;
|
|
14
|
+
if (!resolvedClientId || !resolvedClientSecret) throw new Error("Intlayer credentials not found. Provide clientId/clientSecret or set INTLAYER_CLIENT_ID/INTLAYER_CLIENT_SECRET.");
|
|
15
|
+
const token = (await getIntlayerAPI({}, {
|
|
16
|
+
...config,
|
|
17
|
+
editor: {
|
|
18
|
+
...config.editor,
|
|
19
|
+
clientId: resolvedClientId,
|
|
20
|
+
clientSecret: resolvedClientSecret
|
|
21
|
+
}
|
|
22
|
+
}).oAuth.getOAuth2AccessToken())?.data?.access_token;
|
|
23
|
+
if (!token) throw new Error("Failed to obtain OAuth2 access token. Check your credentials.");
|
|
24
|
+
return getIntlayerAPI({ headers: { Authorization: `Bearer ${token}` } }, config);
|
|
25
|
+
};
|
|
26
|
+
const ok = (data) => ({ content: [{
|
|
27
|
+
type: "text",
|
|
28
|
+
text: JSON.stringify(data, null, 2)
|
|
29
|
+
}] });
|
|
30
|
+
const fail = (label, error) => ({
|
|
31
|
+
content: [{
|
|
32
|
+
type: "text",
|
|
33
|
+
text: `${label} failed: ${error instanceof Error ? error.message : String(error)}`
|
|
34
|
+
}],
|
|
35
|
+
isError: true
|
|
36
|
+
});
|
|
37
|
+
const loadAPITools = (server) => {
|
|
38
|
+
server.registerTool("intlayer-dictionaries-list", {
|
|
39
|
+
title: "List Dictionaries",
|
|
40
|
+
description: "List all dictionaries for the selected project. Returns keys, IDs, and metadata.",
|
|
41
|
+
inputSchema: {
|
|
42
|
+
...authSchema,
|
|
43
|
+
page: z.number().optional().describe("Page number (1-based)"),
|
|
44
|
+
pageSize: z.number().optional().describe("Items per page")
|
|
45
|
+
},
|
|
46
|
+
annotations: { readOnlyHint: true }
|
|
47
|
+
}, async ({ clientId, clientSecret, page, pageSize }) => {
|
|
48
|
+
try {
|
|
49
|
+
return ok(await (await getAPI(clientId, clientSecret)).dictionary.getDictionaries({
|
|
50
|
+
page,
|
|
51
|
+
pageSize
|
|
52
|
+
}));
|
|
53
|
+
} catch (error) {
|
|
54
|
+
return fail("List dictionaries", error);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
server.registerTool("intlayer-dictionary-get", {
|
|
58
|
+
title: "Get Dictionary",
|
|
59
|
+
description: "Get a dictionary by its key, including its full content.",
|
|
60
|
+
inputSchema: {
|
|
61
|
+
...authSchema,
|
|
62
|
+
dictionaryKey: z.string().describe("The dictionary key")
|
|
63
|
+
},
|
|
64
|
+
annotations: { readOnlyHint: true }
|
|
65
|
+
}, async ({ clientId, clientSecret, dictionaryKey }) => {
|
|
66
|
+
try {
|
|
67
|
+
return ok(await (await getAPI(clientId, clientSecret)).dictionary.getDictionary(dictionaryKey));
|
|
68
|
+
} catch (error) {
|
|
69
|
+
return fail("Get dictionary", error);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
server.registerTool("intlayer-dictionary-create", {
|
|
73
|
+
title: "Create Dictionary",
|
|
74
|
+
description: "Create a new dictionary in the selected project.",
|
|
75
|
+
inputSchema: {
|
|
76
|
+
...authSchema,
|
|
77
|
+
key: z.string().describe("Unique key for the dictionary"),
|
|
78
|
+
title: z.string().optional().describe("Human-readable title"),
|
|
79
|
+
description: z.string().optional().describe("Description of the dictionary"),
|
|
80
|
+
content: z.record(z.unknown()).optional().describe("Initial content as JSON object")
|
|
81
|
+
},
|
|
82
|
+
annotations: { destructiveHint: false }
|
|
83
|
+
}, async ({ clientId, clientSecret, key, title, description, content }) => {
|
|
84
|
+
try {
|
|
85
|
+
return ok(await (await getAPI(clientId, clientSecret)).dictionary.addDictionary({
|
|
86
|
+
key,
|
|
87
|
+
title,
|
|
88
|
+
description,
|
|
89
|
+
content
|
|
90
|
+
}));
|
|
91
|
+
} catch (error) {
|
|
92
|
+
return fail("Create dictionary", error);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
server.registerTool("intlayer-dictionary-update", {
|
|
96
|
+
title: "Update Dictionary",
|
|
97
|
+
description: "Update an existing dictionary content or metadata.",
|
|
98
|
+
inputSchema: {
|
|
99
|
+
...authSchema,
|
|
100
|
+
id: z.string().describe("Dictionary ID"),
|
|
101
|
+
key: z.string().optional().describe("New key for the dictionary"),
|
|
102
|
+
title: z.string().optional().describe("New title"),
|
|
103
|
+
description: z.string().optional().describe("New description"),
|
|
104
|
+
content: z.record(z.unknown()).optional().describe("Updated content as JSON object")
|
|
105
|
+
},
|
|
106
|
+
annotations: { destructiveHint: true }
|
|
107
|
+
}, async ({ clientId, clientSecret, id, key, title, description, content }) => {
|
|
108
|
+
try {
|
|
109
|
+
return ok(await (await getAPI(clientId, clientSecret)).dictionary.updateDictionary({
|
|
110
|
+
id,
|
|
111
|
+
key,
|
|
112
|
+
title,
|
|
113
|
+
description,
|
|
114
|
+
content
|
|
115
|
+
}));
|
|
116
|
+
} catch (error) {
|
|
117
|
+
return fail("Update dictionary", error);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
server.registerTool("intlayer-dictionary-delete", {
|
|
121
|
+
title: "Delete Dictionary",
|
|
122
|
+
description: "Delete a dictionary by its ID. This action is irreversible.",
|
|
123
|
+
inputSchema: {
|
|
124
|
+
...authSchema,
|
|
125
|
+
dictionaryId: z.string().describe("Dictionary ID to delete")
|
|
126
|
+
},
|
|
127
|
+
annotations: { destructiveHint: true }
|
|
128
|
+
}, async ({ clientId, clientSecret, dictionaryId }) => {
|
|
129
|
+
try {
|
|
130
|
+
return ok(await (await getAPI(clientId, clientSecret)).dictionary.deleteDictionary(dictionaryId));
|
|
131
|
+
} catch (error) {
|
|
132
|
+
return fail("Delete dictionary", error);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
server.registerTool("intlayer-tags-list", {
|
|
136
|
+
title: "List Tags",
|
|
137
|
+
description: "List all tags for the selected organization.",
|
|
138
|
+
inputSchema: {
|
|
139
|
+
...authSchema,
|
|
140
|
+
page: z.number().optional().describe("Page number (1-based)"),
|
|
141
|
+
pageSize: z.number().optional().describe("Items per page")
|
|
142
|
+
},
|
|
143
|
+
annotations: { readOnlyHint: true }
|
|
144
|
+
}, async ({ clientId, clientSecret, page, pageSize }) => {
|
|
145
|
+
try {
|
|
146
|
+
return ok(await (await getAPI(clientId, clientSecret)).tag.getTags({
|
|
147
|
+
page,
|
|
148
|
+
pageSize
|
|
149
|
+
}));
|
|
150
|
+
} catch (error) {
|
|
151
|
+
return fail("List tags", error);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
server.registerTool("intlayer-tag-create", {
|
|
155
|
+
title: "Create Tag",
|
|
156
|
+
description: "Create a new tag in the organization. Tags can be used to group dictionaries and provide AI context.",
|
|
157
|
+
inputSchema: {
|
|
158
|
+
...authSchema,
|
|
159
|
+
key: z.string().describe("Unique tag key"),
|
|
160
|
+
name: z.string().optional().describe("Display name for the tag"),
|
|
161
|
+
description: z.string().optional().describe("Description of the tag"),
|
|
162
|
+
color: z.string().optional().describe("Tag color (hex code)"),
|
|
163
|
+
instructions: z.string().optional().describe("AI instructions to apply when this tag is used")
|
|
164
|
+
},
|
|
165
|
+
annotations: { destructiveHint: false }
|
|
166
|
+
}, async ({ clientId, clientSecret, key, name, description, color, instructions }) => {
|
|
167
|
+
try {
|
|
168
|
+
return ok(await (await getAPI(clientId, clientSecret)).tag.addTag({
|
|
169
|
+
key,
|
|
170
|
+
name,
|
|
171
|
+
description,
|
|
172
|
+
color,
|
|
173
|
+
instructions
|
|
174
|
+
}));
|
|
175
|
+
} catch (error) {
|
|
176
|
+
return fail("Create tag", error);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
server.registerTool("intlayer-tag-update", {
|
|
180
|
+
title: "Update Tag",
|
|
181
|
+
description: "Update an existing tag.",
|
|
182
|
+
inputSchema: {
|
|
183
|
+
...authSchema,
|
|
184
|
+
tagId: z.string().describe("Tag ID to update"),
|
|
185
|
+
key: z.string().optional().describe("New key"),
|
|
186
|
+
name: z.string().optional().describe("New display name"),
|
|
187
|
+
description: z.string().optional().describe("New description"),
|
|
188
|
+
color: z.string().optional().describe("New color (hex code)"),
|
|
189
|
+
instructions: z.string().optional().describe("New AI instructions")
|
|
190
|
+
},
|
|
191
|
+
annotations: { destructiveHint: true }
|
|
192
|
+
}, async ({ clientId, clientSecret, tagId, key, name, description, color, instructions }) => {
|
|
193
|
+
try {
|
|
194
|
+
return ok(await (await getAPI(clientId, clientSecret)).tag.updateTag(tagId, {
|
|
195
|
+
key,
|
|
196
|
+
name,
|
|
197
|
+
description,
|
|
198
|
+
color,
|
|
199
|
+
instructions
|
|
200
|
+
}));
|
|
201
|
+
} catch (error) {
|
|
202
|
+
return fail("Update tag", error);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
server.registerTool("intlayer-tag-delete", {
|
|
206
|
+
title: "Delete Tag",
|
|
207
|
+
description: "Delete a tag by its ID.",
|
|
208
|
+
inputSchema: {
|
|
209
|
+
...authSchema,
|
|
210
|
+
tagId: z.string().describe("Tag ID to delete")
|
|
211
|
+
},
|
|
212
|
+
annotations: { destructiveHint: true }
|
|
213
|
+
}, async ({ clientId, clientSecret, tagId }) => {
|
|
214
|
+
try {
|
|
215
|
+
return ok(await (await getAPI(clientId, clientSecret)).tag.deleteTag(tagId));
|
|
216
|
+
} catch (error) {
|
|
217
|
+
return fail("Delete tag", error);
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
server.registerTool("intlayer-organizations-list", {
|
|
221
|
+
title: "List Organizations",
|
|
222
|
+
description: "List all organizations the authenticated user belongs to.",
|
|
223
|
+
inputSchema: {
|
|
224
|
+
...authSchema,
|
|
225
|
+
page: z.number().optional().describe("Page number (1-based)"),
|
|
226
|
+
pageSize: z.number().optional().describe("Items per page")
|
|
227
|
+
},
|
|
228
|
+
annotations: { readOnlyHint: true }
|
|
229
|
+
}, async ({ clientId, clientSecret, page, pageSize }) => {
|
|
230
|
+
try {
|
|
231
|
+
return ok(await (await getAPI(clientId, clientSecret)).organization.getOrganizations({
|
|
232
|
+
page,
|
|
233
|
+
pageSize
|
|
234
|
+
}));
|
|
235
|
+
} catch (error) {
|
|
236
|
+
return fail("List organizations", error);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
server.registerTool("intlayer-organization-select", {
|
|
240
|
+
title: "Select Organization",
|
|
241
|
+
description: "Select an organization as the current active organization. Required before accessing organization-specific resources.",
|
|
242
|
+
inputSchema: {
|
|
243
|
+
...authSchema,
|
|
244
|
+
organizationId: z.string().describe("Organization ID to select")
|
|
245
|
+
},
|
|
246
|
+
annotations: { destructiveHint: false }
|
|
247
|
+
}, async ({ clientId, clientSecret, organizationId }) => {
|
|
248
|
+
try {
|
|
249
|
+
return ok(await (await getAPI(clientId, clientSecret)).organization.selectOrganization(organizationId));
|
|
250
|
+
} catch (error) {
|
|
251
|
+
return fail("Select organization", error);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
server.registerTool("intlayer-organization-update", {
|
|
255
|
+
title: "Update Organization",
|
|
256
|
+
description: "Update the selected organization name or settings.",
|
|
257
|
+
inputSchema: {
|
|
258
|
+
...authSchema,
|
|
259
|
+
name: z.string().optional().describe("New organization name"),
|
|
260
|
+
customInstructions: z.string().optional().describe("Custom AI instructions for this organization")
|
|
261
|
+
},
|
|
262
|
+
annotations: { destructiveHint: true }
|
|
263
|
+
}, async ({ clientId, clientSecret, name, customInstructions }) => {
|
|
264
|
+
try {
|
|
265
|
+
return ok(await (await getAPI(clientId, clientSecret)).organization.updateOrganization({
|
|
266
|
+
name,
|
|
267
|
+
customInstructions
|
|
268
|
+
}));
|
|
269
|
+
} catch (error) {
|
|
270
|
+
return fail("Update organization", error);
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
server.registerTool("intlayer-cms-projects-list", {
|
|
274
|
+
title: "List CMS Projects",
|
|
275
|
+
description: "List all Intlayer CMS projects for the selected organization. These are server-side projects, not local project directories.",
|
|
276
|
+
inputSchema: {
|
|
277
|
+
...authSchema,
|
|
278
|
+
page: z.number().optional().describe("Page number (1-based)"),
|
|
279
|
+
pageSize: z.number().optional().describe("Items per page")
|
|
280
|
+
},
|
|
281
|
+
annotations: { readOnlyHint: true }
|
|
282
|
+
}, async ({ clientId, clientSecret, page, pageSize }) => {
|
|
283
|
+
try {
|
|
284
|
+
return ok(await (await getAPI(clientId, clientSecret)).project.getProjects({
|
|
285
|
+
page,
|
|
286
|
+
pageSize
|
|
287
|
+
}));
|
|
288
|
+
} catch (error) {
|
|
289
|
+
return fail("List CMS projects", error);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
server.registerTool("intlayer-cms-project-select", {
|
|
293
|
+
title: "Select CMS Project",
|
|
294
|
+
description: "Select a CMS project as the current active project. Required before accessing project-specific dictionaries.",
|
|
295
|
+
inputSchema: {
|
|
296
|
+
...authSchema,
|
|
297
|
+
projectId: z.string().describe("Project ID to select")
|
|
298
|
+
},
|
|
299
|
+
annotations: { destructiveHint: false }
|
|
300
|
+
}, async ({ clientId, clientSecret, projectId }) => {
|
|
301
|
+
try {
|
|
302
|
+
return ok(await (await getAPI(clientId, clientSecret)).project.selectProject(projectId));
|
|
303
|
+
} catch (error) {
|
|
304
|
+
return fail("Select CMS project", error);
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
server.registerTool("intlayer-cms-project-create", {
|
|
308
|
+
title: "Create CMS Project",
|
|
309
|
+
description: "Create a new CMS project in the selected organization.",
|
|
310
|
+
inputSchema: {
|
|
311
|
+
...authSchema,
|
|
312
|
+
name: z.string().describe("Project name")
|
|
313
|
+
},
|
|
314
|
+
annotations: { destructiveHint: false }
|
|
315
|
+
}, async ({ clientId, clientSecret, name }) => {
|
|
316
|
+
try {
|
|
317
|
+
return ok(await (await getAPI(clientId, clientSecret)).project.addProject({ name }));
|
|
318
|
+
} catch (error) {
|
|
319
|
+
return fail("Create CMS project", error);
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
server.registerTool("intlayer-cms-project-update", {
|
|
323
|
+
title: "Update CMS Project",
|
|
324
|
+
description: "Update the selected CMS project settings.",
|
|
325
|
+
inputSchema: {
|
|
326
|
+
...authSchema,
|
|
327
|
+
name: z.string().optional().describe("New project name")
|
|
328
|
+
},
|
|
329
|
+
annotations: { destructiveHint: true }
|
|
330
|
+
}, async ({ clientId, clientSecret, name }) => {
|
|
331
|
+
try {
|
|
332
|
+
return ok(await (await getAPI(clientId, clientSecret)).project.updateProject({ name }));
|
|
333
|
+
} catch (error) {
|
|
334
|
+
return fail("Update CMS project", error);
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
//#endregion
|
|
340
|
+
export { loadAPITools };
|
|
341
|
+
//# sourceMappingURL=api.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.mjs","names":[],"sources":["../../../src/tools/api.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { getIntlayerAPI } from '@intlayer/api';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod';\n\ntype LoadAPITools = (server: McpServer) => void;\n\nconst authSchema = {\n clientId: z\n .string()\n .optional()\n .describe(\n 'Intlayer OAuth2 client ID (access key). Falls back to INTLAYER_CLIENT_ID env var.'\n ),\n clientSecret: z\n .string()\n .optional()\n .describe(\n 'Intlayer OAuth2 client secret. Falls back to INTLAYER_CLIENT_SECRET env var.'\n ),\n};\n\nconst getAPI = async (clientId?: string, clientSecret?: string) => {\n const config = getConfiguration();\n const resolvedClientId = clientId ?? config.editor.clientId;\n const resolvedClientSecret = clientSecret ?? config.editor.clientSecret;\n\n if (!resolvedClientId || !resolvedClientSecret) {\n throw new Error(\n 'Intlayer credentials not found. Provide clientId/clientSecret or set INTLAYER_CLIENT_ID/INTLAYER_CLIENT_SECRET.'\n );\n }\n\n const configWithCreds = {\n ...config,\n editor: { ...config.editor, clientId: resolvedClientId, clientSecret: resolvedClientSecret },\n };\n\n const tempAPI = getIntlayerAPI({}, configWithCreds);\n const tokenResult = await tempAPI.oAuth.getOAuth2AccessToken();\n const token = (tokenResult as any)?.data?.access_token as string | undefined;\n\n if (!token) {\n throw new Error('Failed to obtain OAuth2 access token. Check your credentials.');\n }\n\n return getIntlayerAPI(\n { headers: { Authorization: `Bearer ${token}` } },\n config\n );\n};\n\nconst ok = (data: unknown) => ({\n content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }],\n});\n\nconst fail = (label: string, error: unknown) => ({\n content: [\n {\n type: 'text' as const,\n text: `${label} failed: ${error instanceof Error ? error.message : String(error)}`,\n },\n ],\n isError: true as const,\n});\n\nexport const loadAPITools: LoadAPITools = (server) => {\n // ── Dictionaries ──────────────────────────────────────────────────────────\n\n server.registerTool(\n 'intlayer-dictionaries-list',\n {\n title: 'List Dictionaries',\n description:\n 'List all dictionaries for the selected project. Returns keys, IDs, and metadata.',\n inputSchema: {\n ...authSchema,\n page: z.number().optional().describe('Page number (1-based)'),\n pageSize: z.number().optional().describe('Items per page'),\n },\n annotations: { readOnlyHint: true },\n },\n async ({ clientId, clientSecret, page, pageSize }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.dictionary.getDictionaries({ page, pageSize } as any);\n return ok(result);\n } catch (error) {\n return fail('List dictionaries', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-dictionary-get',\n {\n title: 'Get Dictionary',\n description: 'Get a dictionary by its key, including its full content.',\n inputSchema: {\n ...authSchema,\n dictionaryKey: z.string().describe('The dictionary key'),\n },\n annotations: { readOnlyHint: true },\n },\n async ({ clientId, clientSecret, dictionaryKey }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.dictionary.getDictionary(dictionaryKey);\n return ok(result);\n } catch (error) {\n return fail('Get dictionary', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-dictionary-create',\n {\n title: 'Create Dictionary',\n description: 'Create a new dictionary in the selected project.',\n inputSchema: {\n ...authSchema,\n key: z.string().describe('Unique key for the dictionary'),\n title: z.string().optional().describe('Human-readable title'),\n description: z.string().optional().describe('Description of the dictionary'),\n content: z.record(z.unknown()).optional().describe('Initial content as JSON object'),\n },\n annotations: { destructiveHint: false },\n },\n async ({ clientId, clientSecret, key, title, description, content }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.dictionary.addDictionary({ key, title, description, content } as any);\n return ok(result);\n } catch (error) {\n return fail('Create dictionary', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-dictionary-update',\n {\n title: 'Update Dictionary',\n description: 'Update an existing dictionary content or metadata.',\n inputSchema: {\n ...authSchema,\n id: z.string().describe('Dictionary ID'),\n key: z.string().optional().describe('New key for the dictionary'),\n title: z.string().optional().describe('New title'),\n description: z.string().optional().describe('New description'),\n content: z.record(z.unknown()).optional().describe('Updated content as JSON object'),\n },\n annotations: { destructiveHint: true },\n },\n async ({ clientId, clientSecret, id, key, title, description, content }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.dictionary.updateDictionary({ id, key, title, description, content } as any);\n return ok(result);\n } catch (error) {\n return fail('Update dictionary', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-dictionary-delete',\n {\n title: 'Delete Dictionary',\n description: 'Delete a dictionary by its ID. This action is irreversible.',\n inputSchema: {\n ...authSchema,\n dictionaryId: z.string().describe('Dictionary ID to delete'),\n },\n annotations: { destructiveHint: true },\n },\n async ({ clientId, clientSecret, dictionaryId }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.dictionary.deleteDictionary(dictionaryId);\n return ok(result);\n } catch (error) {\n return fail('Delete dictionary', error);\n }\n }\n );\n\n // ── Tags ──────────────────────────────────────────────────────────────────\n\n server.registerTool(\n 'intlayer-tags-list',\n {\n title: 'List Tags',\n description: 'List all tags for the selected organization.',\n inputSchema: {\n ...authSchema,\n page: z.number().optional().describe('Page number (1-based)'),\n pageSize: z.number().optional().describe('Items per page'),\n },\n annotations: { readOnlyHint: true },\n },\n async ({ clientId, clientSecret, page, pageSize }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.tag.getTags({ page, pageSize } as any);\n return ok(result);\n } catch (error) {\n return fail('List tags', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-tag-create',\n {\n title: 'Create Tag',\n description:\n 'Create a new tag in the organization. Tags can be used to group dictionaries and provide AI context.',\n inputSchema: {\n ...authSchema,\n key: z.string().describe('Unique tag key'),\n name: z.string().optional().describe('Display name for the tag'),\n description: z.string().optional().describe('Description of the tag'),\n color: z.string().optional().describe('Tag color (hex code)'),\n instructions: z.string().optional().describe('AI instructions to apply when this tag is used'),\n },\n annotations: { destructiveHint: false },\n },\n async ({ clientId, clientSecret, key, name, description, color, instructions }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.tag.addTag({ key, name, description, color, instructions } as any);\n return ok(result);\n } catch (error) {\n return fail('Create tag', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-tag-update',\n {\n title: 'Update Tag',\n description: 'Update an existing tag.',\n inputSchema: {\n ...authSchema,\n tagId: z.string().describe('Tag ID to update'),\n key: z.string().optional().describe('New key'),\n name: z.string().optional().describe('New display name'),\n description: z.string().optional().describe('New description'),\n color: z.string().optional().describe('New color (hex code)'),\n instructions: z.string().optional().describe('New AI instructions'),\n },\n annotations: { destructiveHint: true },\n },\n async ({ clientId, clientSecret, tagId, key, name, description, color, instructions }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.tag.updateTag(tagId, { key, name, description, color, instructions } as any);\n return ok(result);\n } catch (error) {\n return fail('Update tag', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-tag-delete',\n {\n title: 'Delete Tag',\n description: 'Delete a tag by its ID.',\n inputSchema: {\n ...authSchema,\n tagId: z.string().describe('Tag ID to delete'),\n },\n annotations: { destructiveHint: true },\n },\n async ({ clientId, clientSecret, tagId }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.tag.deleteTag(tagId);\n return ok(result);\n } catch (error) {\n return fail('Delete tag', error);\n }\n }\n );\n\n // ── Organizations ─────────────────────────────────────────────────────────\n\n server.registerTool(\n 'intlayer-organizations-list',\n {\n title: 'List Organizations',\n description: 'List all organizations the authenticated user belongs to.',\n inputSchema: {\n ...authSchema,\n page: z.number().optional().describe('Page number (1-based)'),\n pageSize: z.number().optional().describe('Items per page'),\n },\n annotations: { readOnlyHint: true },\n },\n async ({ clientId, clientSecret, page, pageSize }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.organization.getOrganizations({ page, pageSize } as any);\n return ok(result);\n } catch (error) {\n return fail('List organizations', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-organization-select',\n {\n title: 'Select Organization',\n description:\n 'Select an organization as the current active organization. Required before accessing organization-specific resources.',\n inputSchema: {\n ...authSchema,\n organizationId: z.string().describe('Organization ID to select'),\n },\n annotations: { destructiveHint: false },\n },\n async ({ clientId, clientSecret, organizationId }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.organization.selectOrganization(organizationId);\n return ok(result);\n } catch (error) {\n return fail('Select organization', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-organization-update',\n {\n title: 'Update Organization',\n description: 'Update the selected organization name or settings.',\n inputSchema: {\n ...authSchema,\n name: z.string().optional().describe('New organization name'),\n customInstructions: z.string().optional().describe('Custom AI instructions for this organization'),\n },\n annotations: { destructiveHint: true },\n },\n async ({ clientId, clientSecret, name, customInstructions }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.organization.updateOrganization({ name, customInstructions } as any);\n return ok(result);\n } catch (error) {\n return fail('Update organization', error);\n }\n }\n );\n\n // ── Projects ──────────────────────────────────────────────────────────────\n\n server.registerTool(\n 'intlayer-cms-projects-list',\n {\n title: 'List CMS Projects',\n description:\n 'List all Intlayer CMS projects for the selected organization. These are server-side projects, not local project directories.',\n inputSchema: {\n ...authSchema,\n page: z.number().optional().describe('Page number (1-based)'),\n pageSize: z.number().optional().describe('Items per page'),\n },\n annotations: { readOnlyHint: true },\n },\n async ({ clientId, clientSecret, page, pageSize }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.project.getProjects({ page, pageSize } as any);\n return ok(result);\n } catch (error) {\n return fail('List CMS projects', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-cms-project-select',\n {\n title: 'Select CMS Project',\n description:\n 'Select a CMS project as the current active project. Required before accessing project-specific dictionaries.',\n inputSchema: {\n ...authSchema,\n projectId: z.string().describe('Project ID to select'),\n },\n annotations: { destructiveHint: false },\n },\n async ({ clientId, clientSecret, projectId }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.project.selectProject(projectId);\n return ok(result);\n } catch (error) {\n return fail('Select CMS project', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-cms-project-create',\n {\n title: 'Create CMS Project',\n description: 'Create a new CMS project in the selected organization.',\n inputSchema: {\n ...authSchema,\n name: z.string().describe('Project name'),\n },\n annotations: { destructiveHint: false },\n },\n async ({ clientId, clientSecret, name }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.project.addProject({ name } as any);\n return ok(result);\n } catch (error) {\n return fail('Create CMS project', error);\n }\n }\n );\n\n server.registerTool(\n 'intlayer-cms-project-update',\n {\n title: 'Update CMS Project',\n description: 'Update the selected CMS project settings.',\n inputSchema: {\n ...authSchema,\n name: z.string().optional().describe('New project name'),\n },\n annotations: { destructiveHint: true },\n },\n async ({ clientId, clientSecret, name }) => {\n try {\n const api = await getAPI(clientId, clientSecret);\n const result = await api.project.updateProject({ name } as any);\n return ok(result);\n } catch (error) {\n return fail('Update CMS project', error);\n }\n }\n );\n};\n"],"m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AAU,cAAc,WAAW;EAC1C,IAAI;GAGF,OAAO,GAAG,OADW,MADH,OAAO,UAAU,aAAa,EACvB,QAAQ,WAAW,EAAE,MAAM,CAAQ,CAC3C;WACV,OAAO;GACd,OAAO,KAAK,sBAAsB,MAAM;;GAG7C;CAED,OAAO,aACL,+BACA;EACE,OAAO;EACP,aAAa;EACb,aAAa;GACX,GAAG;GACH,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,mBAAmB;GACzD;EACD,aAAa,EAAE,iBAAiB,MAAM;EACvC,EACD,OAAO,EAAE,UAAU,cAAc,WAAW;EAC1C,IAAI;GAGF,OAAO,GAAG,OADW,MADH,OAAO,UAAU,aAAa,EACvB,QAAQ,cAAc,EAAE,MAAM,CAAQ,CAC9C;WACV,OAAO;GACd,OAAO,KAAK,sBAAsB,MAAM;;GAG7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":[],"sources":["../../../src/tools/cli.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport { listProjects } from '@intlayer/chokidar/cli';\nimport {\n build,\n extract,\n fill,\n init,\n listContentDeclarationRows,\n listMissingTranslations,\n pull,\n push,\n} from '@intlayer/cli';\nimport { ALL_LOCALES } from '@intlayer/types/allLocales';\nimport type { LogConfig } from '@intlayer/types/config';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod';\n\ntype LoadCLITools = (server: McpServer) => Promise<void>;\n\nexport const loadCLITools: LoadCLITools = async (server) => {\n server.registerTool(\n 'intlayer-init',\n {\n title: 'Initialize Intlayer',\n description: 'Initialize Intlayer in the project',\n inputSchema: {\n projectRoot: z.string().describe('Project root directory'),\n },\n annotations: {\n destructiveHint: true,\n },\n },\n async ({ projectRoot }) => {\n try {\n await init(projectRoot);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Initialization 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: `Initialization failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-build',\n {\n title: 'Build Dictionaries',\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 annotations: {\n destructiveHint: true,\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 title: 'Fill Translations',\n description:\n 'Fill the dictionaries with missing translations / review translations using Intlayer servers',\n inputSchema: {\n sourceLocale: z\n .nativeEnum(ALL_LOCALES)\n .optional()\n .describe('Source locale'),\n outputLocales: z\n .union([\n z.nativeEnum(ALL_LOCALES),\n z.array(z.nativeEnum(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 annotations: {\n destructiveHint: true,\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 title: 'Push Dictionaries',\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 annotations: {\n destructiveHint: true,\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 title: 'Pull Dictionaries',\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 annotations: {\n destructiveHint: true,\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 title: 'List Content Declarations',\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 absolute: z\n .boolean()\n .optional()\n .describe(\n 'Output the results as absolute paths instead of relative paths'\n ),\n json: z\n .boolean()\n .optional()\n .describe('Output the results as JSON instead of formatted text'),\n },\n annotations: {\n readOnlyHint: true,\n },\n },\n async (props) => {\n try {\n const rows = listContentDeclarationRows(props);\n return {\n content: [\n {\n type: 'text',\n text: props.json\n ? JSON.stringify(rows)\n : 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 title: 'Test Translations',\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 annotations: {\n readOnlyHint: true,\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-extract',\n {\n title: 'Extract strings from Component',\n description:\n 'Extract strings from an existing component to be placed in a .content file close to the component. Trigger this action to make an existing component multilingual. If the component does not exist, create a normal component including text in JSX, and then trigger this tool to extract it.',\n inputSchema: {\n file: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('List of files to extract'),\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 annotations: {\n destructiveHint: true,\n },\n },\n async (props) => {\n try {\n await extract({\n files: Array.isArray(props.file)\n ? props.file\n : props.file\n ? [props.file]\n : undefined,\n configOptions: props.configOptions,\n });\n\n return {\n content: [\n {\n type: 'text',\n text: 'Extract 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: `Extract failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-projects-list',\n {\n title: 'List Projects',\n description:\n 'List all Intlayer projects in the directory. Search for configuration files to find all Intlayer projects.',\n inputSchema: {\n baseDir: z\n .string()\n .optional()\n .describe('Base directory to search from'),\n gitRoot: z\n .boolean()\n .optional()\n .describe(\n 'Search from the git root directory instead of the base directory'\n ),\n absolute: z\n .boolean()\n .optional()\n .describe(\n 'Output the results as absolute paths instead of relative paths'\n ),\n json: z\n .boolean()\n .optional()\n .describe('Output the results as JSON instead of formatted text'),\n },\n annotations: {\n readOnlyHint: true,\n },\n },\n async (props) => {\n try {\n const { searchDir, projectsPath } = await listProjects({\n baseDir: props.baseDir,\n gitRoot: props.gitRoot,\n });\n\n // Handle absolute option similar to CLI command\n const projectsRelativePath = projectsPath\n .map((projectPath) =>\n props.absolute ? projectPath : relative(searchDir, projectPath)\n )\n .map((projectPath) => (projectPath === '' ? '.' : projectPath));\n\n const outputPaths = props.absolute\n ? projectsPath\n : projectsRelativePath;\n\n return {\n content: [\n {\n type: 'text',\n text: props.json\n ? JSON.stringify(outputPaths)\n : JSON.stringify(\n { searchDir, projectsPath: outputPaths },\n null,\n 2\n ),\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: `Projects list failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n};\n"],"mappings":";;;;;;;AAmBA,MAAa,eAA6B,OAAO,WAAW;AAC1D,QAAO,aACL,iBACA;EACE,OAAO;EACP,aAAa;EACb,aAAa,EACX,aAAa,EAAE,QAAQ,CAAC,SAAS,yBAAyB,EAC3D;EACD,aAAa,EACX,iBAAiB,MAClB;EACF,EACD,OAAO,EAAE,kBAAkB;AACzB,MAAI;AACF,SAAM,KAAK,YAAY;AAEvB,UAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM;IACP,CACF,EACF;WACM,OAAO;AAGd,UAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,0BALV,iBAAiB,QAAQ,MAAM,UAAU;IAMtC,CACF,EACF;;GAGN;AAED,QAAO,aACL,kBACA;EACE,OAAO;EACP,aACE;EACF,aAAa;GACX,OAAO,EAAE,SAAS,CAAC,UAAU,CAAC,SAAS,oBAAoB;GAC3D,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,iBAAiB;GACzD,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,cAAc;GAClD,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,mBAAmB;GAC3D,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC,SAAS,iBAAiB;GAC1D,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,aAAa;GACrD;EACD,aAAa,EACX,iBAAiB,MAClB;EACF,EACD,OAAO,EAAE,OAAO,SAAS,KAAK,SAAS,SAAS,aAAa;AAC3D,MAAI;GACF,MAAM,MAA0B,EAAE;AAClC,OAAI,QACF,KAAI,OAAO;AAEb,OAAI,OACF,KAAI,SAAS;AAGf,SAAM,MAAM;IACV;IACA,eAAe;KACb;KACA;KACA;KACA,UAAU,EACR,KAC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M,KAAK,GACZ;IACN,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,mBALV,iBAAiB,QAAQ,MAAM,UAAU;IAMtC,CACF,EACF;;GAGN;AAED,QAAO,aACL,0BACA;EACE,OAAO;EACP,aACE;EACF,aAAa;GACX,SAAS,EACN,QAAQ,CACR,UAAU,CACV,SAAS,gCAAgC;GAC5C,SAAS,EACN,SAAS,CACT,UAAU,CACV,SACC,mEACD;GACH,UAAU,EACP,SAAS,CACT,UAAU,CACV,SACC,iEACD;GACH,MAAM,EACH,SAAS,CACT,UAAU,CACV,SAAS,uDAAuD;GACpE;EACD,aAAa,EACX,cAAc,MACf;EACF,EACD,OAAO,UAAU;AACf,MAAI;GACF,MAAM,EAAE,WAAW,iBAAiB,MAAM,aAAa;IACrD,SAAS,MAAM;IACf,SAAS,MAAM;IAChB,CAAC;GAGF,MAAM,uBAAuB,aAC1B,KAAK,gBACJ,MAAM,WAAW,cAAc,SAAS,WAAW,YAAY,CAChE,CACA,KAAK,gBAAiB,gBAAgB,KAAK,MAAM,YAAa;GAEjE,MAAM,cAAc,MAAM,WACtB,eACA;AAEJ,UAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,MAAM,OACR,KAAK,UAAU,YAAY,GAC3B,KAAK,UACH;KAAE;KAAW,cAAc;KAAa,EACxC,MACA,EACD;IACN,CACF,EACF;WACM,OAAO;AAGd,UAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,yBALV,iBAAiB,QAAQ,MAAM,UAAU;IAMtC,CACF,EACF;;GAGN"}
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":[],"sources":["../../../src/tools/cli.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport { listProjects } from '@intlayer/chokidar/cli';\nimport {\n build,\n extract,\n fill,\n init,\n listContentDeclarationRows,\n listMissingTranslations,\n pull,\n push,\n} from '@intlayer/cli';\nimport { ALL_LOCALES } from '@intlayer/types/allLocales';\nimport type { LogConfig } from '@intlayer/types/config';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod';\n\ntype LoadCLITools = (server: McpServer) => Promise<void>;\n\nexport const loadCLITools: LoadCLITools = async (server) => {\n server.registerTool(\n 'intlayer-init',\n {\n title: 'Initialize Intlayer',\n description: 'Initialize Intlayer in the project',\n inputSchema: {\n projectRoot: z.string().describe('Project root directory'),\n },\n annotations: {\n destructiveHint: true,\n },\n },\n async ({ projectRoot }) => {\n try {\n await init(projectRoot);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Initialization 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: `Initialization failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-build',\n {\n title: 'Build Dictionaries',\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 annotations: {\n destructiveHint: true,\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 title: 'Fill Translations',\n description:\n 'Fill the dictionaries with missing translations / review translations using Intlayer servers',\n inputSchema: {\n sourceLocale: z\n .nativeEnum(ALL_LOCALES)\n .optional()\n .describe('Source locale'),\n outputLocales: z\n .union([\n z.nativeEnum(ALL_LOCALES),\n z.array(z.nativeEnum(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 annotations: {\n destructiveHint: true,\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 title: 'Push Dictionaries',\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 annotations: {\n destructiveHint: true,\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 title: 'Pull Dictionaries',\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 annotations: {\n destructiveHint: true,\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 title: 'List Content Declarations',\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 absolute: z\n .boolean()\n .optional()\n .describe(\n 'Output the results as absolute paths instead of relative paths'\n ),\n json: z\n .boolean()\n .optional()\n .describe('Output the results as JSON instead of formatted text'),\n },\n annotations: {\n readOnlyHint: true,\n },\n },\n async (props) => {\n try {\n const rows = listContentDeclarationRows(props);\n return {\n content: [\n {\n type: 'text',\n text: props.json\n ? JSON.stringify(rows)\n : 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 title: 'Test Translations',\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 annotations: {\n readOnlyHint: true,\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-extract',\n {\n title: 'Extract strings from Component',\n description:\n 'Extract strings from an existing component to be placed in a .content file close to the component. Trigger this action to make an existing component multilingual. If the component does not exist, create a normal component including text in JSX, and then trigger this tool to extract it.',\n inputSchema: {\n file: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('List of files to extract'),\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 annotations: {\n destructiveHint: true,\n },\n },\n async (props) => {\n try {\n await extract({\n files: Array.isArray(props.file)\n ? props.file\n : props.file\n ? [props.file]\n : undefined,\n configOptions: props.configOptions,\n });\n\n return {\n content: [\n {\n type: 'text',\n text: 'Extract 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: `Extract failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.registerTool(\n 'intlayer-projects-list',\n {\n title: 'List Projects',\n description:\n 'List all Intlayer projects in the directory. Search for configuration files to find all Intlayer projects.',\n inputSchema: {\n baseDir: z\n .string()\n .optional()\n .describe('Base directory to search from'),\n gitRoot: z\n .boolean()\n .optional()\n .describe(\n 'Search from the git root directory instead of the base directory'\n ),\n absolute: z\n .boolean()\n .optional()\n .describe(\n 'Output the results as absolute paths instead of relative paths'\n ),\n json: z\n .boolean()\n .optional()\n .describe('Output the results as JSON instead of formatted text'),\n },\n annotations: {\n readOnlyHint: true,\n },\n },\n async (props) => {\n try {\n const { searchDir, projectsPath } = await listProjects({\n baseDir: props.baseDir,\n gitRoot: props.gitRoot,\n });\n\n // Handle absolute option similar to CLI command\n const projectsRelativePath = projectsPath\n .map((projectPath) =>\n props.absolute ? projectPath : relative(searchDir, projectPath)\n )\n .map((projectPath) => (projectPath === '' ? '.' : projectPath));\n\n const outputPaths = props.absolute\n ? projectsPath\n : projectsRelativePath;\n\n return {\n content: [\n {\n type: 'text',\n text: props.json\n ? JSON.stringify(outputPaths)\n : JSON.stringify(\n { searchDir, projectsPath: outputPaths },\n null,\n 2\n ),\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: `Projects list failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n};\n"],"mappings":";;;;;;;AAmBA,MAAa,eAA6B,OAAO,WAAW;CAC1D,OAAO,aACL,iBACA;EACE,OAAO;EACP,aAAa;EACb,aAAa,EACX,aAAa,EAAE,QAAQ,CAAC,SAAS,yBAAyB,EAC3D;EACD,aAAa,EACX,iBAAiB,MAClB;EACF,EACD,OAAO,EAAE,kBAAkB;EACzB,IAAI;GACF,MAAM,KAAK,YAAY;GAEvB,OAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM;IACP,CACF,EACF;WACM,OAAO;GAGd,OAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,0BALV,iBAAiB,QAAQ,MAAM,UAAU;IAMtC,CACF,EACF;;GAGN;CAED,OAAO,aACL,kBACA;EACE,OAAO;EACP,aACE;EACF,aAAa;GACX,OAAO,EAAE,SAAS,CAAC,UAAU,CAAC,SAAS,oBAAoB;GAC3D,SAAS,EAAE,Q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,CAChE,CACA,KAAK,gBAAiB,gBAAgB,KAAK,MAAM,YAAa;GAEjE,MAAM,cAAc,MAAM,WACtB,eACA;GAEJ,OAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,MAAM,OACR,KAAK,UAAU,YAAY,GAC3B,KAAK,UACH;KAAE;KAAW,cAAc;KAAa,EACxC,MACA,EACD;IACN,CACF,EACF;WACM,OAAO;GAGd,OAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,yBALV,iBAAiB,QAAQ,MAAM,UAAU;IAMtC,CACF,EACF;;GAGN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.mjs","names":[],"sources":["../../../src/tools/docs.ts"],"sourcesContent":["import { getSearchAPI } from '@intlayer/api';\nimport 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';\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 title: 'Get Doc List',\n description:\n 'Get the list of docs names and their metadata to get more details about what doc to retrieve',\n inputSchema: {},\n annotations: {\n readOnlyHint: true,\n },\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 title: 'Get Doc by Key',\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 annotations: {\n readOnlyHint: true,\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 title: 'Get Doc by Slug',\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 annotations: {\n readOnlyHint: true,\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 server.registerTool(\n 'fetch-doc-chunks',\n {\n title: 'Fetch Doc Chunks',\n description:\n 'Fetch related doc chunks using keywords or questions. This tool will return the most relevant chunks of documentation based on the input query.',\n inputSchema: {\n query: z.string().describe('The keywords or question to search for'),\n limit: z\n .number()\n .optional()\n .describe('The number of chunks to retrieve (default: 10)'),\n },\n annotations: {\n readOnlyHint: true,\n },\n },\n async ({ query, limit }) => {\n try {\n const { searchDoc } = getSearchAPI();\n const response = await searchDoc({\n input: query,\n limit: limit?.toString(),\n returnContent: 'true',\n });\n\n if (!response.data || !Array.isArray(response.data)) {\n return {\n content: [{ type: 'text', text: 'No relevant chunks found.' }],\n };\n }\n\n const chunks = response.data;\n\n return {\n content: chunks.map((chunk: any) => ({\n type: 'text',\n text: [\n `File: ${chunk.fileKey}`,\n `Title: ${chunk.docName}`,\n `URL: ${chunk.docUrl}`,\n `Chunk: ${chunk.chunkNumber}`,\n `Content:`,\n chunk.content,\n ].join('\\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: `Fetch doc chunks failed: ${errorMessage}` },\n ],\n };\n }\n }\n );\n};\n"],"mappings":";;;;;AAaA,MAAa,gBAA+B,OAAO,WAAW;CAC5D,MAAM,WAAW,aAAa;
|
|
1
|
+
{"version":3,"file":"docs.mjs","names":[],"sources":["../../../src/tools/docs.ts"],"sourcesContent":["import { getSearchAPI } from '@intlayer/api';\nimport 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';\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 title: 'Get Doc List',\n description:\n 'Get the list of docs names and their metadata to get more details about what doc to retrieve',\n inputSchema: {},\n annotations: {\n readOnlyHint: true,\n },\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 title: 'Get Doc by Key',\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 annotations: {\n readOnlyHint: true,\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 title: 'Get Doc by Slug',\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 annotations: {\n readOnlyHint: true,\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 server.registerTool(\n 'fetch-doc-chunks',\n {\n title: 'Fetch Doc Chunks',\n description:\n 'Fetch related doc chunks using keywords or questions. This tool will return the most relevant chunks of documentation based on the input query.',\n inputSchema: {\n query: z.string().describe('The keywords or question to search for'),\n limit: z\n .number()\n .optional()\n .describe('The number of chunks to retrieve (default: 10)'),\n },\n annotations: {\n readOnlyHint: true,\n },\n },\n async ({ query, limit }) => {\n try {\n const { searchDoc } = getSearchAPI();\n const response = await searchDoc({\n input: query,\n limit: limit?.toString(),\n returnContent: 'true',\n });\n\n if (!response.data || !Array.isArray(response.data)) {\n return {\n content: [{ type: 'text', text: 'No relevant chunks found.' }],\n };\n }\n\n const chunks = response.data;\n\n return {\n content: chunks.map((chunk: any) => ({\n type: 'text',\n text: [\n `File: ${chunk.fileKey}`,\n `Title: ${chunk.docName}`,\n `URL: ${chunk.docUrl}`,\n `Chunk: ${chunk.chunkNumber}`,\n `Content:`,\n chunk.content,\n ].join('\\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: `Fetch doc chunks failed: ${errorMessage}` },\n ],\n };\n }\n }\n );\n};\n"],"mappings":";;;;;AAaA,MAAa,gBAA+B,OAAO,WAAW;CAC5D,MAAM,WAAW,aAAa;CAE9B,OAAO,aACL,gBACA;EACE,OAAO;EACP,aACE;EACF,aAAa,EAAE;EACf,aAAa,EACX,cAAc,MACf;EACF,EACD,YAAY;EACV,IAAI;GACF,MAAM,qBAAqB,MAAM,sBAAsB;GAEvD,OAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,KAAK,UAAU,oBAAoB,MAAM,EAAE;IAClD,CACF,EACF;WACM,OAAO;GAGd,OAAO,EACL,SAAS,CACP;IAAE,MAAM;IAAQ,MAAM,wBAHxB,iBAAiB,QAAQ,MAAM,UAAU;IAGuB,CAC/D,EACF;;GAGN;CAED,OAAO,aACL,WACA;EACE,OAAO;EACP,aACE;EACF,aAAa,EACX,QAAQ,EAAE,KAAK,SAAkC,EAClD;EACD,aAAa,EACX,cAAc,MACf;EACF,EACD,OAAO,EAAE,aAAa;EACpB,IAAI;GAEF,OAAO,EACL,SAAS,CAAC;IAAE,MAAM;IAAQ,MAAM,MAFhB,OAAO,OAAiB;IAEH,CAAC,EACvC;WACM,OAAO;GAGd,OAAO,EACL,SAAS,CAAC;IAAE,MAAM;IAAQ,MAAM,mBAFhC,iBAAiB,QAAQ,MAAM,UAAU;IAE0B,CAAC,EACrE;;GAGN;CAED,OAAO,aACL,mBACA;EACE,OAAO;EACP,aACE;EACF,aAAa;GACX,MAAM,EACH,MAAM,CAAC,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE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CACnE,EACF;;GAGN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installSkills.mjs","names":[],"sources":["../../../src/tools/installSkills.ts"],"sourcesContent":["import * as readline from 'node:readline';\nimport {\n installSkills,\n PLATFORMS,\n SKILLS,\n type Skill,\n} from '@intlayer/chokidar/cli';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod';\n\nexport const loadInstallSkillsTool = (server: McpServer): void => {\n server.registerTool(\n 'intlayer-install-skills',\n {\n title: 'Install Intlayer Skills',\n description:\n 'Install Intlayer documentation and skills to the project to assist AI agents. Ask the user for the platform (Cursor, VSCode, OpenCode, Claude, etc.) and which skills they want to install before calling this tool.',\n inputSchema: {\n platform: z\n .enum(PLATFORMS)\n .describe('The platform to install skills for'),\n skills: z.array(z.enum(SKILLS)).describe('List of skills to install'),\n projectRoot: z\n .string()\n .optional()\n .describe(\n 'Root directory of the project. Defaults to current directory.'\n ),\n },\n },\n\n async ({ platform, skills, projectRoot }) => {\n try {\n const root = projectRoot || process.cwd();\n const message = await installSkills(root, platform, skills);\n\n return {\n content: [\n {\n type: 'text',\n text: message,\n },\n ],\n };\n } catch (error) {\n return {\n content: [\n {\n type: 'text',\n text: `Failed to install skills: ${error instanceof Error ? error.message : String(error)}`,\n },\n ],\n isError: true,\n };\n }\n }\n );\n};\n\nexport const runInstallSkillsCLI = async (): Promise<void> => {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n const question = (query: string): Promise<string> =>\n new Promise((resolve) => rl.question(query, resolve));\n\n try {\n console.log('Install Intlayer Skills');\n console.log('-----------------------');\n\n const platformInput = await question(\n 'Which platform are you using? (Cursor, Windsurf, Trae, OpenCode, GitHub, Claude, VSCode, Cline, RooCode, etc. or \"Other\"): '\n );\n\n // we only accept a single platform here, not an array like the main CLI\n const platform =\n PLATFORMS.find(\n (platform) =>\n platform.toLowerCase() === platformInput.trim().toLowerCase()\n ) || ('Other' as const);\n\n console.log(`Selected platform: ${platform}`);\n\n console.log('\\nAvailable skills:');\n\n SKILLS.forEach((skill, i) => {\n console.log(`${i + 1}. ${skill}`);\n });\n\n const skillsInput = await question(\n '\\nWhich skills do you want to install? (comma separated numbers, e.g. 1,2,3 or \"all\"): '\n );\n\n let selectedSkills: Skill[] = [];\n if (skillsInput.trim().toLowerCase() === 'all') {\n selectedSkills = [...SKILLS];\n } else {\n const indices = skillsInput\n .split(',')\n .map((skill) => parseInt(skill.trim(), 10) - 1)\n .filter(\n (skill) => !Number.isNaN(skill) && skill >= 0 && skill < SKILLS.length\n );\n selectedSkills = indices.map((i) => SKILLS[i] as any);\n }\n\n if (selectedSkills.length === 0) {\n console.log('No valid skills selected. Exiting.');\n rl.close();\n return;\n }\n\n console.log(`Installing skills: ${selectedSkills.join(', ')}...`);\n const result = await installSkills(process.cwd(), platform, selectedSkills);\n console.log(result);\n } catch (error) {\n console.error('Error:', error);\n } finally {\n rl.close();\n }\n};\n"],"mappings":";;;;;AAUA,MAAa,yBAAyB,WAA4B;
|
|
1
|
+
{"version":3,"file":"installSkills.mjs","names":[],"sources":["../../../src/tools/installSkills.ts"],"sourcesContent":["import * as readline from 'node:readline';\nimport {\n installSkills,\n PLATFORMS,\n SKILLS,\n type Skill,\n} from '@intlayer/chokidar/cli';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod';\n\nexport const loadInstallSkillsTool = (server: McpServer): void => {\n server.registerTool(\n 'intlayer-install-skills',\n {\n title: 'Install Intlayer Skills',\n description:\n 'Install Intlayer documentation and skills to the project to assist AI agents. Ask the user for the platform (Cursor, VSCode, OpenCode, Claude, etc.) and which skills they want to install before calling this tool.',\n inputSchema: {\n platform: z\n .enum(PLATFORMS)\n .describe('The platform to install skills for'),\n skills: z.array(z.enum(SKILLS)).describe('List of skills to install'),\n projectRoot: z\n .string()\n .optional()\n .describe(\n 'Root directory of the project. Defaults to current directory.'\n ),\n },\n },\n\n async ({ platform, skills, projectRoot }) => {\n try {\n const root = projectRoot || process.cwd();\n const message = await installSkills(root, platform, skills);\n\n return {\n content: [\n {\n type: 'text',\n text: message,\n },\n ],\n };\n } catch (error) {\n return {\n content: [\n {\n type: 'text',\n text: `Failed to install skills: ${error instanceof Error ? error.message : String(error)}`,\n },\n ],\n isError: true,\n };\n }\n }\n );\n};\n\nexport const runInstallSkillsCLI = async (): Promise<void> => {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n const question = (query: string): Promise<string> =>\n new Promise((resolve) => rl.question(query, resolve));\n\n try {\n console.log('Install Intlayer Skills');\n console.log('-----------------------');\n\n const platformInput = await question(\n 'Which platform are you using? (Cursor, Windsurf, Trae, OpenCode, GitHub, Claude, VSCode, Cline, RooCode, etc. or \"Other\"): '\n );\n\n // we only accept a single platform here, not an array like the main CLI\n const platform =\n PLATFORMS.find(\n (platform) =>\n platform.toLowerCase() === platformInput.trim().toLowerCase()\n ) || ('Other' as const);\n\n console.log(`Selected platform: ${platform}`);\n\n console.log('\\nAvailable skills:');\n\n SKILLS.forEach((skill, i) => {\n console.log(`${i + 1}. ${skill}`);\n });\n\n const skillsInput = await question(\n '\\nWhich skills do you want to install? (comma separated numbers, e.g. 1,2,3 or \"all\"): '\n );\n\n let selectedSkills: Skill[] = [];\n if (skillsInput.trim().toLowerCase() === 'all') {\n selectedSkills = [...SKILLS];\n } else {\n const indices = skillsInput\n .split(',')\n .map((skill) => parseInt(skill.trim(), 10) - 1)\n .filter(\n (skill) => !Number.isNaN(skill) && skill >= 0 && skill < SKILLS.length\n );\n selectedSkills = indices.map((i) => SKILLS[i] as any);\n }\n\n if (selectedSkills.length === 0) {\n console.log('No valid skills selected. Exiting.');\n rl.close();\n return;\n }\n\n console.log(`Installing skills: ${selectedSkills.join(', ')}...`);\n const result = await installSkills(process.cwd(), platform, selectedSkills);\n console.log(result);\n } catch (error) {\n console.error('Error:', error);\n } finally {\n rl.close();\n }\n};\n"],"mappings":";;;;;AAUA,MAAa,y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gB,YACb,MAAM,IAAI,CACV,KAAK,UAAU,SAAS,MAAM,MAAM,EAAE,GAAG,GAAG,EAAE,CAC9C,QACE,UAAU,CAAC,OAAO,MAAM,MAAM,IAAI,SAAS,KAAK,QAAQ,OAAO,OAE5C,CAAC,KAAK,MAAM,OAAO,GAAU;EAGvD,IAAI,eAAe,WAAW,GAAG;GAC/B,QAAQ,IAAI,qCAAqC;GACjD,GAAG,OAAO;GACV;;EAGF,QAAQ,IAAI,sBAAsB,eAAe,KAAK,KAAK,CAAC,KAAK;EACjE,MAAM,SAAS,MAAM,cAAc,QAAQ,KAAK,EAAE,UAAU,eAAe;EAC3E,QAAQ,IAAI,OAAO;UACZ,OAAO;EACd,QAAQ,MAAM,UAAU,MAAM;WACtB;EACR,GAAG,OAAO"}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
|
-
|
|
3
1
|
//#region src/client/client.d.ts
|
|
4
2
|
declare const dirname: string;
|
|
5
|
-
type LoadClient = () => Client;
|
|
6
|
-
declare const loadClient: LoadClient;
|
|
7
3
|
//#endregion
|
|
8
|
-
export { dirname
|
|
4
|
+
export { dirname };
|
|
9
5
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","names":[],"sources":["../../../src/client/client.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","names":[],"sources":["../../../src/client/client.ts"],"mappings":";cAIa,OAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
1
|
+
import { McpServer } from "/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js";
|
|
2
2
|
|
|
3
3
|
//#region src/server/server.d.ts
|
|
4
4
|
declare const dirname: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","names":[],"sources":["../../../src/server/server.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"server.d.ts","names":[],"sources":["../../../src/server/server.ts"],"mappings":";;;cAUa,OAAA;AAAA,KAQR,UAAA,IAAc,OAAA;EAAW,OAAA;AAAA,MAAuB,SAAA;AAAA,cAExC,UAAA,EAAY,UAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { McpServer } from "/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js";
|
|
2
|
+
|
|
3
|
+
//#region src/tools/api.d.ts
|
|
4
|
+
type LoadAPITools = (server: McpServer) => void;
|
|
5
|
+
declare const loadAPITools: LoadAPITools;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { loadAPITools };
|
|
8
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","names":[],"sources":["../../../src/tools/api.ts"],"mappings":";;;KAKK,YAAA,IAAgB,MAAA,EAAQ,SAAA;AAAA,cA6DhB,YAAA,EAAc,YAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
1
|
+
import { McpServer } from "/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js";
|
|
2
2
|
|
|
3
3
|
//#region src/tools/cli.d.ts
|
|
4
4
|
type LoadCLITools = (server: McpServer) => Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
1
|
+
import { McpServer } from "/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js";
|
|
2
2
|
|
|
3
3
|
//#region src/tools/docs.d.ts
|
|
4
4
|
type LoadDocsTools = (server: McpServer) => Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
1
|
+
import { McpServer } from "/Users/aymericpineau/Documents/intlayer_/node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js";
|
|
2
2
|
|
|
3
3
|
//#region src/tools/installSkills.d.ts
|
|
4
4
|
declare const loadInstallSkillsTool: (server: McpServer) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/mcp",
|
|
3
|
-
"version": "8.9.
|
|
3
|
+
"version": "8.9.4-canary.0",
|
|
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": [
|
|
@@ -93,27 +93,26 @@
|
|
|
93
93
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
94
94
|
},
|
|
95
95
|
"dependencies": {
|
|
96
|
-
"@
|
|
97
|
-
"@intlayer/
|
|
98
|
-
"@intlayer/
|
|
99
|
-
"@intlayer/
|
|
100
|
-
"@intlayer/
|
|
101
|
-
"@intlayer/
|
|
102
|
-
"@
|
|
96
|
+
"@ai-sdk/mcp": "^1.0.41",
|
|
97
|
+
"@intlayer/api": "8.9.4-canary.0",
|
|
98
|
+
"@intlayer/chokidar": "8.9.4-canary.0",
|
|
99
|
+
"@intlayer/cli": "8.9.4-canary.0",
|
|
100
|
+
"@intlayer/config": "8.9.4-canary.0",
|
|
101
|
+
"@intlayer/docs": "8.9.4-canary.0",
|
|
102
|
+
"@intlayer/types": "8.9.4-canary.0",
|
|
103
103
|
"dotenv": "17.4.2",
|
|
104
104
|
"express": "5.2.1",
|
|
105
105
|
"zod": "4.4.3"
|
|
106
106
|
},
|
|
107
107
|
"devDependencies": {
|
|
108
|
-
"@intlayer/types": "8.9.
|
|
109
|
-
"@modelcontextprotocol/inspector": "0.21.2",
|
|
108
|
+
"@intlayer/types": "8.9.4-canary.0",
|
|
110
109
|
"@types/express": "5.0.6",
|
|
111
|
-
"@types/node": "25.6.
|
|
110
|
+
"@types/node": "25.6.2",
|
|
112
111
|
"@utils/ts-config": "1.0.4",
|
|
113
112
|
"@utils/ts-config-types": "1.0.4",
|
|
114
113
|
"@utils/tsdown-config": "1.0.4",
|
|
115
114
|
"rimraf": "6.1.3",
|
|
116
|
-
"tsdown": "0.
|
|
115
|
+
"tsdown": "0.22.00",
|
|
117
116
|
"typescript": "6.0.3",
|
|
118
117
|
"vitest": "4.1.5"
|
|
119
118
|
},
|