@teambit/cli-mcp-server 0.0.17 → 0.0.19
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 +60 -44
- package/bit-rules-consumer-template.md +11 -0
- package/bit-rules-template.md +108 -0
- package/dist/README.docs.mdx +60 -44
- package/dist/bit-rules-consumer-template.md +11 -0
- package/dist/bit-rules-template.md +108 -0
- package/dist/cli-mcp-server.main.runtime.d.ts +4 -4
- package/dist/cli-mcp-server.main.runtime.js +93 -49
- package/dist/cli-mcp-server.main.runtime.js.map +1 -1
- package/dist/cli-mcp-server.spec.js +68 -11
- package/dist/cli-mcp-server.spec.js.map +1 -1
- package/dist/mcp-server.cmd.d.ts +0 -3
- package/dist/mcp-server.cmd.js +2 -2
- package/dist/mcp-server.cmd.js.map +1 -1
- package/dist/{preview-1749525637445.js → preview-1749698416924.js} +1 -1
- package/dist/rules-cmd.d.ts +20 -0
- package/dist/rules-cmd.js +62 -0
- package/dist/rules-cmd.js.map +1 -0
- package/dist/setup-cmd.d.ts +1 -4
- package/dist/setup-cmd.js +1 -7
- package/dist/setup-cmd.js.map +1 -1
- package/dist/setup-utils.d.ts +28 -3
- package/dist/setup-utils.js +93 -14
- package/dist/setup-utils.js.map +1 -1
- package/package.json +8 -8
package/README.docs.mdx
CHANGED
|
@@ -18,7 +18,7 @@ This server acts as a bridge between MCP clients (such as VS Code, AI tools, or
|
|
|
18
18
|
The Bit CLI MCP Server is included with Bit. If you have Bit installed, you can run the server using:
|
|
19
19
|
|
|
20
20
|
```
|
|
21
|
-
bit mcp-server
|
|
21
|
+
bit mcp-server start
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
## Usage
|
|
@@ -26,16 +26,13 @@ bit mcp-server
|
|
|
26
26
|
### Command-Line Options
|
|
27
27
|
|
|
28
28
|
```
|
|
29
|
-
bit mcp-server [options]
|
|
29
|
+
bit mcp-server start [options]
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
Options:
|
|
33
33
|
|
|
34
|
-
-
|
|
35
|
-
- `--consumer-project`: For non-Bit workspaces that only consume Bit component packages. Enables only "schema", "show", and "remote-search" tools and automatically adds the "--remote" flag to relevant commands.
|
|
36
|
-
- `--include-only <commands>`: Specify a subset of commands to expose as MCP tools (comma-separated list)
|
|
34
|
+
- `--consumer-project`: For non-Bit workspaces that only consume Bit component packages. Enables only "bit_remote_search" and "bit_remote_component_details" tools and automatically adds the "--remote" flag to relevant commands.
|
|
37
35
|
- `--include-additional <commands>`: Add specific commands to the available tools (comma-separated list)
|
|
38
|
-
- `--exclude <commands>`: Prevent specific commands from being exposed (comma-separated list)
|
|
39
36
|
|
|
40
37
|
### Integrating with IDEs
|
|
41
38
|
|
|
@@ -67,11 +64,8 @@ This command automatically configures the MCP server settings in your chosen edi
|
|
|
67
64
|
#### Configuration Options
|
|
68
65
|
|
|
69
66
|
- `--global`: Apply configuration globally (user settings) instead of workspace settings
|
|
70
|
-
- `--extended`: Configure with extended mode enabled
|
|
71
67
|
- `--consumer-project`: Configure for consumer projects
|
|
72
|
-
- `--include-only <commands>`: Specify subset of commands to expose
|
|
73
68
|
- `--include-additional <commands>`: Add specific commands to the available tools
|
|
74
|
-
- `--exclude <commands>`: Prevent specific commands from being exposed
|
|
75
69
|
|
|
76
70
|
#### Examples
|
|
77
71
|
|
|
@@ -79,11 +73,11 @@ This command automatically configures the MCP server settings in your chosen edi
|
|
|
79
73
|
# Basic VS Code setup (workspace level)
|
|
80
74
|
bit mcp-server setup
|
|
81
75
|
|
|
82
|
-
# Global setup for Cursor
|
|
83
|
-
bit mcp-server setup cursor --global
|
|
76
|
+
# Global setup for Cursor
|
|
77
|
+
bit mcp-server setup cursor --global
|
|
84
78
|
|
|
85
|
-
# Setup
|
|
86
|
-
bit mcp-server setup
|
|
79
|
+
# Setup with consumer project mode
|
|
80
|
+
bit mcp-server setup --consumer-project
|
|
87
81
|
```
|
|
88
82
|
|
|
89
83
|
#### Manual Configuration
|
|
@@ -99,7 +93,7 @@ If you need to manually configure the settings, here's a basic example for VS Co
|
|
|
99
93
|
"servers": {
|
|
100
94
|
"bit-cli": {
|
|
101
95
|
"command": "bit",
|
|
102
|
-
"args": ["mcp-server"]
|
|
96
|
+
"args": ["mcp-server", "start"]
|
|
103
97
|
}
|
|
104
98
|
}
|
|
105
99
|
}
|
|
@@ -112,7 +106,7 @@ If you need to manually configure the settings, here's a basic example for VS Co
|
|
|
112
106
|
import { McpClient } from '@modelcontextprotocol/sdk/client';
|
|
113
107
|
|
|
114
108
|
async function example() {
|
|
115
|
-
const client = await McpClient.spawn('bit', ['mcp-server']);
|
|
109
|
+
const client = await McpClient.spawn('bit', ['mcp-server', 'start']);
|
|
116
110
|
|
|
117
111
|
// Call a Bit CLI tool via MCP
|
|
118
112
|
const result = await client.callTool('bit_status', { cwd: '/path/to/workspace' });
|
|
@@ -125,7 +119,7 @@ async function example() {
|
|
|
125
119
|
|
|
126
120
|
## Available Tools
|
|
127
121
|
|
|
128
|
-
The Bit CLI MCP Server operates in
|
|
122
|
+
The Bit CLI MCP Server operates in two modes and provides several specialized tools:
|
|
129
123
|
|
|
130
124
|
### Default Mode
|
|
131
125
|
|
|
@@ -147,29 +141,16 @@ In default mode, the server exposes a minimal set of essential tools focused on
|
|
|
147
141
|
|
|
148
142
|
This mode is designed for applications or projects that are not Bit workspaces but need to consume or work with Bit components as packages. It provides a minimal set of tools focused on component discovery and information:
|
|
149
143
|
|
|
150
|
-
- `
|
|
151
|
-
- `
|
|
144
|
+
- `bit_remote_search`: Search for components in remote scopes
|
|
145
|
+
- `bit_remote_component_details`: Get detailed information about a remote component including basic info and its public API schema (combines the functionality of show and schema commands)
|
|
152
146
|
|
|
153
147
|
In this mode:
|
|
154
148
|
|
|
155
149
|
1. You don't need a Bit workspace initialization
|
|
156
|
-
2.
|
|
157
|
-
3. The `
|
|
158
|
-
4.
|
|
159
|
-
|
|
160
|
-
### Extended Mode (--extended)
|
|
161
|
-
|
|
162
|
-
When started with the `--extended` flag, the server exposes nearly all Bit CLI commands as MCP tools, including:
|
|
163
|
-
|
|
164
|
-
- All lane sub-commands (remove, alias, rename, diff, change-scope, import, fetch, eject, history, etc.)
|
|
165
|
-
- Development tools (build, lint, format)
|
|
166
|
-
- Package management (uninstall, update)
|
|
167
|
-
- Component operations (recover, fork, rename)
|
|
168
|
-
- Workspace management (ws-config, stash, aspect)
|
|
169
|
-
- Analysis tools (insight, deps, why)
|
|
170
|
-
- And many more
|
|
171
|
-
|
|
172
|
-
> **Note:** When using extended mode, some AI models (particularly Gemini and ChatGPT) may struggle with the high number of available tools and respond with "400 Bad Request" or "500 Server Error" errors. This is not due to any issue with specific tools, but rather with how these models handle large tool sets. Claude Sonnet tends to handle extended mode better. If you encounter these errors, try using default mode or selectively adding only the tools you need via the `--include-additional` flag.
|
|
150
|
+
2. Only these 2 tools are available (no workspace-specific tools)
|
|
151
|
+
3. The `--remote` flag is automatically added to component detail queries
|
|
152
|
+
4. The `cwd` parameter is still required but can be any directory (not necessarily a Bit workspace)
|
|
153
|
+
5. You can still add additional tools with the `--include-additional` flag
|
|
173
154
|
|
|
174
155
|
## Tool Parameters
|
|
175
156
|
|
|
@@ -187,21 +168,56 @@ Example tool call for `bit_status`:
|
|
|
187
168
|
|
|
188
169
|
## Custom Tool Selection
|
|
189
170
|
|
|
190
|
-
To customize the available tools
|
|
171
|
+
To customize the available tools:
|
|
191
172
|
|
|
192
173
|
```
|
|
193
|
-
# Include only specific tools
|
|
194
|
-
bit mcp-server --include-only "status,show,tag,snap,import,export"
|
|
195
|
-
|
|
196
174
|
# Add specific tools to the available tools
|
|
197
|
-
bit mcp-server --include-additional "build,lint,format,create,schema"
|
|
175
|
+
bit mcp-server start --include-additional "build,lint,format,create,schema"
|
|
198
176
|
|
|
199
177
|
# For consumer projects (non-Bit workspaces)
|
|
200
|
-
bit mcp-server --consumer-project
|
|
178
|
+
bit mcp-server start --consumer-project
|
|
201
179
|
|
|
202
180
|
# Add specific tools to the consumer project set
|
|
203
|
-
bit mcp-server --consumer-project --include-additional "deps,get,preview"
|
|
181
|
+
bit mcp-server start --consumer-project --include-additional "deps,get,preview"
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Writing AI Assistant Rules
|
|
185
|
+
|
|
186
|
+
The MCP server provides a `rules` command to create instruction files for AI assistants:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
bit mcp-server rules [vscode|cursor|windsurf] [options]
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
This command creates rules/instructions markdown files that provide guidance to AI assistants on how to effectively use the Bit MCP server and follow best practices when working with Bit components.
|
|
193
|
+
|
|
194
|
+
#### Supported Editors
|
|
195
|
+
|
|
196
|
+
- **VS Code**: `bit mcp-server rules vscode` (or just `bit mcp-server rules`)
|
|
197
|
+
- **Cursor**: `bit mcp-server rules cursor`
|
|
198
|
+
- **Windsurf**: `bit mcp-server rules windsurf`
|
|
199
|
+
|
|
200
|
+
#### Configuration Options
|
|
201
|
+
|
|
202
|
+
- `--global`: Write rules to global configuration (default: workspace-specific)
|
|
203
|
+
- `--print`: Print rules content to screen instead of writing to file
|
|
204
|
+
- `--consumer-project`: Generate rules for consumer projects that only use Bit components as packages
|
|
205
|
+
|
|
206
|
+
#### Examples
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
# Basic VS Code rules (workspace level)
|
|
210
|
+
bit mcp-server rules
|
|
211
|
+
|
|
212
|
+
# Global rules for Cursor
|
|
213
|
+
bit mcp-server rules cursor --global
|
|
214
|
+
|
|
215
|
+
# Consumer project rules for VS Code
|
|
216
|
+
bit mcp-server rules --consumer-project
|
|
217
|
+
|
|
218
|
+
# Print rules content to screen for manual setup
|
|
219
|
+
bit mcp-server rules --print
|
|
204
220
|
|
|
205
|
-
#
|
|
206
|
-
bit mcp-server --
|
|
221
|
+
# Print consumer project content for Windsurf (requires manual addition to .windsurfrules)
|
|
222
|
+
bit mcp-server rules windsurf --print --consumer-project
|
|
207
223
|
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: '**'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## How to Install Use and Bit Components
|
|
6
|
+
|
|
7
|
+
- Bit Components are reusable pieces of code in the form of node packages.
|
|
8
|
+
- Search for Bit Components using `bit_remote_search` tool.
|
|
9
|
+
- Use `bit_show` only on Bit Components to get information like package name (to use when installing, e.g. `npm install <package-name>`), APIs and documentation (to use when using in code).
|
|
10
|
+
- If a user is requesting functionality, you can search if there are available components that implement it using `bit_remote_search`.
|
|
11
|
+
- Filter my search with my account name "ACCOUNT" to find components you have created or are a maintainer of.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: '**'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Bit MCP Agent Instructions
|
|
6
|
+
|
|
7
|
+
## Core Objectives
|
|
8
|
+
|
|
9
|
+
- Your goal is to efficiently automate Bit workflows and help users manage and reuse components.
|
|
10
|
+
- You will achieve this by using the provided MCP tools and adhering strictly to the following rules and workflows.
|
|
11
|
+
|
|
12
|
+
## Critical Rules of Engagement - do these steps before any tool or command execution!!!
|
|
13
|
+
|
|
14
|
+
1. **Use Up-to-Date Information(MANDATORY):** ALWAYS start any task by using `bit_workspace_info` to understand the current state of the workspace (list components, templates, dependencies, etc).
|
|
15
|
+
2. **MCP Tools First:** You MUST use the provided MCP tools to interact with Bit. Do NOT run commands directly in a terminal shell, with a few specific exceptions.
|
|
16
|
+
3. **Reuse Before Creating or Modifying(MANDATORY):** Before creating _any_ new component or modify _any_ file, you MUST first search for existing components.
|
|
17
|
+
- Use `bit_workspace_info` to check for local and existing components.
|
|
18
|
+
- Use `bit_remote_search` to find components on the remote scope.
|
|
19
|
+
- Present findings to the user, even if you think creating a new component is simpler.
|
|
20
|
+
4. **Do not rely on cached knowledge:** Always run `bit_command_help` for command details.
|
|
21
|
+
5. **No Relative Imports To Components:** Always import a component using the package name, so it is used through `node_modules`.
|
|
22
|
+
6. **Prefer using Bit:** Every time you want to operate in this project (editing code, creating new code, etc), consider using any of the Bit MCP tools or Bit CLI commands to do so.
|
|
23
|
+
7. **Prioritize creating Bit components and composing over adding functionality to existing components:** New functionality should be a dependency, unless the user specifically asks for a new functionality added to an existing component.
|
|
24
|
+
8. **Use the `bit_commands_list` to understand available commands:** This will help you decide which command to use for a specific operation.
|
|
25
|
+
9. **User may use different terms to describe components:** Be flexible and understand that users may refer to components as "features", "apps", "modules", "pages" or "services". Always clarify with the user what they mean.
|
|
26
|
+
|
|
27
|
+
## Tooling & Command Execution Hierarchy
|
|
28
|
+
|
|
29
|
+
This is the decision-making process for executing any Bit operation.
|
|
30
|
+
|
|
31
|
+
### Step 1: Choose the Correct Generic Execution Tool
|
|
32
|
+
|
|
33
|
+
- If no dedicated tool exists, you must use one of the generic execution tools. Use the `bit_commands_list` output to help you decide:
|
|
34
|
+
- **For Read-Only Operations, use `bit_query`**: Use this for operations that inspect state but do not change the workspace.
|
|
35
|
+
- **For Write Operations, use `bit_execute`**: Use this for operations that modify the workspace, components, or dependencies.
|
|
36
|
+
|
|
37
|
+
### Step 2: Check for Terminal Exceptions
|
|
38
|
+
|
|
39
|
+
- The following commands have rich, interactive, or streaming output and should be run directly in the user's terminal. You should construct the command and advise the user to run it.
|
|
40
|
+
- `bit test`
|
|
41
|
+
- `bit build`
|
|
42
|
+
- `bit start` (long-running processes)
|
|
43
|
+
- `bit watch` (long-running processes)
|
|
44
|
+
- `bit lint`
|
|
45
|
+
- `bit check-types`
|
|
46
|
+
- `bit run` (long-running processes)
|
|
47
|
+
|
|
48
|
+
## Core Workflows
|
|
49
|
+
|
|
50
|
+
### Workflow: Error Diagnosis in a Bit Workspace
|
|
51
|
+
|
|
52
|
+
- `bit_workspace_info` with the "warnings" option to detect errors. Output includes possible solutions, follow them.
|
|
53
|
+
- Rerun `bit_workspace_info` to validate fixes. If error persists, use `bit_component_details` on relevant component(s) for more information.
|
|
54
|
+
|
|
55
|
+
### Workflow: In-Component Code Issues
|
|
56
|
+
|
|
57
|
+
- For code issues (compile, lint, test, type checking), run the relevant terminal command and pass the component ID (e.g. `bit test COMPONENT_ID`).
|
|
58
|
+
- To get complete report for code issues on all components, do not provide component ID (e.g. `bit test`).
|
|
59
|
+
- Adding `--log` CLI option gives more details on errors.
|
|
60
|
+
|
|
61
|
+
### Workflow: Generating New Components, Feature or Apps
|
|
62
|
+
|
|
63
|
+
- **Follow Critical Rule #3 Reuse Before Creating or Modifying.**
|
|
64
|
+
- `bit_workspace_info` lists templates for new components.
|
|
65
|
+
- If a new component is necessary, clarify the TEMPLATE and combination of NAMESPACE(s) (optional) and NAME with the user.
|
|
66
|
+
- Run `bit_component_details` on new components gives information on them, this is useful for making code changes or composing the component into another (as a dependency).
|
|
67
|
+
- After generating a new component, ask if to add implementation to the new component and remember to update all relevant files (e.g. `*.composition.*`, `*.docs.mdx`, `*.spec.*`).
|
|
68
|
+
|
|
69
|
+
### Workflow: Adding Functionality (feature, page, module, function, etc) to Bit Components and Apps
|
|
70
|
+
|
|
71
|
+
- **Follow Critical Rule #3 Reuse Before Creating.**
|
|
72
|
+
- If a potentially reusable component is found, use it as a dependency in the component you want to modify.
|
|
73
|
+
**Hint:** use `bit_component_details` to get API references and documentation.
|
|
74
|
+
**Follow Critical Rule #5 No Relative Imports Between Components**.
|
|
75
|
+
- Validate with user if they want the new functionality to be in a new component before generating any code in any component.
|
|
76
|
+
- If need to create a new component, clarify the TEMPLATE and combination of NAMESPACE(s) (optional) and NAME with the user.
|
|
77
|
+
- After modifying component implementation, always consider updating the following component files `*.composition.*`, `*.docs.mdx`, `*.spec.*`.
|
|
78
|
+
|
|
79
|
+
### Workflow: USE or DEVELOP a Component
|
|
80
|
+
|
|
81
|
+
- Use `bit_component_details` to get the component location.
|
|
82
|
+
- If the component is not in the workspace, and you want to USE it as a dependency, you must first install it (then you can infer to it by its package name).
|
|
83
|
+
- If the component is not in the workspace, and you want to DEVELOP it (modify its source), you must first import it.
|
|
84
|
+
|
|
85
|
+
### Workflow: Collaboration, Change Management and Version Control
|
|
86
|
+
|
|
87
|
+
- Bit uses a concept called "Lanes" to manage changes across components, this is similar to Git branches.
|
|
88
|
+
- Use `bit_workspace_info` to identify the current active lane.
|
|
89
|
+
- You must not snap or export components directly to the `main` lane.
|
|
90
|
+
- Use `bit_execute` for "Bit Lane" commands.
|
|
91
|
+
- If not already on a suitable development lane, suggest a name for the new lane to be created and validate with the user.
|
|
92
|
+
- The workspace automatically switches to a new lane once created.
|
|
93
|
+
- It is good practice to validate code before taking a snapshot (`bit lint`, `bit test`, `bit check-types`).
|
|
94
|
+
- Take a snapshot of all components with a relevant message (similar to `git commit`).
|
|
95
|
+
- Export the snap to the remote scope for review and collaboration (similar to `git push`).
|
|
96
|
+
|
|
97
|
+
## Glossary
|
|
98
|
+
|
|
99
|
+
- **Bit Component:** An extensible, portable software container. Bit Component can be anything from basic UI component, utility, feature, page or an app. Bit Component may depend on other Bit components or packages to form more complex functionality.
|
|
100
|
+
- **Workspace:** A Bit-initialized directory containing components.
|
|
101
|
+
- **Scope:** A collaboration server for components that defines ownership.
|
|
102
|
+
- **Application (App):** A Bit Component with its own runtime. It is usually composed from various features and components.
|
|
103
|
+
- **Development Environment (Env):** A component that bundles development tools (compiler, tester, etc.).
|
|
104
|
+
- **Lane:** A mechanism for managing and releasing modifications across components. `main` is the default lane. Lane is similar in concept to a Git Branch.
|
|
105
|
+
|
|
106
|
+
## Pointers to remember:
|
|
107
|
+
|
|
108
|
+
- For generating ESlint or TypeScript configuration files execute the command `bit workspace-config write --clean`
|
package/dist/README.docs.mdx
CHANGED
|
@@ -18,7 +18,7 @@ This server acts as a bridge between MCP clients (such as VS Code, AI tools, or
|
|
|
18
18
|
The Bit CLI MCP Server is included with Bit. If you have Bit installed, you can run the server using:
|
|
19
19
|
|
|
20
20
|
```
|
|
21
|
-
bit mcp-server
|
|
21
|
+
bit mcp-server start
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
## Usage
|
|
@@ -26,16 +26,13 @@ bit mcp-server
|
|
|
26
26
|
### Command-Line Options
|
|
27
27
|
|
|
28
28
|
```
|
|
29
|
-
bit mcp-server [options]
|
|
29
|
+
bit mcp-server start [options]
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
Options:
|
|
33
33
|
|
|
34
|
-
-
|
|
35
|
-
- `--consumer-project`: For non-Bit workspaces that only consume Bit component packages. Enables only "schema", "show", and "remote-search" tools and automatically adds the "--remote" flag to relevant commands.
|
|
36
|
-
- `--include-only <commands>`: Specify a subset of commands to expose as MCP tools (comma-separated list)
|
|
34
|
+
- `--consumer-project`: For non-Bit workspaces that only consume Bit component packages. Enables only "bit_remote_search" and "bit_remote_component_details" tools and automatically adds the "--remote" flag to relevant commands.
|
|
37
35
|
- `--include-additional <commands>`: Add specific commands to the available tools (comma-separated list)
|
|
38
|
-
- `--exclude <commands>`: Prevent specific commands from being exposed (comma-separated list)
|
|
39
36
|
|
|
40
37
|
### Integrating with IDEs
|
|
41
38
|
|
|
@@ -67,11 +64,8 @@ This command automatically configures the MCP server settings in your chosen edi
|
|
|
67
64
|
#### Configuration Options
|
|
68
65
|
|
|
69
66
|
- `--global`: Apply configuration globally (user settings) instead of workspace settings
|
|
70
|
-
- `--extended`: Configure with extended mode enabled
|
|
71
67
|
- `--consumer-project`: Configure for consumer projects
|
|
72
|
-
- `--include-only <commands>`: Specify subset of commands to expose
|
|
73
68
|
- `--include-additional <commands>`: Add specific commands to the available tools
|
|
74
|
-
- `--exclude <commands>`: Prevent specific commands from being exposed
|
|
75
69
|
|
|
76
70
|
#### Examples
|
|
77
71
|
|
|
@@ -79,11 +73,11 @@ This command automatically configures the MCP server settings in your chosen edi
|
|
|
79
73
|
# Basic VS Code setup (workspace level)
|
|
80
74
|
bit mcp-server setup
|
|
81
75
|
|
|
82
|
-
# Global setup for Cursor
|
|
83
|
-
bit mcp-server setup cursor --global
|
|
76
|
+
# Global setup for Cursor
|
|
77
|
+
bit mcp-server setup cursor --global
|
|
84
78
|
|
|
85
|
-
# Setup
|
|
86
|
-
bit mcp-server setup
|
|
79
|
+
# Setup with consumer project mode
|
|
80
|
+
bit mcp-server setup --consumer-project
|
|
87
81
|
```
|
|
88
82
|
|
|
89
83
|
#### Manual Configuration
|
|
@@ -99,7 +93,7 @@ If you need to manually configure the settings, here's a basic example for VS Co
|
|
|
99
93
|
"servers": {
|
|
100
94
|
"bit-cli": {
|
|
101
95
|
"command": "bit",
|
|
102
|
-
"args": ["mcp-server"]
|
|
96
|
+
"args": ["mcp-server", "start"]
|
|
103
97
|
}
|
|
104
98
|
}
|
|
105
99
|
}
|
|
@@ -112,7 +106,7 @@ If you need to manually configure the settings, here's a basic example for VS Co
|
|
|
112
106
|
import { McpClient } from '@modelcontextprotocol/sdk/client';
|
|
113
107
|
|
|
114
108
|
async function example() {
|
|
115
|
-
const client = await McpClient.spawn('bit', ['mcp-server']);
|
|
109
|
+
const client = await McpClient.spawn('bit', ['mcp-server', 'start']);
|
|
116
110
|
|
|
117
111
|
// Call a Bit CLI tool via MCP
|
|
118
112
|
const result = await client.callTool('bit_status', { cwd: '/path/to/workspace' });
|
|
@@ -125,7 +119,7 @@ async function example() {
|
|
|
125
119
|
|
|
126
120
|
## Available Tools
|
|
127
121
|
|
|
128
|
-
The Bit CLI MCP Server operates in
|
|
122
|
+
The Bit CLI MCP Server operates in two modes and provides several specialized tools:
|
|
129
123
|
|
|
130
124
|
### Default Mode
|
|
131
125
|
|
|
@@ -147,29 +141,16 @@ In default mode, the server exposes a minimal set of essential tools focused on
|
|
|
147
141
|
|
|
148
142
|
This mode is designed for applications or projects that are not Bit workspaces but need to consume or work with Bit components as packages. It provides a minimal set of tools focused on component discovery and information:
|
|
149
143
|
|
|
150
|
-
- `
|
|
151
|
-
- `
|
|
144
|
+
- `bit_remote_search`: Search for components in remote scopes
|
|
145
|
+
- `bit_remote_component_details`: Get detailed information about a remote component including basic info and its public API schema (combines the functionality of show and schema commands)
|
|
152
146
|
|
|
153
147
|
In this mode:
|
|
154
148
|
|
|
155
149
|
1. You don't need a Bit workspace initialization
|
|
156
|
-
2.
|
|
157
|
-
3. The `
|
|
158
|
-
4.
|
|
159
|
-
|
|
160
|
-
### Extended Mode (--extended)
|
|
161
|
-
|
|
162
|
-
When started with the `--extended` flag, the server exposes nearly all Bit CLI commands as MCP tools, including:
|
|
163
|
-
|
|
164
|
-
- All lane sub-commands (remove, alias, rename, diff, change-scope, import, fetch, eject, history, etc.)
|
|
165
|
-
- Development tools (build, lint, format)
|
|
166
|
-
- Package management (uninstall, update)
|
|
167
|
-
- Component operations (recover, fork, rename)
|
|
168
|
-
- Workspace management (ws-config, stash, aspect)
|
|
169
|
-
- Analysis tools (insight, deps, why)
|
|
170
|
-
- And many more
|
|
171
|
-
|
|
172
|
-
> **Note:** When using extended mode, some AI models (particularly Gemini and ChatGPT) may struggle with the high number of available tools and respond with "400 Bad Request" or "500 Server Error" errors. This is not due to any issue with specific tools, but rather with how these models handle large tool sets. Claude Sonnet tends to handle extended mode better. If you encounter these errors, try using default mode or selectively adding only the tools you need via the `--include-additional` flag.
|
|
150
|
+
2. Only these 2 tools are available (no workspace-specific tools)
|
|
151
|
+
3. The `--remote` flag is automatically added to component detail queries
|
|
152
|
+
4. The `cwd` parameter is still required but can be any directory (not necessarily a Bit workspace)
|
|
153
|
+
5. You can still add additional tools with the `--include-additional` flag
|
|
173
154
|
|
|
174
155
|
## Tool Parameters
|
|
175
156
|
|
|
@@ -187,21 +168,56 @@ Example tool call for `bit_status`:
|
|
|
187
168
|
|
|
188
169
|
## Custom Tool Selection
|
|
189
170
|
|
|
190
|
-
To customize the available tools
|
|
171
|
+
To customize the available tools:
|
|
191
172
|
|
|
192
173
|
```
|
|
193
|
-
# Include only specific tools
|
|
194
|
-
bit mcp-server --include-only "status,show,tag,snap,import,export"
|
|
195
|
-
|
|
196
174
|
# Add specific tools to the available tools
|
|
197
|
-
bit mcp-server --include-additional "build,lint,format,create,schema"
|
|
175
|
+
bit mcp-server start --include-additional "build,lint,format,create,schema"
|
|
198
176
|
|
|
199
177
|
# For consumer projects (non-Bit workspaces)
|
|
200
|
-
bit mcp-server --consumer-project
|
|
178
|
+
bit mcp-server start --consumer-project
|
|
201
179
|
|
|
202
180
|
# Add specific tools to the consumer project set
|
|
203
|
-
bit mcp-server --consumer-project --include-additional "deps,get,preview"
|
|
181
|
+
bit mcp-server start --consumer-project --include-additional "deps,get,preview"
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Writing AI Assistant Rules
|
|
185
|
+
|
|
186
|
+
The MCP server provides a `rules` command to create instruction files for AI assistants:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
bit mcp-server rules [vscode|cursor|windsurf] [options]
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
This command creates rules/instructions markdown files that provide guidance to AI assistants on how to effectively use the Bit MCP server and follow best practices when working with Bit components.
|
|
193
|
+
|
|
194
|
+
#### Supported Editors
|
|
195
|
+
|
|
196
|
+
- **VS Code**: `bit mcp-server rules vscode` (or just `bit mcp-server rules`)
|
|
197
|
+
- **Cursor**: `bit mcp-server rules cursor`
|
|
198
|
+
- **Windsurf**: `bit mcp-server rules windsurf`
|
|
199
|
+
|
|
200
|
+
#### Configuration Options
|
|
201
|
+
|
|
202
|
+
- `--global`: Write rules to global configuration (default: workspace-specific)
|
|
203
|
+
- `--print`: Print rules content to screen instead of writing to file
|
|
204
|
+
- `--consumer-project`: Generate rules for consumer projects that only use Bit components as packages
|
|
205
|
+
|
|
206
|
+
#### Examples
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
# Basic VS Code rules (workspace level)
|
|
210
|
+
bit mcp-server rules
|
|
211
|
+
|
|
212
|
+
# Global rules for Cursor
|
|
213
|
+
bit mcp-server rules cursor --global
|
|
214
|
+
|
|
215
|
+
# Consumer project rules for VS Code
|
|
216
|
+
bit mcp-server rules --consumer-project
|
|
217
|
+
|
|
218
|
+
# Print rules content to screen for manual setup
|
|
219
|
+
bit mcp-server rules --print
|
|
204
220
|
|
|
205
|
-
#
|
|
206
|
-
bit mcp-server --
|
|
221
|
+
# Print consumer project content for Windsurf (requires manual addition to .windsurfrules)
|
|
222
|
+
bit mcp-server rules windsurf --print --consumer-project
|
|
207
223
|
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: '**'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## How to Install Use and Bit Components
|
|
6
|
+
|
|
7
|
+
- Bit Components are reusable pieces of code in the form of node packages.
|
|
8
|
+
- Search for Bit Components using `bit_remote_search` tool.
|
|
9
|
+
- Use `bit_show` only on Bit Components to get information like package name (to use when installing, e.g. `npm install <package-name>`), APIs and documentation (to use when using in code).
|
|
10
|
+
- If a user is requesting functionality, you can search if there are available components that implement it using `bit_remote_search`.
|
|
11
|
+
- Filter my search with my account name "ACCOUNT" to find components you have created or are a maintainer of.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: '**'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Bit MCP Agent Instructions
|
|
6
|
+
|
|
7
|
+
## Core Objectives
|
|
8
|
+
|
|
9
|
+
- Your goal is to efficiently automate Bit workflows and help users manage and reuse components.
|
|
10
|
+
- You will achieve this by using the provided MCP tools and adhering strictly to the following rules and workflows.
|
|
11
|
+
|
|
12
|
+
## Critical Rules of Engagement - do these steps before any tool or command execution!!!
|
|
13
|
+
|
|
14
|
+
1. **Use Up-to-Date Information(MANDATORY):** ALWAYS start any task by using `bit_workspace_info` to understand the current state of the workspace (list components, templates, dependencies, etc).
|
|
15
|
+
2. **MCP Tools First:** You MUST use the provided MCP tools to interact with Bit. Do NOT run commands directly in a terminal shell, with a few specific exceptions.
|
|
16
|
+
3. **Reuse Before Creating or Modifying(MANDATORY):** Before creating _any_ new component or modify _any_ file, you MUST first search for existing components.
|
|
17
|
+
- Use `bit_workspace_info` to check for local and existing components.
|
|
18
|
+
- Use `bit_remote_search` to find components on the remote scope.
|
|
19
|
+
- Present findings to the user, even if you think creating a new component is simpler.
|
|
20
|
+
4. **Do not rely on cached knowledge:** Always run `bit_command_help` for command details.
|
|
21
|
+
5. **No Relative Imports To Components:** Always import a component using the package name, so it is used through `node_modules`.
|
|
22
|
+
6. **Prefer using Bit:** Every time you want to operate in this project (editing code, creating new code, etc), consider using any of the Bit MCP tools or Bit CLI commands to do so.
|
|
23
|
+
7. **Prioritize creating Bit components and composing over adding functionality to existing components:** New functionality should be a dependency, unless the user specifically asks for a new functionality added to an existing component.
|
|
24
|
+
8. **Use the `bit_commands_list` to understand available commands:** This will help you decide which command to use for a specific operation.
|
|
25
|
+
9. **User may use different terms to describe components:** Be flexible and understand that users may refer to components as "features", "apps", "modules", "pages" or "services". Always clarify with the user what they mean.
|
|
26
|
+
|
|
27
|
+
## Tooling & Command Execution Hierarchy
|
|
28
|
+
|
|
29
|
+
This is the decision-making process for executing any Bit operation.
|
|
30
|
+
|
|
31
|
+
### Step 1: Choose the Correct Generic Execution Tool
|
|
32
|
+
|
|
33
|
+
- If no dedicated tool exists, you must use one of the generic execution tools. Use the `bit_commands_list` output to help you decide:
|
|
34
|
+
- **For Read-Only Operations, use `bit_query`**: Use this for operations that inspect state but do not change the workspace.
|
|
35
|
+
- **For Write Operations, use `bit_execute`**: Use this for operations that modify the workspace, components, or dependencies.
|
|
36
|
+
|
|
37
|
+
### Step 2: Check for Terminal Exceptions
|
|
38
|
+
|
|
39
|
+
- The following commands have rich, interactive, or streaming output and should be run directly in the user's terminal. You should construct the command and advise the user to run it.
|
|
40
|
+
- `bit test`
|
|
41
|
+
- `bit build`
|
|
42
|
+
- `bit start` (long-running processes)
|
|
43
|
+
- `bit watch` (long-running processes)
|
|
44
|
+
- `bit lint`
|
|
45
|
+
- `bit check-types`
|
|
46
|
+
- `bit run` (long-running processes)
|
|
47
|
+
|
|
48
|
+
## Core Workflows
|
|
49
|
+
|
|
50
|
+
### Workflow: Error Diagnosis in a Bit Workspace
|
|
51
|
+
|
|
52
|
+
- `bit_workspace_info` with the "warnings" option to detect errors. Output includes possible solutions, follow them.
|
|
53
|
+
- Rerun `bit_workspace_info` to validate fixes. If error persists, use `bit_component_details` on relevant component(s) for more information.
|
|
54
|
+
|
|
55
|
+
### Workflow: In-Component Code Issues
|
|
56
|
+
|
|
57
|
+
- For code issues (compile, lint, test, type checking), run the relevant terminal command and pass the component ID (e.g. `bit test COMPONENT_ID`).
|
|
58
|
+
- To get complete report for code issues on all components, do not provide component ID (e.g. `bit test`).
|
|
59
|
+
- Adding `--log` CLI option gives more details on errors.
|
|
60
|
+
|
|
61
|
+
### Workflow: Generating New Components, Feature or Apps
|
|
62
|
+
|
|
63
|
+
- **Follow Critical Rule #3 Reuse Before Creating or Modifying.**
|
|
64
|
+
- `bit_workspace_info` lists templates for new components.
|
|
65
|
+
- If a new component is necessary, clarify the TEMPLATE and combination of NAMESPACE(s) (optional) and NAME with the user.
|
|
66
|
+
- Run `bit_component_details` on new components gives information on them, this is useful for making code changes or composing the component into another (as a dependency).
|
|
67
|
+
- After generating a new component, ask if to add implementation to the new component and remember to update all relevant files (e.g. `*.composition.*`, `*.docs.mdx`, `*.spec.*`).
|
|
68
|
+
|
|
69
|
+
### Workflow: Adding Functionality (feature, page, module, function, etc) to Bit Components and Apps
|
|
70
|
+
|
|
71
|
+
- **Follow Critical Rule #3 Reuse Before Creating.**
|
|
72
|
+
- If a potentially reusable component is found, use it as a dependency in the component you want to modify.
|
|
73
|
+
**Hint:** use `bit_component_details` to get API references and documentation.
|
|
74
|
+
**Follow Critical Rule #5 No Relative Imports Between Components**.
|
|
75
|
+
- Validate with user if they want the new functionality to be in a new component before generating any code in any component.
|
|
76
|
+
- If need to create a new component, clarify the TEMPLATE and combination of NAMESPACE(s) (optional) and NAME with the user.
|
|
77
|
+
- After modifying component implementation, always consider updating the following component files `*.composition.*`, `*.docs.mdx`, `*.spec.*`.
|
|
78
|
+
|
|
79
|
+
### Workflow: USE or DEVELOP a Component
|
|
80
|
+
|
|
81
|
+
- Use `bit_component_details` to get the component location.
|
|
82
|
+
- If the component is not in the workspace, and you want to USE it as a dependency, you must first install it (then you can infer to it by its package name).
|
|
83
|
+
- If the component is not in the workspace, and you want to DEVELOP it (modify its source), you must first import it.
|
|
84
|
+
|
|
85
|
+
### Workflow: Collaboration, Change Management and Version Control
|
|
86
|
+
|
|
87
|
+
- Bit uses a concept called "Lanes" to manage changes across components, this is similar to Git branches.
|
|
88
|
+
- Use `bit_workspace_info` to identify the current active lane.
|
|
89
|
+
- You must not snap or export components directly to the `main` lane.
|
|
90
|
+
- Use `bit_execute` for "Bit Lane" commands.
|
|
91
|
+
- If not already on a suitable development lane, suggest a name for the new lane to be created and validate with the user.
|
|
92
|
+
- The workspace automatically switches to a new lane once created.
|
|
93
|
+
- It is good practice to validate code before taking a snapshot (`bit lint`, `bit test`, `bit check-types`).
|
|
94
|
+
- Take a snapshot of all components with a relevant message (similar to `git commit`).
|
|
95
|
+
- Export the snap to the remote scope for review and collaboration (similar to `git push`).
|
|
96
|
+
|
|
97
|
+
## Glossary
|
|
98
|
+
|
|
99
|
+
- **Bit Component:** An extensible, portable software container. Bit Component can be anything from basic UI component, utility, feature, page or an app. Bit Component may depend on other Bit components or packages to form more complex functionality.
|
|
100
|
+
- **Workspace:** A Bit-initialized directory containing components.
|
|
101
|
+
- **Scope:** A collaboration server for components that defines ownership.
|
|
102
|
+
- **Application (App):** A Bit Component with its own runtime. It is usually composed from various features and components.
|
|
103
|
+
- **Development Environment (Env):** A component that bundles development tools (compiler, tester, etc.).
|
|
104
|
+
- **Lane:** A mechanism for managing and releasing modifications across components. `main` is the default lane. Lane is similar in concept to a Git Branch.
|
|
105
|
+
|
|
106
|
+
## Pointers to remember:
|
|
107
|
+
|
|
108
|
+
- For generating ESlint or TypeScript configuration files execute the command `bit workspace-config write --clean`
|
|
@@ -1,7 +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
|
+
import { SetupOptions, RulesOptions } from './setup-utils';
|
|
5
5
|
export declare class CliMcpServerMain {
|
|
6
6
|
private cli;
|
|
7
7
|
private logger;
|
|
@@ -32,10 +32,7 @@ export declare class CliMcpServerMain {
|
|
|
32
32
|
*/
|
|
33
33
|
private callBitServerAPIWithRoute;
|
|
34
34
|
runMcpServer(options: {
|
|
35
|
-
extended?: boolean;
|
|
36
|
-
includeOnly?: string;
|
|
37
35
|
includeAdditional?: string;
|
|
38
|
-
exclude?: string;
|
|
39
36
|
bitBin?: string;
|
|
40
37
|
consumerProject?: boolean;
|
|
41
38
|
}): Promise<void>;
|
|
@@ -54,6 +51,7 @@ export declare class CliMcpServerMain {
|
|
|
54
51
|
*/
|
|
55
52
|
private extractOwnerFromWorkspace;
|
|
56
53
|
private registerRemoteSearchTool;
|
|
54
|
+
private registerRemoteComponentDetailsTool;
|
|
57
55
|
private registerWorkspaceInfoTool;
|
|
58
56
|
private registerComponentDetailsTool;
|
|
59
57
|
private registerCommandsListTool;
|
|
@@ -80,6 +78,8 @@ export declare class CliMcpServerMain {
|
|
|
80
78
|
private safeBitCommandExecution;
|
|
81
79
|
getEditorDisplayName(editor: string): string;
|
|
82
80
|
setupEditor(editor: string, options: SetupOptions, workspaceDir?: string): Promise<void>;
|
|
81
|
+
writeRulesFile(editor: string, options: RulesOptions, workspaceDir?: string): Promise<void>;
|
|
82
|
+
getRulesContent(consumerProject?: boolean): Promise<string>;
|
|
83
83
|
static slots: never[];
|
|
84
84
|
static dependencies: import("@teambit/harmony").Aspect[];
|
|
85
85
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|