Back to Bit

Bit CLI MCP Server

scopes/mcp/cli-mcp-server/README.docs.mdx

14.8.9-server.15.2 KB
Original Source

Bit CLI MCP Server

The Bit CLI MCP Server provides a Model Context Protocol (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.

Setup

Installation

The Bit CLI MCP Server is included with Bit. To set it up with your IDE, run:

bash
# Basic setup for VS Code (default)
bit mcp-server setup

# Other supported editors
bit mcp-server setup [vscode|cursor|windsurf|roo|cline|claude-code]

# For consumer projects (non-Bit workspaces that only consume Bit components)
bit mcp-server setup --consumer-project

Recommended Setup Steps

After installation, consider these helpful setup steps:

  1. For new workspaces: Set your default scope so the search tool knows which organization to search:

    bash
    bit scope set <your-org.your-scope>
    
  2. Generate rules/instructions (if you haven't already):

    bash
    bit mcp-server rules
    

    This provides the AI agent with comprehensive guidance about Bit and MCP server functionality.

  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.

Manual Configuration

For IDEs not supported by the automatic setup, add this MCP server configuration:

json
{
  "servers": {
    "bit-cli": {
      "type": "stdio",
      "command": "bit",
      "args": ["mcp-server", "start"]
    }
  }
}

Configuration Options

  • --global: Apply configuration globally (user settings) instead of workspace settings
  • --consumer-project: For non-Bit workspaces that only consume Bit components as packages
  • --include-additional <commands>: Add specific commands to the available tools (comma-separated list)

Usage

Running the Server

To manually start the server:

bash
bit mcp-server start [options]

Options:

  • --consumer-project: For non-Bit workspaces that only consume Bit component packages
  • --include-additional <commands>: Add specific commands to the available tools (comma-separated list)

Generating AI Rules

Create instruction files for AI assistants:

bash
bit mcp-server rules [vscode|cursor|windsurf|roo|cline|claude-code] [options]

Options:

  • --global: Write rules to global configuration
  • --consumer-project: Generate rules for consumer projects
  • --print: Print rules content to screen

Available Tools

The Bit CLI MCP Server operates in two modes and provides several specialized tools:

Default Mode

In default mode, the server exposes a minimal set of essential tools focused on core functionality:

  • 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.
  • bit_workspace_info: Get comprehensive workspace information by combining multiple data sources (status, components, apps, templates, dependency graph). Includes current lane information.
  • 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.
  • 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.
  • 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.
  • bit_execute: Execute any Bit command including those that modify workspace state. Use with caution as it allows all operations including destructive ones.
  • bit_commands_list: Get all available Bit commands with descriptions, grouping, and subcommand discovery for comprehensive command exploration.
  • bit_command_help: Get detailed help for specific commands including arguments metadata, flag types, usage examples, and subcommand relationships.

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.

Consumer Project Mode (--consumer-project)

For projects that consume Bit components as packages but aren't Bit workspaces:

  • 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.
  • bit_remote_component_details: Get comprehensive remote component information by combining show and schema commands. Gracefully handles schema failures while providing basic component details.