(cwd: string)
| 5 | |
| 6 | /** Load mcp.config.ts (via jiti) or mcp.config.json from cwd. */ |
| 7 | export async function loadConfig(cwd: string): Promise<MCPCodegenConfig> { |
| 8 | const { existsSync } = await import('node:fs') |
| 9 | const { join } = await import('node:path') |
| 10 | const tsPath = join(cwd, 'mcp.config.ts') |
| 11 | const jsonPath = join(cwd, 'mcp.config.json') |
| 12 | if (existsSync(tsPath)) { |
| 13 | const { createJiti } = await import('jiti') |
| 14 | const jiti = createJiti(import.meta.url) |
| 15 | const mod = await jiti.import<{ default: MCPCodegenConfig }>(tsPath) |
| 16 | return mod.default |
| 17 | } |
| 18 | if (existsSync(jsonPath)) { |
| 19 | const { readFileSync } = await import('node:fs') |
| 20 | return JSON.parse(readFileSync(jsonPath, 'utf8')) as MCPCodegenConfig |
| 21 | } |
| 22 | throw new Error('No mcp.config.ts or mcp.config.json found in ' + cwd) |
| 23 | } |
no test coverage detected