@taiga-ai/mcp-server 0.4.0-dev.386 → 0.4.0-dev.387

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/index.js CHANGED
@@ -167,6 +167,21 @@ var TaigaClient = class {
167
167
  }
168
168
  };
169
169
  //#endregion
170
+ //#region src/config.ts
171
+ const envSchema = z.object({
172
+ TAIGA_API_KEY: z.string().min(1),
173
+ TAIGA_API_URL: z.string().default("https://api.taiga.app")
174
+ });
175
+ /** Null when TAIGA_API_KEY is missing or empty: it is the one setting with no default. */
176
+ function readConfig() {
177
+ const parsed = envSchema.safeParse(process.env);
178
+ if (!parsed.success) return null;
179
+ return {
180
+ apiKey: parsed.data.TAIGA_API_KEY,
181
+ apiUrl: parsed.data.TAIGA_API_URL
182
+ };
183
+ }
184
+ //#endregion
170
185
  //#region src/tools/summarize.ts
171
186
  /**
172
187
  * Strip heavy content from list responses to avoid context window bloat.
@@ -357,17 +372,16 @@ function registerAllTools(server, client) {
357
372
  }
358
373
  //#endregion
359
374
  //#region src/index.ts
360
- const DEFAULT_API_URL = "https://api.taiga.app";
361
375
  async function main() {
362
- const apiKey = process.env.TAIGA_API_KEY;
363
- if (!apiKey) {
376
+ const config = readConfig();
377
+ if (!config) {
364
378
  console.error("Error: TAIGA_API_KEY environment variable is required.");
365
379
  console.error("Create an API key at https://app.taiga.app/settings/api-keys");
366
380
  process.exit(1);
367
381
  }
368
382
  const client = new TaigaClient({
369
- baseUrl: process.env.TAIGA_API_URL ?? DEFAULT_API_URL,
370
- apiKey
383
+ baseUrl: config.apiUrl,
384
+ apiKey: config.apiKey
371
385
  });
372
386
  const introspection = await client.introspect().catch((error) => {
373
387
  const message = error instanceof Error ? error.message : String(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taiga-ai/mcp-server",
3
- "version": "0.4.0-dev.386",
3
+ "version": "0.4.0-dev.387",
4
4
  "description": "MCP server for Taiga -- gives AI assistants access to documents and products",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -0,0 +1,24 @@
1
+ import { afterEach, describe, expect, it, vi } from 'vitest';
2
+
3
+ import { readConfig } from './config.js';
4
+
5
+ afterEach(() => {
6
+ vi.unstubAllEnvs();
7
+ });
8
+
9
+ describe('readConfig', () => {
10
+ it('needs an API key', () => {
11
+ vi.stubEnv('TAIGA_API_KEY', undefined);
12
+ expect(readConfig()).toBeNull();
13
+ vi.stubEnv('TAIGA_API_KEY', '');
14
+ expect(readConfig()).toBeNull();
15
+ });
16
+
17
+ it('defaults the API URL', () => {
18
+ vi.stubEnv('TAIGA_API_KEY', 'taiga_sk_live_test');
19
+ vi.stubEnv('TAIGA_API_URL', undefined);
20
+ expect(readConfig()).toEqual({ apiKey: 'taiga_sk_live_test', apiUrl: 'https://api.taiga.app' });
21
+ vi.stubEnv('TAIGA_API_URL', 'http://localhost:3001');
22
+ expect(readConfig()?.apiUrl).toBe('http://localhost:3001');
23
+ });
24
+ });
package/src/config.ts ADDED
@@ -0,0 +1,25 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * The one place the MCP server reads its environment (PRO-2511), parsed once
5
+ * at startup.
6
+ */
7
+
8
+ const DEFAULT_API_URL = 'https://api.taiga.app';
9
+
10
+ const envSchema = z.object({
11
+ TAIGA_API_KEY: z.string().min(1),
12
+ TAIGA_API_URL: z.string().default(DEFAULT_API_URL),
13
+ });
14
+
15
+ export interface ServerConfig {
16
+ readonly apiKey: string;
17
+ readonly apiUrl: string;
18
+ }
19
+
20
+ /** Null when TAIGA_API_KEY is missing or empty: it is the one setting with no default. */
21
+ export function readConfig(): ServerConfig | null {
22
+ const parsed = envSchema.safeParse(process.env);
23
+ if (!parsed.success) return null;
24
+ return { apiKey: parsed.data.TAIGA_API_KEY, apiUrl: parsed.data.TAIGA_API_URL };
25
+ }
package/src/index.ts CHANGED
@@ -3,22 +3,19 @@
3
3
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
4
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
5
5
  import { TaigaClient } from './client.js';
6
+ import { readConfig } from './config.js';
6
7
  import { registerAllTools } from './tools/index.js';
7
8
  import { SERVER_VERSION } from './version.js';
8
9
 
9
- const DEFAULT_API_URL = 'https://api.taiga.app';
10
-
11
10
  async function main() {
12
- const apiKey = process.env.TAIGA_API_KEY;
13
- if (!apiKey) {
11
+ const config = readConfig();
12
+ if (!config) {
14
13
  console.error('Error: TAIGA_API_KEY environment variable is required.');
15
14
  console.error('Create an API key at https://app.taiga.app/settings/api-keys');
16
15
  process.exit(1);
17
16
  }
18
17
 
19
- const apiUrl = process.env.TAIGA_API_URL ?? DEFAULT_API_URL;
20
-
21
- const client = new TaigaClient({ baseUrl: apiUrl, apiKey });
18
+ const client = new TaigaClient({ baseUrl: config.apiUrl, apiKey: config.apiKey });
22
19
 
23
20
  // Introspect the API key to discover available capabilities
24
21
  const introspection = await client.introspect().catch((error) => {