catbox-mcp-server 1.0.0

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.
Files changed (4) hide show
  1. package/README.md +213 -0
  2. package/index.js +171 -0
  3. package/mcp.json +15 -0
  4. package/package.json +18 -0
package/README.md ADDED
@@ -0,0 +1,213 @@
1
+ # 🐱 Catbox MCP Server
2
+
3
+ A [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server for [Catbox.moe](https://catbox.moe) — a free file hosting service. Upload files via URL, manage albums, and delete files directly from your MCP client (Claude Desktop, Claude Code, etc.).
4
+
5
+ [![npm version](https://img.shields.io/npm/v/catbox-mcp-server)](https://www.npmjs.com/package/catbox-mcp-server)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
7
+
8
+ ---
9
+
10
+ ## ⚠️ Important: Anonymous vs Authenticated
11
+
12
+ Catbox has two user tiers. Understanding this is key:
13
+
14
+ | Capability | 🕶️ Anonymous | 🔑 With Userhash |
15
+ |-----------|:---:|:---:|
16
+ | **Upload files** | ✅ | ✅ |
17
+ | **Delete files** | ❌ | ✅ |
18
+ | **Create album** | ✅ (but **cannot** edit/delete later) | ✅ (fully manageable) |
19
+ | **Edit album** | ❌ | ✅ |
20
+ | **Add/remove album files** | ❌ | ✅ |
21
+ | **Delete album** | ❌ | ✅ |
22
+
23
+ You can get a free userhash by uploading any file to [Catbox.moe](https://catbox.moe) — see [Getting Your Userhash](#-getting-your-userhash).
24
+
25
+ ## ✨ Features
26
+
27
+ | Feature | Description |
28
+ |---------|-------------|
29
+ | ☁️ **URL Upload** | Upload files from any publicly accessible URL |
30
+ | 🗑️ **File Management** | Delete files you've uploaded |
31
+ | 🖼️ **Album Management** | Create, edit, add to, remove from, and delete albums |
32
+
33
+ ## 🧰 Tools
34
+
35
+ | Tool | Description |
36
+ |------|-------------|
37
+ | `url_upload` | Upload a file from a publicly accessible URL |
38
+ | `delete_files` | Delete uploaded files (userhash required) |
39
+ | `create_album` | Create a new album |
40
+ | `edit_album` | Edit album title/description/files (userhash required) |
41
+ | `add_to_album` | Add files to an album (userhash required) |
42
+ | `remove_from_album` | Remove files from an album (userhash required) |
43
+ | `delete_album` | Delete an album (userhash required) |
44
+
45
+ See the [userhash guide](#-getting-your-userhash) to set up authentication for management tools.
46
+
47
+ ## 📦 Installation
48
+
49
+ ### Via npm (recommended)
50
+
51
+ ```bash
52
+ npm install -g catbox-mcp-server
53
+ ```
54
+
55
+ ### Via npx (no install)
56
+
57
+ ```bash
58
+ npx -y catbox-mcp-server
59
+ ```
60
+
61
+ ### From source
62
+
63
+ ```bash
64
+ git clone https://github.com/xxy9468615/catbox.git
65
+ cd catbox
66
+ npm install
67
+ node index.js
68
+ ```
69
+
70
+ ## 🔧 Configuration
71
+
72
+ ### Claude Desktop / Claude Code
73
+
74
+ Add to your `mcpServers` config:
75
+
76
+ ```json
77
+ {
78
+ "mcpServers": {
79
+ "catbox": {
80
+ "command": "npx",
81
+ "args": ["-y", "catbox-mcp-server"],
82
+ "env": {
83
+ "CATBOX_USERHASH": "your-catbox-userhash-here"
84
+ }
85
+ }
86
+ }
87
+ }
88
+ ```
89
+
90
+ ### Environment Variables
91
+
92
+ | Variable | Required | Default | Description |
93
+ |----------|----------|---------|-------------|
94
+ | `CATBOX_USERHASH` | ❌ | — | Your Catbox user hash for authentication. Set this to avoid passing it with every call. |
95
+
96
+ > **💡 Tip:** You can always override the userhash per-tool call by passing it as a parameter — the environment variable is just a convenient default.
97
+
98
+ ### 🔑 Getting Your Userhash
99
+
100
+ No account registration required — you get a userhash just by using Catbox:
101
+
102
+ 1. Go to [Catbox.moe](https://catbox.moe)
103
+ 2. Upload **any file** from your computer (or use this API to upload a URL)
104
+ 3. After upload, the page displays your **userhash** — a hex string like `a1b2c3d4e5f6...`
105
+ 4. **Save it** and use it with any management tool
106
+ 5. You can also get the userhash from the API response when uploading without one
107
+
108
+ > **💡 Without userhash:** You can upload files and create albums, but:
109
+ > - You **cannot** delete any files
110
+ > - Albums created anonymously are **permanent and unmodifiable** — no edits, no deletions
111
+ > - To manage anything, you need your userhash
112
+
113
+ ## 🚀 Usage Examples
114
+
115
+ ### Upload a file from URL
116
+
117
+ ```json
118
+ {
119
+ "url": "https://example.com/image.jpg"
120
+ }
121
+ ```
122
+
123
+ Response:
124
+ ```
125
+ https://files.catbox.moe/abc123.jpg
126
+ ```
127
+
128
+ ### Upload with userhash (to claim ownership)
129
+
130
+ ```json
131
+ {
132
+ "url": "https://example.com/image.jpg",
133
+ "userhash": "a1b2c3d4e5f6"
134
+ }
135
+ ```
136
+
137
+ ### Create an album
138
+
139
+ ```json
140
+ {
141
+ "title": "My Vacation Photos",
142
+ "files": "abc123.jpg def456.png",
143
+ "desc": "Summer 2026 trip",
144
+ "userhash": "a1b2c3d4e5f6"
145
+ }
146
+ ```
147
+
148
+ ### Add files to an album
149
+
150
+ ```json
151
+ {
152
+ "short": "album123",
153
+ "files": "ghi789.jpg jkl012.png",
154
+ "userhash": "a1b2c3d4e5f6"
155
+ }
156
+ ```
157
+
158
+ ### Delete files
159
+
160
+ ```json
161
+ {
162
+ "files": "abc123.jpg def456.png",
163
+ "userhash": "a1b2c3d4e5f6"
164
+ }
165
+ ```
166
+
167
+ ## 🔗 Links
168
+
169
+ - **Catbox.moe**: [https://catbox.moe](https://catbox.moe)
170
+ - **Catbox API / Tools**: [https://catbox.moe/tools.php](https://catbox.moe/tools.php)
171
+ - **Catbox FAQ**: [https://catbox.moe/faq.php](https://catbox.moe/faq.php)
172
+ - **GitHub Repo**: [https://github.com/xxy9468615/catbox](https://github.com/xxy9468615/catbox)
173
+
174
+ ## 📄 License
175
+
176
+ MIT
177
+
178
+ ---
179
+
180
+ ## ⚖️ Disclaimer
181
+
182
+ This MCP server is an **unofficial community tool** and is **not affiliated with, endorsed by, or sponsored by Catbox LLC**.
183
+
184
+ ### Your Responsibilities
185
+
186
+ By using this tool, you agree to comply with [Catbox's Terms of Service](https://catbox.moe/legal.php):
187
+
188
+ - **You own your content** — you must have the right to upload, share, and store any files you upload via this tool
189
+ - **No illegal use** — do not upload copyrighted content without permission, malware, spyware, or any material that violates applicable laws
190
+ - **No commercial use** — Catbox prohibits commercial use of their service without prior written approval from Catbox Executives
191
+ - **No reselling** — you may not resell or supply Catbox services to others
192
+ - **No abuse** — do not spam, harass, or damage Catbox's infrastructure
193
+
194
+ ### No Warranty
195
+
196
+ This tool is provided **"AS IS"**, without any express or implied warranty. The authors are not responsible for:
197
+
198
+ - Any content uploaded or shared through this tool
199
+ - Any loss of data, files, or access to Catbox services
200
+ - Any damages arising from the use or inability to use this tool
201
+ - Any violations of Catbox's Terms of Service by end users
202
+
203
+ **Use at your own risk.** If you have concerns about specific content or usage, contact Catbox at **admin@catbox.moe**.
204
+
205
+ ---
206
+
207
+ ## ☕ Support Catbox
208
+
209
+ Catbox.moe provides a **free** file hosting service with no accounts required. If you find this service useful, consider supporting them:
210
+
211
+ - **Ko-fi**: [https://ko-fi.com/catboxmoe](https://ko-fi.com/catboxmoe)
212
+ - **Spread the word** — tell others about Catbox!
213
+ - **Follow their rules** — be a responsible user so the service stays alive for everyone ❤️
package/index.js ADDED
@@ -0,0 +1,171 @@
1
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import {
4
+ CallToolRequestSchema,
5
+ ListToolsRequestSchema,
6
+ } from "@modelcontextprotocol/sdk/types.js";
7
+ import FormData from "form-data";
8
+ import axios from "axios";
9
+
10
+ const CATBOX_API = "https://catbox.moe/user/api.php";
11
+ const DEFAULT_USERHASH = process.env.CATBOX_USERHASH || null;
12
+
13
+ // ========== 工具定义 ==========
14
+
15
+ const TOOLS = [
16
+ {
17
+ name: "url_upload",
18
+ description: "通过 URL 上传文件到 Catbox",
19
+ inputSchema: {
20
+ type: "object",
21
+ properties: {
22
+ url: { type: "string", description: "文件的直接链接" },
23
+ userhash: { type: "string", description: "用户哈希(可选,匿名上传不填)" },
24
+ },
25
+ required: ["url"],
26
+ },
27
+ },
28
+ {
29
+ name: "delete_files",
30
+ description: "删除已上传的文件",
31
+ inputSchema: {
32
+ type: "object",
33
+ properties: {
34
+ files: { type: "string", description: "要删除的文件名,空格分隔" },
35
+ userhash: { type: "string", description: "用户哈希" },
36
+ },
37
+ required: ["files", "userhash"],
38
+ },
39
+ },
40
+ {
41
+ name: "create_album",
42
+ description: "创建相册",
43
+ inputSchema: {
44
+ type: "object",
45
+ properties: {
46
+ title: { type: "string", description: "相册标题" },
47
+ files: { type: "string", description: "文件名,空格分隔" },
48
+ userhash: { type: "string", description: "用户哈希(可选,匿名创建后无法编辑)" },
49
+ desc: { type: "string", description: "相册描述(可选)" },
50
+ },
51
+ required: ["title", "files"],
52
+ },
53
+ },
54
+ {
55
+ name: "edit_album",
56
+ description: "编辑相册(必须提供所有参数)",
57
+ inputSchema: {
58
+ type: "object",
59
+ properties: {
60
+ short: { type: "string", description: "相册短 ID" },
61
+ title: { type: "string", description: "相册标题" },
62
+ files: { type: "string", description: "文件名,空格分隔" },
63
+ userhash: { type: "string", description: "用户哈希" },
64
+ desc: { type: "string", description: "相册描述" },
65
+ },
66
+ required: ["short", "title", "files", "userhash"],
67
+ },
68
+ },
69
+ {
70
+ name: "add_to_album",
71
+ description: "向相册添加文件",
72
+ inputSchema: {
73
+ type: "object",
74
+ properties: {
75
+ short: { type: "string", description: "相册短 ID" },
76
+ files: { type: "string", description: "文件名,空格分隔" },
77
+ userhash: { type: "string", description: "用户哈希" },
78
+ },
79
+ required: ["short", "files", "userhash"],
80
+ },
81
+ },
82
+ {
83
+ name: "remove_from_album",
84
+ description: "从相册移除文件",
85
+ inputSchema: {
86
+ type: "object",
87
+ properties: {
88
+ short: { type: "string", description: "相册短 ID" },
89
+ files: { type: "string", description: "文件名,空格分隔" },
90
+ userhash: { type: "string", description: "用户哈希" },
91
+ },
92
+ required: ["short", "files", "userhash"],
93
+ },
94
+ },
95
+ {
96
+ name: "delete_album",
97
+ description: "删除相册",
98
+ inputSchema: {
99
+ type: "object",
100
+ properties: {
101
+ short: { type: "string", description: "相册短 ID" },
102
+ userhash: { type: "string", description: "用户哈希" },
103
+ },
104
+ required: ["short", "userhash"],
105
+ },
106
+ },
107
+ ];
108
+
109
+ // ========== 工具处理 ==========
110
+
111
+ async function handleToolCall(name, args) {
112
+ // 使用环境变量中的 userhash 作为默认值
113
+ const userhash = args.userhash || DEFAULT_USERHASH;
114
+
115
+ switch (name) {
116
+ case "url_upload":
117
+ return await apiCall({ reqtype: "urlupload", userhash, url: args.url });
118
+ case "delete_files":
119
+ if (!userhash) throw new Error("需要 userhash 才能删除文件,请在环境变量 CATBOX_USERHASH 中配置或在参数中传入");
120
+ return await apiCall({ reqtype: "deletefiles", userhash, files: args.files });
121
+ case "create_album":
122
+ return await apiCall({ reqtype: "createalbum", userhash, title: args.title, desc: args.desc, files: args.files });
123
+ case "edit_album":
124
+ if (!userhash) throw new Error("需要 userhash 才能编辑相册");
125
+ return await apiCall({ reqtype: "editalbum", userhash, short: args.short, title: args.title, desc: args.desc || "", files: args.files });
126
+ case "add_to_album":
127
+ if (!userhash) throw new Error("需要 userhash 才能添加文件到相册");
128
+ return await apiCall({ reqtype: "addtoalbum", userhash, short: args.short, files: args.files });
129
+ case "remove_from_album":
130
+ if (!userhash) throw new Error("需要 userhash 才能从相册移除文件");
131
+ return await apiCall({ reqtype: "removefromalbum", userhash, short: args.short, files: args.files });
132
+ case "delete_album":
133
+ if (!userhash) throw new Error("需要 userhash 才能删除相册");
134
+ return await apiCall({ reqtype: "deletealbum", userhash, short: args.short });
135
+ default:
136
+ throw new Error(`未知工具: ${name}`);
137
+ }
138
+ }
139
+
140
+ async function apiCall(params) {
141
+ const form = new FormData();
142
+ for (const [k, v] of Object.entries(params)) {
143
+ if (v !== undefined && v !== null) form.append(k, v);
144
+ }
145
+ const res = await axios.post(CATBOX_API, form, { headers: form.getHeaders() });
146
+ return { result: res.data.trim() };
147
+ }
148
+
149
+ // ========== MCP 服务器 ==========
150
+
151
+ const server = new Server(
152
+ { name: "catbox-mcp", version: "1.0.0" },
153
+ { capabilities: { tools: {} } }
154
+ );
155
+
156
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
157
+
158
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
159
+ const { name, arguments: args } = request.params;
160
+ try {
161
+ const result = await handleToolCall(name, args);
162
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
163
+ } catch (e) {
164
+ return { content: [{ type: "text", text: `错误: ${e.message}` }], isError: true };
165
+ }
166
+ });
167
+
168
+ // ========== 启动 ==========
169
+
170
+ const transport = new StdioServerTransport();
171
+ await server.connect(transport);
package/mcp.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "mcpServers": {
3
+ "catbox": {
4
+ "command": "npx",
5
+ "args": [
6
+ "-y",
7
+ "catbox-mcp-server@latest"
8
+ ],
9
+ "type": "stdio",
10
+ "env": {
11
+ "CATBOX_USERHASH": "你的猫盒哈希值,可在环境变量配置,调用时可覆盖"
12
+ }
13
+ }
14
+ }
15
+ }
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "catbox-mcp-server",
3
+ "version": "1.0.0",
4
+ "description": "Catbox.moe MCP Server - 文件上传托管服务",
5
+ "type": "module",
6
+ "main": "index.js",
7
+ "bin": {
8
+ "catbox-mcp-server": "./index.js"
9
+ },
10
+ "scripts": {
11
+ "start": "node index.js"
12
+ },
13
+ "dependencies": {
14
+ "@modelcontextprotocol/sdk": "^1.7.0",
15
+ "axios": "^1.6.0",
16
+ "form-data": "^4.0.0"
17
+ }
18
+ }