Package Docs MCP server

Provides efficient access to NPM/Go/Python package documentation through smart parsing and caching, enabling quick retrieval of up-to-date library information.
Back to servers
Setup instructions
Provider
Sam McLeod
Release date
Dec 29, 2024
Language
TypeScript
Package
Stats
4.5K downloads
76 stars

The MCP Package Documentation Server provides efficient access to package documentation across multiple programming languages, along with Language Server Protocol (LSP) capabilities to enhance developer workflows. It enables LLMs to reference accurate, up-to-date documentation from various package ecosystems.

Installation

You can run the MCP server using npm:

npm install mcp-package-docs

Configuration

Setting Up as an MCP Server

Add the following to your MCP settings configuration:

{
  "mcpServers": {
    "package-docs": {
      "command": "npx",
      "args": ["-y", "mcp-package-docs"],
      "env": {
        "ENABLE_LSP": "true"
      }
    }
  }
}

LSP Configuration

The server includes default configurations for common language servers:

  • TypeScript/JavaScript: typescript-language-server --stdio
  • HTML: vscode-html-language-server --stdio
  • CSS: vscode-css-language-server --stdio
  • JSON: vscode-json-language-server --stdio

You can override these defaults if needed:

{
  "mcpServers": {
    "package-docs": {
      "command": "npx",
      "args": ["-y", "mcp-package-docs"],
      "env": {
        "ENABLE_LSP": "true",
        "TYPESCRIPT_SERVER": "{\"command\":\"/custom/path/typescript-language-server\",\"args\":[\"--stdio\"]}"
      }
    }
  }
}

Available Documentation Tools

Go Documentation

Fetch Go package documentation:

{
  "name": "describe_go_package",
  "arguments": {
    "package": "encoding/json", // required
    "symbol": "Marshal"        // optional
  }
}

Python Documentation

Fetch Python package documentation:

{
  "name": "describe_python_package",
  "arguments": {
    "package": "requests",    // required
    "symbol": "get"          // optional
  }
}

Rust Documentation

Fetch Rust crate documentation:

{
  "name": "describe_rust_package",
  "arguments": {
    "package": "serde",      // required: crate name
    "version": "1.0.219"     // optional: specific version
  }
}

NPM Documentation

Fetch NPM package documentation from public and private registries:

{
  "name": "describe_npm_package",
  "arguments": {
    "package": "axios",      // required - supports both scoped (@org/pkg) and unscoped packages
    "version": "1.6.0"       // optional
  }
}

The tool reads your ~/.npmrc file to determine the correct registry for each package, supporting:

  • Scoped registry configurations
  • Private registries (GitHub Packages, GitLab, Nexus, Artifactory, etc.)
  • Default npm registry as fallback

Documentation Search

Search within package documentation:

{
  "name": "search_package_docs",
  "arguments": {
    "package": "requests",    // required: package name
    "query": "authentication", // required: search query
    "language": "python",     // required: "go", "python", "npm", "swift", or "rust"
    "fuzzy": true            // optional: enable fuzzy matching (default: true)
  }
}

Language Server Protocol Tools

When LSP support is enabled, the following tools become available:

Get Hover Information

{
  "name": "get_hover",
  "arguments": {
    "languageId": "typescript", // required: language identifier
    "filePath": "src/index.ts", // required: path to the source file
    "content": "const x = 1;",  // required: content of the file
    "line": 0,                  // required: zero-based line number
    "character": 6,             // required: zero-based character position
    "projectRoot": "/path/to/project" // optional: project root directory
  }
}

Get Completions

{
  "name": "get_completions",
  "arguments": {
    "languageId": "typescript", // required: language identifier
    "filePath": "src/index.ts", // required: path to the source file
    "content": "const arr = []; arr.",  // required: content of the file
    "line": 0,                  // required: zero-based line number
    "character": 16,            // required: zero-based character position
    "projectRoot": "/path/to/project" // optional: project root directory
  }
}

Get Diagnostics

{
  "name": "get_diagnostics",
  "arguments": {
    "languageId": "typescript", // required: language identifier
    "filePath": "src/index.ts", // required: path to the source file
    "content": "const x: string = 1;",  // required: content of the file
    "projectRoot": "/path/to/project" // optional: project root directory
  }
}

Example Usage in an LLM

Here's how to use the documentation tools from an LLM:

// Looking up Go documentation
const goDocResult = await use_mcp_tool({
  server_name: "package-docs",
  tool_name: "describe_go_package",
  arguments: {
    package: "encoding/json",
    symbol: "Marshal"
  }
});

// Looking up Python documentation
const pythonDocResult = await use_mcp_tool({
  server_name: "package-docs",
  tool_name: "describe_python_package",
  arguments: {
    package: "requests",
    symbol: "post"
  }
});

// Searching within documentation
const searchResult = await use_mcp_tool({
  server_name: "package-docs",
  tool_name: "search_package_docs",
  arguments: {
    package: "serde",
    query: "serialize",
    language: "rust",
    fuzzy: true
  }
});

// Using LSP for hover information
const hoverResult = await use_mcp_tool({
  server_name: "package-docs",
  tool_name: "get_hover",
  arguments: {
    languageId: "typescript",
    filePath: "src/index.ts",
    content: "const axios = require('axios');\naxios.get",
    line: 1,
    character: 7
  }
});

System Requirements

  • Node.js >= 20
  • Go (for Go package documentation)
  • Python 3 (for Python package documentation)
  • Internet connection (for NPM and Rust documentation)
  • Language servers (for LSP functionality):
    • TypeScript/JavaScript: npm install -g typescript-language-server typescript
    • HTML/CSS/JSON: npm install -g vscode-langservers-extracted

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "package-docs" '{"command":"npx","args":["-y","mcp-package-docs"],"env":{"ENABLE_LSP":"true"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "package-docs": {
            "command": "npx",
            "args": [
                "-y",
                "mcp-package-docs"
            ],
            "env": {
                "ENABLE_LSP": "true"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "package-docs": {
            "command": "npx",
            "args": [
                "-y",
                "mcp-package-docs"
            ],
            "env": {
                "ENABLE_LSP": "true"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later