feat: add OpenCode MCP client support (#8422)

* feat: add OpenCode MCP client support

* chore: changeset

---------

Co-authored-by: shadcn <m@shadcn.com>
This commit is contained in:
sam
2026-01-06 13:46:05 +05:30
committed by GitHub
parent f6f2dfa5b2
commit c2fd847d65
4 changed files with 58 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"shadcn": patch
---
add mcp support for opencode

View File

@@ -29,6 +29,7 @@ Select your MCP client and follow the instructions to configure the shadcn MCP s
<TabsTrigger value="cursor">Cursor</TabsTrigger>
<TabsTrigger value="vscode">VS Code</TabsTrigger>
<TabsTrigger value="codex">Codex</TabsTrigger>
<TabsTrigger value="opencode">OpenCode</TabsTrigger>
</TabsList>
<TabsContent value="claude" className="mt-4">
**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
</TabsContent>
<TabsContent value="opencode" className="mt-4">
**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
</TabsContent>
</Tabs>
---

View File

@@ -27,6 +27,7 @@ Ask your registry consumers to configure your registry in their `components.json
<TabsTrigger value="cursor">Cursor</TabsTrigger>
<TabsTrigger value="vscode">VS Code</TabsTrigger>
<TabsTrigger value="codex">Codex</TabsTrigger>
<TabsTrigger value="opencode">OpenCode</TabsTrigger>
</TabsList>
<TabsContent value="claude" className="mt-4">
**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
</TabsContent>
<TabsContent value="opencode" className="mt-4">
**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
</TabsContent>
</Tabs>
You can read more about the MCP server in the [MCP documentation](/docs/mcp).

View File

@@ -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(),
})