0.1.0 • Published 7 months ago

npm-docs-server v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

npm-docs-server

This MCP server provides a tool to fetch the README documentation for a given npm package.

Usage

Tool: get_npm_docs

This tool retrieves the README file from the latest version of a specified npm package.

Input

  • packageName (string, required): The name of the npm package.

Output

The tool returns the content of the README file as a text string. If no README is found, or if there is an error fetching the package information, an error message will be returned.

Implementation Details

The server uses the following steps to retrieve the documentation:

  1. Fetches package metadata from the npm registry API (https://registry.npmjs.org).
  2. Extracts the tarball URL for the latest version of the package.
  3. Downloads the tarball.
  4. Extracts the README file (if it exists) from the tarball. It looks for files named readme, readme.md, readme.txt, or readme.markdown (case-insensitive).
  5. Returns the content of the README file.

Error Handling

The server handles errors such as:

  • Invalid package names.
  • Network errors when fetching data from the npm registry.
  • Errors when extracting the tarball.
  • Missing README files.

Example

To use the tool, send a CallToolRequest with the following parameters:

{
  "name": "get_npm_docs",
  "arguments": {
    "packageName": "axios"
  }
}

This will return the README content for the axios package.

0.1.0

7 months ago