deepseek-as-subagent
Run DeepSeek as a real sub-agent inside Claude Code / Codex CLI — not just a single LLM call. DeepSeek gets its own 7-tool agent loop (Read/Write/Edit/Bash/Glob/Grep/NotebookEdit) inside a sandboxed workspace.
README
deepseek-as-subagent
Run DeepSeek as a real sub-agent inside Claude Code / Codex CLI — not just an LLM endpoint. Claude stays on the main loop (your Max OAuth, your context, your judgment). DeepSeek gets its own Read / Write / Edit / Bash / Glob / Grep / NotebookEdit agent loop for batch / mechanical work.
Claude (your main agent, Max OAuth, expensive but smart)
│
│ decides this is a batch task
│ → delegate_to_deepseek(task, context)
▼
DeepSeek sub-agent (cheap, runs its own loop inside the workspace)
│ Read / Write / Edit / Bash / Glob / Grep / NotebookEdit — all local
│ iterates until done
▼
Final message bubbles back to Claude
Claude verifies a sample of the output, reports to you
Quick start
curl -sSL https://raw.githubusercontent.com/PsChina/deepseek-as-subagent/main/curl-install.sh | bash
One line. Clones the repo to ~/.local/share/deepseek-as-subagent, installs
the Python package in an isolated venv, registers the MCP server with Claude
Code, deploys the skill + /ds slash command, and adds a pure shell alias.
After install, edit ~/.deepseek-mcp/config.json to paste your DeepSeek API
key (get one at platform.deepseek.com). Then
run claude and try /ds write a python hello world to /tmp/hi.py.
Re-run the same curl | bash later to upgrade. For other clients (Codex,
Cursor, Cline) or manual install, see Install below.
How is this different from existing DeepSeek MCP servers?
Most deepseek-mcp-server projects expose DeepSeek as a single LLM call (create_chat_completion, create_anthropic_message). Claude has to read every file itself and feed content into the prompt — DeepSeek only saves you the "thinking" cost, not the "reading/writing" cost. Same for Composio's DeepSeek toolkit.
This project gives DeepSeek its own full agent loop: tool dispatch, file I/O, command execution, multi-turn reasoning — all inside a sandboxed workspace. Claude hands off the entire task and gets a single summary back. The token savings are end-to-end.
What's in the box
- MCP server (Python, stdio transport) exposing one real tool:
delegate_to_deepseek(task, context) - Local agent loop for DeepSeek (
agent_loop.py) with OpenAI-compatible function calling - 7 sandboxed tools for DeepSeek to use: Read / Write / Edit / Bash / Glob / Grep / NotebookEdit (Jupyter cell-level editing)
- Path sandbox + command blacklist (
safety.py) — DeepSeek can't escape your workspace or runrm -rf / - Skill + slash command so Claude knows when to delegate (and when not to)
pureshell alias for one-shot "no DeepSeek today" runs
Install
Claude Code (default)
git clone https://github.com/PsChina/deepseek-as-subagent
cd deepseek-as-subagent
./install.sh
Then edit ~/.deepseek-mcp/config.json and paste your DeepSeek API key.
Get a key at https://platform.deepseek.com (CNY ¥20 lasts a long time).
Codex CLI
See adapters/codex/ — registers the MCP server
with codex and provides instructions you can paste into AGENTS.md.
Cursor / Cline / Claude Desktop / other MCP clients
The MCP server itself is client-agnostic. After pip install -e ., point
your client's MCP config at <repo>/.venv/bin/deepseek-mcp. For
client-specific "when to delegate" hints, see adapters/ —
PRs welcome for new clients.
Usage
After install, just use claude normally. The plugin adds:
delegate_to_deepseek— Claude auto-invokes it when the task fits (seeskills/delegate-to-deepseek/SKILL.md)/ds <task>— force delegation, skip Claude's own judgmentpureshell alias — start Claude with DeepSeek disabled for this session
When delegation actually saves money
Critical rule (encoded in the skill): the delegation decision must happen before Claude reads any source files. If Claude reads first then delegates, both Claude and DeepSeek read the same files — net cost goes up, not down.
The skill enforces: only Glob / LS / read-only Bash are allowed before the delegation decision. If you can't decide without reading, you shouldn't delegate.
Sweet spot for delegation:
- ✅ 10–50 files, mechanical pattern (i18n extract, batch refactor, ETL)
- ✅ Large data + simple processing (log scan, file conversion)
- ❌ Single file < 500 lines (DeepSeek thinking-token overhead > savings)
- ❌ Cross-file design / architectural judgment
- ❌ Tasks needing project-specific idioms from
CLAUDE.md
Architecture
┌─────────────────────────────────────────────────────────────────┐
│ Claude Code (CLI or VSCode extension, your Max OAuth) │
│ ↓ stdio (MCP protocol, no network) │
│ deepseek-as-subagent (this project, Python subprocess) │
│ ↓ HTTPS │
│ api.deepseek.com (your API key, paid per token) │
└─────────────────────────────────────────────────────────────────┘
Everything except the actual DeepSeek API call stays on your machine.
No third-party proxy. No cloud relay. Your code never leaves your laptop.
Configuration
~/.deepseek-mcp/config.json:
{
"api_key": "sk-...",
"model": "deepseek-v4-pro",
"max_turns": 50,
"allowed_tools": ["Read", "Write", "Edit", "Bash", "Glob", "Grep", "NotebookEdit"]
}
Workspace (sandbox root) auto-follows the directory where you launch
claude — DeepSeek shares the same scope as Claude itself, no manual config
needed. To lock the sandbox to a fixed path regardless of cwd, add
"workspace": "/abs/path" to the config.
Override at runtime with env vars: DEEPSEEK_API_KEY, DEEPSEEK_WORKSPACE, DEEPSEEK_MODE=off.
Uninstall
./uninstall.sh
Removes the MCP registration, skill, and slash command. Doesn't touch your Claude Code, your Max OAuth, or your projects.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。