Home / Function/ runMcpInit() — ui Function Reference

runMcpInit() — ui Function Reference

Architecture documentation for the runMcpInit() function in mcp.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  78884bdb_378d_fa2b_7744_13277efd6944["runMcpInit()"]
  469f3289_889f_7728_0d18_3d10de41df93["mcp.ts"]
  78884bdb_378d_fa2b_7744_13277efd6944 -->|defined in| 469f3289_889f_7728_0d18_3d10de41df93
  style 78884bdb_378d_fa2b_7744_13277efd6944 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/shadcn/src/commands/mcp.ts lines 229–265

async function runMcpInit(options: z.infer<typeof mcpInitOptionsSchema>) {
  const { client, cwd } = options

  const clientInfo = CLIENTS.find((c) => c.name === client)
  if (!clientInfo) {
    throw new Error(
      `Unknown client: ${client}. Available clients: ${CLIENTS.map(
        (c) => c.name
      ).join(", ")}`
    )
  }

  const configPath = path.join(cwd, clientInfo.configPath)
  const dir = path.dirname(configPath)
  await fsExtra.ensureDir(dir)

  // Handle JSON format.
  let existingConfig = {}
  try {
    const content = await fs.readFile(configPath, "utf-8")
    existingConfig = JSON.parse(content)
  } catch {}

  const mergedConfig = deepmerge(
    existingConfig,
    clientInfo.config as Record<string, unknown>,
    { arrayMerge: overwriteMerge }
  )

  await fs.writeFile(
    configPath,
    JSON.stringify(mergedConfig, null, 2) + "\n",
    "utf-8"
  )

  return clientInfo.configPath
}

Subdomains

Frequently Asked Questions

What does runMcpInit() do?
runMcpInit() is a function in the ui codebase, defined in packages/shadcn/src/commands/mcp.ts.
Where is runMcpInit() defined?
runMcpInit() is defined in packages/shadcn/src/commands/mcp.ts at line 229.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free