MCPcopy
hub / github.com/davepoon/buildwithclaude / createAddCommand

Function createAddCommand

packages/bwc-cli/src/commands/add.ts:24–124  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22} from '../utils/docker-mcp.js'
23
24export function createAddCommand() {
25 const add = new Command('add')
26 .description('Add subagents, commands, or MCP servers')
27 .option('-a, --agent <name>', 'add a specific subagent')
28 .option('-c, --command <name>', 'add a specific command')
29 .option('-m, --mcp <name>', 'add a specific MCP server')
30 .option('-u, --user', 'force user-level installation (for subagents/commands)')
31 .option('-p, --project', 'force project-level installation (for subagents/commands)')
32 .option('-s, --scope <scope>', 'configuration scope for MCP servers: local, user, or project (default: "local")')
33 .option('-e, --env <env...>', 'set environment variables for MCP servers (e.g. -e KEY=value)')
34 .option('--setup', 'setup Docker MCP gateway in Claude Code')
35 .option('--docker-mcp', 'use Docker MCP Toolkit for MCP servers')
36 .option('--transport <type>', 'transport type for MCP servers: stdio, sse, or http')
37 .option('--url <url>', 'URL for remote MCP servers (required for sse/http transport)')
38 .option('--header <header...>', 'headers for remote MCP servers (e.g. --header "Authorization: Bearer token")')
39 .action(async (options) => {
40 try {
41 const configManager = ConfigManager.getInstance()
42 const registryClient = new RegistryClient(configManager)
43
44 // Log proxy configuration if present
45 if (isProxyConfigured()) {
46 logger.info(`Using proxy: ${getProxyDescription()}`)
47 }
48
49 // Handle explicit scope overrides
50 const forceUserLevel = options.user
51 const forceProjectLevel = options.project
52
53 // Determine installation scope
54 let isProject: boolean
55 if (forceProjectLevel) {
56 // Check if project config exists when forcing project level
57 const projectConfig = configManager.getProjectConfig()
58 if (!projectConfig) {
59 logger.error('No project configuration found. Run "bwc init --project" first.')
60 process.exit(1)
61 }
62 isProject = true
63 logger.info('Installing to project configuration')
64 } else if (forceUserLevel) {
65 await configManager.loadUserConfig()
66 isProject = false
67 logger.info('Installing to user configuration')
68 } else {
69 // Default: use project if it exists
70 isProject = await configManager.isUsingProjectConfig()
71 if (isProject) {
72 logger.info('Installing to project configuration')
73 }
74 }
75
76 // Handle Docker MCP setup
77 if (options.setup) {
78 await setupDockerMCPGatewayCommand(options.scope || 'project')
79 return
80 }
81

Callers 2

add.test.tsFile · 0.90
index.tsFile · 0.85

Calls 13

isProxyConfiguredFunction · 0.85
getProxyDescriptionFunction · 0.85
addSubagentFunction · 0.85
addCommandFunction · 0.85
addDockerMCPServerFunction · 0.85
addRemoteMCPServerFunction · 0.85
addMCPServerFunction · 0.85
interactiveAddFunction · 0.85
getProjectConfigMethod · 0.80
loadUserConfigMethod · 0.80
isUsingProjectConfigMethod · 0.80

Tested by

no test coverage detected