swanlab-mcp 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ SWANLAB_API_KEY=<you_api_key>
@@ -0,0 +1,39 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*.*.*"
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - name: Checkout
14
+ uses: actions/checkout@v4
15
+
16
+ - name: Install uv
17
+ uses: astral-sh/setup-uv@v4
18
+ with:
19
+ version: "latest"
20
+
21
+ - name: Sync Dependencies
22
+ run: uv sync
23
+
24
+ - name: Build Package
25
+ run: uv build
26
+
27
+ - name: Publish to PyPI
28
+ env:
29
+ UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
30
+ run: uv publish
31
+
32
+ - run: cp dist/*.whl .
33
+
34
+ - name: Release
35
+ uses: softprops/action-gh-release@v2
36
+ if: startsWith(github.ref, 'refs/tags/')
37
+ with:
38
+ files: |
39
+ *.whl
@@ -0,0 +1,51 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+
13
+ # IDEs and editors
14
+ .vscode/
15
+ .idea/
16
+
17
+
18
+ # macOS
19
+ .DS_Store
20
+
21
+ # Logs and databases
22
+ *.log
23
+ *.sqlite3
24
+
25
+ # linters and formatters
26
+ .ropeproject/
27
+ .mypy_cache/
28
+ .pytest_cache/
29
+ .coverage
30
+ htmlcov/
31
+ *ruff_cache/
32
+
33
+ # playground
34
+ playground/
35
+
36
+
37
+ # settings
38
+ .claude/*
39
+ .cursor/*
40
+
41
+
42
+ # AI agents
43
+ AGENTS.md
44
+ GEMINI.md
45
+ CLAUDE.md
46
+ IFLOW.md
47
+ QWEN.md
48
+
49
+ # env
50
+ .env
51
+ uv.lock
@@ -0,0 +1,16 @@
1
+ repos:
2
+ - repo: local
3
+ hooks:
4
+ - id: make-format
5
+ name: make format
6
+ entry: make format
7
+ language: system
8
+ pass_filenames: false
9
+ always_run: true
10
+
11
+ - id: commit-msg
12
+ name: commit msg check
13
+ entry: scripts/commit-msg-check.sh
14
+ language: script
15
+ stages: [commit-msg]
16
+ always_run: true
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,5 @@
1
+ .PHONY: format
2
+
3
+ format:
4
+ -uvx isort . --skip-gitignore
5
+ -uvx ruff format . --quiet
@@ -0,0 +1,155 @@
1
+ Metadata-Version: 2.4
2
+ Name: swanlab-mcp
3
+ Version: 0.0.1
4
+ Summary: MCP (Model Context Protocol) server support for SwanLab
5
+ Author-email: CaddiesNew <nexisato0810@gmail.com>
6
+ License: MIT
7
+ Requires-Python: >=3.12
8
+ Requires-Dist: fastmcp>=2.14.4
9
+ Requires-Dist: pydantic-settings>=2.0.0
10
+ Requires-Dist: python-dotenv>=1.2.1
11
+ Requires-Dist: swanlab
12
+ Description-Content-Type: text/markdown
13
+
14
+ # SwanLab-MCP-Server
15
+
16
+ > A Model Context Protocol (MCP) server implementation for SwanLab, combining SwanLab-OpenAPI & FastMCP.
17
+
18
+ ## ✨ Features
19
+
20
+ ### Core Features
21
+
22
+ - **Workspace Management** - List and manage user-accessible workspaces
23
+ - **Project Management** - Create, retrieve, delete projects, and list project information
24
+ - **Experiment Management** - Create, retrieve, delete experiments, and retrieve experiment metrics and summaries
25
+ - **API Integration** - Provide complete platform access through SwanLab OpenAPI
26
+
27
+ ### Tech Stack
28
+
29
+ - **Language**: Python 3.12+
30
+ - **Core Framework**: FastMCP (v2.14.4+)
31
+ - **API Client**: SwanLab SDK
32
+ - **Config Management**: Pydantic Settings
33
+
34
+ ## 🚀 Quick Start
35
+
36
+ ### ❗️Configuration
37
+
38
+ Add the following configuration to your relative mcp config list
39
+
40
+ ```json
41
+ {
42
+ "mcpServers":
43
+ ...
44
+ {
45
+ "swanlab-mcp": {
46
+ "command": "uv",
47
+ "args": ["run", "swanlab_mcp", "--transport", "stdio"],
48
+ "env": {
49
+ "SWANLAB_API_KEY": "your_api_key_here"
50
+ }
51
+ }
52
+ }
53
+ }
54
+ ```
55
+
56
+ For `Claude Code` Users, you can config like this:
57
+
58
+ ```bash
59
+ claude mcp add --env SWANLAB_API_KEY=<your_api_key> -- swanlab_mcp uv run swanlab_mcp --transport stdio
60
+ ```
61
+
62
+ ### Prerequisites
63
+
64
+ - Python >= 3.12
65
+ - SwanLab API Key (get it from [SwanLab](https://swanlab.cn))
66
+
67
+ ### Installation
68
+
69
+ ```bash
70
+ # Using uv (recommended)
71
+ uv sync
72
+
73
+ # Or using pip
74
+ pip install -e .
75
+ ```
76
+
77
+ ### Configuration
78
+
79
+ #### Environment Variables
80
+
81
+ Create a `.env` file and configure your API key:
82
+
83
+ ```bash
84
+ cp .env.template .env
85
+ ```
86
+
87
+ Edit the `.env` file:
88
+
89
+ ```env
90
+ SWANLAB_API_KEY=your_api_key_here
91
+ ```
92
+
93
+ ### Running
94
+
95
+ ```bash
96
+ # Using stdio transport (default)
97
+ python -m swanlab_mcp
98
+
99
+ # Or using CLI
100
+ python -m swanlab_mcp --transport stdio
101
+
102
+ # Check version
103
+ python -m swanlab_mcp --version
104
+ ```
105
+
106
+ ### Usage
107
+
108
+ After configuration, restart Claude Desktop to interact with SwanLab via the MCP protocol.
109
+
110
+ Available Tools:
111
+ - `swanlab_list_workspaces` - List workspaces
112
+ - `swanlab_create_project` - Create project
113
+ - `swanlab_list_projects` - List projects
114
+ - `swanlab_create_experiment` - Create experiment
115
+ - `swanlab_list_experiments` - List experiments
116
+ - `swanlab_get_experiment` - Get experiment details
117
+ - `swanlab_delete_experiment` - Delete experiment
118
+
119
+ ## 🛠️ Development
120
+
121
+ ### Code Formatting
122
+
123
+ ```bash
124
+ # Using Makefile
125
+ make format
126
+
127
+ # Or manually
128
+ uvx isort . --skip-gitignore
129
+ uvx ruff format . --quiet
130
+ ```
131
+
132
+ ### Lint Check
133
+
134
+ ```bash
135
+ uvx ruff check .
136
+ ```
137
+
138
+ ### Pre-commit Hooks
139
+
140
+ ```bash
141
+ bash scripts/install-hooks.sh
142
+ ```
143
+
144
+ ## 📚 References & Acknowledgements
145
+
146
+ - [SwanLab](https://github.com/SwanHubX/SwanLab)
147
+ - [Model Context Protocol](https://modelcontextprotocol.io/docs/getting-started/intro)
148
+ - [FastMCP v2](https://github.com/jlowin/fastmcp)
149
+ - [modelscope-mcp-server](https://github.com/modelscope/modelscope-mcp-server)
150
+ - [TrackIO-mcp-server](https://github.com/fcakyon/trackio-mcp)
151
+ - [Simple-Wandb-mcp-server](https://github.com/tsilva/simple-wandb-mcp-server)
152
+
153
+ ## 📄 License
154
+
155
+ MIT License
@@ -0,0 +1,142 @@
1
+ # SwanLab-MCP-Server
2
+
3
+ > A Model Context Protocol (MCP) server implementation for SwanLab, combining SwanLab-OpenAPI & FastMCP.
4
+
5
+ ## ✨ Features
6
+
7
+ ### Core Features
8
+
9
+ - **Workspace Management** - List and manage user-accessible workspaces
10
+ - **Project Management** - Create, retrieve, delete projects, and list project information
11
+ - **Experiment Management** - Create, retrieve, delete experiments, and retrieve experiment metrics and summaries
12
+ - **API Integration** - Provide complete platform access through SwanLab OpenAPI
13
+
14
+ ### Tech Stack
15
+
16
+ - **Language**: Python 3.12+
17
+ - **Core Framework**: FastMCP (v2.14.4+)
18
+ - **API Client**: SwanLab SDK
19
+ - **Config Management**: Pydantic Settings
20
+
21
+ ## 🚀 Quick Start
22
+
23
+ ### ❗️Configuration
24
+
25
+ Add the following configuration to your relative mcp config list
26
+
27
+ ```json
28
+ {
29
+ "mcpServers":
30
+ ...
31
+ {
32
+ "swanlab-mcp": {
33
+ "command": "uv",
34
+ "args": ["run", "swanlab_mcp", "--transport", "stdio"],
35
+ "env": {
36
+ "SWANLAB_API_KEY": "your_api_key_here"
37
+ }
38
+ }
39
+ }
40
+ }
41
+ ```
42
+
43
+ For `Claude Code` Users, you can config like this:
44
+
45
+ ```bash
46
+ claude mcp add --env SWANLAB_API_KEY=<your_api_key> -- swanlab_mcp uv run swanlab_mcp --transport stdio
47
+ ```
48
+
49
+ ### Prerequisites
50
+
51
+ - Python >= 3.12
52
+ - SwanLab API Key (get it from [SwanLab](https://swanlab.cn))
53
+
54
+ ### Installation
55
+
56
+ ```bash
57
+ # Using uv (recommended)
58
+ uv sync
59
+
60
+ # Or using pip
61
+ pip install -e .
62
+ ```
63
+
64
+ ### Configuration
65
+
66
+ #### Environment Variables
67
+
68
+ Create a `.env` file and configure your API key:
69
+
70
+ ```bash
71
+ cp .env.template .env
72
+ ```
73
+
74
+ Edit the `.env` file:
75
+
76
+ ```env
77
+ SWANLAB_API_KEY=your_api_key_here
78
+ ```
79
+
80
+ ### Running
81
+
82
+ ```bash
83
+ # Using stdio transport (default)
84
+ python -m swanlab_mcp
85
+
86
+ # Or using CLI
87
+ python -m swanlab_mcp --transport stdio
88
+
89
+ # Check version
90
+ python -m swanlab_mcp --version
91
+ ```
92
+
93
+ ### Usage
94
+
95
+ After configuration, restart Claude Desktop to interact with SwanLab via the MCP protocol.
96
+
97
+ Available Tools:
98
+ - `swanlab_list_workspaces` - List workspaces
99
+ - `swanlab_create_project` - Create project
100
+ - `swanlab_list_projects` - List projects
101
+ - `swanlab_create_experiment` - Create experiment
102
+ - `swanlab_list_experiments` - List experiments
103
+ - `swanlab_get_experiment` - Get experiment details
104
+ - `swanlab_delete_experiment` - Delete experiment
105
+
106
+ ## 🛠️ Development
107
+
108
+ ### Code Formatting
109
+
110
+ ```bash
111
+ # Using Makefile
112
+ make format
113
+
114
+ # Or manually
115
+ uvx isort . --skip-gitignore
116
+ uvx ruff format . --quiet
117
+ ```
118
+
119
+ ### Lint Check
120
+
121
+ ```bash
122
+ uvx ruff check .
123
+ ```
124
+
125
+ ### Pre-commit Hooks
126
+
127
+ ```bash
128
+ bash scripts/install-hooks.sh
129
+ ```
130
+
131
+ ## 📚 References & Acknowledgements
132
+
133
+ - [SwanLab](https://github.com/SwanHubX/SwanLab)
134
+ - [Model Context Protocol](https://modelcontextprotocol.io/docs/getting-started/intro)
135
+ - [FastMCP v2](https://github.com/jlowin/fastmcp)
136
+ - [modelscope-mcp-server](https://github.com/modelscope/modelscope-mcp-server)
137
+ - [TrackIO-mcp-server](https://github.com/fcakyon/trackio-mcp)
138
+ - [Simple-Wandb-mcp-server](https://github.com/tsilva/simple-wandb-mcp-server)
139
+
140
+ ## 📄 License
141
+
142
+ MIT License
@@ -0,0 +1,142 @@
1
+ # SwanLab-MCP-Server
2
+
3
+ > SwanLab-MCP-Server 是一个基于 Python 的 MCP(Model Context Protocol)服务器实现,结合了 SwanLab-OpenAPI 和 FastMCP 框架。
4
+
5
+ ## ✨ 功能特性
6
+
7
+ ### 核心功能
8
+
9
+ - **工作空间管理** - 列出和管理用户可访问的工作空间
10
+ - **项目管理** - 创建、获取、删除项目,以及列出项目信息
11
+ - **实验管理** - 创建、获取、删除实验,检索实验指标和摘要
12
+ - **API 集成** - 通过 SwanLab OpenAPI 提供完整的平台访问能力
13
+
14
+ ### 技术栈
15
+
16
+ - **语言**: Python 3.12+
17
+ - **核心框架**: FastMCP (v2.14.4+)
18
+ - **API 客户端**: SwanLab SDK
19
+ - **配置管理**: Pydantic Settings
20
+
21
+ ## 🚀 快速开始
22
+
23
+
24
+ ### ❗️重要【配置方式】
25
+
26
+ 在你对应的 mcp 配置文件中赋值如下配置 (如 `cursor`, `claude code`, 或许也可以手动实现?)
27
+
28
+ ```json
29
+ {
30
+ "mcpServers":
31
+ ...
32
+ {
33
+ "swanlab-mcp": {
34
+ "command": "uvx",
35
+ "args": ["swanlab_mcp", "--transport", "stdio"],
36
+ "env": {
37
+ "SWANLAB_API_KEY": "your_api_key_here"
38
+ }
39
+ }
40
+ }
41
+ }
42
+ ```
43
+ 对于 `Claude Code` 用户,可以一次性配置:
44
+
45
+ ```bash
46
+ claude mcp add --env SWANLAB_API_KEY=<your_api_key> -- swanlab_mcp uv run swanlab_mcp --transport stdio
47
+ ```
48
+
49
+ ### 环境要求
50
+
51
+ - Python >= 3.12
52
+ - SwanLab API Key(从 [SwanLab](https://swanlab.cn) 获取)
53
+
54
+ ### 安装
55
+
56
+ ```bash
57
+ # 使用 uv 安装(推荐)
58
+ uv sync
59
+
60
+ # 或使用 pip
61
+ pip install -e .
62
+ ```
63
+
64
+ ### 配置
65
+
66
+ #### 环境变量
67
+
68
+ 创建 `.env` 文件并配置 API 密钥:
69
+
70
+ ```bash
71
+ cp .env.template .env
72
+ ```
73
+
74
+ 编辑 `.env` 文件:
75
+
76
+ ```env
77
+ SWANLAB_API_KEY=your_api_key_here
78
+ ```
79
+
80
+ ### 运行
81
+
82
+ ```bash
83
+ # 使用 stdio 传输(默认)
84
+ python -m swanlab_mcp
85
+
86
+ # 或使用 CLI
87
+ python -m swanlab_mcp --transport stdio
88
+
89
+ # 查看版本
90
+ python -m swanlab_mcp --version
91
+ ```
92
+
93
+ ### 使用
94
+
95
+ 配置完成后,重启 Claude Desktop,即可通过 MCP 协议与 SwanLab 进行交互。
96
+
97
+ 可用工具:
98
+ - `swanlab_list_workspaces` - 列出工作空间
99
+ - `swanlab_create_project` - 创建项目
100
+ - `swanlab_list_projects` - 列出项目
101
+ - `swanlab_create_experiment` - 创建实验
102
+ - `swanlab_list_experiments` - 列出实验
103
+ - `swanlab_get_experiment` - 获取实验详情
104
+ - `swanlab_delete_experiment` - 删除实验
105
+
106
+ ## 🛠️ 开发
107
+
108
+ ### 代码格式化
109
+
110
+ ```bash
111
+ # 使用 Makefile
112
+ make format
113
+
114
+ # 或手动执行
115
+ uvx isort . --skip-gitignore
116
+ uvx ruff format . --quiet
117
+ ```
118
+
119
+ ### Lint 检查
120
+
121
+ ```bash
122
+ uvx ruff check .
123
+ ```
124
+
125
+ ### Pre-commit 钩子
126
+
127
+ ```bash
128
+ bash scripts/install-hooks.sh
129
+ ```
130
+
131
+ ## 📚 参考资料
132
+
133
+ - [SwanLab](https://github.com/SwanHubX/SwanLab)
134
+ - [Model Context Protocol](https://modelcontextprotocol.io/docs/getting-started/intro)
135
+ - [FastMCP v2](https://github.com/jlowin/fastmcp)
136
+ - [modelscope-mcp-server](https://github.com/modelscope/modelscope-mcp-server)
137
+ - [TrackIO-mcp-server](https://github.com/fcakyon/trackio-mcp)
138
+ - [Simple-Wandb-mcp-server](https://github.com/tsilva/simple-wandb-mcp-server)
139
+
140
+ ## 📄 许可证
141
+
142
+ MIT License
@@ -0,0 +1,45 @@
1
+ [project]
2
+ name = "swanlab-mcp"
3
+ dynamic = ["version"]
4
+ description = "MCP (Model Context Protocol) server support for SwanLab"
5
+ authors = [{ name = "CaddiesNew", email = "nexisato0810@gmail.com" }]
6
+ license = { text = "MIT" }
7
+ readme = "README.md"
8
+ requires-python = ">=3.12"
9
+ dependencies = [
10
+ "fastmcp>=2.14.4",
11
+ "pydantic-settings>=2.0.0",
12
+ "python-dotenv>=1.2.1",
13
+ "swanlab",
14
+ ]
15
+
16
+ [build-system]
17
+ requires = ["hatchling"]
18
+ build-backend = "hatchling.build"
19
+
20
+ [tool.hatch.build.targets.wheel]
21
+ packages = ["src/swanlab_mcp"]
22
+
23
+ [project.scripts]
24
+ swanlab_mcp = "swanlab_mcp.cli:main"
25
+
26
+ [dependency-groups]
27
+ dev = ["pre-commit>=4.3.0", "ruff>=0.14.3"]
28
+
29
+ [tool.hatch.version]
30
+ path = "src/swanlab_mcp/_version.py"
31
+
32
+
33
+ [tool.ruff]
34
+ line-length = 122
35
+ target-version = "py312"
36
+ include = ["**/*.py", "**/*.pyi"]
37
+ src = ["src"]
38
+ exclude = [".git", ".ruff_cache", ".venv", "__pycache__", "build", "dist"]
39
+
40
+ [tool.ruff.lint.isort]
41
+ known-first-party = ["constants", "tools"]
42
+
43
+ [tool.ruff.format]
44
+ quote-style = "double"
45
+ indent-style = "space"