Skip to content

Commit bcb9662

Browse files
committed
feat(cli): add Claude Code CLI support
- Add claude-code IDE detection (detects `claude` CLI) - Generate `claude mcp add` command for Claude Code users - Use HTTP transport with --scope user for global availability - Auto-install handles existing server (remove + re-add) - Display appropriate instructions for Claude Code vs other IDEs
1 parent 3285d40 commit bcb9662

File tree

6 files changed

+76
-7
lines changed

6 files changed

+76
-7
lines changed

src/cli/ide/known/claude-code.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { KnownIDE } from '../types.js'
2+
import { defaultDetection } from '../../detect/index.js'
3+
4+
export const CLAUDE_CODE: KnownIDE = {
5+
brand: 'Claude Code',
6+
id: 'claude-code',
7+
detect: {
8+
darwin: defaultDetection('claude'),
9+
win32: defaultDetection('claude'),
10+
linux: defaultDetection('claude'),
11+
},
12+
settings: {},
13+
}

src/cli/ide/known/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './claude.js'
2+
export * from './claude-code.js'
23
export * from './cursor.js'
34
export * from './trae.js'
45
export * from './vscode.js'

src/cli/ide/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export type IDEId = 'code' | 'trae' | 'cursor' | 'code-insiders' | 'claude' | 'windsurf'
1+
export type IDEId = 'code' | 'trae' | 'cursor' | 'code-insiders' | 'claude' | 'claude-code' | 'windsurf'
22
export type OperatingSystem = 'win32' | 'darwin' | 'linux'
33

44
export interface KnownIDE {

src/cli/install-globally.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,31 @@ import { parse } from 'jsonc-parser'
22
import { writeFile, readFile } from 'node:fs/promises'
33
import { existsSync } from 'node:fs'
44
import { resolve } from 'pathe'
5-
import { getServerConfig, getSettingsPath } from './settings-builder.js'
5+
import { x } from 'tinyexec'
6+
import { getServerConfig, getSettingsPath, getClaudeCodeArgs } from './settings-builder.js'
67
import type { DetectedIDE } from './ide/types.js'
78
import { deepset } from './utils/deepset.js'
89

10+
async function installClaudeCode () {
11+
const args = getClaudeCodeArgs()
12+
const result = await x('claude', args)
13+
14+
if (result.exitCode !== 0) {
15+
if (result.stderr.includes('already exists')) {
16+
// Remove existing and re-add
17+
await x('claude', ['mcp', 'remove', '--scope', 'user', 'vuetify-mcp'])
18+
await x('claude', args, { throwOnError: true })
19+
} else {
20+
throw new Error(result.stderr || 'Failed to add MCP server')
21+
}
22+
}
23+
}
24+
925
async function setIdeSettings (ideInstance: DetectedIDE, remote?: boolean) {
26+
if (ideInstance.ide === 'claude-code') {
27+
return installClaudeCode()
28+
}
29+
1030
if (!ideInstance.settingsDir || !existsSync(ideInstance.settingsDir)) {
1131
return
1232
}

src/cli/intro.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,21 @@ const WELCOME_MESSAGE = 'Welcome to the Vuetify MCP Server'
1212
const CONFIG_TEMPLATE = `
1313
Open your IDE and paste this into your
1414
%settings% file (for %brand%):`
15+
const CLAUDE_CODE_TEMPLATE = `
16+
Run this command to configure Claude Code:`
1517

1618
export const startMessage = blue(WELCOME_MESSAGE)
1719

18-
const configMessage = (ide: DetectedIDE) => blue(
19-
CONFIG_TEMPLATE
20-
.replace('%settings%', underline(join(ide.settingsDir, ide.settingsFile)))
21-
.replace('%brand%', ide.brand),
22-
)
20+
function configMessage (ide: DetectedIDE) {
21+
if (ide.ide === 'claude-code') {
22+
return blue(CLAUDE_CODE_TEMPLATE)
23+
}
24+
return blue(
25+
CONFIG_TEMPLATE
26+
.replace('%settings%', underline(join(ide.settingsDir, ide.settingsFile)))
27+
.replace('%brand%', ide.brand),
28+
)
29+
}
2330

2431
export const intro = (): void => {
2532
console.warn(startMessage)

src/cli/settings-builder.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,35 @@ export function getServerConfig (transport?: 'stdio' | 'http', remote?: boolean)
8787
return npx?.wsl ? wslConfig : defaultConfig
8888
}
8989

90+
export function getClaudeCodeArgs (): string[] {
91+
const apiKey = process.env.VUETIFY_API_KEY
92+
const args = [
93+
'mcp',
94+
'add',
95+
'--transport',
96+
'http',
97+
'--scope',
98+
'user',
99+
SERVER_NAME,
100+
'https://mcp.vuetifyjs.com/mcp',
101+
]
102+
103+
if (apiKey) {
104+
args.push('--header', `Authorization:Bearer ${apiKey}`)
105+
}
106+
107+
return args
108+
}
109+
110+
export function getClaudeCodeCommand (): string {
111+
const args = getClaudeCodeArgs()
112+
return `claude ${args.map(a => a.includes(':') ? `"${a}"` : a).join(' ')}`
113+
}
114+
90115
export const getSettingsBuilder = (ide: IDEId, transport?: 'stdio' | 'http', remote?: boolean): string => {
116+
if (ide === 'claude-code') {
117+
return getClaudeCodeCommand()
118+
}
91119
const config = getServerConfig(transport, remote)
92120
switch (ide) {
93121
case 'code':

0 commit comments

Comments
 (0)