@alternative-path/x-mcp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +364 -0
  3. package/dist/agents/test-planner-context.d.ts +7 -0
  4. package/dist/agents/test-planner-context.d.ts.map +1 -0
  5. package/dist/agents/test-planner-context.js +283 -0
  6. package/dist/agents/test-planner-context.js.map +1 -0
  7. package/dist/agents/test-planner-prompt.d.ts +34 -0
  8. package/dist/agents/test-planner-prompt.d.ts.map +1 -0
  9. package/dist/agents/test-planner-prompt.js +82 -0
  10. package/dist/agents/test-planner-prompt.js.map +1 -0
  11. package/dist/api-client.d.ts +52 -0
  12. package/dist/api-client.d.ts.map +1 -0
  13. package/dist/api-client.js +240 -0
  14. package/dist/api-client.js.map +1 -0
  15. package/dist/index.d.ts +3 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +159 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/tools/auth-tools.d.ts +17 -0
  20. package/dist/tools/auth-tools.d.ts.map +1 -0
  21. package/dist/tools/auth-tools.js +154 -0
  22. package/dist/tools/auth-tools.js.map +1 -0
  23. package/dist/tools/automation-tools.d.ts +25 -0
  24. package/dist/tools/automation-tools.d.ts.map +1 -0
  25. package/dist/tools/automation-tools.js +399 -0
  26. package/dist/tools/automation-tools.js.map +1 -0
  27. package/dist/tools/export-import-tools.d.ts +16 -0
  28. package/dist/tools/export-import-tools.d.ts.map +1 -0
  29. package/dist/tools/export-import-tools.js +62 -0
  30. package/dist/tools/export-import-tools.js.map +1 -0
  31. package/dist/tools/module-tools.d.ts +42 -0
  32. package/dist/tools/module-tools.d.ts.map +1 -0
  33. package/dist/tools/module-tools.js +302 -0
  34. package/dist/tools/module-tools.js.map +1 -0
  35. package/dist/tools/project-tools.d.ts +44 -0
  36. package/dist/tools/project-tools.d.ts.map +1 -0
  37. package/dist/tools/project-tools.js +67 -0
  38. package/dist/tools/project-tools.js.map +1 -0
  39. package/dist/tools/testcase-tools.d.ts +129 -0
  40. package/dist/tools/testcase-tools.d.ts.map +1 -0
  41. package/dist/tools/testcase-tools.js +762 -0
  42. package/dist/tools/testcase-tools.js.map +1 -0
  43. package/dist/tools/testgroup-launch-tools.d.ts +28 -0
  44. package/dist/tools/testgroup-launch-tools.d.ts.map +1 -0
  45. package/dist/tools/testgroup-launch-tools.js +332 -0
  46. package/dist/tools/testgroup-launch-tools.js.map +1 -0
  47. package/package.json +56 -0
@@ -0,0 +1,240 @@
1
+ import axios from "axios";
2
+ import { CookieJar } from "tough-cookie";
3
+ import { wrapper } from "axios-cookiejar-support";
4
+ export class ApiClient {
5
+ client;
6
+ loginClient; // Separate client for login to bypass interceptor
7
+ projectId;
8
+ cookieJar;
9
+ isAuthenticated = false;
10
+ userId; // Store user ID after login
11
+ constructor(baseUrl, apiKey, sessionToken, projectId) {
12
+ this.projectId = projectId;
13
+ this.cookieJar = new CookieJar();
14
+ // Use API root for all requests so paths like /project/getProjects resolve to /api/project/getProjects.
15
+ // If baseUrl is the auth path (e.g. .../api/auth), normalize to .../api.
16
+ const baseURL = baseUrl.replace(/\/auth\/?$/, "") || baseUrl;
17
+ // Build cookie string - support both token and session cookies
18
+ let cookieString = "";
19
+ if (sessionToken) {
20
+ cookieString = `token=${sessionToken}`;
21
+ }
22
+ // Create axios instance with cookie jar support
23
+ const baseAxiosConfig = {
24
+ baseURL,
25
+ timeout: 30000,
26
+ jar: this.cookieJar,
27
+ headers: {
28
+ "Content-Type": "application/json",
29
+ ...(apiKey && { "X-API-Key": apiKey }),
30
+ ...(cookieString && { Cookie: cookieString }),
31
+ ...(projectId && { "x-project-id": projectId }),
32
+ },
33
+ withCredentials: true, // Important for session-based auth
34
+ };
35
+ this.client = wrapper(axios.create(baseAxiosConfig));
36
+ // Create a separate client for login that doesn't have the error interceptor
37
+ // Login returns 403 for invalid credentials, which the interceptor would convert to "Permission denied"
38
+ this.loginClient = wrapper(axios.create(baseAxiosConfig));
39
+ // Helper function to get XSRF-TOKEN from cookie jar
40
+ const getXSRFToken = async (requestUrl) => {
41
+ try {
42
+ // Try multiple URL formats to find the cookie
43
+ const urlsToTry = [];
44
+ if (requestUrl) {
45
+ urlsToTry.push(requestUrl);
46
+ }
47
+ // Add base URL variations
48
+ urlsToTry.push(baseURL);
49
+ urlsToTry.push(baseUrl);
50
+ // Try protocol + host only
51
+ try {
52
+ const urlObj = new URL(baseURL);
53
+ urlsToTry.push(`${urlObj.protocol}//${urlObj.host}`);
54
+ urlsToTry.push(`${urlObj.protocol}//${urlObj.host}/`);
55
+ }
56
+ catch (e) {
57
+ // Ignore URL parsing errors
58
+ }
59
+ // Try each URL until we find the cookie
60
+ for (const url of urlsToTry) {
61
+ try {
62
+ const cookies = await this.cookieJar.getCookies(url);
63
+ const xsrfCookie = cookies.find((cookie) => cookie.key.toLowerCase() === "xsrf-token");
64
+ if (xsrfCookie) {
65
+ return xsrfCookie.value;
66
+ }
67
+ }
68
+ catch (e) {
69
+ // Continue to next URL
70
+ continue;
71
+ }
72
+ }
73
+ return undefined;
74
+ }
75
+ catch (error) {
76
+ return undefined;
77
+ }
78
+ };
79
+ // Request interceptor to add XSRF-TOKEN header and handle project ID
80
+ const requestInterceptor = async (config) => {
81
+ // Ensure headers object exists
82
+ if (!config.headers) {
83
+ config.headers = {};
84
+ }
85
+ // Add XSRF-TOKEN header if available in cookie jar
86
+ // Always check for XSRF-TOKEN cookie and add it to headers
87
+ const requestUrl = config.url ? `${config.baseURL || baseUrl}${config.url}` : baseUrl;
88
+ const xsrfToken = await getXSRFToken(requestUrl);
89
+ if (xsrfToken) {
90
+ config.headers["x-csrf-token"] = xsrfToken;
91
+ }
92
+ // Check if x-project-id was explicitly set to null/undefined to remove it
93
+ if (config.headers["x-project-id"] === null || config.headers["x-project-id"] === undefined) {
94
+ delete config.headers["x-project-id"];
95
+ }
96
+ else if (this.projectId && !config.headers["x-project-id"]) {
97
+ // Only add project ID if it's not already set and projectId is configured
98
+ config.headers["x-project-id"] = this.projectId;
99
+ }
100
+ return config;
101
+ };
102
+ // Add request interceptor to both clients
103
+ this.client.interceptors.request.use(requestInterceptor);
104
+ this.loginClient.interceptors.request.use(requestInterceptor);
105
+ // Add response interceptor for error handling
106
+ this.client.interceptors.response.use((response) => response, (error) => {
107
+ if (error.response) {
108
+ const status = error.response.status;
109
+ const data = error.response.data;
110
+ if (status === 401) {
111
+ throw new Error("Authentication failed. Please check your API credentials or session token.");
112
+ }
113
+ if (status === 403) {
114
+ throw new Error(`Permission denied: ${data?.message || "You don't have permission to perform this action"}`);
115
+ }
116
+ if (status === 404) {
117
+ throw new Error(`Resource not found: ${data?.message || "The requested resource does not exist"}`);
118
+ }
119
+ if (status >= 500) {
120
+ throw new Error(`Server error: ${data?.error || data?.message || "An internal server error occurred"}`);
121
+ }
122
+ throw new Error(data?.error || data?.message || `Request failed with status ${status}`);
123
+ }
124
+ if (error.request) {
125
+ throw new Error("Network error: Unable to connect to the API server. Please check your X_MCP_API_URL.");
126
+ }
127
+ throw error;
128
+ });
129
+ }
130
+ setProjectId(projectId) {
131
+ this.projectId = projectId;
132
+ this.client.defaults.headers["x-project-id"] = projectId;
133
+ }
134
+ setSessionToken(token) {
135
+ this.client.defaults.headers.Authorization = `Bearer ${token}`;
136
+ }
137
+ async login(email, password) {
138
+ try {
139
+ // Fetch CSRF token first: GET a same-origin URL so the server sets XSRF-TOKEN cookie
140
+ const baseURL = this.loginClient.defaults.baseURL;
141
+ const origin = new URL(baseURL).origin;
142
+ await this.loginClient.get(`${origin}/api/healthcheck`);
143
+ // Use loginClient which doesn't have the error interceptor
144
+ // This allows us to handle 403 errors properly (login returns 403 for invalid credentials)
145
+ // baseURL is API root (.../api), so POST to "auth/login" gives .../api/auth/login
146
+ const response = await this.loginClient.post("auth/login", { email, password });
147
+ // Cookies are automatically stored in the jar by axios-cookiejar-support
148
+ this.isAuthenticated = true;
149
+ this.userId = response.data.data.user.id; // Store user ID for use in updates
150
+ return response.data;
151
+ }
152
+ catch (error) {
153
+ this.isAuthenticated = false;
154
+ // Check if this is an Axios error with response data
155
+ if (error.response) {
156
+ const status = error.response.status;
157
+ const data = error.response.data;
158
+ // Login endpoint returns 403 for invalid credentials (not 401)
159
+ if (status === 403 || status === 401) {
160
+ throw new Error(data?.error || data?.message || "Invalid email or password. Please check your credentials.");
161
+ }
162
+ throw new Error(data?.error || data?.message || `Login failed with status ${status}`);
163
+ }
164
+ throw error;
165
+ }
166
+ }
167
+ getIsAuthenticated() {
168
+ return this.isAuthenticated;
169
+ }
170
+ /**
171
+ * Get cookie header string for a given URL (and optionally the API base URL).
172
+ * Used to forward session cookies to the automation agent WebSocket.
173
+ */
174
+ async getCookieStringForUrl(url) {
175
+ const urlsToTry = [url];
176
+ const baseUrl = this.client.defaults.baseURL;
177
+ if (baseUrl && !urlsToTry.includes(baseUrl)) {
178
+ urlsToTry.push(baseUrl);
179
+ try {
180
+ const u = new URL(baseUrl);
181
+ urlsToTry.push(`${u.protocol}//${u.host}`);
182
+ }
183
+ catch (_) { }
184
+ }
185
+ const seen = new Set();
186
+ const parts = [];
187
+ for (const u of urlsToTry) {
188
+ try {
189
+ const cookies = await this.cookieJar.getCookies(u);
190
+ if (Array.isArray(cookies)) {
191
+ for (const c of cookies) {
192
+ if (c && typeof c.key === "string" && !seen.has(c.key)) {
193
+ seen.add(c.key);
194
+ parts.push(`${c.key}=${c.value || ""}`);
195
+ }
196
+ }
197
+ }
198
+ }
199
+ catch (_) {
200
+ continue;
201
+ }
202
+ }
203
+ return parts.join("; ");
204
+ }
205
+ getUserId() {
206
+ return this.userId;
207
+ }
208
+ async get(url, config) {
209
+ const response = await this.client.get(url, config);
210
+ return response.data;
211
+ }
212
+ async post(url, data, config) {
213
+ const response = await this.client.post(url, data, config);
214
+ return response.data;
215
+ }
216
+ async put(url, data, config) {
217
+ const response = await this.client.put(url, data, config);
218
+ return response.data;
219
+ }
220
+ async patch(url, data, config) {
221
+ const response = await this.client.patch(url, data, config);
222
+ return response.data;
223
+ }
224
+ async delete(url, config) {
225
+ const response = await this.client.delete(url, config);
226
+ return response.data;
227
+ }
228
+ // Helper for file uploads
229
+ async postFormData(url, formData, config) {
230
+ const response = await this.client.post(url, formData, {
231
+ ...config,
232
+ headers: {
233
+ ...config?.headers,
234
+ "Content-Type": "multipart/form-data",
235
+ },
236
+ });
237
+ return response.data;
238
+ }
239
+ }
240
+ //# sourceMappingURL=api-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-client.js","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AA8BlD,MAAM,OAAO,SAAS;IACZ,MAAM,CAAgB;IACtB,WAAW,CAAgB,CAAC,kDAAkD;IAC9E,SAAS,CAAU;IACnB,SAAS,CAAY;IACrB,eAAe,GAAY,KAAK,CAAC;IACjC,MAAM,CAAU,CAAC,4BAA4B;IAErD,YACE,OAAe,EACf,MAAe,EACf,YAAqB,EACrB,SAAkB;QAElB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;QAEjC,wGAAwG;QACxG,yEAAyE;QACzE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC;QAE7D,+DAA+D;QAC/D,IAAI,YAAY,GAAG,EAAE,CAAC;QACtB,IAAI,YAAY,EAAE,CAAC;YACjB,YAAY,GAAG,SAAS,YAAY,EAAE,CAAC;QACzC,CAAC;QAED,gDAAgD;QAChD,MAAM,eAAe,GAAG;YACtB,OAAO;YACP,OAAO,EAAE,KAAK;YACd,GAAG,EAAE,IAAI,CAAC,SAAS;YACnB,OAAO,EAAE;gBACP,cAAc,E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AAC;IACvB,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,159 @@
1
+ #!/usr/bin/env node
2
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
5
+ import { ApiClient } from "./api-client.js";
6
+ import { getTestPlannerPromptDefinition, getTestPlannerMessages, X_TEST_PLANNER_NAME, } from "./agents/test-planner-prompt.js";
7
+ import { ModuleTools } from "./tools/module-tools.js";
8
+ import { TestCaseTools } from "./tools/testcase-tools.js";
9
+ import { ExportImportTools } from "./tools/export-import-tools.js";
10
+ import { ProjectTools } from "./tools/project-tools.js";
11
+ import { AuthTools } from "./tools/auth-tools.js";
12
+ import { AutomationTools } from "./tools/automation-tools.js";
13
+ import { TestGroupLaunchTools } from "./tools/testgroup-launch-tools.js";
14
+ class XMCPServer {
15
+ server;
16
+ apiClient;
17
+ moduleTools;
18
+ testCaseTools;
19
+ exportImportTools;
20
+ projectTools;
21
+ authTools;
22
+ automationTools;
23
+ testGroupLaunchTools;
24
+ constructor() {
25
+ this.server = new Server({
26
+ name: "x-mcp",
27
+ version: "1.0.0",
28
+ }, {
29
+ capabilities: {
30
+ tools: {},
31
+ resources: {},
32
+ prompts: {},
33
+ },
34
+ });
35
+ // Initialize API client
36
+ const apiBaseUrl = process.env.X_MCP_API_URL || "http://localhost:3000/api";
37
+ const apiKey = process.env.X_MCP_API_KEY;
38
+ const sessionToken = process.env.X_MCP_SESSION_TOKEN;
39
+ const projectId = process.env.X_MCP_PROJECT_ID;
40
+ const email = process.env.X_MCP_EMAIL;
41
+ const password = process.env.X_MCP_PASSWORD;
42
+ if (!apiBaseUrl) {
43
+ throw new Error("X_MCP_API_URL environment variable is required");
44
+ }
45
+ this.apiClient = new ApiClient(apiBaseUrl, apiKey, sessionToken, projectId);
46
+ this.moduleTools = new ModuleTools(this.apiClient);
47
+ this.testCaseTools = new TestCaseTools(this.apiClient);
48
+ this.exportImportTools = new ExportImportTools(this.apiClient);
49
+ this.projectTools = new ProjectTools(this.apiClient);
50
+ this.authTools = new AuthTools(this.apiClient);
51
+ this.automationTools = new AutomationTools(this.apiClient);
52
+ this.testGroupLaunchTools = new TestGroupLaunchTools(this.apiClient);
53
+ // Auto-login if credentials are provided
54
+ if (email && password) {
55
+ this.autoLogin(email, password).catch((error) => {
56
+ console.error("Auto-login failed:", error.message);
57
+ });
58
+ }
59
+ this.setupHandlers();
60
+ }
61
+ setupHandlers() {
62
+ // List available tools
63
+ this.server.setRequestHandler(ListToolsRequestSchema, async () => {
64
+ return {
65
+ tools: [
66
+ ...this.authTools.getTools(),
67
+ ...this.moduleTools.getTools(),
68
+ ...this.testCaseTools.getTools(),
69
+ ...this.exportImportTools.getTools(),
70
+ ...this.projectTools.getTools(),
71
+ ...this.automationTools.getTools(),
72
+ ...this.testGroupLaunchTools.getTools(),
73
+ ],
74
+ };
75
+ });
76
+ // Handle tool calls
77
+ this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
78
+ const { name, arguments: args } = request.params;
79
+ try {
80
+ // Route to appropriate tool handler
81
+ if (this.authTools.handles(name)) {
82
+ return await this.authTools.handle(name, args);
83
+ }
84
+ if (this.moduleTools.handles(name)) {
85
+ return await this.moduleTools.handle(name, args);
86
+ }
87
+ if (this.testCaseTools.handles(name)) {
88
+ return await this.testCaseTools.handle(name, args);
89
+ }
90
+ if (this.exportImportTools.handles(name)) {
91
+ return await this.exportImportTools.handle(name, args);
92
+ }
93
+ if (this.projectTools.handles(name)) {
94
+ return await this.projectTools.handle(name, args);
95
+ }
96
+ if (this.automationTools.handles(name)) {
97
+ return await this.automationTools.handle(name, args);
98
+ }
99
+ if (this.testGroupLaunchTools.handles(name)) {
100
+ return await this.testGroupLaunchTools.handle(name, args);
101
+ }
102
+ throw new Error(`Unknown tool: ${name}`);
103
+ }
104
+ catch (error) {
105
+ return {
106
+ content: [
107
+ {
108
+ type: "text",
109
+ text: `Error: ${error.message || String(error)}`,
110
+ },
111
+ ],
112
+ isError: true,
113
+ };
114
+ }
115
+ });
116
+ // List resources (optional - for future use)
117
+ this.server.setRequestHandler(ListResourcesRequestSchema, async () => {
118
+ return {
119
+ resources: [],
120
+ };
121
+ });
122
+ // List prompts (x-test-planner agent)
123
+ this.server.setRequestHandler(ListPromptsRequestSchema, async () => {
124
+ return {
125
+ prompts: [getTestPlannerPromptDefinition()],
126
+ };
127
+ });
128
+ // Get prompt (x-test-planner agent)
129
+ this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {
130
+ const { name, arguments: args } = request.params;
131
+ if (name !== X_TEST_PLANNER_NAME) {
132
+ throw new Error(`Unknown prompt: ${name}`);
133
+ }
134
+ return getTestPlannerMessages(args);
135
+ });
136
+ }
137
+ async autoLogin(email, password) {
138
+ try {
139
+ await this.apiClient.login(email, password);
140
+ console.error("X-MCP: Auto-login successful");
141
+ }
142
+ catch (error) {
143
+ console.error("X-MCP: Auto-login failed:", error.message);
144
+ throw error;
145
+ }
146
+ }
147
+ async run() {
148
+ const transport = new StdioServerTransport();
149
+ await this.server.connect(transport);
150
+ console.error("X-MCP server running on stdio");
151
+ }
152
+ }
153
+ // Start the server
154
+ const server = new XMCPServer();
155
+ server.run().catch((error) => {
156
+ console.error("Fatal error in X-MCP server:", error);
157
+ process.exit(1);
158
+ });
159
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE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AACnB,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;AAChC,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAC3B,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;IACrD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Tool } from "@modelcontextprotocol/sdk/types.js";
2
+ import { ApiClient } from "../api-client.js";
3
+ export declare class AuthTools {
4
+ private apiClient;
5
+ constructor(apiClient: ApiClient);
6
+ getTools(): Tool[];
7
+ handles(name: string): boolean;
8
+ handle(name: string, args: any): Promise<{
9
+ content: {
10
+ type: string;
11
+ text: string;
12
+ }[];
13
+ }>;
14
+ private login;
15
+ private checkAuthStatus;
16
+ }
17
+ //# sourceMappingURL=auth-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-tools.d.ts","sourceRoot":"","sources":["../../src/tools/auth-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAiB,MAAM,kBAAkB,CAAC;AAE5D,qBAAa,SAAS;IACR,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAExC,QAAQ,IAAI,IAAI,EAAE;IAiClB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIxB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG;;;;;;YAWtB,KAAK;YA0DL,eAAe;CAqF9B"}
@@ -0,0 +1,154 @@
1
+ export class AuthTools {
2
+ apiClient;
3
+ constructor(apiClient) {
4
+ this.apiClient = apiClient;
5
+ }
6
+ getTools() {
7
+ return [
8
+ {
9
+ name: "login",
10
+ description: "Login to the Product-X system using email and password. This creates a session that will be used for all subsequent API requests.",
11
+ inputSchema: {
12
+ type: "object",
13
+ properties: {
14
+ email: {
15
+ type: "string",
16
+ description: "Email address for login",
17
+ },
18
+ password: {
19
+ type: "string",
20
+ description: "Password for login",
21
+ },
22
+ },
23
+ required: ["email", "password"],
24
+ },
25
+ },
26
+ {
27
+ name: "check_auth_status",
28
+ description: "Check if the MCP server is currently authenticated with the API. When authenticated, returns the logged-in user (id, username, user_email).",
29
+ inputSchema: {
30
+ type: "object",
31
+ properties: {},
32
+ },
33
+ },
34
+ ];
35
+ }
36
+ handles(name) {
37
+ return ["login", "check_auth_status"].includes(name);
38
+ }
39
+ async handle(name, args) {
40
+ switch (name) {
41
+ case "login":
42
+ return await this.login(args);
43
+ case "check_auth_status":
44
+ return await this.checkAuthStatus(args);
45
+ default:
46
+ throw new Error(`Unknown auth tool: ${name}`);
47
+ }
48
+ }
49
+ async login(args) {
50
+ const { email, password } = args;
51
+ if (!email || !password) {
52
+ throw new Error("Email and password are required");
53
+ }
54
+ try {
55
+ const response = await this.apiClient.login(email, password);
56
+ return {
57
+ content: [
58
+ {
59
+ type: "text",
60
+ text: JSON.stringify({
61
+ success: response.success,
62
+ message: response.message,
63
+ data: {
64
+ user: {
65
+ id: response.data.user.id,
66
+ username: response.data.user.username,
67
+ user_email: response.data.user.user_email,
68
+ roles: response.data.user.roles,
69
+ permissions: response.data.user.permissions,
70
+ project_roles_permissions: response.data.user.project_roles_permissions,
71
+ token: response.data.user.token,
72
+ org_id: response.data.user.org_id,
73
+ authority_level: response.data.user.authority_level,
74
+ },
75
+ },
76
+ }, null, 2),
77
+ },
78
+ ],
79
+ };
80
+ }
81
+ catch (error) {
82
+ return {
83
+ content: [
84
+ {
85
+ type: "text",
86
+ text: JSON.stringify({
87
+ success: false,
88
+ error: error.message || "Login failed",
89
+ }, null, 2),
90
+ },
91
+ ],
92
+ isError: true,
93
+ };
94
+ }
95
+ }
96
+ async checkAuthStatus(args) {
97
+ const isAuthenticated = this.apiClient.getIsAuthenticated();
98
+ if (!isAuthenticated) {
99
+ return {
100
+ content: [
101
+ {
102
+ type: "text",
103
+ text: JSON.stringify({
104
+ authenticated: false,
105
+ message: "MCP server is not authenticated. Please use the login tool to authenticate.",
106
+ }, null, 2),
107
+ },
108
+ ],
109
+ };
110
+ }
111
+ try {
112
+ const response = await this.apiClient.get("auth/getCurrentLoggedInUser");
113
+ const user = response.data?.user;
114
+ const roles = user?.roles;
115
+ const roleNames = Array.isArray(roles)
116
+ ? roles.map((r) => (typeof r === "string" ? r : r.name ?? String(r)))
117
+ : undefined;
118
+ return {
119
+ content: [
120
+ {
121
+ type: "text",
122
+ text: JSON.stringify({
123
+ authenticated: true,
124
+ message: "MCP server is authenticated",
125
+ user: user
126
+ ? {
127
+ id: user.id,
128
+ username: user.username,
129
+ user_email: user.user_email,
130
+ roles: roleNames ?? user.roles,
131
+ }
132
+ : undefined,
133
+ }, null, 2),
134
+ },
135
+ ],
136
+ };
137
+ }
138
+ catch (error) {
139
+ return {
140
+ content: [
141
+ {
142
+ type: "text",
143
+ text: JSON.stringify({
144
+ authenticated: false,
145
+ message: "Session may have expired or could not retrieve user. Please use the login tool to authenticate.",
146
+ error: error?.message || String(error),
147
+ }, null, 2),
148
+ },
149
+ ],
150
+ };
151
+ }
152
+ }
153
+ }
154
+ //# sourceMappingURL=auth-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-tools.js","sourceRoot":"","sources":["../../src/tools/auth-tools.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,SAAS;IACA;IAApB,YAAoB,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAE5C,QAAQ;QACN,OAAO;YACL;gBACE,IAAI,EAAE,OAAO;gBACb,WAAW,EACT,mIAAmI;gBACrI,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,KAAK,EAAE;4BACL,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,yBAAyB;yBACvC;wBACD,QAAQ,EAAE;4BACR,IAAI,E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CAAC,SAAS,CAClB;4BACE,aAAa,EAAE,KAAK;4BACpB,OAAO,EACL,iGAAiG;4BACnG,KAAK,EAAE,KAAK,EAAE,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC;yBACvC,EACD,IAAI,EACJ,CAAC,CACF;qBACF;iBACF;aACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,25 @@
1
+ import { Tool } from "@modelcontextprotocol/sdk/types.js";
2
+ import { ApiClient } from "../api-client.js";
3
+ export declare class AutomationTools {
4
+ private apiClient;
5
+ constructor(apiClient: ApiClient);
6
+ getTools(): Tool[];
7
+ handles(name: string): boolean;
8
+ handle(name: string, args: any): Promise<{
9
+ content: {
10
+ type: "text";
11
+ text: string;
12
+ }[];
13
+ }>;
14
+ private fetchModels;
15
+ private getCurrentUserId;
16
+ private formatInstructions;
17
+ private runExecutionOverWebSocket;
18
+ private generateNlpScript;
19
+ private formatToolOutput;
20
+ private parseExecutionTime;
21
+ private parseStatus;
22
+ private formattedResponse;
23
+ private jsonResponse;
24
+ }
25
+ //# sourceMappingURL=automation-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automation-tools.d.ts","sourceRoot":"","sources":["../../src/tools/automation-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAc7C,qBAAa,eAAe;IACd,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAExC,QAAQ,IAAI,IAAI,EAAE;IAyClB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIxB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG;;;;;;YAOtB,WAAW;YAWX,gBAAgB;IAY9B,OAAO,CAAC,kBAAkB;YAQZ,yBAAyB;YAsJzB,iBAAiB;IAqI/B,OAAO,CAAC,gBAAgB;IAuDxB,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,YAAY;CAGrB"}