@seed-design/mcp 0.1.7 → 0.1.9-20250806034801

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,21 @@ function registerPrompts(server) {
678
677
  });
679
678
  }
680
679
 
681
- var version = "0.1.7";
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)}`);
706
- return null;
684
+ const explorer = cosmiconfig("mcp", {
685
+ searchPlaces: [
686
+ configPath
687
+ ]
688
+ });
689
+ const searchResult = await explorer.search();
690
+ if (!searchResult) {
691
+ logger.error(`Config file not found: ${configPath}`);
692
+ return {};
707
693
  }
694
+ return searchResult.config;
708
695
  }
709
696
 
710
697
  // Initialize CLI
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-design/mcp",
3
- "version": "0.1.7",
3
+ "version": "0.1.9-20250806034801",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/daangn/seed-design.git",
@@ -23,8 +23,9 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@modelcontextprotocol/sdk": "^1.10.2",
26
- "@seed-design/figma": "0.1.7",
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,18 @@ 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> {
12
+ const explorer = cosmiconfig("mcp", {
13
+ searchPlaces: [configPath],
14
+ });
15
15
 
16
- if (!fs.existsSync(resolvedPath)) {
17
- logger.error(`Config file not found: ${resolvedPath}`);
18
- return null;
19
- }
16
+ const searchResult = await explorer.search();
20
17
 
21
- // Handle different file types
22
- if (resolvedPath.endsWith(".json")) {
23
- const content = fs.readFileSync(resolvedPath, "utf-8");
24
- return JSON.parse(content);
25
- }
18
+ if (!searchResult) {
19
+ logger.error(`Config file not found: ${configPath}`);
26
20
 
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
- return null;
21
+ return {};
46
22
  }
23
+
24
+ return searchResult.config;
47
25
  }