MCP (Model Context Protocol) server support for SwanLab
Project description
SwanLab-MCP-Server
A Model Context Protocol (MCP) server implementation for SwanLab, combining SwanLab-OpenAPI & FastMCP.
✨ Features
Core Features
- Workspace Management - List and manage user-accessible workspaces
- Project Management - Create, retrieve, delete projects, and list project information
- Experiment Management - Create, retrieve, delete experiments, and retrieve experiment metrics and summaries
- API Integration - Provide complete platform access through SwanLab OpenAPI
Tech Stack
- Language: Python 3.12+
- Core Framework: FastMCP (v2.14.4+)
- API Client: SwanLab SDK
- Config Management: Pydantic Settings
🚀 Quick Start
❗️Configuration
Add the following configuration to your relative mcp config list
{
"mcpServers":
...
{
"swanlab-mcp": {
"command": "uv",
"args": ["run", "swanlab_mcp", "--transport", "stdio"],
"env": {
"SWANLAB_API_KEY": "your_api_key_here"
}
}
}
}
For Claude Code Users, you can config like this:
claude mcp add --env SWANLAB_API_KEY=<your_api_key> -- swanlab_mcp uv run swanlab_mcp --transport stdio
Prerequisites
- Python >= 3.12
- SwanLab API Key (get it from SwanLab)
Installation
# Using uv (recommended)
uv sync
# Or using pip
pip install -e .
Configuration
Environment Variables
Create a .env file and configure your API key:
cp .env.template .env
Edit the .env file:
SWANLAB_API_KEY=your_api_key_here
Running
# Using stdio transport (default)
python -m swanlab_mcp
# Or using CLI
python -m swanlab_mcp --transport stdio
# Check version
python -m swanlab_mcp --version
Usage
After configuration, restart Claude Desktop to interact with SwanLab via the MCP protocol.
Available Tools:
swanlab_list_workspaces- List workspacesswanlab_create_project- Create projectswanlab_list_projects- List projectsswanlab_create_experiment- Create experimentswanlab_list_experiments- List experimentsswanlab_get_experiment- Get experiment detailsswanlab_delete_experiment- Delete experiment
🛠️ Development
Code Formatting
# Using Makefile
make format
# Or manually
uvx isort . --skip-gitignore
uvx ruff format . --quiet
Lint Check
uvx ruff check .
Pre-commit Hooks
bash scripts/install-hooks.sh
📚 References & Acknowledgements
- SwanLab
- Model Context Protocol
- FastMCP v2
- modelscope-mcp-server
- TrackIO-mcp-server
- Simple-Wandb-mcp-server
📄 License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swanlab_mcp-0.0.1.tar.gz.
File metadata
- Download URL: swanlab_mcp-0.0.1.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29db0d03c8f5e629ec6cdb6d26bbe23208fd3d843078139ebc0ca12b22c9ef5d
|
|
| MD5 |
257c0c91e5e8b78514f7c216c22be33f
|
|
| BLAKE2b-256 |
5d2d76e34f2858ec64eaa422069a29b8092ab4507f42a9b010166902a6328dd6
|
File details
Details for the file swanlab_mcp-0.0.1-py3-none-any.whl.
File metadata
- Download URL: swanlab_mcp-0.0.1-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e63faa8379edb907d3464c00f25104a14cb8ce1ea3c0a6488b639e8b1055668
|
|
| MD5 |
f13815e953442f14ccb6ba1e51b734c4
|
|
| BLAKE2b-256 |
ac7dd954c0d3b766df1e9756c198d9e0977e20fd9396fa8a08eec1b1036c2916
|