pub-mcp
# pub-mcp π¦β¨
[](https://www.npmjs.com/package/pub-mcp)
[](https://opensource.org/licenses/MIT)
[](https://nodejs.org)
[](https://www.typescriptlang.org)
> MCP (Model Context Protocol) server for pub.dev - Open Source. Enables LLMs and AI assistants to access Dart/Flutter package information from pub.dev.
---
## β‘ Quick Start
### Option 1: Install Globally
```bash
npm install -g pub-mcp
pub-mcp
```
### Option 2: Use npx (Recommended)
No installation required! Use directly in your MCP config:
```json
{
"mcpServers": {
"pub-mcp": {
"command": "npx",
"args": ["-y", "pub-mcp"]
}
}
}
```
### Option 3: Local Installation
```bash
npm install pub-mcp
npx pub-mcp
```
That's it! Your MCP server is running on port 3000 (HTTP) and listening on stdio.
---
## π― Features
| Feature | Description |
| ------------------------- | ----------------------------------------------- |
| π **Package Search** | Search packages on pub.dev by query |
| π¦ **Package Info** | Get metadata, versions, publisher info |
| β **Package Score** | Pana points, likes, downloads, tags |
| π **Changelog** | Package changelog for any version |
| π **Metrics** | Comprehensive metrics (info + score + versions) |
| π **README** | Package README with GitHub fallback |
| π **Dependencies** | Package dependency tree |
| π **MCP Resources** | Access packages as resources |
| π **Dual Transport** | Stdio and Streamable HTTP |
| πΎ **LRU Caching** | Built-in caching for performance |
| β‘ **Rate Limiting** | Retry with exponential backoff |
| π **Structured Logging** | Pino logger integration |
---
## π Usage
### Starting the Server
```bash
# Both transports (default - stdio + HTTP on port 3000)
pub-mcp
# Stdio only (for Claude Desktop, etc.)
pub-mcp --stdio
# HTTP only
pub-mcp --http
# HTTP on custom port
pub-mcp --http --port 8080
# Check version
pub-mcp --version
# Check API health
pub-mcp --health
```
### Connecting AI Clients
#### Claude Desktop / VS Code / Cursor
Add to your MCP settings file:
- **Claude Desktop**: `~/Library/Application Support/Claude/claude_desktop_config.json`
- **VS Code**: `~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/Model Context Protocol/mcp_settings.json`
- **Cursor**: `[project root]/.cursor/mcp.json`
**Option 1: npx (Recommended - no installation needed)**
```json
{
"mcpServers": {
"pub-mcp": {
"command": "npx",
"args": ["-y", "pub-mcp"]
}
}
}
```
**Option 2: Global installation**
```json
{
"mcpServers": {
"pub-mcp": {
"command": "pub-mcp",
"args": ["--stdio"]
}
}
}
```
**Option 3: Local installation**
```json
{
"mcpServers": {
"pub-mcp": {
"command": "node",
"args": ["./node_modules/pub-mcp/dist/cli.js", "--stdio"]
}
}
}
```
#### Other MCP Clients
```bash
# Start HTTP server
pub-mcp --http
# Connect to http://localhost:3000/mcp
```
---
## π§ Configuration
Environment variables (optional, can be set in `.env`):
| Variable | Default | Description |
| ------------------------- | ------------------------ | ----------------------------------- |
| `PORT` | `3000` | HTTP server port |
| `CACHE_TTL` | `3600` | Cache TTL in seconds |
| `CACHE_MAX_ITEMS` | `500` | Maximum cache items |
| `MAX_CONCURRENT_REQUESTS` | `5` | Concurrent request limit |
| `RETRY_ATTEMPTS` | `3` | Retry attempts |
| `PUB_DEV_API_URL` | `https://pub.dev/api` | pub.dev API URL |
| `GITHUB_API_URL` | `https://api.github.com` | GitHub API URL |
| `GITHUB_TOKEN` | - | GitHub token for higher rate limits |
| `LOG_LEVEL` | `info` | Logging level |
---
## π οΈ MCP Tools
| Tool | Description | Parameters |
| ---------------------- | ----------------------------- | ----------------------------- |
| `search_packages` | π Search packages on pub.dev | `query`, `limit?` |
| `get_package_info` | π¦ Get package details | `name` |
| `get_package_versions` | π Get all package versions | `name` |
| `get_readme` | π Get package README | `name`, `version?`, `format?` |
| `get_dependencies` | π Get package dependencies | `name`, `version?` |
| `get_package_score` | β Get score & metrics | `name` |
| `get_changelog` | π Get package changelog | `name`, `version?` |
| `get_package_metrics` | π Get comprehensive metrics | `name` |
### π Get Readme Format
The `get_readme` tool supports a `format` parameter:
```json
{
"name": "get_readme",
"arguments": {
"name": "http",
"format": "markdown" // "markdown" | "text" | "html"
}
}
```
---
## π MCP Resources
| URI | Description |
| ------------------------ | ---------------------------------------- |
| `pub://popular-packages` | π¦ List of popular Dart/Flutter packages |
| `pub://package/{name}` | π Package documentation and metrics |
---
## π‘ Examples
### π Search Packages
```json
{
"name": "search_packages",
"arguments": {
"query": "http client",
"limit": 5
}
}
```
**Response:**
```json
{
"packages": [
{
"name": "http",
"description": "A composable, Future-based library for making HTTP requests.",
"latestVersion": "1.2.1"
},
{ "name": "dio", "description": "A powerful HTTP client for Dart.", "latestVersion": "5.4.0" }
],
"total": 2
}
```
### β Get Package Score
```json
{
"name": "get_package_score",
"arguments": {
"name": "http"
}
}
```
**Response:**
```json
{
"grantedPoints": 160,
"maxPoints": 160,
"likeCount": 8425,
"downloadCount30Days": 8375591,
"tags": ["sdk:dart", "sdk:flutter", "topic:http", "topic:network"]
}
```
### π Get Package Metrics
```json
{
"name": "get_package_metrics",
"arguments": {
"name": "provider"
}
}
```
**Response:**
```json
{
"info": {
"name": "provider",
"description": "A wrapper around InheritedNotifier...",
"latestVersion": "6.1.2",
"published": "2024-01-15T..."
},
"score": {
"grantedPoints": 160,
"maxPoints": 160,
"likeCount": 3200,
"downloadCount30Days": 1500000,
"tags": ["sdk:flutter", "is:flutter-friendly"]
},
"versionCount": 45,
"latestVersion": "6.1.2"
}
```
---
## ποΈ Development
```bash
# Clone and install
git clone https://github.com/testx1011/pub-mcp.git
cd pub-mcp
npm install
# Build
npm run build
# Development mode with watch
npm run dev
# Run tests
npm run test
# Watch mode for tests
npm run test:watch
# Lint code
npm run lint
# Format code
npm run format
```
---
## π License
MIT License - see [LICENSE](LICENSE) file.
---
## π€ Contributing
Contributions are welcome! Please read our [Contributing Guidelines](CONTRIBUTING.md) first.
---
<p align="center">
Made with β€οΈ for the Dart/Flutter community
</p>
TDQS
Scored across 10 tools
Most tools are clearly distinct (get_dependencies, get_changelog, get_example, get_readme, search_packages). However, get_package_score, get_package_metrics, and get_package_info overlap significantlyβget_package_metrics explicitly bundles info + score + versions, making it hard to know which tool to call for a simple lookup.
All tools follow a consistent snake_case verb_noun pattern (get_* and search_*). No mixed conventions or vague verbs.
10 tools is well-scoped for a pub.dev package-inspection server. Each operation maps to a distinct facet of package data, and none feels like filler.
The surface covers search, info, versions, score, metrics, dependencies, changelog, example, and readmeβa thorough read-only lifecycle. Minor gaps like retrieving a specific version's full metadata or publisher/ownership info are easily worked around.