Skip to main content
OpenCode is an open-source AI coding assistant. The Braintrust MCP server integrates with OpenCode, giving it access to your Braintrust projects, experiments, and logs.

Setup

1

Install OpenCode

If you haven’t already, install OpenCode.
2

Add the Braintrust MCP server

Edit your OpenCode configuration file and add the Braintrust MCP server:
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "braintrust": {
      "type": "remote",
      "url": "https://api.braintrust.dev/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_BRAINTRUST_API_KEY"
      }
    }
  }
}
Replace YOUR_BRAINTRUST_API_KEY with your actual API key.
3

Restart OpenCode

Restart OpenCode to apply the configuration changes.

Usage

Once configured, OpenCode can access Braintrust data through the MCP server. You can fetch experiment results, query logs, log data, and more. See MCP documentation for details. Example prompts in OpenCode:
  • “Show me my recent Braintrust experiments”
  • “Query the last 10 logged requests with errors”
  • “What’s the average latency for the summarizer prompt today?”
  • “Compare costs between my GPT-4 and Claude experiments”

Troubleshooting

  • Verify the JSON configuration syntax is correct (no trailing commas, proper quotes)
  • Check that you’re editing the correct configuration file
  • Try restarting OpenCode completely
  • Consult the OpenCode config documentation for config file locations
  • Verify your API key is correct (no extra spaces or quotes)
  • Ensure you can log into Braintrust in your browser
  • Check that the Authorization header is properly formatted
  • Generate a new API key if needed
  • Verify the URL is exactly https://api.braintrust.dev/mcp (no trailing slash)
  • Check your internet connection
  • Corporate networks may need to allowlist api.braintrust.dev and *.braintrust.dev
  • Ensure the JSON file is valid (use a JSON validator)
  • Verify the $schema field is correct
  • Check file permissions
  • Look for error messages in OpenCode’s console or logs

Next steps