@testomatio/mcp 1.0.5 → 1.0.7

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 (2) hide show
  1. package/index.js +40 -7
  2. package/package.json +5 -2
package/index.js CHANGED
@@ -7,10 +7,31 @@ import {
7
7
  ListToolsRequestSchema,
8
8
  } from '@modelcontextprotocol/sdk/types.js';
9
9
  import { program } from 'commander';
10
+ import { fileURLToPath } from 'url';
11
+
12
+ function normalizeString(value) {
13
+ return typeof value === 'string' ? value.trim() : value;
14
+ }
15
+
16
+ function normalizeBaseUrl(value) {
17
+ if (typeof value !== 'string') {
18
+ return value;
19
+ }
20
+
21
+ const trimmed = value.trim();
22
+ // Remove any internal whitespace characters that may appear when the URL
23
+ // gets broken across lines (e.g. "http://\n localhost:3000").
24
+ return trimmed.replace(/\s+/g, '');
25
+ }
10
26
 
11
27
  class TestomatioMCPServer {
12
28
  constructor(config) {
13
- this.config = config;
29
+ this.config = {
30
+ ...config,
31
+ token: normalizeString(config.token),
32
+ projectId: normalizeString(config.projectId),
33
+ baseUrl: normalizeBaseUrl(config.baseUrl),
34
+ };
14
35
  this.jwtToken = null;
15
36
  this.server = new Server(
16
37
  {
@@ -1285,9 +1306,13 @@ function parseArgs() {
1285
1306
 
1286
1307
  const options = program.opts();
1287
1308
 
1288
- const token = options.token || process.env.TESTOMATIO_API_TOKEN;
1289
- const projectId = options.project || process.env.TESTOMATIO_PROJECT_ID;
1290
- const baseUrl = options.baseUrl || process.env.TESTOMATIO_BASE_URL || 'https://app.testomat.io';
1309
+ const token = normalizeString(options.token || process.env.TESTOMATIO_API_TOKEN);
1310
+ const projectId = normalizeString(options.project || process.env.TESTOMATIO_PROJECT_ID);
1311
+ const baseUrl = normalizeBaseUrl(
1312
+ options.baseUrl ||
1313
+ process.env.TESTOMATIO_BASE_URL ||
1314
+ 'https://app.testomat.io'
1315
+ );
1291
1316
 
1292
1317
  if (!token) {
1293
1318
  console.error('Error: API token is required. Use --token <token> or set TESTOMATIO_API_TOKEN environment variable');
@@ -1314,7 +1339,15 @@ async function main() {
1314
1339
  }
1315
1340
  }
1316
1341
 
1317
- // Only run main() if this file is executed directly (not imported)
1318
- if (import.meta.url === `file://${process.argv[1]}`) {
1319
- main().catch(console.error);
1342
+ // Run main() when executed directly or as a bin script
1343
+ // Don't run when imported as a module for testing
1344
+ if (import.meta.url.startsWith('file://') && process.argv[1]) {
1345
+ const modulePath = fileURLToPath(import.meta.url);
1346
+ const isDirectExecution = process.argv[1].includes('index.js') ||
1347
+ process.argv[1] === modulePath ||
1348
+ process.argv[1].endsWith('/testomatio-mcp');
1349
+
1350
+ if (isDirectExecution) {
1351
+ main().catch(console.error);
1352
+ }
1320
1353
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/mcp",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Model Context Protocol server for Testomatio API",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -13,11 +13,14 @@
13
13
  "test": "node --experimental-vm-modules node_modules/.bin/jest",
14
14
  "test:unit": "node --experimental-vm-modules node_modules/.bin/jest",
15
15
  "test:integration": "node --experimental-vm-modules node_modules/.bin/jest --config jest.integration.config.js",
16
+ "test:e2e": "node --experimental-vm-modules node_modules/.bin/jest --config jest.e2e.config.js",
16
17
  "test:watch": "node --experimental-vm-modules node_modules/.bin/jest --watch",
17
18
  "test:integration:watch": "node --experimental-vm-modules node_modules/.bin/jest --config jest.integration.config.js --watch",
19
+ "test:e2e:watch": "node --experimental-vm-modules node_modules/.bin/jest --config jest.e2e.config.js --watch",
18
20
  "test:coverage": "node --experimental-vm-modules node_modules/.bin/jest --coverage",
19
21
  "test:coverage:integration": "node --experimental-vm-modules node_modules/.bin/jest --config jest.integration.config.js --coverage",
20
- "test:all": "node --experimental-vm-modules node_modules/.bin/jest --config jest.integration.config.js"
22
+ "test:coverage:e2e": "node --experimental-vm-modules node_modules/.bin/jest --config jest.e2e.config.js --coverage",
23
+ "test:all": "npm run test:unit && npm run test:integration && npm run test:e2e"
21
24
  },
22
25
  "keywords": [
23
26
  "testomatio",