deepwiki-mcp

repository·main·Indexed 23 days ago

https://github.com/regenrek/deepwiki-mcp

An unofficial Model Context Protocol (MCP) server designed to crawl Deepwiki documentation URLs and convert the content into structured Markdown for LLMs and AI coding agents. It provides the `deepwiki_fetch` tool with support for aggregate and page-based output modes, configurable crawl depth, and various transport modes including stdio, HTTP, and SSE.

Tokens
5.1K
Snippets
15
Records
34
Agent score
78%

What's inside deepwiki-mcp

  1. Use the unbuild --stub command for development

    main
    The unbuild --stub command (powered by jiti) creates a stub of the dist directory. This allows you to link your project and run it without needing to constantly watch and rebuild the entire bundle during development.
  2. Configure unbuild with build.config.ts

    main

    For advanced control, create a build.config.ts file. You can use the defineBuildConfig helper to provide configuration. unbuild supports multiple build configurations by passing an array to defineBuildConfig.

    Key Configuration Options:

    • entries: An array of entry points. Can be strings or objects specifying a builder (like mkdist or untyped), input, and outDir.
    • outDir: The output directory (defaults to dist).
    • declaration: Controls .d.ts generation.
      • 'compatible': Generates .d.mts, .d.cts, and .d.ts.
      • 'node16': Generates .d.mts and .d.cts.
      • true: Equivalent to 'compatible'.
      • false: Disables declaration generation.
      • undefined: Auto-detects based on package.json types field.
    • rollup: Configuration object for the underlying Rollup bundler (e.g., minify, inlineDependencies).
    import { defineBuildConfig } from 'unbuild'
    
    export default defineBuildConfig({
      entries: [
        './src/index',
        {
          builder: 'mkdist',
          input: './src/package/components/',
          outDir: './build/components',
        },
      ],
    
      outDir: 'build',
    
      declaration: true,
    })
  3. Install and build Deepwiki MCP from source

    main

    To run the server from source for local development:

    1. Clone the repository: git clone https://github.com/regenrek/deepwiki-mcp.git
    2. Navigate to the directory: cd deepwiki-mcp
    3. Install dependencies: npm install
    4. Build the package: npm run build
    git clone https://github.com/regenrek/deepwiki-mcp.git
    cd deepwiki-mcp
    npm install
    npm run build
  4. Set up unbuild for a JavaScript project

    main

    To use unbuild as your build system, follow these steps:

    1. Create your source entry point (e.g., src/index.ts).
    2. Update your package.json to include build scripts and export definitions. unbuild automatically infers configuration from package.json fields.
    3. Run the build using npx unbuild.

    Required package.json structure:

    {
      "type": "module",
      "scripts": {
        "build": "unbuild",
        "prepack": "unbuild"
      },
      "exports": {
        ".": {
          "import": "./dist/index.mjs",
          "require": "./dist/index.cjs"
        }
      },
      "main": "./dist/index.cjs",
      "types": "./dist/index.d.ts",
      "files": ["dist"]
    }
    npx unbuild
  5. Install the Deepwiki MCP Server in Cursor

    main

    To use the Deepwiki MCP server in Cursor, add the following configuration to your .cursor/mcp.json file. This uses npx to run the latest version of the mcp-deepwiki package.

    ⚠️ IMPORTANT NOTICE: This server is currently not working since DeepWiki has cut off the possibility to scrape it. The maintainer recommends using the official DeepWiki MCP server at https://docs.devin.ai/work-with-devin/deepwiki-mcp.

    {
      "mcpServers": {
        "mcp-deepwiki": {
          "command": "npx",
          "args": ["-y", "mcp-deepwiki@latest"]
        }
      }
    }
  6. Deploy Deepwiki MCP using Docker

    main

    You can run the server in a container. Use stdio transport for development or --http for production-ready HTTP transport.

    Build the image:

    docker build -t mcp-deepwiki .

    Run with stdio (Development):

    docker run -it --rm mcp-deepwiki

    Run with HTTP (Production):

    docker run -d -p 3000:3000 mcp-deepwiki --http --port 3000

    Run with HTTP and Environment Variables:

    docker run -d -p 3000:3000 \
      -e DEEPWIKI_MAX_CONCURRENCY=10 \
      -e DEEPWIKI_REQUEST_TIMEOUT=60000 \
      mcp-deepwiki --http --port 3000
  7. Configure Deepwiki MCP via environment variables

    main

    You can tune the crawler's performance and reliability by setting the following environment variables in a .env file in the project root:

    VariableDescriptionDefault
    DEEPWIKI_MAX_CONCURRENCYMaximum concurrent requests5
    DEEPWIKI_REQUEST_TIMEOUTRequest timeout in milliseconds30000
    DEEPWIKI_MAX_RETRIESMaximum retry attempts for failed requests3
    DEEPWIKI_RETRY_DELAYBase delay for retry backoff in milliseconds250
    DEEPWIKI_MAX_CONCURRENCY=10
    DEEPWIKI_REQUEST_TIMEOUT=60000
    DEEPWIKI_MAX_RETRIES=5
    DEEPWIKI_RETRY_DELAY=500
  8. Troubleshoot Deepwiki MCP issues

    main

    Permission Denied

    If you encounter EACCES errors when running the CLI, ensure the binary is executable:

    chmod +x ./node_modules/.bin/mcp-deepwiki

    Connection Refused

    Verify if the port (default 3000) is available or blocked:

    lsof -i :3000

    Timeout Errors

    For large repositories, increase the timeout and concurrency via environment variables:

    DEEPWIKI_REQUEST_TIMEOUT=60000 DEEPWIKI_MAX_CONCURRENCY=10 npx mcp-deepwiki
  9. Enable Decorators support in unbuild

    main

    To support experimental decorators, configure the esbuild options within the rollup object in your build.config.ts to pass tsconfigRaw settings.

    import { defineBuildConfig } from 'unbuild'
    
    export default defineBuildConfig({
      rollup: {
        esbuild: {
          tsconfigRaw: {
            compilerOptions: {
              experimentalDecorators: true,
            },
          },
        },
      },
    })
  10. Use the `deepwiki_fetch` MCP tool

    main

    The package registers a tool named deepwiki_fetch that can be used with any MCP-compatible client. It crawls Deepwiki URLs, sanitizes the HTML, and returns content in Markdown format.

    Parameters

    • url (required): The starting URL of the Deepwiki repository.
    • mode (optional): Output mode. Use aggregate (default) for a single Markdown document or pages for structured page data.
    • maxDepth (optional): Maximum depth of pages to crawl (default: 10).
    {
      "action": "deepwiki_fetch",
      "params": {
        "url": "https://deepwiki.com/user/repo",
        "mode": "aggregate",
        "maxDepth": "1"
      }
    }
  11. Configure the HTML sanitization schema

    main

    The sanitizeSchema object defines the allowed HTML tags and attributes used by the server to clean content. It extends the defaultSchema from hast-util-sanitize with specific restrictions to ensure security and content cleanliness.

    By default, the following modifications are applied:

    • Removed Tags: img, script, style, header, footer, nav are stripped from the allowed list.
    • Removed Global Attributes: The attributes style, onload, and onclick are stripped from all elements (*).
    export const sanitizeSchema: SanitizeOptions = {
      ...defaultSchema,
      tagNames: (defaultSchema.tagNames ?? []).filter(
        t =>
          !['img', 'script', 'style', 'header', 'footer', 'nav'].includes(t),
      ),
      attributes: {
        ...defaultSchema.attributes,
        '*': (defaultSchema.attributes?.['*'] ?? []).filter(
          attr => !['style', 'onload', 'onclick'].includes(attr),
        ),
      },
    }