@seed-design/mcp 0.1.8 → 0.1.9-20250806055925

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/bin/index.mjs CHANGED
@@ -6,8 +6,7 @@ import { v4 } from 'uuid';
6
6
  import WebSocket$1 from 'ws';
7
7
  import { createRestNormalizer, figma, react, getFigmaColorVariableNames } from '@seed-design/figma';
8
8
  import { z } from 'zod';
9
- import fs from 'node:fs';
10
- import path from 'node:path';
9
+ import { cosmiconfig } from 'cosmiconfig';
11
10
 
12
11
  /**
13
12
  * Custom logging module that writes to stderr instead of stdout
@@ -678,33 +677,17 @@ function registerPrompts(server) {
678
677
  });
679
678
  }
680
679
 
681
- var version = "0.1.8";
680
+ var version = "0.1.9-20250806034801";
682
681
 
683
682
  // Config loader
684
683
  async function loadConfig(configPath) {
685
- try {
686
- const resolvedPath = path.resolve(process.cwd(), configPath);
687
- if (!fs.existsSync(resolvedPath)) {
688
- logger.error(`Config file not found: ${resolvedPath}`);
689
- return null;
690
- }
691
- // Handle different file types
692
- if (resolvedPath.endsWith(".json")) {
693
- const content = fs.readFileSync(resolvedPath, "utf-8");
694
- return JSON.parse(content);
695
- }
696
- if (resolvedPath.endsWith(".js") || resolvedPath.endsWith(".mjs") || resolvedPath.endsWith(".ts") || resolvedPath.endsWith(".mts")) {
697
- // For JS/MJS/TS/MTS files, we can dynamically import with Bun
698
- // Bun has built-in TypeScript support without requiring transpilation
699
- const config = await import(resolvedPath);
700
- return config.default || config;
701
- }
702
- logger.error(`Unsupported config file format: ${resolvedPath}`);
703
- return null;
704
- } catch (error) {
705
- logger.error(`Failed to load config file: ${error instanceof Error ? error.message : String(error)}`);
684
+ const explorer = cosmiconfig("mcp");
685
+ const searchResult = await explorer.load(configPath);
686
+ if (!searchResult) {
687
+ logger.error(`Config file not found: ${configPath}`);
706
688
  return null;
707
689
  }
690
+ return searchResult.config;
708
691
  }
709
692
 
710
693
  // Initialize CLI
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-design/mcp",
3
- "version": "0.1.8",
3
+ "version": "0.1.9-20250806055925",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/daangn/seed-design.git",
@@ -25,6 +25,7 @@
25
25
  "@modelcontextprotocol/sdk": "^1.10.2",
26
26
  "@seed-design/figma": "0.1.8",
27
27
  "cac": "^6.7.14",
28
+ "cosmiconfig": "^9.0.0",
28
29
  "uuid": "^11.1.0",
29
30
  "ws": "^8.18.1",
30
31
  "yargs": "^18.0.0",
package/src/config.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import type { CreatePipelineConfig } from "@seed-design/figma/codegen/targets/react";
2
- import fs from "node:fs";
3
- import path from "node:path";
4
2
  import { logger } from "./logger";
3
+ import { cosmiconfig } from "cosmiconfig";
5
4
 
6
5
  // Define config type
7
6
  export interface McpConfig {
@@ -9,39 +8,16 @@ export interface McpConfig {
9
8
  }
10
9
 
11
10
  // Config loader
12
- export async function loadConfig(configPath: string) {
13
- try {
14
- const resolvedPath = path.resolve(process.cwd(), configPath);
11
+ export async function loadConfig(configPath: string): Promise<McpConfig | null> {
12
+ const explorer = cosmiconfig("mcp");
15
13
 
16
- if (!fs.existsSync(resolvedPath)) {
17
- logger.error(`Config file not found: ${resolvedPath}`);
18
- return null;
19
- }
14
+ const searchResult = await explorer.load(configPath);
20
15
 
21
- // Handle different file types
22
- if (resolvedPath.endsWith(".json")) {
23
- const content = fs.readFileSync(resolvedPath, "utf-8");
24
- return JSON.parse(content);
25
- }
16
+ if (!searchResult) {
17
+ logger.error(`Config file not found: ${configPath}`);
26
18
 
27
- if (
28
- resolvedPath.endsWith(".js") ||
29
- resolvedPath.endsWith(".mjs") ||
30
- resolvedPath.endsWith(".ts") ||
31
- resolvedPath.endsWith(".mts")
32
- ) {
33
- // For JS/MJS/TS/MTS files, we can dynamically import with Bun
34
- // Bun has built-in TypeScript support without requiring transpilation
35
- const config = await import(resolvedPath);
36
- return config.default || config;
37
- }
38
-
39
- logger.error(`Unsupported config file format: ${resolvedPath}`);
40
- return null;
41
- } catch (error) {
42
- logger.error(
43
- `Failed to load config file: ${error instanceof Error ? error.message : String(error)}`,
44
- );
45
19
  return null;
46
20
  }
21
+
22
+ return searchResult.config;
47
23
  }