Deepwiki MCP Server是一个非官方的Deepwiki MCP Server,能通过MCP获取Deepwiki的网址,抓取所有相关页面,将这些页面转换为Markdown格式,能选择输出单个文档或者按页面列出内容。

Deepwiki MCP Server功能

1、域名安全:只处理来自deepwiki.org的网址,保障处理的安全性。

2、HTML清理:可以去除页面中的页眉、页脚、导航、脚本以及广告等元素,让获取的内容更纯净。

3、链接重写:调整链接,在Markdown格式中能正常使用。

4、多种输出格式:支持输出单个文档,能输出结构化的页面数据。

5、高性能:具备快速抓取能力,可以调节并发数和抓取深度,提升处理效率。

6、NLP功能:能根据库名进行搜索,方便查找特定内容。

Deepwiki MCP Server使用方法

1、使用提示

deepwiki fetch how can i use gpt-image-1 with "vercel ai" sdk

deepwiki fetch how can i create new blocks in shadcn?

deepwiki fetch i want to understand how X works 2、获取完整文档(默认方式)

use deepwiki https://deepwiki.org/shadcn-ui/ui

use deepwiki multiple pages https://deepwiki.org/shadcn-ui/ui

3、获取单页面内容

use deepwiki fetch single page https://deepwiki.org/tailwindlabs/tailwindcss/2.2-theme-system

4、通过短格式获取

use deepwiki fetch tailwindlabs/tailwindcss

deepwiki fetch library

deepwiki fetch url

deepwiki fetch <name>/<repo>

deepwiki multiple pages ...

deepwiki single page url ...

Cursor配置

.cursor/mcp.json文件中添加以下内容:

{
    "mcpServers": {
        "mcp-deepwiki": {
            "command": "npx",
            "args": ["-y", "mcp-deepwiki@latest"]
        }
    }
}

MCP工具集成

该工具包注册了一个名为deepwiki_fetch的工具,可用于任何支持MCP的客户端,使用示例如下:

{
    "action": "deepwiki_fetch",
    "params": {
        "url": "https://deepwiki.org/user/repo",
        "mode": "aggregate",
        "maxDepth": "1"
    }
}

参数说明

1、url(必填):Deepwiki仓库的起始网址。

2、mode(可选):输出模式,aggregate表示输出单个Markdown文档(默认值),pages表示输出结构化的页面数据。

3、maxDepth(可选):页面抓取的最大深度,默认值为10。

响应格式

1、成功响应(聚合模式)

{
    "status": "ok",
    "data": "# Page Title\n\nPage content...\n\n---\n\n# Another Page\n\nMore content...",
    "totalPages": 5,
    "totalBytes": 25000,
    "elapsedMs": 1200
}

2、成功响应(页面模式)

{
    "status": "ok",
    "data": [
        {
            "path": "index",
            "markdown": "# Home Page\n\nWelcome to the repository."
        },
        {
            "path": "section/page1",
            "markdown": "# First Page\n\nThis is the first page content."
        }
    ],
    "totalPages": 2,
    "totalBytes": 12000,
    "elapsedMs": 800
}

3、错误响应

{
    "status": "error",
    "code": "DOMAIN_NOT_ALLOWED",
    "message": "Only deepwiki.org domains are allowed"
}

4、部分成功响应

{
    "status": "partial",
    "data": "# Page Title\n\nPage content...",
    "errors": [
        {
            "url": "https://deepwiki.org/user/repo/page2",
            "reason": "HTTP error: 404"
        }
    ],
    "totalPages": 1,
    "totalBytes": 5000,
    "elapsedMs": 950
}

Deepwiki MCP Server本地开发与部署

本地开发 安装与使用

.cursor/mcp.json文件中配置如下:

{
    "mcpServers": {
        "mcp-deepwiki": {
            "command": "node",
            "args": ["./bin/cli.mjs"]
        }
    }
}

从源代码开始开发:

1、克隆仓库:git clone https://github.com/regenrek/mcp-deepwiki.git,然后进入项目目录:cd mcp-deepwiki

2、安装依赖:npm install

3、构建项目:npm run build

直接API调用

可以通过HTTP进行直接API调用,示例如下:

curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "id": "req-1",
    "action": "deepwiki_fetch",
    "params": {
      "url": "https://deepwiki.org/user/repo",
      "mode": "aggregate"
    }
  }'

配置环境变量

1、DEEPWIKI_MAX_CONCURRENCY:最大并发请求数,默认值为5。

2、DEEPWIKI_REQUEST_TIMEOUT:请求超时时间(毫秒),默认值为30000。

3、DEEPWIKI_MAX_RETRIES:失败请求的最大重试次数,默认值为3。

4、DEEPWIKI_RETRY_DELAY:重试退避的基础延迟时间(毫秒),默认值为250。

在项目根目录创建一个.env文件来配置这些变量,示例:

DEEPWIKI_MAX_CONCURRENCY=10
DEEPWIKI_REQUEST_TIMEOUT=60000
DEEPWIKI_MAX_RETRIES=5
DEEPWIKI_RETRY_DELAY=500

Docker部署

1、构建镜像:docker build -t mcp-deepwiki.

2、以标准输入输出(stdio)方式运行(用于开发):docker run -it --rm mcp-deepwiki

3、以HTTP方式运行(用于生产):docker run -d -p 3000:3000 mcp-deepwiki --http --port 3000

4、运行并设置环境变量:

docker run -d -p 3000:3000 \
  -e DEEPWIKI_MAX_CONCURRENCY=10 \
  -e DEEPWIKI_REQUEST_TIMEOUT=60000 \
  mcp-deepwiki --http --port 3000

Deepwiki MCP Server开发操作

1、安装依赖:pnpm install

2、以stdio方式在开发模式下运行:pnpm run dev-stdio

3、运行测试:pnpm test

4、运行代码检查:pnpm run lint

5、构建项目:pnpm run build

Deepwiki MCP Server常见问题和解决方法

1、权限被拒绝:如果运行CLI时出现EACCES错误,确保二进制文件可执行,命令如下:chmod +x ./node_modules/.bin/mcp-deepwiki

2、连接被拒绝:确保端口可用且未被防火墙阻止,可以使用以下命令检查端口是否被占用:lsof -i :3000

3、超时错误:对于大型仓库,可以考虑增加超时时间和并发数,示例命令:DEEPWIKI_REQUEST_TIMEOUT=60000 DEEPWIKI_MAX_CONCURRENCY=10 npx mcp-deepwiki