@teambit/cli-mcp-server 0.0.0-00149e000ea14bbdcb0391c0d576b4a2b40f8cde

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.
@@ -0,0 +1,117 @@
1
+ # Bit CLI MCP Server
2
+
3
+ The Bit CLI MCP Server provides a [Model Context Protocol (MCP)](https://github.com/modelcontextprotocol/mcp) interface to Bit's command-line functionality. It acts as a bridge between MCP clients (such as VS Code, AI tools, or your own applications) and the Bit CLI, enabling programmatic access to Bit workspace and component management operations.
4
+
5
+ ## Setup
6
+
7
+ ### Installation
8
+
9
+ The Bit CLI MCP Server is included with Bit. To set it up with your IDE, run:
10
+
11
+ ```bash
12
+ # Basic setup for VS Code (default)
13
+ bit mcp-server setup
14
+
15
+ # Other supported editors
16
+ bit mcp-server setup [vscode|cursor|windsurf|roo|cline|claude-code]
17
+
18
+ # For consumer projects (non-Bit workspaces that only consume Bit components)
19
+ bit mcp-server setup --consumer-project
20
+ ```
21
+
22
+ #### Recommended Setup Steps
23
+
24
+ After installation, consider these helpful setup steps:
25
+
26
+ 1. **For new workspaces**: Set your default scope so the search tool knows which organization to search:
27
+
28
+ ```bash
29
+ bit scope set <your-org.your-scope>
30
+ ```
31
+
32
+ 2. **Generate rules/instructions** (if you haven't already):
33
+
34
+ ```bash
35
+ bit mcp-server rules
36
+ ```
37
+
38
+ This provides the AI agent with comprehensive guidance about Bit and MCP server functionality.
39
+
40
+ 3. **VS Code users**: Make sure to select "agent" mode instead of "ask" mode in the chat interface. For first-time users, open the command palette and search for "MCP: List servers" to find and start the Bit server.
41
+
42
+ ### Manual Configuration
43
+
44
+ For IDEs not supported by the automatic setup, add this MCP server configuration:
45
+
46
+ ```json
47
+ {
48
+ "servers": {
49
+ "bit-cli": {
50
+ "type": "stdio",
51
+ "command": "bit",
52
+ "args": ["mcp-server", "start"]
53
+ }
54
+ }
55
+ }
56
+ ```
57
+
58
+ ### Configuration Options
59
+
60
+ - `--global`: Apply configuration globally (user settings) instead of workspace settings
61
+ - `--consumer-project`: For non-Bit workspaces that only consume Bit components as packages
62
+ - `--include-additional <commands>`: Add specific commands to the available tools (comma-separated list)
63
+
64
+ ## Usage
65
+
66
+ ### Running the Server
67
+
68
+ To manually start the server:
69
+
70
+ ```bash
71
+ bit mcp-server start [options]
72
+ ```
73
+
74
+ Options:
75
+
76
+ - `--consumer-project`: For non-Bit workspaces that only consume Bit component packages
77
+ - `--include-additional <commands>`: Add specific commands to the available tools (comma-separated list)
78
+
79
+ ### Generating AI Rules
80
+
81
+ Create instruction files for AI assistants:
82
+
83
+ ```bash
84
+ bit mcp-server rules [vscode|cursor|windsurf|roo|cline|claude-code] [options]
85
+ ```
86
+
87
+ Options:
88
+
89
+ - `--global`: Write rules to global configuration
90
+ - `--consumer-project`: Generate rules for consumer projects
91
+ - `--print`: Print rules content to screen
92
+
93
+ ## Available Tools
94
+
95
+ The Bit CLI MCP Server operates in two modes and provides several specialized tools:
96
+
97
+ ### Default Mode
98
+
99
+ In default mode, the server exposes a minimal set of essential tools focused on core functionality:
100
+
101
+ - `bit_remote_search`: Search for components with automatic organization detection from workspace's defaultScope (e.g., "teambit" from "teambit.defender"). Executes multiple queries in parallel and deduplicates results. Use arrays of related terms or synonyms for better results.
102
+ - `bit_workspace_info`: Get comprehensive workspace information by combining multiple data sources (status, components, apps, templates, dependency graph). Includes current lane information.
103
+ - `bit_component_details`: Get detailed information about multiple components in parallel (up to 5 max to prevent context overload). Includes documentation from .docs.mdx files, example usage from composition files, and optionally the component's public API schema with exported functions/types. Returns partial results with detailed failure information if some components fail.
104
+ - `bit_create`: Create components using templates with batch support. Supports multiple component names in single call and extensive configuration options (namespace, scope, environment). Validates template existence and prevents conflicts.
105
+ - `bit_query`: Execute read-only Bit commands from a curated whitelist of safe commands (status, list, show, info, diff, log, graph, etc.). Prevents accidental workspace modifications.
106
+ - `bit_execute`: Execute any Bit command including those that modify workspace state. Use with caution as it allows all operations including destructive ones.
107
+ - `bit_commands_list`: Get all available Bit commands with descriptions, grouping, and subcommand discovery for comprehensive command exploration.
108
+ - `bit_command_help`: Get detailed help for specific commands including arguments metadata, flag types, usage examples, and subcommand relationships.
109
+
110
+ > **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.
111
+
112
+ ### Consumer Project Mode (--consumer-project)
113
+
114
+ For projects that consume Bit components as packages but aren't Bit workspaces:
115
+
116
+ - `bit_remote_search`: Search for components across all organizations available to the logged-in user (requires `bit login`). Executes multiple queries in parallel and deduplicates results.
117
+ - `bit_remote_component_details`: Get comprehensive remote component information by combining show and schema commands. Gracefully handles schema failures while providing basic component details.
@@ -0,0 +1,117 @@
1
+ # Bit CLI MCP Server
2
+
3
+ The Bit CLI MCP Server provides a [Model Context Protocol (MCP)](https://github.com/modelcontextprotocol/mcp) interface to Bit's command-line functionality. It acts as a bridge between MCP clients (such as VS Code, AI tools, or your own applications) and the Bit CLI, enabling programmatic access to Bit workspace and component management operations.
4
+
5
+ ## Setup
6
+
7
+ ### Installation
8
+
9
+ The Bit CLI MCP Server is included with Bit. To set it up with your IDE, run:
10
+
11
+ ```bash
12
+ # Basic setup for VS Code (default)
13
+ bit mcp-server setup
14
+
15
+ # Other supported editors
16
+ bit mcp-server setup [vscode|cursor|windsurf|roo|cline|claude-code]
17
+
18
+ # For consumer projects (non-Bit workspaces that only consume Bit components)
19
+ bit mcp-server setup --consumer-project
20
+ ```
21
+
22
+ #### Recommended Setup Steps
23
+
24
+ After installation, consider these helpful setup steps:
25
+
26
+ 1. **For new workspaces**: Set your default scope so the search tool knows which organization to search:
27
+
28
+ ```bash
29
+ bit scope set <your-org.your-scope>
30
+ ```
31
+
32
+ 2. **Generate rules/instructions** (if you haven't already):
33
+
34
+ ```bash
35
+ bit mcp-server rules
36
+ ```
37
+
38
+ This provides the AI agent with comprehensive guidance about Bit and MCP server functionality.
39
+
40
+ 3. **VS Code users**: Make sure to select "agent" mode instead of "ask" mode in the chat interface. For first-time users, open the command palette and search for "MCP: List servers" to find and start the Bit server.
41
+
42
+ ### Manual Configuration
43
+
44
+ For IDEs not supported by the automatic setup, add this MCP server configuration:
45
+
46
+ ```json
47
+ {
48
+ "servers": {
49
+ "bit-cli": {
50
+ "type": "stdio",
51
+ "command": "bit",
52
+ "args": ["mcp-server", "start"]
53
+ }
54
+ }
55
+ }
56
+ ```
57
+
58
+ ### Configuration Options
59
+
60
+ - `--global`: Apply configuration globally (user settings) instead of workspace settings
61
+ - `--consumer-project`: For non-Bit workspaces that only consume Bit components as packages
62
+ - `--include-additional <commands>`: Add specific commands to the available tools (comma-separated list)
63
+
64
+ ## Usage
65
+
66
+ ### Running the Server
67
+
68
+ To manually start the server:
69
+
70
+ ```bash
71
+ bit mcp-server start [options]
72
+ ```
73
+
74
+ Options:
75
+
76
+ - `--consumer-project`: For non-Bit workspaces that only consume Bit component packages
77
+ - `--include-additional <commands>`: Add specific commands to the available tools (comma-separated list)
78
+
79
+ ### Generating AI Rules
80
+
81
+ Create instruction files for AI assistants:
82
+
83
+ ```bash
84
+ bit mcp-server rules [vscode|cursor|windsurf|roo|cline|claude-code] [options]
85
+ ```
86
+
87
+ Options:
88
+
89
+ - `--global`: Write rules to global configuration
90
+ - `--consumer-project`: Generate rules for consumer projects
91
+ - `--print`: Print rules content to screen
92
+
93
+ ## Available Tools
94
+
95
+ The Bit CLI MCP Server operates in two modes and provides several specialized tools:
96
+
97
+ ### Default Mode
98
+
99
+ In default mode, the server exposes a minimal set of essential tools focused on core functionality:
100
+
101
+ - `bit_remote_search`: Search for components with automatic organization detection from workspace's defaultScope (e.g., "teambit" from "teambit.defender"). Executes multiple queries in parallel and deduplicates results. Use arrays of related terms or synonyms for better results.
102
+ - `bit_workspace_info`: Get comprehensive workspace information by combining multiple data sources (status, components, apps, templates, dependency graph). Includes current lane information.
103
+ - `bit_component_details`: Get detailed information about multiple components in parallel (up to 5 max to prevent context overload). Includes documentation from .docs.mdx files, example usage from composition files, and optionally the component's public API schema with exported functions/types. Returns partial results with detailed failure information if some components fail.
104
+ - `bit_create`: Create components using templates with batch support. Supports multiple component names in single call and extensive configuration options (namespace, scope, environment). Validates template existence and prevents conflicts.
105
+ - `bit_query`: Execute read-only Bit commands from a curated whitelist of safe commands (status, list, show, info, diff, log, graph, etc.). Prevents accidental workspace modifications.
106
+ - `bit_execute`: Execute any Bit command including those that modify workspace state. Use with caution as it allows all operations including destructive ones.
107
+ - `bit_commands_list`: Get all available Bit commands with descriptions, grouping, and subcommand discovery for comprehensive command exploration.
108
+ - `bit_command_help`: Get detailed help for specific commands including arguments metadata, flag types, usage examples, and subcommand relationships.
109
+
110
+ > **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.
111
+
112
+ ### Consumer Project Mode (--consumer-project)
113
+
114
+ For projects that consume Bit components as packages but aren't Bit workspaces:
115
+
116
+ - `bit_remote_search`: Search for components across all organizations available to the logged-in user (requires `bit login`). Executes multiple queries in parallel and deduplicates results.
117
+ - `bit_remote_component_details`: Get comprehensive remote component information by combining show and schema commands. Gracefully handles schema failures while providing basic component details.
@@ -0,0 +1,2 @@
1
+ import { Aspect } from '@teambit/harmony';
2
+ export declare const CliMcpServerAspect: Aspect;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CliMcpServerAspect = void 0;
7
+ function _harmony() {
8
+ const data = require("@teambit/harmony");
9
+ _harmony = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ const CliMcpServerAspect = exports.CliMcpServerAspect = _harmony().Aspect.create({
15
+ id: 'teambit.mcp/cli-mcp-server'
16
+ });
17
+
18
+ //# sourceMappingURL=cli-mcp-server.aspect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_harmony","data","require","CliMcpServerAspect","exports","Aspect","create","id"],"sources":["cli-mcp-server.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const CliMcpServerAspect = Aspect.create({\n id: 'teambit.mcp/cli-mcp-server',\n});\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAGE,iBAAM,CAACC,MAAM,CAAC;EAC9CC,EAAE,EAAE;AACN,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,123 @@
1
+ import type { CLIMain } from '@teambit/cli';
2
+ import type { Logger, LoggerMain } from '@teambit/logger';
3
+ import { Http } from '@teambit/scope.network';
4
+ import type { SetupOptions, RulesOptions } from '@teambit/mcp.mcp-config-writer';
5
+ export declare class CliMcpServerMain {
6
+ private cli;
7
+ private logger;
8
+ private bitBin;
9
+ private _http;
10
+ private isConsumerProjectMode;
11
+ private serverPort?;
12
+ private serverUrl?;
13
+ private serverToken?;
14
+ private serverProcess;
15
+ private serverInitPromise?;
16
+ private readonly readOnlyCommands;
17
+ constructor(cli: CLIMain, logger: Logger);
18
+ getHttp(): Promise<Http>;
19
+ /**
20
+ * Discover or spawn a bit-server, then read its bearer token. Concurrent
21
+ * callers share a single in-flight promise so they can't race each other
22
+ * into spawning duplicate servers (which would otherwise overwrite the
23
+ * shared `server-token.txt`).
24
+ */
25
+ private ensureBitServer;
26
+ private getBitServerPort;
27
+ /**
28
+ * Build the URL used to dial the local bit-server. Mirrors the api-server's
29
+ * bind host: `BIT_SERVER_HOST` lets hosted environments (e.g. cloud
30
+ * workspaces) reach bit-server on a non-loopback interface. `0.0.0.0` /
31
+ * `::` are bind-only wildcards (not valid destinations) so dial loopback
32
+ * instead; raw IPv6 addresses get bracketed for URL safety.
33
+ */
34
+ private buildServerUrl;
35
+ /**
36
+ * Read the bearer token written by bit-server (1.13.166+) for authenticating
37
+ * to the local HTTP API. Returns undefined for older bit-server versions
38
+ * that don't write a token file (no auth required), or when the workspace
39
+ * has no scope yet. Other read errors (EACCES, etc.) surface so the user
40
+ * sees the real cause instead of a misleading 401.
41
+ */
42
+ private getBitServerToken;
43
+ /**
44
+ * Start a new bit-server process
45
+ */
46
+ private startBitServer;
47
+ /**
48
+ * Call bit-server API endpoint using cli-raw route
49
+ */
50
+ private callBitServerAPI;
51
+ /**
52
+ * Call bit-server API endpoint using IDE route
53
+ */
54
+ private callBitServerIDEAPI;
55
+ /**
56
+ * Generic method to call bit-server API with different routes
57
+ */
58
+ private callBitServerAPIWithRoute;
59
+ runMcpServer(options: {
60
+ includeAdditional?: string;
61
+ bitBin?: string;
62
+ consumerProject?: boolean;
63
+ }): Promise<void>;
64
+ private shouldIncludeCommand;
65
+ private buildZodSchema;
66
+ private buildCommandArgs;
67
+ private getToolName;
68
+ private registerToolForCommand;
69
+ /**
70
+ * Read and parse workspace.jsonc file from a given directory
71
+ */
72
+ private readWorkspaceJsonc;
73
+ /**
74
+ * Extract owner from defaultScope in workspace.jsonc
75
+ * If defaultScope contains a dot, split by dot and take the first part
76
+ */
77
+ private extractOwnerFromWorkspace;
78
+ private registerRemoteSearchTool;
79
+ private registerRemoteComponentDetailsTool;
80
+ private registerWorkspaceInfoTool;
81
+ private registerComponentDetailsTool;
82
+ private registerCreateTool;
83
+ private registerCommandsListTool;
84
+ private registerCommandHelpTool;
85
+ private registerQueryTool;
86
+ private registerExecuteTool;
87
+ private processSubCommands;
88
+ private runBit;
89
+ /**
90
+ * Helper method to execute a bit-server API call with standardized error handling
91
+ */
92
+ private executeBitServerCommand;
93
+ /**
94
+ * Helper method to format any result as CallToolResult
95
+ */
96
+ private formatAsCallToolResult;
97
+ /**
98
+ * Helper method to format error as CallToolResult
99
+ */
100
+ private formatErrorAsCallToolResult;
101
+ /**
102
+ * Helper method to safely execute a bit command with error handling
103
+ */
104
+ private safeBitCommandExecution;
105
+ private validateBitBin;
106
+ getEditorDisplayName(editor: string): string;
107
+ /**
108
+ * Get the path to the editor config file based on editor type and scope
109
+ */
110
+ getEditorConfigPath(editor: string, isGlobal: boolean, workspaceDir?: string): string;
111
+ setupEditor(editor: string, options: SetupOptions, workspaceDir?: string): Promise<void>;
112
+ writeRulesFile(editor: string, options: RulesOptions, workspaceDir?: string): Promise<void>;
113
+ getRulesContent(consumerProject?: boolean, forceStandard?: boolean): Promise<string>;
114
+ /**
115
+ * Get the path to the rules file based on editor type and scope
116
+ */
117
+ getRulesFilePath(editor: string, isGlobal: boolean, workspaceDir?: string): string;
118
+ static slots: never[];
119
+ static dependencies: import("@teambit/harmony").Aspect[];
120
+ static runtime: import("@teambit/harmony").RuntimeDefinition;
121
+ static provider([cli, loggerMain]: [CLIMain, LoggerMain]): Promise<CliMcpServerMain>;
122
+ }
123
+ export default CliMcpServerMain;