packagelens-mcp

Advanced and Local Usage

This document collects the deeper, more technical details for contributors and folks running PackageLens MCP locally.

How to Test (local)

Basic smoke test (CLI, no MCP)

You should see JSON/text output with package lists, README content, weekly downloads, and an extracted snippet.

Demo CLI (no MCP)

A tiny CLI is included to try functionality directly during development.

npx -y packagelens-mcp@latest --help
# Or try a standalone search via the built-in demo commands in this
# repo (dev only)
pnpm demo:search -- react debounce hook

# Version pinning guidance
# - Latest (moving): use @latest
# - Major pin: packagelens-mcp@0 (gets newest 0.x)
# - Minor pin: packagelens-mcp@0.1 (newest 0.1.x)
# - Exact: packagelens-mcp@0.1.3
# Tip: check the current version with
# `npm view packagelens-mcp version`.

Fetch README

pnpm demo:readme -- react
pnpm demo:readme -- lodash 4.17.21

Enriched info (downloads + GitHub)

pnpm demo:info -- react

Downloads

pnpm demo:downloads -- react week

Usage snippet

pnpm demo:snippet -- react

Tool Schemas

PackageLens MCP provides 8 tools with automatic ecosystem detection. All tools use smart detection to automatically determine the package ecosystem from context. When ecosystem cannot be determined, tools ask for user clarification.

Package Information

smart_package_info

smart_get_readme

smart_get_usage_snippet

Version & Dependency Analysis

smart_get_versions

smart_get_dependencies

Download Statistics

smart_get_downloads

Comparison

compare_packages

Example MCP Messages (stdio)

Initialize

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "initialize",
  "params": {
    "clientInfo": { "name": "demo", "version": "0.0.0" },
    "capabilities": {}
  }
}

List tools

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/list"
}
{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "smart_search",
    "arguments": { "query": "Find JavaScript debounce hooks", "size": 10 }
  }
}

Call smart_get_readme

{
  "jsonrpc": "2.0",
  "id": 4,
  "method": "tools/call",
  "params": {
    "name": "smart_get_readme",
    "arguments": { "packageName": "react" }
  }
}

Call smart_package_info

{
  "jsonrpc": "2.0",
  "id": 5,
  "method": "tools/call",
  "params": {
    "name": "smart_package_info",
    "arguments": { "packageName": "react", "includeReadme": false }
  }
}

Call smart_get_versions

{
  "jsonrpc": "2.0",
  "id": 6,
  "method": "tools/call",
  "params": {
    "name": "smart_get_versions",
    "arguments": {
      "packageName": "react",
      "limit": 10,
      "since": "6 months"
    }
  }
}

Call smart_get_dependencies

{
  "jsonrpc": "2.0",
  "id": 7,
  "method": "tools/call",
  "params": {
    "name": "smart_get_dependencies",
    "arguments": { "packageName": "express" }
  }
}

Call smart_get_downloads

{
  "jsonrpc": "2.0",
  "id": 8,
  "method": "tools/call",
  "params": {
    "name": "smart_get_downloads",
    "arguments": { "packageName": "react", "period": "week" }
  }
}

Call compare_packages

{
  "jsonrpc": "2.0",
  "id": 9,
  "method": "tools/call",
  "params": {
    "name": "compare_packages",
    "arguments": {
      "items": [
        { "ecosystem": "npm", "name": "react" },
        { "ecosystem": "npm", "name": "vue" },
        { "ecosystem": "npm", "name": "svelte" }
      ]
    }
  }
}

Troubleshooting

Development

Security notes

Roadmap