pub-mcp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +13 -0
- package/.editorconfig +14 -0
- package/.env.example +15 -0
- package/.eslintrc.cjs +21 -0
- package/.github/workflows/ci.yml +63 -0
- package/.prettierrc +7 -0
- package/CHANGELOG.md +84 -0
- package/CODE_OF_CONDUCT.md +34 -0
- package/CONTRIBUTING.md +55 -0
- package/Dockerfile +13 -0
- package/LICENSE +21 -0
- package/README.md +287 -0
- package/dist/cache/cache.d.ts +27 -0
- package/dist/cache/cache.d.ts.map +1 -0
- package/dist/cache/cache.js +94 -0
- package/dist/cache/cache.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +286 -0
- package/dist/cli.js.map +1 -0
- package/dist/clients/githubClient.d.ts +33 -0
- package/dist/clients/githubClient.d.ts.map +1 -0
- package/dist/clients/githubClient.js +126 -0
- package/dist/clients/githubClient.js.map +1 -0
- package/dist/clients/pubClient.d.ts +28 -0
- package/dist/clients/pubClient.d.ts.map +1 -0
- package/dist/clients/pubClient.js +223 -0
- package/dist/clients/pubClient.js.map +1 -0
- package/dist/server-http.d.ts +7 -0
- package/dist/server-http.d.ts.map +1 -0
- package/dist/server-http.js +139 -0
- package/dist/server-http.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +69 -0
- package/dist/server.js.map +1 -0
- package/dist/toolRegistry.d.ts +74 -0
- package/dist/toolRegistry.d.ts.map +1 -0
- package/dist/toolRegistry.js +80 -0
- package/dist/toolRegistry.js.map +1 -0
- package/dist/tools/index.d.ts +142 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +214 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types/index.d.ts +55 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/rateLimiter.d.ts +13 -0
- package/dist/utils/rateLimiter.d.ts.map +1 -0
- package/dist/utils/rateLimiter.js +42 -0
- package/dist/utils/rateLimiter.js.map +1 -0
- package/package.json +72 -0
- package/skills-lock.json +25 -0
- package/src/cache/cache.ts +124 -0
- package/src/cli.ts +350 -0
- package/src/clients/githubClient.ts +169 -0
- package/src/clients/pubClient.ts +312 -0
- package/src/tools/index.ts +266 -0
- package/src/types/index.ts +61 -0
- package/src/utils/rateLimiter.ts +56 -0
- package/tsconfig.json +24 -0
- package/vitest.config.ts +14 -0
package/.dockerignore
ADDED
package/.editorconfig
ADDED
package/.env.example
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Cache Configuration
|
|
2
|
+
CACHE_TTL=3600
|
|
3
|
+
CACHE_MAX_ITEMS=500
|
|
4
|
+
|
|
5
|
+
# Rate Limiting
|
|
6
|
+
MAX_CONCURRENT_REQUESTS=5
|
|
7
|
+
RETRY_ATTEMPTS=3
|
|
8
|
+
|
|
9
|
+
# API Configuration
|
|
10
|
+
PUB_DEV_API_URL=https://pub.dev/api
|
|
11
|
+
GITHUB_API_URL=https://api.github.com
|
|
12
|
+
GITHUB_TOKEN=
|
|
13
|
+
|
|
14
|
+
# Logging
|
|
15
|
+
LOG_LEVEL=info
|
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
parser: '@typescript-eslint/parser',
|
|
4
|
+
parserOptions: {
|
|
5
|
+
ecmaVersion: 2022,
|
|
6
|
+
sourceType: 'module',
|
|
7
|
+
},
|
|
8
|
+
extends: [
|
|
9
|
+
'eslint:recommended',
|
|
10
|
+
'plugin:@typescript-eslint/recommended',
|
|
11
|
+
],
|
|
12
|
+
plugins: ['@typescript-eslint'],
|
|
13
|
+
env: {
|
|
14
|
+
node: true,
|
|
15
|
+
es2022: true,
|
|
16
|
+
},
|
|
17
|
+
rules: {
|
|
18
|
+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
19
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, develop]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main, develop]
|
|
8
|
+
release:
|
|
9
|
+
types: [published]
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
lint:
|
|
13
|
+
name: Lint
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-node@v4
|
|
18
|
+
with:
|
|
19
|
+
node-version: '20'
|
|
20
|
+
cache: 'npm'
|
|
21
|
+
- run: npm ci
|
|
22
|
+
- run: npm run lint
|
|
23
|
+
|
|
24
|
+
test:
|
|
25
|
+
name: Test
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v4
|
|
29
|
+
- uses: actions/setup-node@v4
|
|
30
|
+
with:
|
|
31
|
+
node-version: '20'
|
|
32
|
+
cache: 'npm'
|
|
33
|
+
- run: npm ci
|
|
34
|
+
- run: npm run test
|
|
35
|
+
|
|
36
|
+
build:
|
|
37
|
+
name: Build
|
|
38
|
+
runs-on: ubuntu-latest
|
|
39
|
+
needs: [lint, test]
|
|
40
|
+
steps:
|
|
41
|
+
- uses: actions/checkout@v4
|
|
42
|
+
- uses: actions/setup-node@v4
|
|
43
|
+
with:
|
|
44
|
+
node-version: '20'
|
|
45
|
+
cache: 'npm'
|
|
46
|
+
- run: npm ci
|
|
47
|
+
- run: npm run build
|
|
48
|
+
|
|
49
|
+
publish:
|
|
50
|
+
name: Publish
|
|
51
|
+
runs-on: ubuntu-latest
|
|
52
|
+
needs: [build]
|
|
53
|
+
if: github.event_name == 'release'
|
|
54
|
+
steps:
|
|
55
|
+
- uses: actions/checkout@v4
|
|
56
|
+
- uses: actions/setup-node@v4
|
|
57
|
+
with:
|
|
58
|
+
node-version: '20'
|
|
59
|
+
registry-url: 'https://registry.npmjs.org'
|
|
60
|
+
- run: npm ci
|
|
61
|
+
- run: npm publish
|
|
62
|
+
env:
|
|
63
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/.prettierrc
ADDED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Changelog 📝
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2024-04-09
|
|
11
|
+
|
|
12
|
+
### 🎉 Added
|
|
13
|
+
|
|
14
|
+
- **Dual Transport Support** - Both stdio and Streamable HTTP
|
|
15
|
+
- `pub-mcp` - Both transports
|
|
16
|
+
- `pub-mcp --stdio` - Stdio only
|
|
17
|
+
- `pub-mcp --http` - HTTP only
|
|
18
|
+
- `pub-mcp --http --port 8080` - Custom port
|
|
19
|
+
|
|
20
|
+
- **New MCP Tools**
|
|
21
|
+
- `get_package_score` - Get pana points, likes, downloads, tags
|
|
22
|
+
- `get_changelog` - Get package changelog
|
|
23
|
+
- `get_package_metrics` - Comprehensive metrics (info + score + versions)
|
|
24
|
+
|
|
25
|
+
- **Enhanced `get_readme`**
|
|
26
|
+
- Added `format` parameter: `markdown`, `text`, `html`
|
|
27
|
+
|
|
28
|
+
- **MCP Resources**
|
|
29
|
+
- `pub://popular-packages` - List of popular packages
|
|
30
|
+
- `pub://package/{name}` - Package documentation and metrics
|
|
31
|
+
|
|
32
|
+
### 🛠️ Changed
|
|
33
|
+
|
|
34
|
+
- Refactored CLI to unified entry point
|
|
35
|
+
- Improved error handling in HTTP transport
|
|
36
|
+
- Better structured logging
|
|
37
|
+
|
|
38
|
+
### 📦 Dependencies
|
|
39
|
+
|
|
40
|
+
- Updated `@modelcontextprotocol/sdk` to v1.29.0
|
|
41
|
+
- Added `express` and `cors` for HTTP transport
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## [0.0.1] - 2024-04-09
|
|
46
|
+
|
|
47
|
+
### 🎉 Added
|
|
48
|
+
|
|
49
|
+
- MCP server with stdio transport
|
|
50
|
+
- pub.dev API client with search, getPackage, getPackageVersions, getReadme, getDependencies
|
|
51
|
+
- LRU caching layer for package info, versions, readme, and search results
|
|
52
|
+
- GitHub fallback integration for README when pub.dev has no content
|
|
53
|
+
- Rate limiting with p-limit
|
|
54
|
+
- CLI runner with health check and version commands
|
|
55
|
+
- Structured logging with Pino
|
|
56
|
+
- Unit tests for all modules
|
|
57
|
+
- GitHub Actions CI workflow
|
|
58
|
+
|
|
59
|
+
### 🛠️ Tools
|
|
60
|
+
|
|
61
|
+
- `ping` - Check server health
|
|
62
|
+
- `health` - Get server status
|
|
63
|
+
- `search_packages` - Search packages on pub.dev
|
|
64
|
+
- `get_package_info` - Get package details
|
|
65
|
+
- `get_package_versions` - Get package versions
|
|
66
|
+
- `get_readme` - Get package README (with GitHub fallback)
|
|
67
|
+
- `get_dependencies` - Get package dependencies
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Roadmap 🗺️
|
|
72
|
+
|
|
73
|
+
### Planned Features
|
|
74
|
+
|
|
75
|
+
- [ ] SSE (Server-Sent Events) support for streaming
|
|
76
|
+
- [ ] OAuth authentication for HTTP transport
|
|
77
|
+
- [ ] Prometheus metrics endpoint
|
|
78
|
+
- [ ] Health check endpoint with detailed status
|
|
79
|
+
- [ ] Package search suggestions
|
|
80
|
+
- [ ] Trending packages resource
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
<p align="right"><i>Changelog generated by <a href="https://github.com/conventional-changelog/conventional-changelog">conventional-changelog</a></i></p>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone.
|
|
6
|
+
|
|
7
|
+
## Our Standards
|
|
8
|
+
|
|
9
|
+
Examples of behavior that contributes to a positive environment:
|
|
10
|
+
|
|
11
|
+
- Using welcoming and inclusive language
|
|
12
|
+
- Being respectful of differing viewpoints and experiences
|
|
13
|
+
- Gracefully accepting constructive criticism
|
|
14
|
+
- Focusing on what is best for the community
|
|
15
|
+
- Showing empathy towards other community members
|
|
16
|
+
|
|
17
|
+
Examples of unacceptable behavior:
|
|
18
|
+
|
|
19
|
+
- Harassment of any kind
|
|
20
|
+
- Publishing others' private information without permission
|
|
21
|
+
- Disrespectful or discriminatory comments
|
|
22
|
+
- Public or private harassment
|
|
23
|
+
|
|
24
|
+
## Enforcement Responsibilities
|
|
25
|
+
|
|
26
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior.
|
|
27
|
+
|
|
28
|
+
## Reporting
|
|
29
|
+
|
|
30
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior can be reported by contacting the maintainers.
|
|
31
|
+
|
|
32
|
+
## Attribution
|
|
33
|
+
|
|
34
|
+
This Code of Conduct is adapted from the Contributor Covenant.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Contributing to pub-mcp
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing!
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
1. Fork the repository
|
|
8
|
+
2. Clone your fork: `git clone https://github.com/YOUR_USERNAME/pub-mcp.git`
|
|
9
|
+
3. Install dependencies: `npm install`
|
|
10
|
+
4. Create a feature branch: `git checkout -b feature/my-feature`
|
|
11
|
+
|
|
12
|
+
## Development Workflow
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Run tests
|
|
16
|
+
npm run test
|
|
17
|
+
|
|
18
|
+
# Run linter
|
|
19
|
+
npm run lint
|
|
20
|
+
|
|
21
|
+
# Build
|
|
22
|
+
npm run build
|
|
23
|
+
|
|
24
|
+
# Run all checks
|
|
25
|
+
npm run check
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Code Style
|
|
29
|
+
|
|
30
|
+
- Use TypeScript
|
|
31
|
+
- Follow existing code patterns
|
|
32
|
+
- Run `npm run format` before committing
|
|
33
|
+
- Ensure tests pass
|
|
34
|
+
|
|
35
|
+
## Testing
|
|
36
|
+
|
|
37
|
+
- Write tests for new features
|
|
38
|
+
- Run `npm run test` to verify
|
|
39
|
+
- Coverage target: 80%+
|
|
40
|
+
|
|
41
|
+
##提交
|
|
42
|
+
|
|
43
|
+
- Use clear commit messages
|
|
44
|
+
- Reference issues in commits
|
|
45
|
+
|
|
46
|
+
## Pull Requests
|
|
47
|
+
|
|
48
|
+
1. Ensure all tests pass
|
|
49
|
+
2. Ensure linting passes
|
|
50
|
+
3. Update documentation if needed
|
|
51
|
+
4. Submit PR with description
|
|
52
|
+
|
|
53
|
+
## Questions?
|
|
54
|
+
|
|
55
|
+
Open an issue for questions about contributing.
|
package/Dockerfile
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
# pub-mcp 📦✨
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/pub-mcp)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://nodejs.org)
|
|
6
|
+
[](https://www.typescriptlang.org)
|
|
7
|
+
|
|
8
|
+
> MCP (Model Context Protocol) server for pub.dev - Open Source. Enables LLMs and AI assistants to access Dart/Flutter package information from pub.dev.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## ⚡ Quick Start
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Install globally
|
|
16
|
+
npm install -g pub-mcp
|
|
17
|
+
|
|
18
|
+
# Start server (stdio + HTTP)
|
|
19
|
+
pub-mcp
|
|
20
|
+
|
|
21
|
+
# Or start with just HTTP on custom port
|
|
22
|
+
pub-mcp --http --port 8080
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
That's it! Your MCP server is running on port 3000 (HTTP) and listening on stdio.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 🎯 Features
|
|
30
|
+
|
|
31
|
+
| Feature | Description |
|
|
32
|
+
| ------------------------- | ----------------------------------------------- |
|
|
33
|
+
| 🔍 **Package Search** | Search packages on pub.dev by query |
|
|
34
|
+
| 📦 **Package Info** | Get metadata, versions, publisher info |
|
|
35
|
+
| ⭐ **Package Score** | Pana points, likes, downloads, tags |
|
|
36
|
+
| 📝 **Changelog** | Package changelog for any version |
|
|
37
|
+
| 📊 **Metrics** | Comprehensive metrics (info + score + versions) |
|
|
38
|
+
| 📖 **README** | Package README with GitHub fallback |
|
|
39
|
+
| 🔗 **Dependencies** | Package dependency tree |
|
|
40
|
+
| 🌐 **MCP Resources** | Access packages as resources |
|
|
41
|
+
| 🚇 **Dual Transport** | Stdio and Streamable HTTP |
|
|
42
|
+
| 💾 **LRU Caching** | Built-in caching for performance |
|
|
43
|
+
| ⚡ **Rate Limiting** | Retry with exponential backoff |
|
|
44
|
+
| 📝 **Structured Logging** | Pino logger integration |
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 🚀 Usage
|
|
49
|
+
|
|
50
|
+
### Starting the Server
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Both transports (default - stdio + HTTP on port 3000)
|
|
54
|
+
pub-mcp
|
|
55
|
+
|
|
56
|
+
# Stdio only (for Claude Desktop, etc.)
|
|
57
|
+
pub-mcp --stdio
|
|
58
|
+
|
|
59
|
+
# HTTP only
|
|
60
|
+
pub-mcp --http
|
|
61
|
+
|
|
62
|
+
# HTTP on custom port
|
|
63
|
+
pub-mcp --http --port 8080
|
|
64
|
+
|
|
65
|
+
# Check version
|
|
66
|
+
pub-mcp --version
|
|
67
|
+
|
|
68
|
+
# Check API health
|
|
69
|
+
pub-mcp --health
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Connecting AI Clients
|
|
73
|
+
|
|
74
|
+
#### Claude Desktop
|
|
75
|
+
|
|
76
|
+
Add to your `claude_desktop_config.json`:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"mcpServers": {
|
|
81
|
+
"pub-mcp": {
|
|
82
|
+
"command": "pub-mcp",
|
|
83
|
+
"args": ["--stdio"]
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### Other MCP Clients
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Start HTTP server
|
|
93
|
+
pub-mcp --http
|
|
94
|
+
|
|
95
|
+
# Connect to http://localhost:3000/mcp
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 🔧 Configuration
|
|
101
|
+
|
|
102
|
+
Environment variables (optional, can be set in `.env`):
|
|
103
|
+
|
|
104
|
+
| Variable | Default | Description |
|
|
105
|
+
| ------------------------- | ------------------------ | ----------------------------------- |
|
|
106
|
+
| `PORT` | `3000` | HTTP server port |
|
|
107
|
+
| `CACHE_TTL` | `3600` | Cache TTL in seconds |
|
|
108
|
+
| `CACHE_MAX_ITEMS` | `500` | Maximum cache items |
|
|
109
|
+
| `MAX_CONCURRENT_REQUESTS` | `5` | Concurrent request limit |
|
|
110
|
+
| `RETRY_ATTEMPTS` | `3` | Retry attempts |
|
|
111
|
+
| `PUB_DEV_API_URL` | `https://pub.dev/api` | pub.dev API URL |
|
|
112
|
+
| `GITHUB_API_URL` | `https://api.github.com` | GitHub API URL |
|
|
113
|
+
| `GITHUB_TOKEN` | - | GitHub token for higher rate limits |
|
|
114
|
+
| `LOG_LEVEL` | `info` | Logging level |
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 🛠️ MCP Tools
|
|
119
|
+
|
|
120
|
+
| Tool | Description | Parameters |
|
|
121
|
+
| ---------------------- | ----------------------------- | ----------------------------- |
|
|
122
|
+
| `search_packages` | 🔍 Search packages on pub.dev | `query`, `limit?` |
|
|
123
|
+
| `get_package_info` | 📦 Get package details | `name` |
|
|
124
|
+
| `get_package_versions` | 📋 Get all package versions | `name` |
|
|
125
|
+
| `get_readme` | 📖 Get package README | `name`, `version?`, `format?` |
|
|
126
|
+
| `get_dependencies` | 🔗 Get package dependencies | `name`, `version?` |
|
|
127
|
+
| `get_package_score` | ⭐ Get score & metrics | `name` |
|
|
128
|
+
| `get_changelog` | 📝 Get package changelog | `name`, `version?` |
|
|
129
|
+
| `get_package_metrics` | 📊 Get comprehensive metrics | `name` |
|
|
130
|
+
|
|
131
|
+
### 📖 Get Readme Format
|
|
132
|
+
|
|
133
|
+
The `get_readme` tool supports a `format` parameter:
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"name": "get_readme",
|
|
138
|
+
"arguments": {
|
|
139
|
+
"name": "http",
|
|
140
|
+
"format": "markdown" // "markdown" | "text" | "html"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 📚 MCP Resources
|
|
148
|
+
|
|
149
|
+
| URI | Description |
|
|
150
|
+
| ------------------------ | ---------------------------------------- |
|
|
151
|
+
| `pub://popular-packages` | 📦 List of popular Dart/Flutter packages |
|
|
152
|
+
| `pub://package/{name}` | 📋 Package documentation and metrics |
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 💡 Examples
|
|
157
|
+
|
|
158
|
+
### 🔍 Search Packages
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
{
|
|
162
|
+
"name": "search_packages",
|
|
163
|
+
"arguments": {
|
|
164
|
+
"query": "http client",
|
|
165
|
+
"limit": 5
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Response:**
|
|
171
|
+
|
|
172
|
+
```json
|
|
173
|
+
{
|
|
174
|
+
"packages": [
|
|
175
|
+
{
|
|
176
|
+
"name": "http",
|
|
177
|
+
"description": "A composable, Future-based library for making HTTP requests.",
|
|
178
|
+
"latestVersion": "1.2.1"
|
|
179
|
+
},
|
|
180
|
+
{ "name": "dio", "description": "A powerful HTTP client for Dart.", "latestVersion": "5.4.0" }
|
|
181
|
+
],
|
|
182
|
+
"total": 2
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### ⭐ Get Package Score
|
|
187
|
+
|
|
188
|
+
```json
|
|
189
|
+
{
|
|
190
|
+
"name": "get_package_score",
|
|
191
|
+
"arguments": {
|
|
192
|
+
"name": "http"
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Response:**
|
|
198
|
+
|
|
199
|
+
```json
|
|
200
|
+
{
|
|
201
|
+
"grantedPoints": 160,
|
|
202
|
+
"maxPoints": 160,
|
|
203
|
+
"likeCount": 8425,
|
|
204
|
+
"downloadCount30Days": 8375591,
|
|
205
|
+
"tags": ["sdk:dart", "sdk:flutter", "topic:http", "topic:network"]
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### 📊 Get Package Metrics
|
|
210
|
+
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"name": "get_package_metrics",
|
|
214
|
+
"arguments": {
|
|
215
|
+
"name": "provider"
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**Response:**
|
|
221
|
+
|
|
222
|
+
```json
|
|
223
|
+
{
|
|
224
|
+
"info": {
|
|
225
|
+
"name": "provider",
|
|
226
|
+
"description": "A wrapper around InheritedNotifier...",
|
|
227
|
+
"latestVersion": "6.1.2",
|
|
228
|
+
"published": "2024-01-15T..."
|
|
229
|
+
},
|
|
230
|
+
"score": {
|
|
231
|
+
"grantedPoints": 160,
|
|
232
|
+
"maxPoints": 160,
|
|
233
|
+
"likeCount": 3200,
|
|
234
|
+
"downloadCount30Days": 1500000,
|
|
235
|
+
"tags": ["sdk:flutter", "is:flutter-friendly"]
|
|
236
|
+
},
|
|
237
|
+
"versionCount": 45,
|
|
238
|
+
"latestVersion": "6.1.2"
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## 🏗️ Development
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# Clone and install
|
|
248
|
+
git clone https://github.com/yourusername/pub-mcp.git
|
|
249
|
+
cd pub-mcp
|
|
250
|
+
npm install
|
|
251
|
+
|
|
252
|
+
# Build
|
|
253
|
+
npm run build
|
|
254
|
+
|
|
255
|
+
# Development mode with watch
|
|
256
|
+
npm run dev
|
|
257
|
+
|
|
258
|
+
# Run tests
|
|
259
|
+
npm run test
|
|
260
|
+
|
|
261
|
+
# Watch mode for tests
|
|
262
|
+
npm run test:watch
|
|
263
|
+
|
|
264
|
+
# Lint code
|
|
265
|
+
npm run lint
|
|
266
|
+
|
|
267
|
+
# Format code
|
|
268
|
+
npm run format
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## 📄 License
|
|
274
|
+
|
|
275
|
+
MIT License - see [LICENSE](LICENSE) file.
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## 🤝 Contributing
|
|
280
|
+
|
|
281
|
+
Contributions are welcome! Please read our [Contributing Guidelines](CONTRIBUTING.md) first.
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
<p align="center">
|
|
286
|
+
Made with ❤️ for the Dart/Flutter community
|
|
287
|
+
</p>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface CacheOptions {
|
|
2
|
+
ttl: number;
|
|
3
|
+
maxItems: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class LRUCache<T> {
|
|
6
|
+
private cache;
|
|
7
|
+
private ttl;
|
|
8
|
+
private maxItems;
|
|
9
|
+
constructor(options: CacheOptions);
|
|
10
|
+
get(key: string): T | undefined;
|
|
11
|
+
set(key: string, value: T, ttl?: number): void;
|
|
12
|
+
has(key: string): boolean;
|
|
13
|
+
delete(key: string): void;
|
|
14
|
+
clear(): void;
|
|
15
|
+
size(): number;
|
|
16
|
+
private cleanup;
|
|
17
|
+
stats(): {
|
|
18
|
+
size: number;
|
|
19
|
+
hits: number;
|
|
20
|
+
misses: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export declare function createCache<T>(options: CacheOptions): LRUCache<T>;
|
|
24
|
+
export declare function getPackageCache(): LRUCache<unknown>;
|
|
25
|
+
export declare function getSearchCache(): LRUCache<unknown>;
|
|
26
|
+
export declare function clearAllCaches(): void;
|
|
27
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/cache/cache.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAOD,qBAAa,QAAQ,CAAC,CAAC;IACrB,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,QAAQ,CAAS;gBAEb,OAAO,EAAE,YAAY;IAMjC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAkB/B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI;IAY9C,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAYzB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIzB,KAAK,IAAI,IAAI;IAIb,IAAI,IAAI,MAAM;IAKd,OAAO,CAAC,OAAO;IASf,KAAK,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;CAOxD;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,GAAG,QAAQ,CAAC,CAAC,CAAC,CAEjE;AAUD,wBAAgB,eAAe,IAAI,QAAQ,CAAC,OAAO,CAAC,CAKnD;AAED,wBAAgB,cAAc,IAAI,QAAQ,CAAC,OAAO,CAAC,CAKlD;AAED,wBAAgB,cAAc,IAAI,IAAI,CAGrC"}
|