MCP HubMCP Hub
sammcj

mcp-package-docs

by: sammcj

An MCP server that provides LLMs with efficient access to package documentation across multiple programming languages

53created 29/12/2024
Visit
LLM
documentation

📌Overview

Purpose: The MCP Server provides efficient access to package documentation for Large Language Models (LLMs) across various programming languages, enhancing development workflows with smart documentation features.

Overview: Designed to streamline access to documentation, this server supports multiple programming languages and integrates seamlessly with Language Server Protocol (LSP) functionalities, enabling intuitive documentation lookup and code assistance for developers.

Key Features:

  • Multi-Language Support: Access documentation for Go, Python, NPM packages, and Rust crates using native tooling.

  • Smart Documentation Parsing: Offers structured output, focused information, and versatile search capabilities, including specific symbol lookups and fuzzy matching.

  • Advanced Search Features: Enables context-aware searches with relevance scoring and supports symbol extraction from documentation results.

  • Language Server Protocol (LSP) Support: Provides hovering information, code completions, and diagnostics, with extensibility for additional languages.

  • Performance Optimised: Features built-in caching and efficient memory usage, ensuring a responsive user experience.


MCP Server Documentation

An MCP (Model Context Protocol) server that provides LLMs with efficient access to package documentation across multiple programming languages and language server protocol (LSP) capabilities.

Features

  • Multi-Language Support:

    • Go packages via go doc
    • Python libraries via built-in help()
    • NPM packages via registry documentation (including private registries)
    • Rust crates via crates.io and docs.rs
  • Smart Documentation Parsing:

    • Structured output with description, usage, and examples
    • Focused information to avoid context overload
    • Support for specific symbol/function lookups
    • Fuzzy and exact search capabilities across documentation
  • Advanced Search Features:

    • Context-aware results with relevance scoring
    • Symbol extraction from search results
  • Language Server Protocol (LSP) Support:

    • Hover information for code symbols
    • Code completions
    • Diagnostics (errors and warnings)
  • Performance Optimized:

    • Built-in caching
    • Efficient parsing
    • Minimal memory footprint

Installation

npx -y mcp-package-docs

To install Package Docs for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install mcp-package-docs --client claude

Usage

MCP Server Configuration

  1. Add to your MCP settings configuration:
{
  "mcpServers": {
    "package-docs": {
      "command": "npx",
      "args": ["-y", "mcp-package-docs"],
      "env": {
        "ENABLE_LSP": "true" // Optional: Enable Language Server Protocol support
      }
    }
  }
}
  1. The server provides the following tools:

lookups for package documentation

  • Go Packages:
{
  "name": "describe_go_package",
  "arguments": {
    "package": "encoding/json", // required
    "symbol": "Marshal"        // optional
  }
}
  • Python Packages:
{
  "name": "describe_python_package",
  "arguments": {
    "package": "requests",    // required
    "symbol": "get"          // optional
  }
}
  • Rust Crates:
{
  "name": "describe_rust_package",
  "arguments": {
    "package": "serde"      // required
  }
}
  • Search Documentation:
{
  "name": "search_package_docs",
  "arguments": {
    "package": "requests",    // required
    "query": "authentication", // required
    "language": "python"     // required
  }
}
  • NPM Packages:
{
  "name": "describe_npm_package",
  "arguments": {
    "package": "axios",      // required
    "version": "1.6.0"       // optional
  }
}

Language Server Protocol (LSP) Tools

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

get_hover

Get hover information for a position in a document:

{
  "name": "get_hover",
  "arguments": {
    "languageId": "typescript",
    "filePath": "src/index.ts",
    "content": "const x = 1;",
    "line": 0,
    "character": 6,
    "projectRoot": "/path/to/project"
  }
}

get_completions

Get completion suggestions for a position in a document:

{
  "name": "get_completions",
  "arguments": {
    "languageId": "typescript",
    "filePath": "src/index.ts",
    "content": "const arr = []; arr.",
    "line": 0,
    "character": 16,
    "projectRoot": "/path/to/project"
  }
}

get_diagnostics

Get diagnostic information (errors, warnings) for a document:

{
  "name": "get_diagnostics",
  "arguments": {
    "languageId": "typescript",
    "filePath": "src/index.ts",
    "content": "const x: string = 1;",
    "projectRoot": "/path/to/project"
  }
}

Requirements

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

Development

# Install dependencies
npm i

# Build
npm run build

# Watch mode
npm run watch

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License. See the LICENSE file for details.