SwanLab MCP Server
Let your AI coding assistant write SwanLab tracking code and look up experiment data.
中文 · Quick Start · What It Does · What's Inside · Development
SwanLab MCP Server hands the official swanlab-skill to AI coding assistants like Claude Code and Codex. The assistant reads that guide, then writes tracking code for you or runs swanlab api in your terminal to look up experiments.
Queries go through the swanlab command on your own machine with your own login, so the assistant sees exactly what you would see doing it by hand. The server itself needs no API key — install it and it works.
Quick Start
If you're using a coding agent like Claude Code or Codex, just send it the following prompt and it will install everything for you:
Fetch the installation guide and follow it: https://raw.githubusercontent.com/Nexisato/SwanLab-MCP/main/README.md
Doing it by hand is just as easy.
1. Install and log in
pip install swanlab
swanlab login # paste your API key from https://swanlab.cn
Once is enough — both the server and your assistant reuse it.
2. Add the MCP server
Claude Code:
claude mcp add -- swanlab-mcp uvx --from swanlab-mcp swanlab_mcp --transport stdio
Codex:
codex mcp add swanlab-mcp -- uvx --from swanlab-mcp swanlab_mcp --transport stdio
Codex writes it to ~/.codex/config.toml, which is the same as adding this entry by hand:
[mcp_servers.swanlab-mcp]
command = "uvx"
args = ["--from", "swanlab-mcp", "swanlab_mcp", "--transport", "stdio"]
Any other client:
{
"mcpServers": {
"swanlab-mcp": {
"command": "uvx",
"args": ["--from", "swanlab-mcp", "swanlab_mcp", "--transport", "stdio"]
}
}
}
uvxpullsswanlab-mcpfrom PyPI on first run, so no prior installation is needed. To install it into your current environment instead, runpip install swanlab-mcpand replaceuvx --from swanlab-mcpabove withswanlab_mcp;swanlab_mcp --versionconfirms the installation.
3. Just ask
Plot the loss curve of username/project/run1 and compare it with run2 and run3.
What It Does
| You want | The assistant will |
|---|---|
| Add experiment tracking | Write swanlab.init / log / finish code, with image, audio, text |
| Inspect one run | Run swanlab api for metrics, logs, summaries and media |
| Find matching experiments | Filter runs by config or summary conditions |
| Chart and compare runs | Run the bundled plotting scripts for line charts and run rankings |
What's Inside
swanlab-skill ships with the server and is readable as soon as you connect — nothing extra to install:
SKILL.md— the entry point, telling the assistant which reference to read for the task at handreferences/— how to use the SDK, how to use the CLI, data model and terminology, comparison and report writingscripts/— a single-run line chart and a multi-run ranking comparison
Both plotting scripts expect an existing swanlab login, plus matplotlib and numpy in the environment.
Development
uv sync --all-groups
uv run pytest
uv run ruff check .
uv run swanlab_mcp --version
Skill content is copied from the upstream repository and committed, so every update shows up in the diff:
git clone https://github.com/SwanHubX/SwanLab-Skill ../SwanLab-Skill
make sync-skills
License
MIT License © 2026 Emotion Machine (Beijing) Technology Co., Ltd.
Metadata
Release files for swanlab-mcp 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| swanlab_mcp-0.3.2.tar.gz | 50.3 kB | Without provenance | Details for swanlab_mcp-0.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| swanlab_mcp-0.3.2-py3-none-any.whl | Python 3 | none | any | Details for swanlab_mcp-0.3.2-py3-none-any.whl |
Total release size: 97.5 kB
Release files / swanlab_mcp-0.3.2.tar.gz
| Download URL | swanlab_mcp-0.3.2.tar.gz |
|---|---|
| Size | 50.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ed07637f57235de987dfecb61dfc6e0c4799124b936fd5d3d0d41ec99e10357e
|
|
BLAKE2b-256 checksum How to use checksums |
30b6a0fef156f854efea4fbad0a22d8998d5f1582208f8a32b095bef9d7d1e74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.12 {"installer":{"name":"uv","version":"0.13.12","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}
|
Release files / swanlab_mcp-0.3.2-py3-none-any.whl
| Download URL | swanlab_mcp-0.3.2-py3-none-any.whl |
|---|---|
| Size | 47.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c64e3ef0ba1984b5642d9e9fcd583322651245bf7d242cea1d04e173b9ae95a
|
|
BLAKE2b-256 checksum How to use checksums |
7ea6dc9780cf4340dac7e2d6efbf1f23f8c5fc5b30ed403a64be1ceda4e2cb5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.12 {"installer":{"name":"uv","version":"0.13.12","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}
|
Security for swanlab-mcp 0.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.