@teambit/cli-mcp-server 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.docs.mdx +52 -30
- package/dist/README.docs.mdx +52 -30
- package/dist/cli-mcp-server.main.runtime.d.ts +5 -1
- package/dist/cli-mcp-server.main.runtime.js +166 -98
- package/dist/cli-mcp-server.main.runtime.js.map +1 -1
- package/dist/cli-mcp-server.spec.d.ts +1 -0
- package/dist/cli-mcp-server.spec.js +532 -0
- package/dist/cli-mcp-server.spec.js.map +1 -0
- package/dist/mcp-server.cmd.d.ts +15 -2
- package/dist/mcp-server.cmd.js +29 -2
- package/dist/mcp-server.cmd.js.map +1 -1
- package/dist/{preview-1748661443929.js → preview-1749007248643.js} +1 -1
- package/dist/setup-cmd.d.ts +23 -0
- package/dist/setup-cmd.js +58 -0
- package/dist/setup-cmd.js.map +1 -0
- package/dist/setup-utils.d.ts +53 -0
- package/dist/setup-utils.js +259 -0
- package/dist/setup-utils.js.map +1 -0
- package/package.json +17 -6
package/README.docs.mdx
CHANGED
|
@@ -37,42 +37,61 @@ Options:
|
|
|
37
37
|
- `--include-additional <commands>`: Add specific commands to the default set (comma-separated list)
|
|
38
38
|
- `--exclude <commands>`: Prevent specific commands from being exposed (comma-separated list)
|
|
39
39
|
|
|
40
|
-
### Integrating with
|
|
40
|
+
### Integrating with IDEs
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
The easiest way to integrate the MCP server with your IDE is to use the `setup` command:
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
```bash
|
|
45
|
+
# Basic setup for VS Code (default)
|
|
46
|
+
bit mcp-server setup
|
|
47
|
+
```
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
49
|
+
This will automatically configure your VS Code settings to use the Bit MCP server. See the [Automatic Setup](#automatic-integration-setup) section below for more options.
|
|
50
|
+
|
|
51
|
+
### Automatic Integration Setup
|
|
52
|
+
|
|
53
|
+
The **recommended way** to integrate the MCP server with your IDE is using the `setup` command:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
bit mcp-server setup [vscode|cursor|windsurf] [options]
|
|
58
57
|
```
|
|
59
58
|
|
|
60
|
-
|
|
59
|
+
This command automatically configures the MCP server settings in your chosen editor. If no editor is specified, it defaults to VS Code.
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
61
|
+
#### Supported Editors
|
|
62
|
+
|
|
63
|
+
- **VS Code**: `bit mcp-server setup vscode` (or just `bit mcp-server setup`)
|
|
64
|
+
- **Cursor**: `bit mcp-server setup cursor`
|
|
65
|
+
- **Windsurf**: `bit mcp-server setup windsurf`
|
|
66
|
+
|
|
67
|
+
#### Configuration Options
|
|
68
|
+
|
|
69
|
+
- `--global`: Apply configuration globally (user settings) instead of workspace settings
|
|
70
|
+
- `--extended`: Configure with extended mode enabled
|
|
71
|
+
- `--consumer-project`: Configure for consumer projects
|
|
72
|
+
- `--include-only <commands>`: Specify subset of commands to expose
|
|
73
|
+
- `--include-additional <commands>`: Add specific commands to the default set
|
|
74
|
+
- `--exclude <commands>`: Prevent specific commands from being exposed
|
|
75
|
+
|
|
76
|
+
#### Examples
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Basic VS Code setup (workspace level)
|
|
80
|
+
bit mcp-server setup
|
|
81
|
+
|
|
82
|
+
# Global setup for Cursor with extended mode
|
|
83
|
+
bit mcp-server setup cursor --global --extended
|
|
84
|
+
|
|
85
|
+
# Setup for Windsurf with consumer project mode
|
|
86
|
+
bit mcp-server setup windsurf --consumer-project
|
|
73
87
|
```
|
|
74
88
|
|
|
75
|
-
|
|
89
|
+
#### Manual Configuration
|
|
90
|
+
|
|
91
|
+
If you need to manually configure the settings, here's a basic example for VS Code:
|
|
92
|
+
|
|
93
|
+
1. Open VS Code settings (JSON) by pressing `Ctrl + Shift + P` (or `Cmd + Shift + P` on macOS) and typing `Preferences: Open Settings (JSON)`
|
|
94
|
+
2. Add the following configuration:
|
|
76
95
|
|
|
77
96
|
```json
|
|
78
97
|
{
|
|
@@ -80,7 +99,7 @@ For consumer projects that only use Bit component packages:
|
|
|
80
99
|
"servers": {
|
|
81
100
|
"bit-cli": {
|
|
82
101
|
"command": "bit",
|
|
83
|
-
"args": ["mcp-server"
|
|
102
|
+
"args": ["mcp-server"]
|
|
84
103
|
}
|
|
85
104
|
}
|
|
86
105
|
}
|
|
@@ -122,7 +141,10 @@ In default mode, the server exposes a minimal set of essential tools focused on
|
|
|
122
141
|
|
|
123
142
|
- `bit_workspace_info`: Get comprehensive workspace information including status, components list, apps, templates, and dependency graph
|
|
124
143
|
- `bit_component_details`: Get detailed information about a specific component including basic info and optionally its public API schema
|
|
125
|
-
- `
|
|
144
|
+
- `bit_commands_list`: Get all available Bit commands with descriptions and groups (for command discovery)
|
|
145
|
+
- `bit_command_help`: Get detailed help for a specific Bit command including syntax, arguments, flags, and usage examples
|
|
146
|
+
|
|
147
|
+
> **Command Discovery vs. Command Help**: Use `bit_commands_list` to discover what commands are available in Bit, then use `bit_command_help` with a specific command name to get detailed usage information including arguments, flags, and examples.
|
|
126
148
|
|
|
127
149
|
- **Generic Execution Tools:**
|
|
128
150
|
- `bit_query`: Execute read-only Bit commands that safely inspect workspace and component state without making modifications
|
package/dist/README.docs.mdx
CHANGED
|
@@ -37,42 +37,61 @@ Options:
|
|
|
37
37
|
- `--include-additional <commands>`: Add specific commands to the default set (comma-separated list)
|
|
38
38
|
- `--exclude <commands>`: Prevent specific commands from being exposed (comma-separated list)
|
|
39
39
|
|
|
40
|
-
### Integrating with
|
|
40
|
+
### Integrating with IDEs
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
The easiest way to integrate the MCP server with your IDE is to use the `setup` command:
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
```bash
|
|
45
|
+
# Basic setup for VS Code (default)
|
|
46
|
+
bit mcp-server setup
|
|
47
|
+
```
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
49
|
+
This will automatically configure your VS Code settings to use the Bit MCP server. See the [Automatic Setup](#automatic-integration-setup) section below for more options.
|
|
50
|
+
|
|
51
|
+
### Automatic Integration Setup
|
|
52
|
+
|
|
53
|
+
The **recommended way** to integrate the MCP server with your IDE is using the `setup` command:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
bit mcp-server setup [vscode|cursor|windsurf] [options]
|
|
58
57
|
```
|
|
59
58
|
|
|
60
|
-
|
|
59
|
+
This command automatically configures the MCP server settings in your chosen editor. If no editor is specified, it defaults to VS Code.
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
61
|
+
#### Supported Editors
|
|
62
|
+
|
|
63
|
+
- **VS Code**: `bit mcp-server setup vscode` (or just `bit mcp-server setup`)
|
|
64
|
+
- **Cursor**: `bit mcp-server setup cursor`
|
|
65
|
+
- **Windsurf**: `bit mcp-server setup windsurf`
|
|
66
|
+
|
|
67
|
+
#### Configuration Options
|
|
68
|
+
|
|
69
|
+
- `--global`: Apply configuration globally (user settings) instead of workspace settings
|
|
70
|
+
- `--extended`: Configure with extended mode enabled
|
|
71
|
+
- `--consumer-project`: Configure for consumer projects
|
|
72
|
+
- `--include-only <commands>`: Specify subset of commands to expose
|
|
73
|
+
- `--include-additional <commands>`: Add specific commands to the default set
|
|
74
|
+
- `--exclude <commands>`: Prevent specific commands from being exposed
|
|
75
|
+
|
|
76
|
+
#### Examples
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Basic VS Code setup (workspace level)
|
|
80
|
+
bit mcp-server setup
|
|
81
|
+
|
|
82
|
+
# Global setup for Cursor with extended mode
|
|
83
|
+
bit mcp-server setup cursor --global --extended
|
|
84
|
+
|
|
85
|
+
# Setup for Windsurf with consumer project mode
|
|
86
|
+
bit mcp-server setup windsurf --consumer-project
|
|
73
87
|
```
|
|
74
88
|
|
|
75
|
-
|
|
89
|
+
#### Manual Configuration
|
|
90
|
+
|
|
91
|
+
If you need to manually configure the settings, here's a basic example for VS Code:
|
|
92
|
+
|
|
93
|
+
1. Open VS Code settings (JSON) by pressing `Ctrl + Shift + P` (or `Cmd + Shift + P` on macOS) and typing `Preferences: Open Settings (JSON)`
|
|
94
|
+
2. Add the following configuration:
|
|
76
95
|
|
|
77
96
|
```json
|
|
78
97
|
{
|
|
@@ -80,7 +99,7 @@ For consumer projects that only use Bit component packages:
|
|
|
80
99
|
"servers": {
|
|
81
100
|
"bit-cli": {
|
|
82
101
|
"command": "bit",
|
|
83
|
-
"args": ["mcp-server"
|
|
102
|
+
"args": ["mcp-server"]
|
|
84
103
|
}
|
|
85
104
|
}
|
|
86
105
|
}
|
|
@@ -122,7 +141,10 @@ In default mode, the server exposes a minimal set of essential tools focused on
|
|
|
122
141
|
|
|
123
142
|
- `bit_workspace_info`: Get comprehensive workspace information including status, components list, apps, templates, and dependency graph
|
|
124
143
|
- `bit_component_details`: Get detailed information about a specific component including basic info and optionally its public API schema
|
|
125
|
-
- `
|
|
144
|
+
- `bit_commands_list`: Get all available Bit commands with descriptions and groups (for command discovery)
|
|
145
|
+
- `bit_command_help`: Get detailed help for a specific Bit command including syntax, arguments, flags, and usage examples
|
|
146
|
+
|
|
147
|
+
> **Command Discovery vs. Command Help**: Use `bit_commands_list` to discover what commands are available in Bit, then use `bit_command_help` with a specific command name to get detailed usage information including arguments, flags, and examples.
|
|
126
148
|
|
|
127
149
|
- **Generic Execution Tools:**
|
|
128
150
|
- `bit_query`: Execute read-only Bit commands that safely inspect workspace and component state without making modifications
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CLIMain } from '@teambit/cli';
|
|
2
2
|
import { Logger, LoggerMain } from '@teambit/logger';
|
|
3
3
|
import { Http } from '@teambit/scope.network';
|
|
4
|
+
import { SetupOptions } from './setup-utils';
|
|
4
5
|
export declare class CliMcpServerMain {
|
|
5
6
|
private cli;
|
|
6
7
|
private logger;
|
|
@@ -47,7 +48,8 @@ export declare class CliMcpServerMain {
|
|
|
47
48
|
private registerRemoteSearchTool;
|
|
48
49
|
private registerWorkspaceInfoTool;
|
|
49
50
|
private registerComponentDetailsTool;
|
|
50
|
-
private
|
|
51
|
+
private registerCommandsListTool;
|
|
52
|
+
private registerCommandHelpTool;
|
|
51
53
|
private registerQueryTool;
|
|
52
54
|
private registerExecuteTool;
|
|
53
55
|
private processSubCommands;
|
|
@@ -68,6 +70,8 @@ export declare class CliMcpServerMain {
|
|
|
68
70
|
* Helper method to safely execute a bit command with error handling
|
|
69
71
|
*/
|
|
70
72
|
private safeBitCommandExecution;
|
|
73
|
+
getEditorDisplayName(editor: string): string;
|
|
74
|
+
setupEditor(editor: string, options: SetupOptions, workspaceDir?: string): Promise<void>;
|
|
71
75
|
static slots: never[];
|
|
72
76
|
static dependencies: import("@teambit/harmony").Aspect[];
|
|
73
77
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
@@ -18,6 +18,13 @@ function _child_process() {
|
|
|
18
18
|
};
|
|
19
19
|
return data;
|
|
20
20
|
}
|
|
21
|
+
function _fsExtra() {
|
|
22
|
+
const data = _interopRequireDefault(require("fs-extra"));
|
|
23
|
+
_fsExtra = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
21
28
|
function _cliMcpServer() {
|
|
22
29
|
const data = require("./cli-mcp-server.aspect");
|
|
23
30
|
_cliMcpServer = function () {
|
|
@@ -81,6 +88,20 @@ function _nodeFetch() {
|
|
|
81
88
|
};
|
|
82
89
|
return data;
|
|
83
90
|
}
|
|
91
|
+
function _setupCmd() {
|
|
92
|
+
const data = require("./setup-cmd");
|
|
93
|
+
_setupCmd = function () {
|
|
94
|
+
return data;
|
|
95
|
+
};
|
|
96
|
+
return data;
|
|
97
|
+
}
|
|
98
|
+
function _setupUtils() {
|
|
99
|
+
const data = require("./setup-utils");
|
|
100
|
+
_setupUtils = function () {
|
|
101
|
+
return data;
|
|
102
|
+
};
|
|
103
|
+
return data;
|
|
104
|
+
}
|
|
84
105
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
85
106
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
86
107
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -247,8 +268,7 @@ class CliMcpServerMain {
|
|
|
247
268
|
}
|
|
248
269
|
|
|
249
270
|
// Resolve the real path to handle symlinks (e.g., /tmp -> /private/tmp on macOS)
|
|
250
|
-
const
|
|
251
|
-
const realCwd = fs.realpathSync(cwd);
|
|
271
|
+
const realCwd = _fsExtra().default.realpathSync(cwd);
|
|
252
272
|
let body;
|
|
253
273
|
let url;
|
|
254
274
|
if (isIDERoute) {
|
|
@@ -389,10 +409,9 @@ class CliMcpServerMain {
|
|
|
389
409
|
// Register the bit_component_details tool
|
|
390
410
|
this.registerComponentDetailsTool(server);
|
|
391
411
|
|
|
392
|
-
// Register
|
|
393
|
-
this.
|
|
394
|
-
|
|
395
|
-
// Register arbitrary command execution tools
|
|
412
|
+
// Register command discovery and help tools
|
|
413
|
+
this.registerCommandsListTool(server);
|
|
414
|
+
this.registerCommandHelpTool(server);
|
|
396
415
|
this.registerQueryTool(server);
|
|
397
416
|
this.registerExecuteTool(server);
|
|
398
417
|
await server.connect(new (_stdio().StdioServerTransport)());
|
|
@@ -647,134 +666,147 @@ class CliMcpServerMain {
|
|
|
647
666
|
}
|
|
648
667
|
});
|
|
649
668
|
}
|
|
650
|
-
|
|
651
|
-
const toolName = '
|
|
652
|
-
const description = 'Get
|
|
669
|
+
registerCommandsListTool(server) {
|
|
670
|
+
const toolName = 'bit_commands_list';
|
|
671
|
+
const description = 'Get all available Bit commands with descriptions and groups. Use this to discover what commands are available.';
|
|
653
672
|
const schema = {
|
|
654
673
|
extendedDescription: _zod().z.boolean().optional().describe('Include extended descriptions for commands (default: false)'),
|
|
655
|
-
internal: _zod().z.boolean().optional().describe('Include internal/debug commands (default: false)')
|
|
656
|
-
command: _zod().z.string().optional().describe('Get info for a specific command only'),
|
|
657
|
-
subcommand: _zod().z.string().optional().describe('Get info for subcommands of a specific main command')
|
|
674
|
+
internal: _zod().z.boolean().optional().describe('Include internal/debug commands (default: false)')
|
|
658
675
|
};
|
|
659
676
|
server.tool(toolName, description, schema, async params => {
|
|
660
677
|
try {
|
|
661
678
|
const {
|
|
662
679
|
extendedDescription = false,
|
|
663
|
-
internal = false
|
|
664
|
-
command: specificCommand,
|
|
665
|
-
subcommand: specificSubcommand
|
|
680
|
+
internal = false
|
|
666
681
|
} = params;
|
|
667
682
|
const commandsInfo = [];
|
|
668
683
|
const shouldSkipCommand = cmd => {
|
|
669
684
|
return Boolean(cmd.private && !internal || cmd.description.startsWith('DEPRECATED'));
|
|
670
685
|
};
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
686
|
+
|
|
687
|
+
// Build list of all commands
|
|
688
|
+
this.cli.commands.forEach(cmd => {
|
|
689
|
+
if (shouldSkipCommand(cmd)) return;
|
|
690
|
+
const mainCmdName = (0, _cli().getCommandName)(cmd);
|
|
691
|
+
const groupKey = cmd.group;
|
|
675
692
|
const commandInfo = {
|
|
676
|
-
name:
|
|
677
|
-
description: cmd.description || ''
|
|
693
|
+
name: mainCmdName,
|
|
694
|
+
description: cmd.description || '',
|
|
695
|
+
alias: cmd.alias || ''
|
|
678
696
|
};
|
|
679
697
|
if (extendedDescription && cmd.extendedDescription) {
|
|
680
698
|
commandInfo.extendedDescription = cmd.extendedDescription;
|
|
681
699
|
}
|
|
682
700
|
if (groupKey) commandInfo.group = this.cli.groups[groupKey] || groupKey;
|
|
683
|
-
if (!detailed) return commandInfo;
|
|
684
|
-
|
|
685
|
-
// Add detailed information
|
|
686
701
|
if (cmd.helpUrl) commandInfo.helpUrl = cmd.helpUrl;
|
|
702
|
+
|
|
703
|
+
// Add subcommands summary
|
|
704
|
+
if (cmd.commands && cmd.commands.length > 0) {
|
|
705
|
+
commandInfo.subcommands = cmd.commands.filter(subCmd => !shouldSkipCommand(subCmd)).map(subCmd => ({
|
|
706
|
+
name: (0, _cli().getCommandName)(subCmd),
|
|
707
|
+
description: subCmd.description || '',
|
|
708
|
+
alias: subCmd.alias || ''
|
|
709
|
+
}));
|
|
710
|
+
}
|
|
711
|
+
commandsInfo.push(commandInfo);
|
|
712
|
+
});
|
|
713
|
+
commandsInfo.sort((a, b) => a.name.localeCompare(b.name));
|
|
714
|
+
const result = JSON.stringify({
|
|
715
|
+
total: commandsInfo.length,
|
|
716
|
+
commands: commandsInfo
|
|
717
|
+
}, null, 2);
|
|
718
|
+
this.logger.debug(`[MCP-DEBUG] Successfully retrieved commands list. Total: ${commandsInfo.length}`);
|
|
719
|
+
return this.formatAsCallToolResult(result);
|
|
720
|
+
} catch (error) {
|
|
721
|
+
this.logger.error(`[MCP-DEBUG] Error in bit_commands_list tool: ${error.message}`);
|
|
722
|
+
return this.formatErrorAsCallToolResult(error, 'getting commands list');
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
registerCommandHelpTool(server) {
|
|
727
|
+
const toolName = 'bit_command_help';
|
|
728
|
+
const description = 'Get detailed help for a specific Bit command including syntax, arguments, flags, and usage examples. Use this to understand exactly how to use a command.';
|
|
729
|
+
const schema = {
|
|
730
|
+
command: _zod().z.string().describe('The command name to get help for (e.g., "status", "install", "create")'),
|
|
731
|
+
subcommand: _zod().z.string().optional().describe('Optional subcommand name (e.g., for "lane show", use command="lane" and subcommand="show")')
|
|
732
|
+
};
|
|
733
|
+
server.tool(toolName, description, schema, async params => {
|
|
734
|
+
try {
|
|
735
|
+
const {
|
|
736
|
+
command: requestedCommand,
|
|
737
|
+
subcommand: requestedSubcommand
|
|
738
|
+
} = params;
|
|
739
|
+
let commandInfo = null;
|
|
740
|
+
const buildDetailedCommandInfo = (cmd, parentName) => {
|
|
741
|
+
const cmdName = parentName ? `${parentName} ${(0, _cli().getCommandName)(cmd)}` : (0, _cli().getCommandName)(cmd);
|
|
742
|
+
const info = {
|
|
743
|
+
name: cmdName,
|
|
744
|
+
description: cmd.description || '',
|
|
745
|
+
extendedDescription: cmd.extendedDescription || '',
|
|
746
|
+
alias: cmd.alias || '',
|
|
747
|
+
group: cmd.group ? this.cli.groups[cmd.group] || cmd.group : '',
|
|
748
|
+
helpUrl: cmd.helpUrl || '',
|
|
749
|
+
private: cmd.private || false
|
|
750
|
+
};
|
|
751
|
+
|
|
752
|
+
// Add arguments information
|
|
687
753
|
const argsData = (0, _cli().getArgsData)(cmd);
|
|
688
754
|
if (argsData.length > 0) {
|
|
689
|
-
|
|
755
|
+
info.arguments = argsData.map(arg => ({
|
|
690
756
|
name: arg.nameRaw,
|
|
691
757
|
description: arg.description || '',
|
|
692
758
|
required: arg.required,
|
|
693
759
|
isArray: arg.isArray
|
|
694
760
|
}));
|
|
695
761
|
}
|
|
696
|
-
|
|
697
|
-
|
|
762
|
+
|
|
763
|
+
// Add options/flags information
|
|
764
|
+
info.options = (0, _cli().getFlagsData)(cmd);
|
|
765
|
+
|
|
766
|
+
// Add examples if available
|
|
767
|
+
if (cmd.examples) {
|
|
768
|
+
info.examples = cmd.examples;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
// Add subcommands if available (including private ones for help purposes)
|
|
698
772
|
if (cmd.commands && cmd.commands.length > 0) {
|
|
699
|
-
|
|
700
|
-
name:
|
|
773
|
+
info.subcommands = cmd.commands.map(subCmd => ({
|
|
774
|
+
name: (0, _cli().getCommandName)(subCmd),
|
|
701
775
|
description: subCmd.description || '',
|
|
702
|
-
alias: subCmd.alias || ''
|
|
703
|
-
private: Boolean(subCmd.private)
|
|
776
|
+
alias: subCmd.alias || ''
|
|
704
777
|
}));
|
|
705
778
|
}
|
|
706
|
-
return
|
|
779
|
+
return info;
|
|
707
780
|
};
|
|
708
781
|
|
|
709
|
-
//
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
782
|
+
// Search for the requested command
|
|
783
|
+
this.cli.commands.forEach(cmd => {
|
|
784
|
+
const mainCmdName = (0, _cli().getCommandName)(cmd);
|
|
785
|
+
if (requestedSubcommand) {
|
|
786
|
+
// Looking for a subcommand
|
|
787
|
+
if (mainCmdName === requestedCommand && cmd.commands) {
|
|
788
|
+
const subCmd = cmd.commands.find(sub => (0, _cli().getCommandName)(sub) === requestedSubcommand);
|
|
714
789
|
if (subCmd) {
|
|
715
|
-
|
|
716
|
-
if (info) commandsInfo.push(info);
|
|
790
|
+
commandInfo = buildDetailedCommandInfo(subCmd, requestedCommand);
|
|
717
791
|
}
|
|
718
792
|
}
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
this.cli.commands.forEach(cmd => {
|
|
724
|
-
if ((0, _cli().getCommandName)(cmd) === specificSubcommand && cmd.commands) {
|
|
725
|
-
cmd.commands.forEach(subCmd => {
|
|
726
|
-
const info = buildCommandInfo(subCmd, specificSubcommand, cmd.group);
|
|
727
|
-
if (info) commandsInfo.push(info);
|
|
728
|
-
});
|
|
729
|
-
}
|
|
730
|
-
});
|
|
731
|
-
}
|
|
732
|
-
// Handle specific command lookup or general listing
|
|
733
|
-
else {
|
|
734
|
-
const isDetailedMode = Boolean(specificCommand);
|
|
735
|
-
this.cli.commands.forEach(cmd => {
|
|
736
|
-
const mainCmdName = (0, _cli().getCommandName)(cmd);
|
|
737
|
-
|
|
738
|
-
// Process main command
|
|
739
|
-
if (!specificCommand || mainCmdName === specificCommand) {
|
|
740
|
-
const info = buildCommandInfo(cmd, undefined, undefined, isDetailedMode);
|
|
741
|
-
if (info && (!specificCommand || info.name === specificCommand)) {
|
|
742
|
-
commandsInfo.push(info);
|
|
743
|
-
}
|
|
793
|
+
} else {
|
|
794
|
+
// Looking for a main command
|
|
795
|
+
if (mainCmdName === requestedCommand) {
|
|
796
|
+
commandInfo = buildDetailedCommandInfo(cmd);
|
|
744
797
|
}
|
|
745
|
-
|
|
746
|
-
// Process subcommands
|
|
747
|
-
if (cmd.commands) {
|
|
748
|
-
cmd.commands.forEach(subCmd => {
|
|
749
|
-
const subCmdInfo = buildCommandInfo(subCmd, mainCmdName, cmd.group, isDetailedMode);
|
|
750
|
-
if (subCmdInfo && (!specificCommand || subCmdInfo.name === specificCommand)) {
|
|
751
|
-
commandsInfo.push(subCmdInfo);
|
|
752
|
-
}
|
|
753
|
-
});
|
|
754
|
-
}
|
|
755
|
-
});
|
|
756
|
-
}
|
|
757
|
-
commandsInfo.sort((a, b) => a.name.localeCompare(b.name));
|
|
758
|
-
if (commandsInfo.length === 0) {
|
|
759
|
-
let errorMessage = 'No commands found';
|
|
760
|
-
if (specificCommand && specificSubcommand) {
|
|
761
|
-
errorMessage = `No subcommand "${specificSubcommand}" found for command: ${specificCommand}`;
|
|
762
|
-
} else if (specificCommand) {
|
|
763
|
-
errorMessage = `No command found with name: ${specificCommand}`;
|
|
764
|
-
} else if (specificSubcommand) {
|
|
765
|
-
errorMessage = `No subcommands found for command: ${specificSubcommand}`;
|
|
766
798
|
}
|
|
767
|
-
|
|
799
|
+
});
|
|
800
|
+
if (!commandInfo) {
|
|
801
|
+
const commandFullName = requestedSubcommand ? `${requestedCommand} ${requestedSubcommand}` : requestedCommand;
|
|
802
|
+
return this.formatAsCallToolResult(`Command not found: ${commandFullName}`);
|
|
768
803
|
}
|
|
769
|
-
const result = JSON.stringify(
|
|
770
|
-
|
|
771
|
-
commands: commandsInfo
|
|
772
|
-
}, null, 2);
|
|
773
|
-
this.logger.debug(`[MCP-DEBUG] Successfully retrieved commands info. Total: ${commandsInfo.length}`);
|
|
804
|
+
const result = JSON.stringify(commandInfo, null, 2);
|
|
805
|
+
this.logger.debug(`[MCP-DEBUG] Successfully retrieved command help for: ${commandInfo.name}`);
|
|
774
806
|
return this.formatAsCallToolResult(result);
|
|
775
807
|
} catch (error) {
|
|
776
|
-
this.logger.error(`[MCP-DEBUG] Error in
|
|
777
|
-
return this.formatErrorAsCallToolResult(error, 'getting
|
|
808
|
+
this.logger.error(`[MCP-DEBUG] Error in bit_command_help tool: ${error.message}`);
|
|
809
|
+
return this.formatErrorAsCallToolResult(error, 'getting command help');
|
|
778
810
|
}
|
|
779
811
|
});
|
|
780
812
|
}
|
|
@@ -828,21 +860,30 @@ class CliMcpServerMain {
|
|
|
828
860
|
}
|
|
829
861
|
registerExecuteTool(server) {
|
|
830
862
|
const toolName = 'bit_execute';
|
|
831
|
-
const description = 'Execute
|
|
863
|
+
const description = 'Execute Bit commands that make changes to workspace or components (not read-only).';
|
|
832
864
|
const schema = {
|
|
833
865
|
cwd: _zod().z.string().describe('Path to workspace directory'),
|
|
834
|
-
command: _zod().z.string().describe('The Bit command to execute (e.g., "
|
|
866
|
+
command: _zod().z.string().describe('The Bit command to execute (e.g., "import", "tag", "export", "remove")'),
|
|
835
867
|
args: _zod().z.array(_zod().z.string()).optional().describe('Arguments to pass to the command'),
|
|
836
868
|
flags: _zod().z.record(_zod().z.union([_zod().z.string(), _zod().z.boolean()])).optional().describe('Flags to pass to the command as key-value pairs')
|
|
837
869
|
};
|
|
838
870
|
server.tool(toolName, description, schema, async params => {
|
|
839
871
|
try {
|
|
840
|
-
|
|
872
|
+
let {
|
|
841
873
|
command,
|
|
842
|
-
args = []
|
|
874
|
+
args = []
|
|
875
|
+
} = params;
|
|
876
|
+
const {
|
|
843
877
|
flags = {},
|
|
844
878
|
cwd
|
|
845
879
|
} = params;
|
|
880
|
+
|
|
881
|
+
// Handle sub-commands: if command has multiple words, move the second word to args
|
|
882
|
+
const commandParts = command.trim().split(/\s+/);
|
|
883
|
+
if (commandParts.length > 1) {
|
|
884
|
+
command = commandParts[0];
|
|
885
|
+
args = [commandParts[1], ...args];
|
|
886
|
+
}
|
|
846
887
|
this.logger.debug(`[MCP-DEBUG] Executing command: ${command} with args: ${JSON.stringify(args)} and flags: ${JSON.stringify(flags)}`);
|
|
847
888
|
const result = await this.callBitServerAPI(command, args, flags, cwd);
|
|
848
889
|
return this.formatAsCallToolResult(result);
|
|
@@ -965,10 +1006,37 @@ class CliMcpServerMain {
|
|
|
965
1006
|
}
|
|
966
1007
|
}
|
|
967
1008
|
}
|
|
1009
|
+
|
|
1010
|
+
// Setup command business logic methods
|
|
1011
|
+
getEditorDisplayName(editor) {
|
|
1012
|
+
return _setupUtils().McpSetupUtils.getEditorDisplayName(editor);
|
|
1013
|
+
}
|
|
1014
|
+
async setupEditor(editor, options, workspaceDir) {
|
|
1015
|
+
const supportedEditors = ['vscode', 'cursor', 'windsurf'];
|
|
1016
|
+
const editorLower = editor.toLowerCase();
|
|
1017
|
+
if (!supportedEditors.includes(editorLower)) {
|
|
1018
|
+
throw new Error(`Editor "${editor}" is not supported yet. Currently supported: ${supportedEditors.join(', ')}`);
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
// Add workspaceDir to options if provided
|
|
1022
|
+
const setupOptions = _objectSpread({}, options);
|
|
1023
|
+
if (workspaceDir) {
|
|
1024
|
+
setupOptions.workspaceDir = workspaceDir;
|
|
1025
|
+
}
|
|
1026
|
+
if (editorLower === 'vscode') {
|
|
1027
|
+
await _setupUtils().McpSetupUtils.setupVSCode(setupOptions);
|
|
1028
|
+
} else if (editorLower === 'cursor') {
|
|
1029
|
+
await _setupUtils().McpSetupUtils.setupCursor(setupOptions);
|
|
1030
|
+
} else if (editorLower === 'windsurf') {
|
|
1031
|
+
await _setupUtils().McpSetupUtils.setupWindsurf(setupOptions);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
968
1034
|
static async provider([cli, loggerMain]) {
|
|
969
1035
|
const logger = loggerMain.createLogger(_cliMcpServer().CliMcpServerAspect.id);
|
|
970
1036
|
const mcpServer = new CliMcpServerMain(cli, logger);
|
|
971
|
-
|
|
1037
|
+
const mcpServerCmd = new (_mcpServer().McpServerCmd)(mcpServer);
|
|
1038
|
+
mcpServerCmd.commands = [new (_mcpServer().McpStartCmd)(mcpServer), new (_setupCmd().McpSetupCmd)(mcpServer)];
|
|
1039
|
+
cli.register(mcpServerCmd);
|
|
972
1040
|
return mcpServer;
|
|
973
1041
|
}
|
|
974
1042
|
}
|