Overview
Bazel MCP Server is a local server that exposes the functionality of the Bazel build system to MCP-enabled AI agents, facilitating the use of Bazel in environments lacking a command-line tool or with misconfigured shells.
To use the Bazel MCP Server, you can either integrate it with tools like Cursor or Claude Desktop by adding specific configurations, or run it directly from GitHub without installation using the command: npx -y github:nacgarg/bazel-mcp-server.
- Build specified Bazel targets with
bazel_build_target- Query dependency graphs withbazel_query_target- Run tests for specified targets withbazel_test_target- List all available targets withbazel_list_targets- Fetch external dependencies withbazel_fetch_dependencies- Change workspace path at runtime withbazel_set_workspace_path
- Enabling Bazel functionality in AI agents without direct command-line access.
- Facilitating builds and tests in environments with misconfigured shells.
- Providing a local server for Bazel commands in various development setups.
Add to your AI client
Use these steps to connect Bazel MCP Server in Cursor, Claude, VS Code, and other MCP-compatible apps. The same JSON appears in the Use with menu above for one-click copy.
Cursor
Add this to your .cursor/mcp.json file in your project root, then restart Cursor.
.cursor/mcp.json
{
"mcpServers": {
"bazel-mcp-server-nacgarg": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-bazel-mcp-server-nacgarg"
]
}
}
}Claude Desktop
Add this server entry to the mcpServers object in your Claude Desktop config, then restart the app.
~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
{
"mcpServers": {
"bazel-mcp-server-nacgarg": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-bazel-mcp-server-nacgarg"
]
}
}
}Claude Code
Add this to your project's .mcp.json file. Claude Code will detect it automatically.
.mcp.json (project root)
{
"mcpServers": {
"bazel-mcp-server-nacgarg": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-bazel-mcp-server-nacgarg"
]
}
}
}VS Code (Copilot)
Add this to your .vscode/mcp.json file. Requires the GitHub Copilot extension with MCP support enabled.
.vscode/mcp.json
{
"servers": {
"bazel-mcp-server-nacgarg": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-bazel-mcp-server-nacgarg"
]
}
}
}Windsurf
Add this to your Windsurf MCP config file, then restart Windsurf.
~/.codeium/windsurf/mcp_config.json
{
"mcpServers": {
"bazel-mcp-server-nacgarg": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-bazel-mcp-server-nacgarg"
]
}
}
}Cline
Open Cline settings, navigate to MCP Servers, and add this server configuration.
Cline MCP Settings (via UI)
{
"mcpServers": {
"bazel-mcp-server-nacgarg": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-bazel-mcp-server-nacgarg"
]
}
}
}FAQ
Can I run Bazel MCP Server without installation?
Yes! You can run it directly using `npx` command.
What if I need to specify the Bazel binary path?
You can provide the path using the `--bazel_path` flag in your configuration.
Is there a way to enable verbose logging?
Yes, set the `DEBUG=true` environment variable to enable verbose logging.7:["$","div",null,{"className":"container mx-auto flex flex-col gap-4","children":["$L26","$L27",["$","$L28",null,{"currentProject":{"id":2219,"uuid":"99254bb6-fcfa-4a4a-975c-c76087b5c0f9","name":"bazel-mcp-server","title":"Bazel MCP Server","description":"MCP server for Bazel","avatar_url":"https://avatars.githubusercontent.com/u/8907939?v=4","created_at":"2025-03-09T04:23:26.159Z","updated_at":"2025-03-12T10:20:32.095Z","status":"created","author_name":"nacgarg","author_avatar_url":"https://avatars.githubusercontent.com/u/8907939?v=4","tags":"[]","category":"developer-tools","is_featured":false,"sort":1,"url":"https://github.com/nacgarg/bazel-mcp-server","target":"_self","content":"$29","summary":"$2a","img_url":null,"type":null,"metadata":"{\"star\":\"0\",\"license\":\"MIT license\",\"language\":\"JavaScript\",\"is_official\":false,\"latest_commit_time\":\"2025-03-07 01:08:38\"}","user_uuid":null,"tools":null,"sse_url":null,"sse_provider":null,"sse_params":null,"is_official":false,"server_command":null,"server_params":null,"server_config":null,"allow_call":false,"is_innovation":false,"is_dxt":false,"dxt_manifest":null,"dxt_file_url":null,"is_audit":false},"randomProjects":[],"currentServerKey":"$undefined"}]]}]