Deepwiki MCP Server: Fetch and Convert Wiki Pages to Markdown

5月14日 Published inAI Tools

The Deepwiki MCP Server is an unofficial utility designed to extract content from Deepwiki and convert it into Markdown format. Operating via the Model Context Protocol, it allows you to provide a Deepwiki URL, crawl its pages, remove unnecessary boilerplate, and receive either a consolidated Markdown file or a structured list of individual pages.

What It Does

  1. Domain Lock: Restricted exclusively to https://deepwiki.org URLs to prevent unintended external crawling.

  2. HTML Cleaning: Automatically strips headers, footers, navigation bars, scripts, and advertisements, leaving you with clean content.

  3. Link Rewriting: Updates internal links to ensure they remain functional within the Markdown output.

  4. Flexible Output: Choose between a single aggregated document or a set of distinct pages.

  5. Efficient Crawling: Allows for adjustable concurrency and crawl depth, enabling the server to handle large repositories without stalling.

  6. NLP Search: Easily locate specific content by searching for library names.

How to Use It

Quick Prompts

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

Fetch the Whole Repo (Default)

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

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

Fetch a Single Page

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

Short Formats

use deepwiki fetch tailwindlabs/tailwindcss

deepwiki fetch library

deepwiki fetch url

deepwiki fetch <name>/<repo>

deepwiki multiple pages ...

deepwiki single page url ...

Cursor Setup

Add the following to your .cursor/mcp.json file:

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

MCP Tool Integration

The package registers a tool named deepwiki_fetch. You can use it in any MCP-compatible client with the following structure:

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

Parameters

  • url (required): The starting URL for the Deepwiki repository.
  • mode (optional): aggregate returns a single Markdown file; pages returns structured page data. Defaults to aggregate.
  • maxDepth (optional): Determines how deep the crawler should go. Defaults to 10.

Response Examples

Success (Aggregate Mode)

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

Success (Pages Mode)

{
    "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
}

Error

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

Partial Success

{
    "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
}

Local Development and Deployment

Local Setup

For development purposes, configure your .cursor/mcp.json as follows:

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

To build the project from source:

  1. Clone the repository: git clone https://github.com/regenrek/mcp-deepwiki.git then cd mcp-deepwiki.
  2. Install dependencies: npm install.
  3. Build the project: npm run build.

Direct HTTP API

You can also interact with the server via HTTP:

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"
    }
  }'

Environment Variables

  • DEEPWIKI_MAX_CONCURRENCY: The maximum number of parallel requests. Defaults to 5.
  • DEEPWIKI_REQUEST_TIMEOUT: Request timeout in milliseconds. Defaults to 30000.
  • DEEPWIKI_MAX_RETRIES: Number of retry attempts on failure. Defaults to 3.
  • DEEPWIKI_RETRY_DELAY: The base backoff delay in milliseconds. Defaults to 250.

You can set these by creating a .env file in the project root:

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

Docker

  1. Build the image: docker build -t mcp-deepwiki .
  2. Run with stdio (development): docker run -it --rm mcp-deepwiki
  3. Run with HTTP (production): docker run -d -p 3000:3000 mcp-deepwiki --http --port 3000
  4. Run with custom environment variables:
docker run -d -p 3000:3000 \
  -e DEEPWIKI_MAX_CONCURRENCY=10 \
  -e DEEPWIKI_REQUEST_TIMEOUT=60000 \
  mcp-deepwiki --http --port 3000

Development Commands

  • Install dependencies: pnpm install
  • Dev mode (stdio): pnpm run dev-stdio
  • Run tests: pnpm test
  • Lint code: pnpm run lint
  • Build project: pnpm run build

Common Issues and Fixes

  • Permission Denied: If you encounter an EACCES error, ensure the binary is executable by running: chmod +x ./node_modules/.bin/mcp-deepwiki
  • Connection Refused: Verify that the port is available using lsof -i :3000 and ensure your firewall is not blocking the connection.
  • Timeout Errors: For particularly large repositories, increase the timeout and concurrency limits: DEEPWIKI_REQUEST_TIMEOUT=60000 DEEPWIKI_MAX_CONCURRENCY=10 npx mcp-deepwiki