🌐 中文说明 | English
A comprehensive Go library, CLI tool, and MCP server for 115 cloud storage. It provides a full-featured driver for 115.com's API, supporting login, file operations, upload/download, offline downloads, and more.
- Features
- Installation
- Quick Start
- CLI
- MCP Server
- API Reference
- Troubleshooting
- Project Structure
- Contributing
- License
Authentication — Cookie-based login, QR code login, and user identity verification.
File Operations — List, rename, move, copy, delete, download, upload (with rapid upload via SHA1 deduplication and multipart upload via Aliyun OSS), search with filters, and get file info/statistics.
Offline Downloads — Add HTTP, ED2K, and magnet link download tasks; list, delete, and clear tasks.
Share — Create share links and download files via share code.
Recycle Bin — List, restore, and permanently delete items.
CLI — Full-featured command-line interface with colored table output, JSON mode for scripts, shell completions, and multiple profile support.
MCP Server — Model Context Protocol server for AI application integration (Claude Desktop, Cursor, etc.).
✨ Fork Enhancements — This fork (Suntoa12138/115driver) includes additional improvements beyond upstream:
- Config-file-based authentication — MCP server reads cookies and config from
~/.115driver/config.toml, no need to pass--cookieon every launch- Default offline save directory — Both CLI and MCP respect
default_offline_save_dirfrom configuration- API compatibility fixes — Handles 115 API response format changes for
imei_infoand download URL fields
⚠️ This is an enhanced fork. The following upstream-unmerged improvements are included:
- Config-file-based authentication — MCP reads cookie from
~/.115driver/config.tomlvia--profile- Default offline save directory — CLI & MCP respect
default_offline_save_dirfrom config- API compatibility fixes — Handles 115 API response format changes for
imei_infoand download URL fieldsAll install commands below point to this enhanced fork.
# To use as a Go library (add a replace directive in your go.mod pointing to this fork)
go get github.com/SheltonZhu/115driver
# Then add the replace directive:
# go mod edit -replace github.com/SheltonZhu/115driver=github.com/suntao12138/115driver@latestpackage main
import (
"github.com/SheltonZhu/115driver/pkg/driver"
"log"
)
func main() {
// Option 1: Import credentials from cookie string
cr, err := driver.CredentialFromCookie("your_cookie_string")
if err != nil {
log.Fatalf("Failed to create credential: %v", err)
}
// Option 2: Create credentials manually
// cr := &driver.Credential{
// UID: "your_uid",
// CID: "your_cid",
// SEID: "your_seid",
// KID: "your_kid",
// }
// Create client with credentials
client := driver.Default().ImportCredential(cr)
// Check login status
if err := client.LoginCheck(); err != nil {
log.Fatalf("Login failed: %v", err)
}
log.Println("Successfully logged in!")
}The examples below assume you have an authenticated client (see Basic Usage above).
// Download a file using pickcode
downloadInfo, err := client.Download("pickcode_here")
if err != nil { /* handle error */ }
fileReader, _ := downloadInfo.Get()
defer fileReader.Close()
// write fileReader to file...// Upload a file (auto-selects rapid upload or multipart via OSS)
file, _ := os.Open("/path/to/local/file.zip")
defer file.Close()
fileInfo, _ := file.Stat()
uploadID, err := client.RapidUploadOrByOSS(
"0", // parent directory ID ("0" for root)
fileInfo.Name(),
fileInfo.Size(),
file,
)// List files in root directory
files, err := client.List("0")
for _, f := range files {
log.Printf("File: %s, Size: %d, Type: %s", f.Name, f.Size, f.Type)
}// Search for files
results, err := client.Search(&driver.SearchOption{
SearchValue: "document",
Limit: 100,
})
for _, r := range results.Files {
log.Printf("File: %s, Size: %d", r.Name, r.Size)
}// Add offline download task
taskIDs, err := client.AddOfflineTaskURIs(
[]string{"https://example.com/file.zip"},
"0", // "0" for root directory
)115driver includes a CLI tool for interacting with 115 cloud storage from the command line, designed for both human use (colored table output) and AI agent consumption (--json flag).
# Install the enhanced CLI from this fork
go install github.com/suntao12138/115driver/cmd/115driver@latest# QR code login (interactive)
115driver login
# Cookie login
115driver login --cookie "UID=xxx;CID=xxx;SEID=xxx;KID=xxx"
# Verify identity
115driver whoami
# Account and storage info
115driver infoCredentials are stored in ~/.115driver/config.toml and support multiple profiles.
--cookieflagDRIVER115_COOKIEenvironment variable- Config file (
~/.115driver/config.toml)
Additional env vars: DRIVER115_CONFIG (config path), DRIVER115_PROFILE (profile name).
# List files
115driver ls /path/to/dir
115driver ls -l /path/to/dir # detailed view
# File info
115driver stat /path/to/file
# Account and storage info
115driver info
# Create directories
115driver mkdir /new/dir
115driver mkdir -p /deep/nested/dir # create parents
# Move / Copy / Rename / Delete
115driver mv /source/file /dest/dir
115driver cp /source/file /dest/dir
115driver rename /path/to/file new_name
115driver rm /path/to/file
# Upload & Download
115driver upload /local/file /remote/dir
115driver download /remote/file /local/dir
# Search
115driver search keyword
115driver search keyword -t video # filter by type
115driver search keyword --sort size # sort results
# Offline downloads (HTTP/ED2K/magnet)
115driver offline add <url>
115driver offline add <url> -d /save/dir
115driver offline list
115driver offline rm <hash>All commands support --json for machine-readable output:
115driver --json ls /path/to/dir
115driver --json stat /path/to/file
115driver --json info# Bash
echo 'source <(115driver completion bash)' >> ~/.bashrc
# Zsh
echo 'source <(115driver completion zsh)' >> ~/.zshrc
# Fish
115driver completion fish > ~/.config/fish/completions/115driver.fish115driver includes an MCP (Model Context Protocol) server for AI application integration (Claude Desktop, Cursor, etc.).
Option 1: go install
# Install the enhanced MCP server from this fork
go install github.com/suntao12138/115driver/mcp@latestOption 2: build from source
# Clone this enhanced fork
git clone https://github.com/suntao12138/115driver.git
cd 115driver
go build -o 115driver-mcp-server ./mcp/# If installed via go install:
mcp --profile main # Read cookie from config (recommended)
mcp --cookie="UID=xxx;CID=xxx;SEID=xxx;KID=xxx" # Or pass cookie directly
# If built from source:
./115driver-mcp-server --profile main| Category | Tools |
|---|---|
| Account | getAccountInfo |
| Directory | listDirectory |
| File | stat, mkdir, delete, rename, move, copy, upload_from_url, upload_from_local, download_file, get_download_info |
| Search | search |
| Offline | listOfflineTasks, addOfflineTaskURIs, deleteOfflineTasks, clearOfflineTasks |
| Share | getShareSnap |
| Recycle | listRecycleBin, revertRecycleBin, cleanRecycleBin |
The --cookie flag can be omitted if ~/.115driver/config.toml has a valid cookie:
# Use default profile from config
./115driver-mcp-server --profile main
# Or rely on environment variables
DRIVER115_PROFILE=main ./115driver-mcp-serverConfig file priority: --config flag > DRIVER115_CONFIG env var > ~/.115driver/config.toml.
Profile priority: --profile flag > DRIVER115_PROFILE env var > default_profile in config > main.
The addOfflineTaskURIs tool's save_dir_id parameter is now optional — if omitted, the default_offline_save_dir from config (if set) is used automatically. Run 115driver login first to generate the config file.
Add to your claude_desktop_config.json:
{
"mcpServers": {
"115driver": {
"command": "mcp",
"args": ["--profile", "main"]
}
}
}Tip: When using this enhanced fork's binary (installed via
go installor built locally), setcommandto115driver-mcp-serveror the appropriate binary path. Using--profile mainreads the cookie from~/.115driver/config.tomlautomatically, eliminating the need to expose secrets in config files. Run115driver loginfirst to generate the config file before starting MCP.
For detailed API documentation, visit pkg.go.dev.
If you encounter login issues:
- Make sure your cookie is valid and not expired
- Check that all required fields (UID, CID, SEID, KID) are present
- Try logging in through the web interface first to obtain a fresh cookie
If upload or download fails:
- Verify file paths are correct
- Check your internet connection
- Ensure you have sufficient storage space
- Check the returned error message for specific details
The 115 API may have rate limits. If you encounter rate limiting errors:
- Add delays between operations
- Implement retry logic with exponential backoff
- Consider using a proxy if needed
115driver/ # Go 1.23+
├── cmd/
│ └── 115driver/ # CLI entry point (go install binary)
├── cli/ # CLI implementation
│ ├── cmd/ # Cobra commands
│ └── internal/ # Internal packages (auth, output, resolver)
├── internal/ # Shared app-level helpers
├── pkg/
│ ├── driver/ # Core driver (client, login, file, upload, download, search, share, offline)
│ └── crypto/ # Cryptography utilities (ECDH, AES, RSA)
└── mcp/ # MCP server (stdin/stdout JSON-RPC 2.0)
├── main.go # Entry point
└── server/tools/ # Tool implementations (account, dir, file, search, offline, share, recycle)
Contributions are welcome! Please feel free to submit a Pull Request.
|
SheltonZhu |
xhofe |
Ovear |
power721 |
|
suntao12138 |