NiWaRe commited on
Commit
7b2da21
Β·
1 Parent(s): ef4e95e

fix tool issues and add quickstart

Browse files
README.md CHANGED
@@ -8,41 +8,139 @@ app_file: app.py
8
  pinned: false
9
  ---
10
 
11
- # Weights & Biases MCP Server on HuggingFace Spaces
 
 
 
 
 
 
12
 
13
- A [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server for querying [Weights & Biases](https://www.wandb.ai/) data, hosted on HuggingFace Spaces.
14
 
15
- This server allows MCP clients to:
16
- - πŸ“Š Query W&B Models runs and sweeps
17
- - πŸ” Query W&B Weave traces, evaluations and datasets
18
- - πŸ€– Query [wandbot](https://github.com/wandb/wandbot), the W&B support agent
19
- - πŸ“ Write text and charts to W&B Reports
20
 
21
- ## πŸš€ Quick Start - Use This Server Directly!
22
 
23
- ### No Setup Required! πŸŽ‰
 
 
 
 
24
 
25
- You can use this server immediately with your own W&B API key:
 
 
 
 
26
 
27
- 1. **Get your W&B API key** from [wandb.ai/authorize](https://wandb.ai/authorize)
28
- 2. **Configure your MCP client** with:
29
- - **Server URL**: `https://niware-wandb-mcp-server.hf.space/mcp`
30
- - **Authentication**: Your W&B API key as Bearer token
31
- 3. **Start querying** your W&B data!
 
 
 
 
 
 
32
 
33
- That's it! No server configuration, no duplication needed. Each user provides their own API key, ensuring secure access to their own W&B projects.
34
 
35
- ## πŸ–₯️ Using with MCP Clients
36
 
37
- ### Mistral LeChat
38
- 1. Go to Settings β†’ Custom MCP Connectors
39
- 2. Add a new connector:
40
- - **Server URL**: `https://niware-wandb-mcp-server.hf.space/mcp`
41
- - **Authentication**: Choose "API Key Authentication"
42
- - **API Key**: Your W&B API key from [wandb.ai/authorize](https://wandb.ai/authorize)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
- ### Cursor
45
- Add to `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):
46
  ```json
47
  {
48
  "mcpServers": {
@@ -58,81 +156,419 @@ Add to `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):
58
  }
59
  ```
60
 
61
- ### Claude Desktop / Claude Code
62
- Configure in your MCP settings with the server URL and Bearer token authentication.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
- ## πŸ”§ Available MCP Tools
 
 
 
 
 
 
 
65
 
66
- ### W&B Models
67
- - **`query_wandb_tool`**: Execute GraphQL queries against W&B experiment tracking data
 
 
 
 
68
 
69
- ### W&B Weave
70
- - **`query_weave_traces_tool`**: Query Weave evaluations and traces with filtering and pagination
71
- - **`count_weave_traces_tool`**: Count traces matching filters without returning data
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
- ### Support & Reports
74
- - **`query_wandb_support_bot`**: Get help from wandbot, the W&B support agent
75
- - **`create_wandb_report_tool`**: Create W&B Reports with markdown and visualizations
76
- - **`query_wandb_entity_projects`**: List available W&B entities and projects
77
 
78
- ## πŸ“ Example Queries
 
79
 
 
 
 
80
  ```
81
- How many openai.chat traces are in my wandb-team/my-project weave project?
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  ```
 
 
 
 
 
83
 
 
 
 
84
  ```
85
- Show me the latest 10 runs from my experiment tracking project and create a report with the results.
 
 
 
86
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  ```
89
- What's the best performing model in my latest sweep? Plot the results.
 
 
 
 
 
 
 
 
90
  ```
 
 
 
 
 
 
 
 
 
91
 
92
- ## πŸ’» Run Locally (Optional)
 
 
 
 
 
 
93
 
94
- Want to run your own instance or develop locally? Check out the main repository:
95
 
96
  ```bash
97
- # Install and run from source
98
  git clone https://github.com/wandb/wandb-mcp-server
99
  cd wandb-mcp-server
100
- uv run src/wandb_mcp_server/server.py --transport http
 
101
  ```
102
 
103
- See the [GitHub repository](https://github.com/wandb/wandb-mcp-server) for installation instructions for various MCP clients.
104
 
105
- ## πŸ” Troubleshooting
106
 
107
- ### Connection Issues?
108
- 1. **Verify your API key**: Ensure it's correctly copied from [wandb.ai/authorize](https://wandb.ai/authorize)
109
- 2. **Check the endpoint**: Must include `/mcp` suffix: `https://niware-wandb-mcp-server.hf.space/mcp`
110
- 3. **Headers required**: Include both `Authorization` and `Accept` headers as shown above
111
 
112
- ### Query Tips
113
- - Always specify your W&B entity and project name in queries
114
- - Be specific rather than overly broad in your questions
115
- - Verify you have access to the projects you're querying
116
 
117
- ## πŸ” Security
 
 
 
118
 
119
- - **Your API key is never stored** - It's only used transiently for your requests
120
- - **Each user is isolated** - Your key only accesses your W&B data
121
- - **No server configuration needed** - The server doesn't have its own W&B access
122
- - **Industry-standard Bearer tokens** - Same pattern as GitHub, OpenAI, etc.
123
 
124
- ## πŸ“š Resources
125
 
126
- - [Model Context Protocol Documentation](https://modelcontextprotocol.io/)
127
- - [Weights & Biases Documentation](https://docs.wandb.ai/)
128
- - [W&B Weave Documentation](https://weave-docs.wandb.ai/)
129
- - [Source Code Repository](https://github.com/wandb/wandb-mcp-server)
130
- - [Get Your W&B API Key](https://wandb.ai/authorize)
131
 
132
- ## πŸ“„ License
 
 
 
133
 
134
- This project is licensed under the MIT License. See the [GitHub repository](https://github.com/wandb/wandb-mcp-server) for details.
135
 
136
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
 
138
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
8
  pinned: false
9
  ---
10
 
11
+ <p align="center">
12
+ <picture>
13
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wandb/wandb/main/assets/logo-dark.svg">
14
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/wandb/wandb/main/assets/logo-light.svg">
15
+ <img src="https://raw.githubusercontent.com/wandb/wandb/main/assets/logo-light.svg" width="600" alt="Weights & Biases">
16
+ </picture>
17
+ </p>
18
 
19
+ # Weights & Biases MCP Server
20
 
21
+ A Model Context Protocol (MCP) server that provides seamless access to [Weights & Biases](https://www.wandb.ai/) for ML experiments and agent applications.
 
 
 
 
22
 
23
+ ## Example Use Cases
24
 
25
+ ### 1. πŸ” Analyze ML Experiments
26
+ ```
27
+ "Show me the top 5 runs with the highest accuracy from my wandb-smle/hiring-agent-demo-public project and create a report comparing their hyperparameters"
28
+ ```
29
+ The MCP server queries W&B runs, compares metrics, and generates a shareable report with visualizations.
30
 
31
+ ### 2. πŸ› Debug LLM Applications
32
+ ```
33
+ "Find all failed OpenAI chat traces in my weave project from the last 24 hours and analyze their error patterns"
34
+ ```
35
+ The server retrieves Weave traces, filters by status, and provides detailed error analysis for debugging.
36
 
37
+ ### 3. πŸ“Š Evaluate Model Performance
38
+ ```
39
+ "Compare the F1 scores across all evaluations in my RAG pipeline and identify which prompts performed best"
40
+ ```
41
+ The server queries Weave evaluations, aggregates scores, and highlights top-performing configurations.
42
+
43
+ ### 4. πŸ€– Get Expert Help with W&B/Weave
44
+ ```
45
+ "How do I implement custom metrics in Weave evaluations? Show me an example with async scorers"
46
+ ```
47
+ The integrated [wandbot](https://github.com/wandb/wandbot) support agent provides detailed answers, code examples, and debugging assistance for any W&B or Weave-related questions.
48
 
49
+ ## Deployment Options
50
 
51
+ This MCP server can be deployed in three ways:
52
 
53
+ ### 🌐 Option 1: Use the Hosted Server (Recommended)
54
+
55
+ Use our publicly hosted server on Hugging Face Spaces - no installation needed!
56
+
57
+ **Server URL:** `https://niware-wandb-mcp-server.hf.space/mcp`
58
+
59
+ Configure your MCP client to connect to the hosted server with your W&B API key as authentication. See the [Client Configuration](#mcp-client-configuration-for-hosted-server) section below for details.
60
+
61
+ ### πŸ’» Option 2: Local Development (STDIO)
62
+
63
+ Run the server locally with direct stdio communication - best for development and testing.
64
+
65
+ ### πŸ”Œ Option 3: Self-Hosted HTTP Server
66
+
67
+ Deploy your own HTTP server with API key authentication - great for team deployments or custom infrastructure.
68
+
69
+ ---
70
+
71
+ ## Installation
72
+
73
+ ### For Hosted Server Users
74
+
75
+ No installation needed! Skip to [Client Configuration](#mcp-client-configuration-for-hosted-server).
76
+
77
+ ### For Local Installation
78
+
79
+ These instructions are for running the MCP server locally (Options 2 & 3).
80
+
81
+ ### Prerequisites
82
+
83
+ #### 1. Install UV Package Manager
84
+
85
+ UV is required to run the MCP server. Install it using one of these methods:
86
+
87
+ **macOS/Linux:**
88
+ ```bash
89
+ curl -LsSf https://astral.sh/uv/install.sh | sh
90
+ ```
91
+
92
+ **macOS (Homebrew):**
93
+ ```bash
94
+ brew install uv
95
+ ```
96
+
97
+ **Windows:**
98
+ ```powershell
99
+ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
100
+ ```
101
+
102
+ #### 2. Get Your W&B API Key
103
+
104
+ You'll need a Weights & Biases API key. Get yours at: [https://wandb.ai/authorize](https://wandb.ai/authorize)
105
+
106
+ Configure your API key using one of these methods (first one recommended to have the other default parameters too):
107
+
108
+ 1. **`.env` file** in your project (copy from `env.example`):
109
+ ```bash
110
+ cp env.example .env
111
+ # Edit .env and add your API key
112
+ ```
113
+
114
+ 2. **`.netrc` file**:
115
+ ```bash
116
+ uvx wandb login
117
+ ```
118
+
119
+ 3. **Environment variable** (recommended):
120
+ ```bash
121
+ export WANDB_API_KEY=your-api-key
122
+ ```
123
+
124
+ 4. **Command-line argument**:
125
+ ```bash
126
+ wandb_mcp_server --wandb-api-key your-api-key
127
+ ```
128
+
129
+ #### 3. Environment Configuration (Optional)
130
+
131
+ The server includes [wandbot](https://github.com/wandb/wandbot) support for answering W&B/Weave questions. **wandbot works out-of-the-box without any configuration!** It uses the default public endpoint automatically.
132
+
133
+ See `env.example` for optional configuration like custom wandbot instances or other advanced settings.
134
+
135
+ ### MCP Client Configuration for Hosted Server
136
+
137
+ To use the hosted server, configure your MCP client with the following settings:
138
+
139
+ <details>
140
+ <summary><b>πŸ–±οΈ Cursor IDE (Hosted Server)</b></summary>
141
+
142
+ Add to `.cursor/mcp.json` or `~/.cursor/mcp.json`:
143
 
 
 
144
  ```json
145
  {
146
  "mcpServers": {
 
156
  }
157
  ```
158
 
159
+ Replace `YOUR_WANDB_API_KEY` with your actual W&B API key from [wandb.ai/authorize](https://wandb.ai/authorize).
160
+ </details>
161
+
162
+ <details>
163
+ <summary><b>🎨 Mistral LeChat (Hosted Server)</b></summary>
164
+
165
+ 1. Go to LeChat Settings β†’ Custom MCP Connectors
166
+ 2. Click "Add MCP Connector"
167
+ 3. Configure with:
168
+ - **Server URL**: `https://niware-wandb-mcp-server.hf.space/mcp`
169
+ - **Authentication**: Choose "API Key Authentication"
170
+ - **Token**: Enter your W&B API key
171
+ </details>
172
+
173
+ ### MCP Client Setup for Local Server
174
+
175
+ Choose your MCP client from the options below for local server setup:
176
+
177
+ <details>
178
+ <summary><b>πŸ–±οΈ Cursor IDE</b></summary>
179
+
180
+ **Quick Install (Project-specific):**
181
+ ```bash
182
+ uvx --from git+https://github.com/wandb/wandb-mcp-server -- add_to_client --config_path .cursor/mcp.json && uvx wandb login
183
+ ```
184
+
185
+ **Quick Install (Global):**
186
+ ```bash
187
+ uvx --from git+https://github.com/wandb/wandb-mcp-server -- add_to_client --config_path ~/.cursor/mcp.json && uvx wandb login
188
+ ```
189
+
190
+ <details>
191
+ <summary>Manual Configuration</summary>
192
+
193
+ Add to `.cursor/mcp.json` or `~/.cursor/mcp.json`:
194
+
195
+ ```json
196
+ {
197
+ "mcpServers": {
198
+ "wandb": {
199
+ "command": "uvx",
200
+ "args": [
201
+ "--from",
202
+ "git+https://github.com/wandb/wandb-mcp-server",
203
+ "wandb_mcp_server"
204
+ ],
205
+ "env": {
206
+ "WANDB_API_KEY": "your-api-key"
207
+ }
208
+ }
209
+ }
210
+ }
211
+ ```
212
+ </details>
213
+ </details>
214
+
215
+ <details>
216
+ <summary><b>🌊 Windsurf IDE</b></summary>
217
+
218
+ **Quick Install:**
219
+ ```bash
220
+ uvx --from git+https://github.com/wandb/wandb-mcp-server -- add_to_client --config_path ~/.codeium/windsurf/mcp_config.json && uvx wandb login
221
+ ```
222
+
223
+ <details>
224
+ <summary>Manual Configuration</summary>
225
+
226
+ Add to `~/.codeium/windsurf/mcp_config.json`:
227
+
228
+ ```json
229
+ {
230
+ "mcpServers": {
231
+ "wandb": {
232
+ "command": "uvx",
233
+ "args": [
234
+ "--from",
235
+ "git+https://github.com/wandb/wandb-mcp-server",
236
+ "wandb_mcp_server"
237
+ ],
238
+ "env": {
239
+ "WANDB_API_KEY": "your-api-key"
240
+ }
241
+ }
242
+ }
243
+ }
244
+ ```
245
+ </details>
246
+ </details>
247
+
248
+ <details>
249
+ <summary><b>πŸ’¬ Gemini</b></summary>
250
+ **Quick Install:**
251
+ Uses the `.gemini-extension.json` in this repo's root:
252
 
253
+ ```bash
254
+ gemini extensions install https://github.com/wandb/wandb-mcp-server
255
+ ```
256
+
257
+ **Then set your API key (choose one):**
258
+ ```bash
259
+ # Option 1: Export API key directly
260
+ export WANDB_API_KEY=your-api-key
261
 
262
+ # Option 2: Use wandb login (opens browser)
263
+ uvx wandb login
264
+ ```
265
+ <details>
266
+ <summary>Manual Configuration</summary>
267
+ Create `gemini-extension.json` in your project root (use `--path=path/to/gemini-extension.json` to add local folder):
268
 
269
+ ```json
270
+ {
271
+ "name": "Weights and Biases MCP Server",
272
+ "version": "0.1.0",
273
+ "mcpServers": {
274
+ "wandb": {
275
+ "command": "uv",
276
+ "args": [
277
+ "run",
278
+ "--directory",
279
+ "/path/to/wandb-mcp-server",
280
+ "wandb_mcp_server",
281
+ "--transport",
282
+ "stdio"
283
+ ],
284
+ "env": {
285
+ "WANDB_API_KEY": "$WANDB_API_KEY"
286
+ }
287
+ }
288
+ }
289
+ }
290
+ ```
291
+ </details>
292
 
293
+ Note: Replace `/path/to/wandb-mcp-server` with your installation path.
294
+ </details>
 
 
295
 
296
+ <details>
297
+ <summary><b>πŸ€– Claude Desktop</b></summary>
298
 
299
+ **Quick Install:**
300
+ ```bash
301
+ uvx --from git+https://github.com/wandb/wandb-mcp-server -- add_to_client --config_path "~/Library/Application Support/Claude/claude_desktop_config.json" && uvx wandb login
302
  ```
303
+
304
+ <details>
305
+ <summary>Manual Configuration</summary>
306
+
307
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
308
+
309
+ ```json
310
+ {
311
+ "mcpServers": {
312
+ "wandb": {
313
+ "command": "uvx",
314
+ "args": [
315
+ "--from",
316
+ "git+https://github.com/wandb/wandb-mcp-server",
317
+ "wandb_mcp_server"
318
+ ],
319
+ "env": {
320
+ "WANDB_API_KEY": "your-api-key"
321
+ }
322
+ }
323
+ }
324
+ }
325
  ```
326
+ </details>
327
+ </details>
328
+
329
+ <details>
330
+ <summary><b>πŸ’» Claude Code</b></summary>
331
 
332
+ **Quick Install:**
333
+ ```bash
334
+ claude mcp add wandb -- uvx --from git+https://github.com/wandb/wandb-mcp-server wandb_mcp_server && uvx wandb login
335
  ```
336
+
337
+ **With API Key:**
338
+ ```bash
339
+ claude mcp add wandb -e WANDB_API_KEY=your-api-key -- uvx --from git+https://github.com/wandb/wandb-mcp-server wandb_mcp_server
340
  ```
341
+ </details>
342
+
343
+ <details>
344
+ <summary><b>🌐 ChatGPT, LeChat, Claude</b></summary>
345
+ Try our hosted public version: [HF Spaces](https://huggingface.co/spaces/NiWaRe/wandb-mcp-server)
346
+
347
+ This version allows you to configure your WANDB_API_KEY directly in the interface to access your own projects or to work with all publich projects otherwise. Follow the instructions in the space to add it to LeChat, ChatGPT, or Claude. We'll have an official hosted version soon.
348
+ </details>
349
+
350
+ ## Available Tools
351
+
352
+ The server provides the following MCP tools:
353
+
354
+ ### W&B Models Tools
355
+ - **`query_wandb_tool`** - Execute GraphQL queries against W&B experiment tracking data (runs, sweeps, artifacts)
356
+
357
+ ### Weave Tools
358
+ - **`query_weave_traces_tool`** - Query LLM traces and evaluations with filtering and pagination
359
+ - **`count_weave_traces_tool`** - Efficiently count traces without returning data
360
+
361
+ ### Support & Reporting
362
+ - **`query_wandb_support_bot`** - Get help from [wandbot](https://github.com/wandb/wandbot), our RAG-powered technical support agent that can answer any W&B/Weave questions, help debug issues, and provide code examples (works out-of-the-box, no configuration needed!)
363
+ - **`create_wandb_report_tool`** - Create W&B Reports with markdown and visualizations
364
+ - **`query_wandb_entity_projects`** - List available entities and projects
365
+
366
+ ## Usage Tips
367
+
368
+ ### Be Specific About Projects
369
+ Always specify the W&B entity and project name in your queries:
370
+
371
+ βœ… **Good:** "Show traces from wandb-team/my-project"
372
+ ❌ **Bad:** "Show my traces"
373
+
374
+ ### Avoid Overly Broad Questions
375
+ Be specific to get better results:
376
+
377
+ βœ… **Good:** "What eval had the highest F1 score in the last week?"
378
+ ❌ **Bad:** "What's my best evaluation?"
379
+
380
+ ### Verify Complete Data Retrieval
381
+ When analyzing performance across multiple runs, ask the LLM to confirm it retrieved all available data to ensure comprehensive analysis.
382
+
383
+ ## Self-Hosting Guide
384
+
385
+ ### Deploy to Hugging Face Spaces
386
+
387
+ Deploy your own instance of the W&B MCP Server on Hugging Face Spaces:
388
+
389
+ 1. **Fork this repository** or clone it locally
390
+ 2. **Create a new Space on Hugging Face:**
391
+ - Go to [huggingface.co/spaces](https://huggingface.co/spaces)
392
+ - Click "Create new Space"
393
+ - Choose "Docker" as the SDK
394
+ - Set visibility as needed
395
+
396
+ 3. **Push the code to your Space:**
397
+ ```bash
398
+ git remote add hf-space https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
399
+ git push hf-space main
400
+ ```
401
+
402
+ 4. **Your server will be available at:**
403
+ ```
404
+ https://YOUR_USERNAME-YOUR_SPACE_NAME.hf.space/mcp
405
+ ```
406
+
407
+ See [HUGGINGFACE_DEPLOYMENT.md](HUGGINGFACE_DEPLOYMENT.md) for detailed deployment instructions.
408
+
409
+ ### Run Local HTTP Server
410
 
411
+ Run the server locally with HTTP transport for development or testing:
412
+
413
+ ```bash
414
+ # Install dependencies
415
+ pip install -r requirements.txt
416
+
417
+ # Run with authentication (recommended)
418
+ python app.py
419
+
420
+ # Or run without authentication (development only)
421
+ MCP_AUTH_DISABLED=true python app.py
422
+ ```
423
+
424
+ The server will be available at `http://localhost:7860/mcp`
425
+
426
+ **Authentication:** See [AUTH_README.md](AUTH_README.md) for details on Bearer token authentication.
427
+
428
+ ### File Structure for Deployment
429
+
430
+ ```
431
+ wandb-mcp-server/
432
+ β”œβ”€β”€ app.py # HF Spaces/HTTP server entry point
433
+ β”œβ”€β”€ Dockerfile # Container configuration for HF Spaces
434
+ β”œβ”€β”€ requirements.txt # Python dependencies for HTTP deployment
435
+ β”œβ”€β”€ index.html # Landing page for web interface
436
+ β”œβ”€β”€ AUTH_README.md # Authentication documentation
437
+ β”œβ”€β”€ HUGGINGFACE_DEPLOYMENT.md # HF Spaces deployment guide
438
+ β”œβ”€β”€ src/
439
+ β”‚ └── wandb_mcp_server/
440
+ β”‚ β”œβ”€β”€ server.py # Core MCP server (STDIO & HTTP)
441
+ β”‚ β”œβ”€β”€ auth.py # Bearer token authentication
442
+ β”‚ └── mcp_tools/ # Tool implementations
443
+ └── pyproject.toml # Package configuration for local/pip install
444
+ ```
445
+
446
+ ## Advanced Configuration
447
+
448
+ ### Enabling Weave Tracing for MCP Operations
449
+
450
+ Track all MCP tool calls using [Weave's MCP integration](https://weave-docs.wandb.ai/guides/integrations/mcp):
451
+
452
+ ```bash
453
+ # Enable Weave tracing for MCP operations
454
+ export WEAVE_DISABLED=false
455
+ export MCP_LOGS_WANDB_ENTITY=your-entity
456
+ export MCP_LOGS_WANDB_PROJECT=mcp-logs
457
+
458
+ # Optional: trace list operations
459
+ export MCP_TRACE_LIST_OPERATIONS=true
460
+ ```
461
+
462
+ This provides detailed observability into tool calls, resource access, and prompt generation across your MCP system.
463
+
464
+ ### Logging Configuration
465
+
466
+ Control server logging with environment variables:
467
+
468
+ ```bash
469
+ # Server log level
470
+ export MCP_SERVER_LOG_LEVEL=INFO # DEBUG, INFO, WARNING, ERROR
471
+
472
+ # W&B/Weave output control
473
+ export WANDB_SILENT=False # Show W&B output
474
+ export WEAVE_SILENT=False # Show Weave output
475
+
476
+ # Debug mode
477
+ export WANDB_DEBUG=true # Verbose W&B logging
478
  ```
479
+
480
+ ### Transport Options
481
+
482
+ #### STDIO Transport (Default for Local Development)
483
+ For local development where the MCP client and server run on the same machine:
484
+ ```bash
485
+ wandb_mcp_server --transport stdio
486
+ # Or with UV:
487
+ uvx --from git+https://github.com/wandb/wandb-mcp-server wandb_mcp_server
488
  ```
489
+ - Requires W&B API key in environment
490
+ - Direct communication via stdin/stdout
491
+ - Best for local IDE integrations (Cursor, Windsurf, etc.)
492
+
493
+ #### HTTP Transport (For Remote Access)
494
+ For remote access, web applications, or hosted deployments:
495
+ ```bash
496
+ # Using the FastAPI app (recommended)
497
+ python app.py # Runs on port 7860 by default
498
 
499
+ # Or using the CLI
500
+ wandb_mcp_server --transport http --host 0.0.0.0 --port 8080
501
+ ```
502
+ - Clients provide W&B API key as Bearer token
503
+ - Supports authentication middleware
504
+ - Uses Server-Sent Events (SSE) for streaming
505
+ - Ideal for hosted deployments and web clients
506
 
507
+ ### Running from Source
508
 
509
  ```bash
 
510
  git clone https://github.com/wandb/wandb-mcp-server
511
  cd wandb-mcp-server
512
+ wandb login
513
+ uv run src/wandb_mcp_server/server.py
514
  ```
515
 
516
+ ## Troubleshooting
517
 
518
+ ### Error: spawn uv ENOENT
519
 
520
+ If `uv` cannot be found:
 
 
 
521
 
522
+ 1. Reinstall UV:
523
+ ```bash
524
+ curl -LsSf https://astral.sh/uv/install.sh | sh
525
+ ```
526
 
527
+ 2. Create a system-wide symlink:
528
+ ```bash
529
+ sudo ln -s ~/.local/bin/uv /usr/local/bin/uv
530
+ ```
531
 
532
+ 3. Restart your application/IDE
 
 
 
533
 
534
+ ### Authentication Issues
535
 
536
+ Verify W&B authentication:
537
+ ```bash
538
+ uvx wandb login
539
+ ```
 
540
 
541
+ Or check if your API key is set:
542
+ ```bash
543
+ echo $WANDB_API_KEY
544
+ ```
545
 
546
+ ## Testing
547
 
548
+ Run integration tests with LLM providers:
549
+
550
+ ```bash
551
+ # Set API key in .env
552
+ echo "ANTHROPIC_API_KEY=your-key" >> .env
553
+
554
+ # Run specific test file
555
+ uv run pytest -s -n 10 tests/test_query_wandb_gql.py
556
+
557
+ # Debug single test
558
+ pytest -s -n 1 "tests/test_query_weave_traces.py::test_query_weave_trace[sample_name]" -v --log-cli-level=DEBUG
559
+ ```
560
+
561
+ ## Contributing
562
+
563
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
564
+
565
+ ## License
566
+
567
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
568
+
569
+ ## Support
570
 
571
+ - [W&B Documentation](https://docs.wandb.ai)
572
+ - [Weave Documentation](https://weave-docs.wandb.ai)
573
+ - [GitHub Issues](https://github.com/wandb/wandb-mcp-server/issues)
574
+ - [W&B Community Forum](https://community.wandb.ai)
gemini-extension.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "wandb-weave",
3
+ "version": "0.1.0",
4
+ "mcpServers": {
5
+ "wandb-weave": {
6
+ "command": "uv",
7
+ "args": [
8
+ "run",
9
+ "--directory",
10
+ "/Users/niware_wb/Documents/code_projects/mcp_experiments/wandb-mcp-server",
11
+ "wandb_mcp_server",
12
+ "--transport",
13
+ "stdio"
14
+ ],
15
+ "env": {
16
+ "WANDB_API_KEY": "<your-api-key>"
17
+ }
18
+ }
19
+ }
20
+ }
index.html CHANGED
@@ -230,13 +230,69 @@
230
  </div>
231
 
232
  <div class="setup-steps" style="background: #f0fdf4; border-color: #86efac;">
233
- <h3 style="color: #166534;">βœ… Ready to Use!</h3>
234
- <ol>
235
- <li>Get your W&B API key from <a href="https://wandb.ai/authorize" target="_blank">wandb.ai/authorize</a></li>
236
- <li>Configure your MCP client with the endpoint above</li>
237
- <li>Provide your API key as Bearer token or API Key authentication</li>
238
- </ol>
239
- <p style="margin-top: 15px; color: #166534;"><strong>No server configuration needed!</strong> Each user provides their own API key for secure access to their W&B data.</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
  </div>
241
 
242
  <div class="examples">
 
230
  </div>
231
 
232
  <div class="setup-steps" style="background: #f0fdf4; border-color: #86efac;">
233
+ <h3 style="color: #166534;">πŸš€ Quick Setup</h3>
234
+
235
+ <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin: 20px 0;">
236
+
237
+ <div style="background: white; padding: 20px; border-radius: 8px; border-left: 4px solid #4299e1;">
238
+ <h4 style="margin: 0 0 10px 0; color: #2d3748;">πŸ“ Cursor</h4>
239
+ <ul style="margin: 0; padding-left: 20px; font-size: 0.9em;">
240
+ <li>Add to <code>~/.cursor/mcp.json</code>:</li>
241
+ </ul>
242
+ <pre style="background: #1a202c; color: #e2e8f0; padding: 10px; border-radius: 4px; font-size: 0.8em; margin: 10px 0; overflow-x: auto;">"wandb": {
243
+ "transport": "http",
244
+ "url": "https://niware-wandb-mcp-server.hf.space/mcp",
245
+ "headers": {
246
+ "Authorization": "Bearer YOUR_WANDB_API_KEY",
247
+ "Accept": "application/json, text/event-stream"
248
+ }
249
+ }</pre>
250
+ </div>
251
+
252
+ <div style="background: white; padding: 20px; border-radius: 8px; border-left: 4px solid #38b2ac;">
253
+ <h4 style="margin: 0 0 10px 0; color: #2d3748;">πŸ–₯️ Claude Desktop</h4>
254
+ <ul style="margin: 0; padding-left: 20px; font-size: 0.9em;">
255
+ <li>Add to <code>claude_desktop_config.json</code>:</li>
256
+ </ul>
257
+ <pre style="background: #1a202c; color: #e2e8f0; padding: 10px; border-radius: 4px; font-size: 0.8em; margin: 10px 0; overflow-x: auto;">{
258
+ "mcpServers": {
259
+ "wandb-stdio": {
260
+ "command": "uvx",
261
+ "args": ["--from", "git+https://github.com/wandb/wandb-mcp-server.git", "wandb-mcp-server"],
262
+ "env": {
263
+ "WANDB_API_KEY": "YOUR_WANDB_API_KEY"
264
+ }
265
+ }
266
+ }
267
+ }</pre>
268
+ </div>
269
+
270
+ <div style="background: white; padding: 20px; border-radius: 8px; border-left: 4px solid #f56565;">
271
+ <h4 style="margin: 0 0 10px 0; color: #2d3748;">πŸ’¬ LeChat</h4>
272
+ <ul style="margin: 0; padding-left: 20px; font-size: 0.9em;">
273
+ <li>MCP Server URL: <code>https://niware-wandb-mcp-server.hf.space/mcp</code></li>
274
+ <li>Auth: Bearer token</li>
275
+ <li>Token: Your W&B API key</li>
276
+ </ul>
277
+ </div>
278
+
279
+ <div style="background: white; padding: 20px; border-radius: 8px; border-left: 4px solid #9f7aea;">
280
+ <h4 style="margin: 0 0 10px 0; color: #2d3748;">πŸ€– Gemini CLI</h4>
281
+ <ul style="margin: 0; padding-left: 20px; font-size: 0.9em;">
282
+ <li>Install extension:</li>
283
+ </ul>
284
+ <pre style="background: #1a202c; color: #e2e8f0; padding: 10px; border-radius: 4px; font-size: 0.8em; margin: 10px 0; overflow-x: auto;">gemini extensions install https://github.com/wandb/wandb-mcp-server</pre>
285
+ <ul style="margin: 10px 0 0 0; padding-left: 20px; font-size: 0.9em;">
286
+ <li>Then set API key (choose one):</li>
287
+ <li style="margin-left: 15px;">β€’ <code>export WANDB_API_KEY=your-key</code></li>
288
+ <li style="margin-left: 15px;">β€’ <code>uvx wandb login</code> (opens browser)</li>
289
+ </ul>
290
+ </div>
291
+ </div>
292
+
293
+ <p style="margin-top: 15px; color: #166534; text-align: center;">
294
+ <strong>Get your API key:</strong> <a href="https://wandb.ai/authorize" target="_blank" style="color: #166534;">wandb.ai/authorize</a>
295
+ </p>
296
  </div>
297
 
298
  <div class="examples">
pyproject.toml CHANGED
@@ -14,8 +14,6 @@ dependencies = [
14
  "wandb-workspaces>=0.1.12",
15
  "networkx>=3.4.2",
16
  "requests>=2.31.0",
17
- "fastapi>=0.104.0",
18
- "uvicorn>=0.24.0",
19
  ]
20
 
21
  [build-system]
@@ -33,6 +31,10 @@ test = [
33
  "pytest-xdist>=3.6.1",
34
  "pytest-asyncio>=0.26.0",
35
  ]
 
 
 
 
36
 
37
  [tool.hatch.build.targets.wheel]
38
  packages = ["src/wandb_mcp_server"]
 
14
  "wandb-workspaces>=0.1.12",
15
  "networkx>=3.4.2",
16
  "requests>=2.31.0",
 
 
17
  ]
18
 
19
  [build-system]
 
31
  "pytest-xdist>=3.6.1",
32
  "pytest-asyncio>=0.26.0",
33
  ]
34
+ http = [
35
+ "fastapi>=0.104.0",
36
+ "uvicorn>=0.24.0",
37
+ ]
38
 
39
  [tool.hatch.build.targets.wheel]
40
  packages = ["src/wandb_mcp_server"]
src/wandb_mcp_server/mcp_tools/list_wandb_entities_projects.py CHANGED
@@ -94,9 +94,9 @@ def list_entity_projects(entity: str | None = None) -> dict[str, list[dict[str,
94
  "entity": project.entity,
95
  "description": getattr(project, "description", None),
96
  "visibility": getattr(project, "visibility", None),
97
- "created_at": project.created_at,
98
- "updated_at": project.updated_at,
99
- "tags": project.tags,
100
  }
101
  projects_data.append(project_dict)
102
 
 
94
  "entity": project.entity,
95
  "description": getattr(project, "description", None),
96
  "visibility": getattr(project, "visibility", None),
97
+ "created_at": getattr(project, "created_at", None),
98
+ "updated_at": getattr(project, "updated_at", None),
99
+ "tags": getattr(project, "tags", []),
100
  }
101
  projects_data.append(project_dict)
102
 
src/wandb_mcp_server/mcp_tools/query_wandbot.py CHANGED
@@ -34,7 +34,7 @@ str
34
 
35
 
36
  def query_wandbot_api(question: str) -> Dict[str, Any]:
37
- wandbot_base_url = os.getenv("WANDBOT_BASE_URL", "https://morg--wandbot-api-wandbotapi-serve.modal.run")
38
  QUERY_ENDPOINT = f"{wandbot_base_url}/chat/query"
39
  STATUS_ENDPOINT = f"{wandbot_base_url}/status"
40
  QUERY_TIMEOUT_SECONDS = 40
 
34
 
35
 
36
  def query_wandbot_api(question: str) -> Dict[str, Any]:
37
+ wandbot_base_url = os.getenv("WANDBOT_BASE_URL", "https://weightsandbiases-wandbot--wandbot-api-wandbotapi-serve.modal.run")
38
  QUERY_ENDPOINT = f"{wandbot_base_url}/chat/query"
39
  STATUS_ENDPOINT = f"{wandbot_base_url}/status"
40
  QUERY_TIMEOUT_SECONDS = 40
src/wandb_mcp_server/server.py CHANGED
@@ -276,14 +276,14 @@ def register_tools(mcp_instance: FastMCP) -> None:
276
  async def query_weave_traces_tool(
277
  entity_name: str,
278
  project_name: str,
279
- filters: Dict = {},
280
  sort_by: str = "started_at",
281
  sort_direction: str = "desc",
282
  limit: int = 10000000,
283
  include_costs: bool = True,
284
  include_feedback: bool = True,
285
- columns: list = [],
286
- expand_columns: list = [],
287
  truncate_length: int = 200,
288
  return_full_data: bool = False,
289
  metadata_only: bool = False,
 
276
  async def query_weave_traces_tool(
277
  entity_name: str,
278
  project_name: str,
279
+ filters: Dict[str, Any] = {},
280
  sort_by: str = "started_at",
281
  sort_direction: str = "desc",
282
  limit: int = 10000000,
283
  include_costs: bool = True,
284
  include_feedback: bool = True,
285
+ columns: List[str] = [],
286
+ expand_columns: List[str] = [],
287
  truncate_length: int = 200,
288
  return_full_data: bool = False,
289
  metadata_only: bool = False,
uv.lock CHANGED
@@ -2092,7 +2092,6 @@ name = "wandb-mcp-server"
2092
  version = "0.1.0"
2093
  source = { editable = "." }
2094
  dependencies = [
2095
- { name = "fastapi" },
2096
  { name = "httpx" },
2097
  { name = "mcp", extra = ["cli"] },
2098
  { name = "networkx" },
@@ -2101,13 +2100,16 @@ dependencies = [
2101
  { name = "requests" },
2102
  { name = "simple-parsing" },
2103
  { name = "tiktoken" },
2104
- { name = "uvicorn" },
2105
  { name = "wandb" },
2106
  { name = "wandb-workspaces" },
2107
  { name = "weave" },
2108
  ]
2109
 
2110
  [package.optional-dependencies]
 
 
 
 
2111
  test = [
2112
  { name = "anthropic" },
2113
  { name = "litellm" },
@@ -2123,7 +2125,7 @@ dev = [
2123
  [package.metadata]
2124
  requires-dist = [
2125
  { name = "anthropic", marker = "extra == 'test'", specifier = ">=0.50.0" },
2126
- { name = "fastapi", specifier = ">=0.104.0" },
2127
  { name = "httpx", specifier = ">=0.28.1" },
2128
  { name = "litellm", marker = "extra == 'test'", specifier = ">=1.67.2" },
2129
  { name = "mcp", extras = ["cli"], specifier = ">=1.0.0" },
@@ -2135,12 +2137,12 @@ requires-dist = [
2135
  { name = "requests", specifier = ">=2.31.0" },
2136
  { name = "simple-parsing", specifier = ">=0.1.7" },
2137
  { name = "tiktoken", specifier = ">=0.9.0" },
2138
- { name = "uvicorn", specifier = ">=0.24.0" },
2139
  { name = "wandb", specifier = ">=0.19.8" },
2140
  { name = "wandb-workspaces", specifier = ">=0.1.12" },
2141
  { name = "weave", specifier = ">=0.51.56" },
2142
  ]
2143
- provides-extras = ["test"]
2144
 
2145
  [package.metadata.requires-dev]
2146
  dev = [{ name = "ruff", specifier = ">=0.11.12" }]
 
2092
  version = "0.1.0"
2093
  source = { editable = "." }
2094
  dependencies = [
 
2095
  { name = "httpx" },
2096
  { name = "mcp", extra = ["cli"] },
2097
  { name = "networkx" },
 
2100
  { name = "requests" },
2101
  { name = "simple-parsing" },
2102
  { name = "tiktoken" },
 
2103
  { name = "wandb" },
2104
  { name = "wandb-workspaces" },
2105
  { name = "weave" },
2106
  ]
2107
 
2108
  [package.optional-dependencies]
2109
+ http = [
2110
+ { name = "fastapi" },
2111
+ { name = "uvicorn" },
2112
+ ]
2113
  test = [
2114
  { name = "anthropic" },
2115
  { name = "litellm" },
 
2125
  [package.metadata]
2126
  requires-dist = [
2127
  { name = "anthropic", marker = "extra == 'test'", specifier = ">=0.50.0" },
2128
+ { name = "fastapi", marker = "extra == 'http'", specifier = ">=0.104.0" },
2129
  { name = "httpx", specifier = ">=0.28.1" },
2130
  { name = "litellm", marker = "extra == 'test'", specifier = ">=1.67.2" },
2131
  { name = "mcp", extras = ["cli"], specifier = ">=1.0.0" },
 
2137
  { name = "requests", specifier = ">=2.31.0" },
2138
  { name = "simple-parsing", specifier = ">=0.1.7" },
2139
  { name = "tiktoken", specifier = ">=0.9.0" },
2140
+ { name = "uvicorn", marker = "extra == 'http'", specifier = ">=0.24.0" },
2141
  { name = "wandb", specifier = ">=0.19.8" },
2142
  { name = "wandb-workspaces", specifier = ">=0.1.12" },
2143
  { name = "weave", specifier = ">=0.51.56" },
2144
  ]
2145
+ provides-extras = ["test", "http"]
2146
 
2147
  [package.metadata.requires-dev]
2148
  dev = [{ name = "ruff", specifier = ">=0.11.12" }]