Skip to main content
The W&B MCP (Model Context Protocol) server lets you query and analyze your W&B data from your IDE or MCP client. It also provides your client with programmatic access to W&B’s documentation, giving it additional context and accuracy when generating responses to W&B-related queries. Use can it to analyze experiments, debug traces, create reports, and get help with integrating your applications with W&B features.

Prerequisites

  • Get your W&B API key from wandb.ai/authorize.
  • Set your key as an environment variable named WANDB_API_KEY.

Configure your MCP client to use the W&B’s remote MCP server

W&B provides a hosted MCP server at https://mcp.withwandb.com that requires no installation. The following instructions show how to configure the hosted server with various AI assistants and IDEs.
  1. On macOS, open the Cursor menu, select Settings, and then select Cursor Settings. One Windows or Linux, open the Preferences menu, select Settings, and then select Cursor Settings.
  2. From the Cursor Settings menu, select Tools and MCP. This opens the Tools menu.
  3. In the Installed MCP Servers section, select Add Custom MCP. This opens the mcp.json configuration file.
  4. In the configuration file, in the mcpServers JSON object, add the following wandb object, like this:
{
  "mcpServers": {
    "wandb": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/wandb/wandb-mcp-server",
        "wandb_mcp_server"
      ],
      "env": {
        "WANDB_API_KEY": "${WANDB_API_KEY}"
      }
    }
  }
}
  1. Restart Cursor to make the changes take effect.
  2. Verify that the chat agent has access to the W&B MCP server by telling it to, “List the projects in my W&B account.”
For more detailed information, see Cursor’s documentation.

Set up a local version of the W&B MCP server

If you need to run the MCP server locally for development, testing, or air-gapped environments, you can install and run it on your machine.

Prerequisites

  • Python 3.10 or higher
  • uv (recommended) or pip
To install uv, run the following cURL command:
curl -LsSf https://astral.sh/uv/install.sh | sh

Install the W&B MCP server on your local machine

To install the W&B MCP server on your local machine:
  1. run one of the following commands:
uv install wandb-mcp-server
  1. Once you have successfully installed the server, add the following JSON object to your MCP client configuration:
{
  "mcpServers": {
    "wandb": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/wandb/wandb-mcp-server",
        "wandb_mcp_server"
      ],
      "env": {
        "WANDB_API_KEY": "YOUR_API_KEY"
      }
    }
  }
}
The code tells your MCP client, such as Cursor, to use the local W&B MCP server instead of the server hosted by W&B at https://mcp.withwandb.com/mcp.
  1. For web-based clients or testing, run the server with HTTP transport:
uvx wandb_mcp_server --transport http --host 0.0.0.0 --port 8080
To expose the local server to external clients like OpenAI, use ngrok:
# Start the HTTP server
uvx wandb-mcp-server --transport http --port 8080

# In another terminal, expose with ngrok
ngrok http 8080
If you expose the server using ngrok, update your MCP client configuration to use the ngrok URL.

Usage tips

  • Provide your W&B project and entity name: Specify the W&B entity and project in your queries for accurate results.
  • Avoid overly broad questions: Instead of “what is my best evaluation?”, ask “what eval had the highest f1 score?”
  • Verify data retrieval: When asking broad questions like “what are my best performing runs?”, ask the assistant to confirm it retrieved all available runs.