diff --git a/.changeset/shy-aliens-decide.md b/.changeset/shy-aliens-decide.md new file mode 100644 index 0000000000..494d35c802 --- /dev/null +++ b/.changeset/shy-aliens-decide.md @@ -0,0 +1,5 @@ +--- +"shadcn": patch +--- + +add mcp support for opencode diff --git a/apps/v4/content/docs/(root)/mcp.mdx b/apps/v4/content/docs/(root)/mcp.mdx index d697513673..9c6e3112e5 100644 --- a/apps/v4/content/docs/(root)/mcp.mdx +++ b/apps/v4/content/docs/(root)/mcp.mdx @@ -29,6 +29,7 @@ Select your MCP client and follow the instructions to configure the shadcn MCP s Cursor VS Code Codex + OpenCode **Run the following command** in your project: @@ -95,6 +96,19 @@ Select your MCP client and follow the instructions to configure the shadcn MCP s - Create a contact form using components from the shadcn registry + + + **Run the following command** in your project: + ```bash + npx shadcn@latest mcp init --client opencode + ``` + + **Restart OpenCode** and try the following prompts: + - Show me all available components in the shadcn registry + - Add the button, dialog and card components to my project + - Create a contact form using components from the shadcn registry + + --- diff --git a/apps/v4/content/docs/registry/mcp.mdx b/apps/v4/content/docs/registry/mcp.mdx index 850a6d68b4..8531ef01aa 100644 --- a/apps/v4/content/docs/registry/mcp.mdx +++ b/apps/v4/content/docs/registry/mcp.mdx @@ -27,6 +27,7 @@ Ask your registry consumers to configure your registry in their `components.json Cursor VS Code Codex + OpenCode **Configure your registry** in your `components.json` file: @@ -118,6 +119,28 @@ Ask your registry consumers to configure your registry in their `components.json - Create a landing page using items from the acme registry + + + **Configure your registry** in your `components.json` file: + + ```json title="components.json" showLineNumbers + { + "registries": { + "@acme": "https://acme.com/r/{name}.json" + } + } + ``` + + **Run the following command** in your project: + ```bash + npx shadcn@latest mcp init --client opencode + ``` + + **Restart OpenCode** and try the following prompts: + - Show me the components in the acme registry + - Create a landing page using items from the acme registry + + You can read more about the MCP server in the [MCP documentation](/docs/mcp). diff --git a/packages/shadcn/src/commands/mcp.ts b/packages/shadcn/src/commands/mcp.ts index 7c576e4e34..d42f77172a 100644 --- a/packages/shadcn/src/commands/mcp.ts +++ b/packages/shadcn/src/commands/mcp.ts @@ -68,6 +68,21 @@ command = "npx" args = ["shadcn@${SHADCN_MCP_VERSION}", "mcp"] `, }, + { + name: "opencode", + label: "OpenCode", + configPath: "opencode.json", + config: { + $schema: "https://opencode.ai/config.json", + mcp: { + shadcn: { + type: "local", + command: ["npx", `shadcn@${SHADCN_MCP_VERSION}`, "mcp"], + enabled: true, + }, + }, + }, + }, ] as const const DEPENDENCIES = [`shadcn@${SHADCN_MCP_VERSION}`] @@ -92,7 +107,7 @@ export const mcp = new Command() }) const mcpInitOptionsSchema = z.object({ - client: z.enum(["claude", "cursor", "vscode", "codex"]), + client: z.enum(["claude", "cursor", "vscode", "codex", "opencode"]), cwd: z.string(), })