Sponsored by Deepsite.site

Mcp Npm_docs Server

Created By
bsmi0219 months ago
An MCP server that provides a tool to fetch metadata and documentation (including README content) for NPM packages, using a local cache to improve performance.
Content

# NPM Documentation MCP Server

An MCP server that provides a tool to fetch metadata and documentation (including README content) for NPM packages, using a local cache to improve performance.

Features

  • Fetches package metadata and README content using the npms.io API.
  • Caches results locally using SQLite (better-sqlite3).
  • Provides the getNpmPackageDocs MCP tool.
  • Follows the standard MCP server structure.

Project Structure

  • /src: Contains all source code.
    • /config: Configuration management (ConfigurationManager).
    • /services: Core logic (NpmDocService, CacheService).
    • /tools: MCP tool definition (npmDocsTool.ts, npmDocsToolParams.ts).
    • /types: TypeScript interfaces and custom errors (npmDocsTypes.ts).
    • /utils: Shared utility functions (logger.ts, errors.ts).
    • createServer.ts: Server instance creation and tool registration.
    • server.ts: Main application entry point.
  • /dist: Compiled JavaScript output (generated by npm run build). Contains the default cache DB file (npm-docs-cache.db).
  • package.json: Project metadata and dependencies.
  • tsconfig.json: TypeScript compiler options.
  • .eslintrc.json: ESLint configuration.
  • .prettierrc.json: Prettier configuration.
  • .gitignore: Git ignore rules.

Installation & Setup

  1. Clone the repository (if applicable).

  2. Install Dependencies:

    npm install
    
  3. Build the Server:

    npm run build
    

    This compiles the TypeScript code into the dist/ directory.

Configuration

The server can be configured using environment variables:

  • NPM_CACHE_TTL: Cache Time-To-Live in seconds. (Default: 86400 - 24 hours)
  • NPM_CACHE_DB_PATH: Path to the SQLite database file. (Default: ./dist/npm-docs-cache.db - relative to the project root after build). If set, this overrides the default. Can be an absolute path or relative to the current working directory where the server is started.
  • LOG_LEVEL: Set to debug for verbose logging. (Default: info) Note: The NPM_REGISTRY_URL config variable exists but is currently ignored as the server uses the npms.io API.

Running the Server

You can run the compiled server directly using Node:

node dist/server.js

For development, use the dev script for auto-reloading:

npm run dev

MCP Integration

To use this server with an MCP client (like Cline), add its configuration to your MCP settings file (e.g., cline_mcp_settings.json):

{
  "mcpServers": {
    // ... other servers
    "npm-docs-server": {
      "command": "node",
      "args": [
        "/path/to/mcp-npm_docs-server/dist/server.js" // <-- IMPORTANT: Use the absolute path to the compiled server.js
      ],
      "env": {
        // Optional: Set environment variables here if needed
        // "NPM_CACHE_TTL": "3600",
        // "NPM_CACHE_DB_PATH": "/path/to/your/cache.db",
        // "LOG_LEVEL": "debug"
      },
      "disabled": false, // Ensure it's enabled
      "autoApprove": [
          "getNpmPackageDocs" // Optional: Auto-approve the tool
       ]
    }
    // ... other servers
  }
}

Replace /path/to/mcp-npm_docs-server with the actual absolute path to this project directory on your system.

Provided MCP Tool

getNpmPackageDocs

Retrieves documentation and metadata for a specified NPM package.

Parameters:

  • packageName (string, required): The exact name of the NPM package (e.g., 'react', 'axios', '@azure/storage-blob'). Case-sensitive.
  • forceFresh (boolean, optional, default: false): If true, bypasses the local cache and fetches fresh data from the npms.io API.

Returns:

A JSON object conforming to the NpmDocumentation interface, including:

  • name
  • version
  • description
  • homepage (if available)
  • repository (URL, if available)
  • author (name, if available)
  • license (if available)
  • keywords (if available)
  • dependencies
  • devDependencies
  • readmeContent (string containing README markdown, if available via npms.io)

Example Usage (MCP Tool Call):

<use_mcp_tool>
  <server_name>npm-docs-server</server_name>
  <tool_name>getNpmPackageDocs</tool_name>
  <arguments>
  {
    "packageName": "lodash",
    "forceFresh": false
  }
  </arguments>
</use_mcp_tool>

Linting and Formatting

  • Lint: npm run lint
  • Format: npm run format

Code will be automatically linted and formatted on commit via Husky and lint-staged (if Husky is installed).

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
WindsurfThe new purpose-built IDE to harness magic
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
CursorThe AI Code Editor
DeepChatYour AI Partner on Desktop
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Playwright McpPlaywright MCP server
ChatWiseThe second fastest AI chatbot™
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Amap Maps高德地图官方 MCP Server
Serper MCP ServerA Serper MCP Server
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Tavily Mcp