### Development Setup and Commands Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md Commands for installing dependencies, running in development mode, testing, linting, and building the package. ```bash pnpm install ``` ```bash pnpm run dev-stdio ``` ```bash pnpm test ``` ```bash pnpm run lint ``` ```bash pnpm run build ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/regenrek/deepwiki-mcp/blob/main/CONTRIBUTING.md Run this command after cloning the repository to install all necessary project dependencies. ```bash npm install ``` -------------------------------- ### Install and Build from Source Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md These bash commands outline the steps to clone the deepwiki-mcp repository, install its dependencies using npm, and build the package. ```bash # Clone the repository git clone https://github.com/regenrek/deepwiki-mcp.git cd deepwiki-mcp # Install dependencies npm install # Build the package npm run build ``` -------------------------------- ### Create and Start MCP Server Source: https://context7.com/regenrek/deepwiki-mcp/llms.txt Instantiate an MCP server with custom options, register tools, and start it with a specified transport. Handles graceful shutdown on SIGTERM and SIGINT. ```typescript import { createServer, startServer, stopServer } from 'mcp-deepwiki'; import { deepwikiTool } from 'mcp-deepwiki/tools/deepwiki'; // Create MCP server instance const mcp = createServer({ name: 'my-custom-server', version: '1.0.0' }); // Register tools deepwikiTool({ mcp }); // Handle graceful shutdown process.on('SIGTERM', () => stopServer(mcp)); process.on('SIGINT', () => stopServer(mcp)); // Start with desired transport await startServer(mcp, { type: 'stdio' }); // OR await startServer(mcp, { type: 'http', port: 3000, endpoint: '/mcp' }); // OR await startServer(mcp, { type: 'sse', port: 3000 }); ``` -------------------------------- ### Example Deepwiki Fetch Prompts Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md Use these prompts with the deepwiki fetch command to retrieve information from Deepwiki. ```bash deepwiki fetch how can i use gpt-image-1 with "vercel ai" sdk ``` ```bash deepwiki fetch how can i create new blocks in shadcn? ``` ```bash deepwiki fetch i want to understand how X works ``` -------------------------------- ### Run Deepwiki-to-Markdown MCP Server in Development Source: https://github.com/regenrek/deepwiki-mcp/blob/main/CONTRIBUTING.md Execute this command to start the server in development mode. Choose the appropriate mode (stdio, http, sse) based on your needs. ```bash npm run dev-stdio ``` -------------------------------- ### Run unbuild CLI Source: https://github.com/regenrek/deepwiki-mcp/blob/main/docs/unbuild.md Executes the unbuild command to start the build process. ```sh npx unbuild ``` -------------------------------- ### Deepwiki MCP CLI Transport Modes Source: https://context7.com/regenrek/deepwiki-mcp/llms.txt Examples of running the Deepwiki MCP CLI with different transport modes: stdio (default), HTTP, and SSE. Includes commands for starting the server with custom ports. ```bash # Run with stdio transport (default - for MCP clients) npx mcp-deepwiki@latest ``` ```bash # Run with HTTP transport on custom port npx mcp-deepwiki@latest --http --port 4200 ``` ```bash # Run with SSE transport npx mcp-deepwiki@latest --sse --port 4201 ``` -------------------------------- ### Cursor IDE MCP Configuration Source: https://context7.com/regenrek/deepwiki-mcp/llms.txt Configuration examples for integrating Deepwiki MCP with the Cursor IDE by defining the server command and arguments in the .cursor/mcp.json file. ```json // .cursor/mcp.json { "mcpServers": { "mcp-deepwiki": { "command": "npx", "args": ["-y", "mcp-deepwiki@latest"] } } } ``` ```json // Local development configuration { "mcpServers": { "mcp-deepwiki": { "command": "node", "args": ["./bin/cli.mjs"] } } } ``` -------------------------------- ### Project Structure Overview Source: https://github.com/regenrek/deepwiki-mcp/blob/main/CONTRIBUTING.md This is a representation of the project's directory structure, outlining the location of core functionality, tests, tools, and server setup files. ```text src/ ├── functions/ # Core functionality │ ├── __tests__/ # Unit tests │ ├── crawler.ts # Website crawling logic │ ├── converter.ts # HTML to Markdown conversion │ ├── types.ts # TypeScript interfaces & schemas │ └── utils.ts # Utility functions ├── tools/ # MCP tool definitions │ ├── deepwiki.ts # Deepwiki fetch tool │ └── mytool.ts # Example tool ├── index.ts # Main entry point ├── server.ts # MCP server setup └── types.ts # Core type definitions ``` -------------------------------- ### Environment Variables Configuration Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md This example shows how to configure Deepwiki MCP server settings by creating a `.env` file with custom values for concurrency, timeouts, and retries. ```dotenv DEEPWIKI_MAX_CONCURRENCY=10 DEEPWIKI_REQUEST_TIMEOUT=60000 DEEPWIKI_MAX_RETRIES=5 DEEPWIKI_RETRY_DELAY=500 ``` -------------------------------- ### Troubleshooting: Adjust Timeout and Concurrency Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md Example of how to adjust request timeout and maximum concurrency for handling large repositories. ```bash DEEPWIKI_REQUEST_TIMEOUT=60000 DEEPWIKI_MAX_CONCURRENCY=10 npx mcp-deepwiki ``` -------------------------------- ### Basic Build Configuration with Typed Output Source: https://github.com/regenrek/deepwiki-mcp/blob/main/docs/unbuild.md Configure unbuild for standard TypeScript builds, generating both JavaScript and declaration files. Includes an example of a custom 'untyped' builder for schema generation. ```javascript import { defineBuildConfig } from "unbuild"; export default defineBuildConfig({ entries: [ "src/index.ts", { builder: "untyped", input: "src/index.ts", outDir: "schema", name: "schema", }, ], declaration: true, rollup: { emitCJS: true, }, }); ``` -------------------------------- ### Build Configuration with Custom Rollup Hooks and Externals Source: https://github.com/regenrek/deepwiki-mcp/blob/main/docs/unbuild.md Example of an unbuild configuration that includes custom rollup hooks for modifying build options and specifies a list of external dependencies to exclude from the bundle. ```javascript import { defineBuildConfig } from 'unbuild' import { addRollupTimingsPlugin, stubOptions } from '../../debug/build-config' export default defineBuildConfig({ declaration: true, entries: [ 'src/index', ], stubOptions, hooks: { 'rollup:options' (ctx, options) { addRollupTimingsPlugin(options) }, }, externals: [ '@rspack/core', '@nuxt/schema', 'nitropack', 'nitro', 'webpack', 'vite', 'h3', ], }) ``` -------------------------------- ### Validate FetchRequest Inputs Source: https://context7.com/regenrek/deepwiki-mcp/llms.txt Provides examples of valid inputs for the FetchRequest schema, demonstrating different URL formats and parameter combinations. Use these examples to test the schema validation. ```typescript FetchRequest.parse({ url: 'https://deepwiki.com/vercel/ai' }); ``` ```typescript FetchRequest.parse({ url: 'vercel/ai' }); ``` ```typescript FetchRequest.parse({ url: 'vercel ai' }); ``` ```typescript FetchRequest.parse({ url: 'tailwindcss' }); ``` ```typescript FetchRequest.parse({ url: 'how to use shadcn', maxDepth: 0, mode: 'pages' }); ``` -------------------------------- ### MCP Tool: deepwiki_fetch Requests Source: https://context7.com/regenrek/deepwiki-mcp/llms.txt Examples of requests to the deepwiki_fetch tool, demonstrating different input formats like full URLs, shorthand, and natural language queries. Includes success and error response formats. ```json // MCP Tool Request - Full URL { "action": "deepwiki_fetch", "params": { "url": "https://deepwiki.com/shadcn-ui/ui", "mode": "aggregate", "maxDepth": 1, "verbose": false } } ``` ```json // MCP Tool Request - Shorthand format { "action": "deepwiki_fetch", "params": { "url": "vercel/ai", "maxDepth": 1 } } ``` ```json // MCP Tool Request - Natural language query (NLP extraction) { "action": "deepwiki_fetch", "params": { "url": "how can i use gpt-image-1 with vercel ai sdk", "maxDepth": 0 } } ``` ```json // Success Response { "content": [ { "type": "text", "text": "# /index\n\n## Getting Started\n\nWelcome to the documentation..." }, { "type": "text", "text": "# /installation\n\n## Installation\n\nRun the following command..." } ] } ``` ```json // Error Response - Invalid domain { "status": "error", "code": "DOMAIN_NOT_ALLOWED", "message": "Only deepwiki.com domains are allowed" } ``` ```json // Error Response - Validation failure { "status": "error", "code": "VALIDATION", "message": "Request failed schema validation", "details": { "fieldErrors": { "url": ["Invalid url"] } } } ``` -------------------------------- ### MCP Tool Integration Example Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md This JSON object represents a typical action payload for the `deepwiki_fetch` tool within an MCP-compatible client. It specifies the URL, mode, and maximum crawl depth. ```json { "action": "deepwiki_fetch", "params": { "url": "https://deepwiki.com/user/repo", "mode": "aggregate", "maxDepth": "1" } } ``` -------------------------------- ### Web Crawl with Configuration Source: https://context7.com/regenrek/deepwiki-mcp/llms.txt Perform a breadth-first web crawl starting from a root URL, with options for max depth, progress reporting, and verbosity. Handles robots.txt and throttling. ```typescript import { crawl } from 'mcp-deepwiki/lib/httpCrawler'; const result = await crawl({ root: new URL('https://deepwiki.com/vercel/ai'), maxDepth: 1, // 0 = only root page, 1 = root + linked pages emit: (event) => { // Progress callback console.log(`Fetched ${event.url}: ${event.bytes} bytes in ${event.elapsedMs}ms`); console.log(`Progress: ${event.fetched} done, ${event.queued} queued, ${event.retries} retries`); }, verbose: true }); // Result structure // { // html: { // '/': '...', // '/installation': '...', // '/getting-started': '...' // }, // errors: [ // { path: '/broken-link', reason: 'HTTP error: 404' } // ], // bytes: 125000, // elapsedMs: 2500 // } ``` -------------------------------- ### Fetch Complete Documentation (Default) Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md Use these commands to fetch the complete documentation for a given URL, either as a single document or multiple pages. ```bash use deepwiki https://deepwiki.com/shadcn-ui/ui ``` ```bash use deepwiki multiple pages https://deepwiki.com/shadcn-ui/ui ``` -------------------------------- ### Fetch Single Page Documentation Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md Use this command to fetch documentation for a single page from a specific URL. ```bash use deepwiki fetch single page https://deepwiki.com/tailwindlabs/tailwindcss/2.2-theme-system ``` -------------------------------- ### Basic unbuild configuration Source: https://github.com/regenrek/deepwiki-mcp/blob/main/docs/unbuild.md Specifies the entry points for the build process in a configuration file. ```js export default { entries: ['./src/index'], } ``` -------------------------------- ### Configure package.json for unbuild Source: https://github.com/regenrek/deepwiki-mcp/blob/main/docs/unbuild.md Sets up package.json scripts and exports for unbuild to manage the build process. ```json { "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"] } ``` -------------------------------- ### Build Configuration with Rollup Plugins and Size Analysis Source: https://github.com/regenrek/deepwiki-mcp/blob/main/docs/unbuild.md Demonstrates an unbuild configuration that integrates rollup plugins like 'unplugin-purge-polyfills' and 'rollup-plugin-visualizer'. It conditionally enables bundle size analysis based on an environment variable. ```javascript import type { InputPluginOption } from 'rollup' import process from 'node:process' import { visualizer } from 'rollup-plugin-visualizer' import { defineBuildConfig } from 'unbuild' import { purgePolyfills } from 'unplugin-purge-polyfills' const isAnalysingSize = process.env.BUNDLE_SIZE === 'true' export default defineBuildConfig({ declaration: !isAnalysingSize, failOnWarn: !isAnalysingSize, hooks: { 'rollup:options': function (ctx, options) { const plugins = (options.plugins ||= []) as InputPluginOption[] plugins.push(purgePolyfills.rollup({ logLevel: 'verbose' })) if (isAnalysingSize) { plugins.unshift(visualizer({ template: 'raw-data' })) } }, }, rollup: { dts: { respectExternal: false, }, inlineDependencies: true, resolve: { exportConditions: ['production', 'node'], }, }, entries: ['src/index'], externals: [ '@nuxt/test-utils', 'fsevents', 'node:url', 'node:buffer', 'node:path', 'node:child_process', 'node:process', 'node:path', 'node:os', ], }) ``` -------------------------------- ### Advanced unbuild configuration with mkdist Source: https://github.com/regenrek/deepwiki-mcp/blob/main/docs/unbuild.md Configures unbuild with multiple entry points, including a mkdist builder for bundleless transpilation, and specifies the output directory. ```js import { defineBuildConfig } from 'unbuild' export default defineBuildConfig({ // If entries is not provided, will be automatically inferred from package.json entries: [ // default './src/index', // mkdist builder transpiles file-to-file keeping original sources structure { builder: 'mkdist', input: './src/package/components/', outDir: './build/components', }, ], // Change outDir, default is 'dist' outDir: 'build', // Generates .d.ts declaration file declaration: true, }) ``` -------------------------------- ### Build Configuration with Multiple Formats and Output Directories Source: https://github.com/regenrek/deepwiki-mcp/blob/main/docs/unbuild.md Set up unbuild to generate both ESM and CJS formats for plugin modules, specifying distinct output directories and file extensions. Declaration files are enabled. ```javascript import { defineBuildConfig } from "unbuild"; export default defineBuildConfig({ entries: [ "src/index.ts", { input: "src/plugins/", outDir: "dist/plugins/", format: "esm", }, { input: "src/plugins/", outDir: "dist/plugins/", format: "cjs", ext: "cjs", declaration: false, }, ], declaration: true, rollup: { emitCJS: true, }, }); ``` -------------------------------- ### Fetch Documentation by Shortform Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md Retrieve documentation using a shortform identifier which typically includes the author/organization and repository name. ```bash use deepwiki fetch tailwindlabs/tailwindcss ``` -------------------------------- ### Build and Run Docker Image Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md Commands to build the Docker image and run it with different transport methods (stdio, HTTP) and environment variables. ```bash docker build -t mcp-deepwiki . ``` ```bash docker run -it --rm mcp-deepwiki ``` ```bash docker run -d -p 3000:3000 mcp-deepwiki --http --port 3000 ``` ```bash docker run -d -p 3000:3000 \ -e DEEPWIKI_MAX_CONCURRENCY=10 \ -e DEEPWIKI_REQUEST_TIMEOUT=60000 \ mcp-deepwiki --http --port 3000 ``` -------------------------------- ### Troubleshooting: Make Binary Executable Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md Command to make the mcp-deepwiki binary executable if you encounter EACCES errors. ```bash chmod +x ./node_modules/.bin/mcp-deepwiki ``` -------------------------------- ### Run Project Linting Source: https://github.com/regenrek/deepwiki-mcp/blob/main/CONTRIBUTING.md Run this command to check code quality and style using ESLint. This helps maintain consistency across the codebase. ```bash npm run lint ``` -------------------------------- ### Clone Deepwiki-to-Markdown MCP Repository Source: https://github.com/regenrek/deepwiki-mcp/blob/main/CONTRIBUTING.md Use this command to clone the project repository to your local machine. ```bash git clone https://github.com/regenrek/mcp-deepwiki.git ``` -------------------------------- ### Docker Build and Run Commands Source: https://context7.com/regenrek/deepwiki-mcp/llms.txt Commands for building a Docker image for mcp-deepwiki and running it with different transports and configurations. ```bash # Build the Docker image docker build -t mcp-deepwiki . # Run with stdio transport (development) docker run -it --rm mcp-deepwiki # Run with HTTP transport (production) docker run -d -p 3000:3000 mcp-deepwiki --http --port 3000 # Run with custom environment variables docker run -d -p 3000:3000 \ -e DEEPWIKI_MAX_CONCURRENCY=10 \ -e DEEPWIKI_REQUEST_TIMEOUT=60000 \ -e GITHUB_TOKEN=ghp_xxx \ mcp-deepwiki --http --port 3000 ``` -------------------------------- ### Multiple unbuild configurations Source: https://github.com/regenrek/deepwiki-mcp/blob/main/docs/unbuild.md Defines multiple build configurations, including a minified build, and specifies declaration generation options. ```js import { defineBuildConfig } from 'unbuild' export default defineBuildConfig([ { // If entries is not provided, will be automatically inferred from package.json entries: [ // default './src/index', // mkdist builder transpiles file-to-file keeping original sources structure { builder: 'mkdist', input: './src/package/components/', outDir: './build/components', }, ], // Change outDir, default is 'dist' outDir: 'build', /** * `compatible` means "src/index.ts" will generate "dist/index.d.mts", "dist/index.d.cts" and "dist/index.d.ts". * `node16` means "src/index.ts" will generate "dist/index.d.mts" and "dist/index.d.cts". * `true` is equivalent to `compatible`. * `false` will disable declaration generation. * `undefined` will auto detect based on "package.json". If "package.json" has "types" field, it will be `"compatible"`, otherwise `false`. */ declaration: 'compatible', }, { name: 'minified', entries: ['./src/index'], outDir: 'build/min', rollup: { esbuild: { minify: true, }, }, }, ]) ``` -------------------------------- ### Deepwiki Fetch Command Variants Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md These commands demonstrate various ways to use the deepwiki fetch command, including fetching by library name, URL, or shortform, and specifying multiple pages. ```bash deepwiki fetch library deepwiki fetch url deepwiki fetch / deepwiki multiple pages ... deepwiki single page url ... ``` -------------------------------- ### Run Project Tests Source: https://github.com/regenrek/deepwiki-mcp/blob/main/CONTRIBUTING.md Execute this command to run all project tests. Ensure all tests pass before submitting a pull request. ```bash npm test ``` -------------------------------- ### Direct HTTP API Call to Deepwiki MCP Source: https://context7.com/regenrek/deepwiki-mcp/llms.txt Demonstrates how to make a direct HTTP POST request to the Deepwiki MCP server's /mcp endpoint, specifying the action and parameters for fetching documentation. ```bash # Direct HTTP API call curl -X POST http://localhost:4200/mcp \ -H "Content-Type: application/json" \ -d '{ "id": "req-1", "action": "deepwiki_fetch", "params": { "url": "https://deepwiki.com/vercel/ai", "mode": "aggregate" } }' ``` -------------------------------- ### Conditional Build Configuration for Development and Production Source: https://github.com/regenrek/deepwiki-mcp/blob/main/docs/unbuild.md Defines separate unbuild configurations for development and production environments. The production build uses 'mkdist' for efficient file processing, while the development build focuses on a CLI entry point with specific rollup and esbuild options. ```javascript import { defineBuildConfig } from 'unbuild' // Separeate config required for dev because mkdist + cli-entry doesn't work // with stub. It will create a .d.ts and .mjs file in the src folder const dev = defineBuildConfig({ entries: ['src/cli-entry'], outDir: 'dist', clean: true, declaration: true, rollup: { inlineDependencies: true, esbuild: { target: 'node18', minify: false, }, }, }) const prod = defineBuildConfig({ entries: [ { builder: 'mkdist', cleanDist: true, input: './src/', pattern: ['**/*.{ts,tsx}', '!**/template/**'], }, ], outDir: 'dist', clean: true, declaration: true, rollup: { inlineDependencies: true, esbuild: { target: 'node18', minify: false, }, }, }) const config = process.env.BUILD_ENV === 'production' ? prod : dev export default config ``` -------------------------------- ### Environment Variables Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md Configuration options for the Deepwiki MCP Server that can be set using environment variables. ```APIDOC ## Environment Variables ### Description These environment variables allow you to configure the behavior of the Deepwiki MCP Server, such as concurrency, timeouts, and retries. ### Variables - **DEEPWIKI_MAX_CONCURRENCY** (integer) - Maximum concurrent requests (default: 5). - **DEEPWIKI_REQUEST_TIMEOUT** (integer) - Request timeout in milliseconds (default: 30000). - **DEEPWIKI_MAX_RETRIES** (integer) - Maximum retry attempts for failed requests (default: 3). - **DEEPWIKI_RETRY_DELAY** (integer) - Base delay for retry backoff in milliseconds (default: 250). ### Example Configuration (`.env` file) ``` DEEPWIKI_MAX_CONCURRENCY=10 DEEPWIKI_REQUEST_TIMEOUT=60000 DEEPWIKI_MAX_RETRIES=5 DEEPWIKI_RETRY_DELAY=500 ``` ``` -------------------------------- ### Direct API Call via cURL Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md This cURL command demonstrates how to make a direct POST request to the local MCP server endpoint to fetch documentation. ```bash curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "id": "req-1", "action": "deepwiki_fetch", "params": { "url": "https://deepwiki.com/user/repo", "mode": "aggregate" } }' ``` -------------------------------- ### Local Development MCP Server Configuration Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md This JSON configuration is used for local development, specifying the command to run the local Deepwiki MCP server using Node.js. ```json { "mcpServers": { "mcp-deepwiki": { "command": "node", "args": ["./bin/cli.mjs"] } } } ``` -------------------------------- ### Export a log function Source: https://github.com/regenrek/deepwiki-mcp/blob/main/docs/unbuild.md Defines a simple log function to be exported from the entry point. ```js export function log(...args) { console.log(...args) } ``` -------------------------------- ### Troubleshooting: Check Port Usage Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md Command to check if a specific port is currently in use. ```bash lsof -i :3000 ``` -------------------------------- ### Cursor MCP Server Configuration Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md Add this JSON configuration to your `.cursor/mcp.json` file to integrate the Deepwiki MCP server with Cursor. ```json { "mcpServers": { "mcp-deepwiki": { "command": "npx", "args": ["-y", "mcp-deepwiki@latest"] } } } ``` -------------------------------- ### Success Response (Pages Mode) Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md This JSON structure details a successful response when fetching documentation in pages mode, providing an array of individual page objects, each with a path and Markdown content. ```json { "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 } ``` -------------------------------- ### Enable decorators support in unbuild Source: https://github.com/regenrek/deepwiki-mcp/blob/main/docs/unbuild.md Configures unbuild to support experimental decorators by passing tsconfigRaw options to esbuild. ```ts import { defineBuildConfig } from 'unbuild' export default defineBuildConfig({ rollup: { esbuild: { tsconfigRaw: { compilerOptions: { experimentalDecorators: true, }, }, }, }, }) ``` -------------------------------- ### Success Response (Aggregate Mode) Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md This JSON structure represents a successful response when fetching documentation in aggregate mode, containing the combined Markdown content and metadata. ```json { "status": "ok", "data": "# Page Title\n\nPage content...\n\n---\n\n# Another Page\n\nMore content...", "totalPages": 5, "totalBytes": 25000, "elapsedMs": 1200 } ``` -------------------------------- ### MCP Tool: deepwiki_search Request and Response Source: https://context7.com/regenrek/deepwiki-mcp/llms.txt Demonstrates a request to the deepwiki_search tool for finding specific information within documentation, including parameters and the structure of the success response with highlighted matches. ```json // MCP Tool Request { "action": "deepwiki_search", "params": { "url": "https://deepwiki.com/tailwindlabs/tailwindcss", "query": "dark mode", "maxMatches": 10, "maxDepth": 1, "mode": "aggregate", "verbose": false } } ``` ```json // Success Response { "status": "ok", "query": "dark mode", "matches": [ { "path": "/2.2-theme-system", "snippet": "...configure **dark mode** in your tailwind.config.js file by setting the darkMode..." }, { "path": "/configuration", "snippet": "...The **dark mode** strategy can be set to 'media' or 'class' depending..." } ], "totalSearchedPages": 15 } ``` -------------------------------- ### Generate sourcemaps with unbuild Source: https://github.com/regenrek/deepwiki-mcp/blob/main/docs/unbuild.md Enables sourcemap generation for the build output. ```ts import { defineBuildConfig } from 'unbuild' export default defineBuildConfig({ sourcemap: true, }) ``` -------------------------------- ### Deepwiki Fetch Tool API Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md This section details the `deepwiki_fetch` tool, which can be integrated with MCP-compatible clients to crawl and process Deepwiki content. ```APIDOC ## POST /mcp ### Description This endpoint is used to initiate a Deepwiki crawl and content conversion process via the MCP tool. ### Method POST ### Endpoint /mcp ### Parameters #### Request Body - **action** (string) - Required - The action to perform, should be `deepwiki_fetch`. - **params** (object) - Required - Parameters for the `deepwiki_fetch` action. - **url** (string) - Required - The starting URL of the Deepwiki repository. - **mode** (string) - Optional - Output mode. Can be `aggregate` (single Markdown document, default) or `pages` (structured page data). - **maxDepth** (string) - Optional - Maximum depth of pages to crawl (default: 10). ### Request Example ```json { "id": "req-1", "action": "deepwiki_fetch", "params": { "url": "https://deepwiki.com/user/repo", "mode": "aggregate", "maxDepth": "1" } } ``` ### Response #### Success Response (Aggregate Mode) - **status** (string) - Indicates the status of the operation ('ok'). - **data** (string) - The aggregated Markdown content. - **totalPages** (integer) - The total number of pages crawled. - **totalBytes** (integer) - The total size of the content in bytes. - **elapsedMs** (integer) - The time taken for the operation in milliseconds. #### Success Response (Pages Mode) - **status** (string) - Indicates the status of the operation ('ok'). - **data** (array) - An array of objects, where each object contains `path` and `markdown` for a page. - **path** (string) - The path of the page within the repository. - **markdown** (string) - The Markdown content of the page. - **totalPages** (integer) - The total number of pages crawled. - **totalBytes** (integer) - The total size of the content in bytes. - **elapsedMs** (integer) - The time taken for the operation in milliseconds. #### Error Response - **status** (string) - Indicates the status of the operation ('error'). - **code** (string) - An error code (e.g., 'DOMAIN_NOT_ALLOWED'). - **message** (string) - A description of the error. #### Partial Success Response - **status** (string) - Indicates the status of the operation ('partial'). - **data** (string) - The successfully crawled Markdown content. - **errors** (array) - An array of objects detailing the errors encountered during crawling. - **url** (string) - The URL that failed to crawl. - **reason** (string) - The reason for the failure. - **totalPages** (integer) - The total number of pages successfully crawled. - **totalBytes** (integer) - The total size of the successfully crawled content in bytes. - **elapsedMs** (integer) - The time taken for the operation in milliseconds. ``` -------------------------------- ### Deepwiki MCP Environment Variables Configuration Source: https://context7.com/regenrek/deepwiki-mcp/llms.txt Environment variables for configuring the crawler behavior of Deepwiki MCP, including concurrency, timeouts, retries, and optional GitHub token for rate limits. ```bash # .env file DEEPWIKI_MAX_CONCURRENCY=10 # Maximum concurrent requests (default: 5) DEEPWIKI_REQUEST_TIMEOUT=60000 # Request timeout in ms (default: 30000) DEEPWIKI_MAX_RETRIES=5 # Maximum retry attempts (default: 3) DEEPWIKI_RETRY_DELAY=500 # Base delay for retry backoff in ms (default: 250) GITHUB_TOKEN=ghp_xxx... # Optional: GitHub token for higher API rate limits ``` -------------------------------- ### Progress Events During Crawling Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md These log messages indicate the progress of the crawling process, showing which URLs were fetched, the amount of data transferred, and the time taken. ```text Fetched https://deepwiki.com/user/repo: 12500 bytes in 450ms (status: 200) Fetched https://deepwiki.com/user/repo/page1: 8750 bytes in 320ms (status: 200) Fetched https://deepwiki.com/user/repo/page2: 6200 bytes in 280ms (status: 200) ``` -------------------------------- ### Define FetchRequest Zod Schema Source: https://context7.com/regenrek/deepwiki-mcp/llms.txt Defines the input parameters for the deepwiki_fetch tool using Zod, including URL formats, crawl depth, output mode, and verbose logging. Use this schema to validate inputs for the fetch tool. ```typescript import { z } from 'zod'; const ModeEnum = z.enum(['aggregate', 'pages']); const FetchRequest = z.object({ // URL formats: full URL, owner/repo, "owner repo", or single keyword url: z.string().describe( 'should be a URL, owner/repo name (e.g. "vercel/ai"), ' + 'a two-word "owner repo" form (e.g. "vercel ai"), ' + 'or a single library keyword' ), // Crawl depth: 0 = single page, 1 = root + linked pages (max allowed) maxDepth: z.number().int().min(0).max(1).default(1), // Output mode affects link rewriting mode: ModeEnum.default('aggregate'), // Enable verbose logging to stderr verbose: z.boolean().default(false), }); ``` -------------------------------- ### Resolve Repository Name Source: https://context7.com/regenrek/deepwiki-mcp/llms.txt Query the GitHub Search API to resolve single-word library names into the 'owner/repo' format. Supports authentication via GITHUB_TOKEN for increased rate limits. ```typescript import { resolveRepo } from 'mcp-deepwiki/utils/resolveRepoFetch'; // Resolve library name to GitHub repo const repo = await resolveRepo('tailwindcss'); // Returns: 'tailwindlabs/tailwindcss' const aiRepo = await resolveRepo('ai'); // Returns: 'vercel/ai' // With authentication for higher rate limits process.env.GITHUB_TOKEN = 'ghp_your_token_here'; const result = await resolveRepo('react'); // Returns: 'facebook/react' // Error handling try { const unknown = await resolveRepo('nonexistent-library-xyz'); } catch (error) { console.error(error.message); // 'no match' } ``` -------------------------------- ### Convert HTML to Markdown Source: https://context7.com/regenrek/deepwiki-mcp/llms.txt Convert HTML content to Markdown format using a unified pipeline. Supports 'aggregate' mode for anchor links and 'pages' mode for file-based links. ```typescript import { htmlToMarkdown } from 'mcp-deepwiki/converter/htmlToMarkdown'; const html = `

Getting Started

Install the package:

npm install my-package
API Reference
`; // Mode: 'aggregate' - rewrites links as anchors (#docs/api) const markdownAggregate = await htmlToMarkdown(html, 'aggregate'); // Output: // # Getting Started // // Install the package: // // ``` // npm install my-package // ``` // // [API Reference](#docs/api) // Mode: 'pages' - rewrites links as markdown files (docs/api.md) const markdownPages = await htmlToMarkdown(html, 'pages'); // Links become: [API Reference](docs/api.md) ``` -------------------------------- ### Partial Success Response Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md This JSON structure represents a partial success response, where some pages were fetched successfully, but errors occurred for others. It includes the successfully fetched data and a list of errors. ```json { "status": "partial", "data": "# Page Title\n\nPage content...", "errors": [ { "url": "https://deepwiki.com/user/repo/page2", "reason": "HTTP error: 404" } ], "totalPages": 1, "totalBytes": 5000, "elapsedMs": 950 } ``` -------------------------------- ### Error Response Source: https://github.com/regenrek/deepwiki-mcp/blob/main/README.md This JSON object illustrates an error response, indicating a failure due to disallowed domains. ```json { "status": "error", "code": "DOMAIN_NOT_ALLOWED", "message": "Only deepwiki.com domains are allowed" } ``` -------------------------------- ### Extract Keywords from Text Source: https://context7.com/regenrek/deepwiki-mcp/llms.txt Utilize NLP to extract relevant keywords, such as library or project names, from natural language queries. Filters out common stop words. ```typescript import { extractKeyword } from 'mcp-deepwiki/utils/extractKeyword'; // Extract library names from natural language extractKeyword('how can i use gpt-image-1 with vercel ai sdk'); // Returns: 'gpt-image-1' extractKeyword('i want to understand how tailwind works'); // Returns: 'tailwind' extractKeyword('what is the latest version of react'); // Returns: 'version' (or 'react' depending on NLP analysis) extractKeyword('how to upgrade'); // Returns: undefined (stop words filtered out) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.