@nekzus/mcp-server 1.22.0 → 1.24.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/README.md +183 -277
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +7 -53
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +242 -602
- package/dist/index.js.map +1 -1
- package/dist/src/cache.d.ts +22 -0
- package/dist/src/cache.d.ts.map +1 -0
- package/dist/src/cache.js +68 -0
- package/dist/src/cache.js.map +1 -0
- package/dist/src/config.d.ts +11 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +45 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/handlers/index.d.ts +2 -0
- package/dist/src/handlers/index.d.ts.map +1 -0
- package/dist/src/handlers/index.js +2 -0
- package/dist/src/handlers/index.js.map +1 -0
- package/dist/src/http.d.ts +16 -0
- package/dist/src/http.d.ts.map +1 -0
- package/dist/src/http.js +109 -0
- package/dist/src/http.js.map +1 -0
- package/dist/src/icons.d.ts +21 -0
- package/dist/src/icons.d.ts.map +1 -0
- package/dist/src/icons.js +29 -0
- package/dist/src/icons.js.map +1 -0
- package/dist/src/prompts/index.d.ts +3 -0
- package/dist/src/prompts/index.d.ts.map +1 -0
- package/dist/src/prompts/index.js +22 -0
- package/dist/src/prompts/index.js.map +1 -0
- package/dist/src/resources/index.d.ts +3 -0
- package/dist/src/resources/index.d.ts.map +1 -0
- package/dist/src/resources/index.js +62 -0
- package/dist/src/resources/index.js.map +1 -0
- package/dist/src/schemas.d.ts +145 -0
- package/dist/src/schemas.d.ts.map +1 -0
- package/dist/src/schemas.js +201 -0
- package/dist/src/schemas.js.map +1 -0
- package/dist/src/server.d.ts +7 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +23 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/tools/index.d.ts +4 -0
- package/dist/src/tools/index.d.ts.map +1 -0
- package/dist/src/tools/index.js +407 -0
- package/dist/src/tools/index.js.map +1 -0
- package/dist/src/utils/fetch-retry.d.ts +5 -0
- package/dist/src/utils/fetch-retry.d.ts.map +1 -0
- package/dist/src/utils/fetch-retry.js +69 -0
- package/dist/src/utils/fetch-retry.js.map +1 -0
- package/dist/src/utils/version-resolver.d.ts +14 -0
- package/dist/src/utils/version-resolver.d.ts.map +1 -0
- package/dist/src/utils/version-resolver.js +76 -0
- package/dist/src/utils/version-resolver.js.map +1 -0
- package/llms-full.txt +350 -477
- package/package.json +5 -3
package/llms-full.txt
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# NPM Sentinel MCP Server - Full Documentation
|
|
1
|
+
# NPM Sentinel MCP Server - Full Protocol & Technical Documentation
|
|
2
2
|
|
|
3
3
|
## Protocol Specification
|
|
4
|
-
Version:
|
|
5
|
-
Transport: stdio
|
|
6
|
-
|
|
4
|
+
Version: MCP v2 (@modelcontextprotocol/server & @modelcontextprotocol/core)
|
|
5
|
+
Transport: stdio / Streamable HTTP (SSE)
|
|
6
|
+
Capabilities: resources, prompts, tools, logging, structuredOutput
|
|
7
7
|
|
|
8
8
|
### Indirect Prompt Injection Safeguards (OWASP LLM01)
|
|
9
9
|
All tools returning raw 3rd-party Markdown/text (`npmPackageReadme`, `npmChangelogAnalysis`) implement Defense-in-Depth safeguards:
|
|
@@ -11,647 +11,520 @@ All tools returning raw 3rd-party Markdown/text (`npmPackageReadme`, `npmChangel
|
|
|
11
11
|
- **Metadata Flags (`_meta`)**: Attaches `_meta.untrustedExternalContent = true` and `_meta.sources` arrays to response content.
|
|
12
12
|
- **Tool & Prompt Directives**: Tool schemas and prompts explicitly instruct consuming models to process content strictly as passive data.
|
|
13
13
|
|
|
14
|
-
###
|
|
15
|
-
All package
|
|
16
|
-
-
|
|
17
|
-
- Avoids registry 404 errors when an exact SemVer string is omitted.
|
|
14
|
+
### Batch Rate Limits & Input Sanitization
|
|
15
|
+
- **Batch Size Capping**: All 18 multi-package analysis tools enforce a maximum limit of 25 package names per request (`PackageListSchema`).
|
|
16
|
+
- **Search Query Sanitization**: `npmSearch` enforces a 100-character cap on `query` (`SearchQuerySchema`) and filters control characters (`\0`, `\r`, `\n`, `\t`).
|
|
18
17
|
|
|
19
|
-
## Architecture
|
|
18
|
+
## Modular Architecture (`src/`)
|
|
20
19
|
```mermaid
|
|
21
20
|
flowchart TD
|
|
22
|
-
Client[MCP Client] <-->|MCP
|
|
23
|
-
|
|
24
|
-
Server -->|Analysis| Security[Security DB]
|
|
25
|
-
Server -->|Metrics| Stats[Download Stats]
|
|
21
|
+
Client[MCP v2 Client] <-->|MCP JSON-RPC| Transport[Stdio / HTTP Transport]
|
|
22
|
+
Transport <--> Server[src/server.ts createServer]
|
|
26
23
|
|
|
27
|
-
subgraph
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
subgraph Modular Server Core
|
|
25
|
+
Server --> ToolsReg[src/tools/index.ts]
|
|
26
|
+
Server --> ResReg[src/resources/index.ts]
|
|
27
|
+
Server --> PromptReg[src/prompts/index.ts]
|
|
28
|
+
Server --> Config[src/config.ts]
|
|
29
|
+
Server --> Cache[src/cache.ts FIFO Cache]
|
|
31
30
|
end
|
|
32
31
|
|
|
33
|
-
subgraph
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
subgraph Handlers Layer
|
|
33
|
+
ToolsReg --> Handlers[src/handlers/index.ts]
|
|
34
|
+
Handlers --> Registry[NPM Registry API]
|
|
35
|
+
Handlers --> DepsDev[Google deps.dev / OSV.dev]
|
|
36
|
+
Handlers --> NPMS[npms.io API]
|
|
37
|
+
Handlers --> GitHub[GitHub API / Scorecard]
|
|
38
38
|
end
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
##
|
|
41
|
+
## Features & Capabilities
|
|
42
42
|
|
|
43
|
-
###
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
Rate Limits: Follows npm registry limits
|
|
48
|
-
Description: Package metadata and version information interface
|
|
43
|
+
### 1. Dual Output Protocol (`structuredContent` + `content`)
|
|
44
|
+
Every tool handler call processes inputs through Zod validation (`inputSchema` and `outputSchema`) and wraps responses using `withStructuredOutput`. The client receives both:
|
|
45
|
+
- `content`: Human-readable stringified JSON formatted text item.
|
|
46
|
+
- `structuredContent`: Deserialized native JSON object matching the tool's `outputSchema`.
|
|
49
47
|
|
|
50
|
-
###
|
|
51
|
-
|
|
52
|
-
Methods: GET
|
|
53
|
-
Update Frequency: Daily
|
|
54
|
-
Severity Levels: Low, Medium, High, Critical
|
|
55
|
-
Description: Vulnerability and security analysis interface
|
|
48
|
+
### 2. Embedded Vector SVG Data URI Icons
|
|
49
|
+
All registered tools, resources, and prompts expose pre-rendered SVG Data URIs (`data:image/svg+xml`) in their `icons` array for rich presentation in modern MCP UI clients.
|
|
56
50
|
|
|
57
|
-
###
|
|
58
|
-
|
|
59
|
-
Methods: GET, SUBSCRIBE
|
|
60
|
-
Update Frequency: Real-time
|
|
61
|
-
Metrics Types: Downloads, Stars, Issues, Updates
|
|
62
|
-
Description: Package analytics and statistics interface
|
|
51
|
+
### 3. Context Diagnostics Logging
|
|
52
|
+
Handlers issue real-time diagnostic logs (`info`) using `ctx.mcpReq.log` during execution.
|
|
63
53
|
|
|
64
|
-
|
|
54
|
+
### 4. Indirect Prompt Injection Safeguards (OWASP LLM01)
|
|
55
|
+
All tools returning raw 3rd-party Markdown/text (`npmPackageReadme`, `npmChangelogAnalysis`) implement Defense-in-Depth safeguards:
|
|
56
|
+
- **XML Demarcation**: Wraps raw external text inside `<untrusted_external_content source="..." package="..." type="...">` tags.
|
|
57
|
+
- **Metadata Flags (`_meta`)**: Attaches `_meta.untrustedExternalContent = true` and `_meta.sources` arrays to response content.
|
|
58
|
+
- **Tool & Prompt Directives**: Tool schemas and prompts explicitly instruct consuming models to process content strictly as passive data.
|
|
65
59
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
### 5. Smart SemVer Version Resolution
|
|
61
|
+
All package version querying tools (`npmDeprecated`, `npmLatest`, `npmDeps`, `npmTypes`, `npmPackageReadme`, `npmLicenseCompatibility`, `npmCompare`) implement 4-step SemVer resolution:
|
|
62
|
+
- Automatically resolves major version shorthands (`express@2`), version prefixes (`v4`), wildcard sub-versions (`4.x`), and SemVer ranges (`^4`, `~4.18`) to the highest matching release.
|
|
63
|
+
- Avoids registry 404 errors when an exact SemVer string is omitted.
|
|
64
|
+
- Caches abbreviated packument lookups (`Accept: application/vnd.npm.install-v1+json`) for maximum performance.
|
|
69
65
|
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
interface NpmVersionsInput {
|
|
73
|
-
packages: string[];
|
|
74
|
-
}
|
|
66
|
+
---
|
|
75
67
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
68
|
+
## Resources Specification
|
|
69
|
+
|
|
70
|
+
### `doc://server/readme`
|
|
71
|
+
- **Content-Type**: `text/markdown`
|
|
72
|
+
- **Description**: Main NPM Sentinel MCP server README documentation.
|
|
73
|
+
- **Icon**: SVG Document Data URI.
|
|
74
|
+
|
|
75
|
+
### `doc://mcp/specification`
|
|
76
|
+
- **Content-Type**: `text/plain`
|
|
77
|
+
- **Description**: Complete Model Context Protocol technical specification (`llms-full.txt`).
|
|
78
|
+
- **Icon**: SVG Document Data URI.
|
|
82
79
|
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Prompts Specification
|
|
83
|
+
|
|
84
|
+
### `analyze-package`
|
|
85
|
+
- **Description**: Generates an interactive prompt payload for deep AI analysis of an NPM package including security, performance, dependencies, and health metrics.
|
|
86
|
+
- **Arguments**:
|
|
87
|
+
- `package` (string, required): Name of the NPM package to analyze.
|
|
88
|
+
- **Icon**: SVG Security Data URI.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Tool Specifications (19 Tools)
|
|
93
|
+
|
|
94
|
+
All tools accept an optional `ignoreCache: true` parameter and return standardized responses.
|
|
95
|
+
|
|
96
|
+
### Standard Error Format (e.g. Empty Array `packages: []` or Invalid Input)
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"queryPackages": [],
|
|
100
|
+
"results": [],
|
|
101
|
+
"status": "error",
|
|
102
|
+
"error": "No package names provided in request",
|
|
103
|
+
"message": "The packages parameter must contain at least one package name."
|
|
85
104
|
}
|
|
86
105
|
```
|
|
87
106
|
|
|
88
|
-
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
#### 1. `npmLatest`
|
|
89
110
|
```typescript
|
|
90
111
|
interface NpmLatestInput {
|
|
91
112
|
packages: string[];
|
|
113
|
+
ignoreCache?: boolean;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
interface LatestVersionResult {
|
|
117
|
+
packageInput: string;
|
|
118
|
+
packageName: string;
|
|
119
|
+
versionQueried: string;
|
|
120
|
+
status: 'success' | 'error';
|
|
121
|
+
data?: {
|
|
122
|
+
version: string;
|
|
123
|
+
description: string;
|
|
124
|
+
license: string;
|
|
125
|
+
homepage: string;
|
|
126
|
+
repository: any;
|
|
127
|
+
dependencies: Record<string, string>;
|
|
128
|
+
integrity: string;
|
|
129
|
+
tarball: string;
|
|
130
|
+
distTags: Record<string, string>;
|
|
131
|
+
};
|
|
92
132
|
}
|
|
133
|
+
```
|
|
93
134
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
135
|
+
#### 2. `npmVersions`
|
|
136
|
+
```typescript
|
|
137
|
+
interface NpmVersionsInput {
|
|
138
|
+
packages: string[];
|
|
139
|
+
ignoreCache?: boolean;
|
|
98
140
|
}
|
|
99
141
|
|
|
100
|
-
interface
|
|
101
|
-
|
|
142
|
+
interface VersionsResult {
|
|
143
|
+
packageInput: string;
|
|
144
|
+
packageName: string;
|
|
145
|
+
status: 'success' | 'error';
|
|
146
|
+
data?: {
|
|
147
|
+
allVersions: string[];
|
|
148
|
+
tags: Record<string, string>;
|
|
149
|
+
latestVersionTag: string;
|
|
150
|
+
};
|
|
102
151
|
}
|
|
103
152
|
```
|
|
104
153
|
|
|
105
|
-
#### npmDeps
|
|
154
|
+
#### 3. `npmDeps`
|
|
106
155
|
```typescript
|
|
107
156
|
interface NpmDepsInput {
|
|
108
157
|
packages: string[];
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
158
|
+
ignoreCache?: boolean;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
interface NpmDepsResult {
|
|
162
|
+
packageInput: string;
|
|
163
|
+
packageName: string;
|
|
164
|
+
status: 'success' | 'error';
|
|
165
|
+
data?: {
|
|
166
|
+
directDependencies: Record<string, string>;
|
|
167
|
+
devDependencies: Record<string, string>;
|
|
168
|
+
peerDependencies: Record<string, string>;
|
|
169
|
+
transitiveCount: number;
|
|
170
|
+
transitiveDependenciesList: string[];
|
|
121
171
|
};
|
|
122
172
|
}
|
|
123
173
|
```
|
|
124
174
|
|
|
125
|
-
#### npmTypes
|
|
175
|
+
#### 4. `npmTypes`
|
|
126
176
|
```typescript
|
|
127
177
|
interface NpmTypesInput {
|
|
128
178
|
packages: string[];
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
179
|
+
ignoreCache?: boolean;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
interface NpmTypesResult {
|
|
183
|
+
packageInput: string;
|
|
184
|
+
packageName: string;
|
|
185
|
+
status: 'success' | 'error';
|
|
186
|
+
data?: {
|
|
187
|
+
hasNativeTypes: boolean;
|
|
188
|
+
definitelyTypedPackage: string | null;
|
|
189
|
+
hasDefinitelyTyped: boolean;
|
|
190
|
+
tsStatus: 'native' | 'definitely-typed' | 'none';
|
|
191
|
+
};
|
|
140
192
|
}
|
|
141
193
|
```
|
|
142
194
|
|
|
143
|
-
#### npmSize
|
|
195
|
+
#### 5. `npmSize`
|
|
144
196
|
```typescript
|
|
145
197
|
interface NpmSizeInput {
|
|
146
198
|
packages: string[];
|
|
199
|
+
ignoreCache?: boolean;
|
|
147
200
|
}
|
|
148
201
|
|
|
149
|
-
interface
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
[packageName: string]: SizeMetrics;
|
|
202
|
+
interface NpmSizeResult {
|
|
203
|
+
packageInput: string;
|
|
204
|
+
packageName: string;
|
|
205
|
+
status: 'success' | 'error';
|
|
206
|
+
data?: {
|
|
207
|
+
unpackedSize: number;
|
|
208
|
+
fileCount: number;
|
|
209
|
+
sizeFormatted: string;
|
|
210
|
+
};
|
|
159
211
|
}
|
|
160
212
|
```
|
|
161
213
|
|
|
162
|
-
#### npmVulnerabilities
|
|
214
|
+
#### 6. `npmVulnerabilities`
|
|
163
215
|
```typescript
|
|
164
216
|
interface NpmVulnerabilitiesInput {
|
|
165
217
|
packages: string[];
|
|
218
|
+
ignoreCache?: boolean;
|
|
166
219
|
}
|
|
167
220
|
|
|
168
|
-
interface
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
cvssScore?: number;
|
|
175
|
-
url?: string;
|
|
221
|
+
interface VulnerabilityAdvisory {
|
|
222
|
+
id: string;
|
|
223
|
+
summary: string;
|
|
224
|
+
details: string;
|
|
225
|
+
severity: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
|
|
226
|
+
aliases: string[];
|
|
176
227
|
}
|
|
177
228
|
|
|
178
|
-
interface
|
|
179
|
-
|
|
229
|
+
interface NpmVulnerabilitiesResult {
|
|
230
|
+
packageInput: string;
|
|
231
|
+
packageName: string;
|
|
232
|
+
status: 'success' | 'error';
|
|
233
|
+
data?: {
|
|
234
|
+
vulnerabilityCount: number;
|
|
235
|
+
scannedPackagesCount: number;
|
|
236
|
+
advisories: VulnerabilityAdvisory[];
|
|
237
|
+
};
|
|
180
238
|
}
|
|
181
239
|
```
|
|
182
240
|
|
|
183
|
-
#### npmTrends
|
|
241
|
+
#### 7. `npmTrends`
|
|
184
242
|
```typescript
|
|
185
243
|
interface NpmTrendsInput {
|
|
186
244
|
packages: string[];
|
|
187
|
-
period
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
interface NpmTrendsResponse {
|
|
203
|
-
[packageName: string]: TrendMetrics;
|
|
245
|
+
period?: 'last-week' | 'last-month' | 'last-year';
|
|
246
|
+
ignoreCache?: boolean;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
interface NpmTrendsResult {
|
|
250
|
+
packageInput: string;
|
|
251
|
+
packageName: string;
|
|
252
|
+
status: 'success' | 'error';
|
|
253
|
+
data?: {
|
|
254
|
+
period: string;
|
|
255
|
+
totalDownloads: number;
|
|
256
|
+
downloads: Array<{ day: string; downloads: number }>;
|
|
257
|
+
};
|
|
204
258
|
}
|
|
205
259
|
```
|
|
206
260
|
|
|
207
|
-
#### npmCompare
|
|
261
|
+
#### 8. `npmCompare`
|
|
208
262
|
```typescript
|
|
209
263
|
interface NpmCompareInput {
|
|
210
264
|
packages: string[];
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
265
|
+
ignoreCache?: boolean;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
interface NpmCompareResult {
|
|
269
|
+
packagesCompared: string[];
|
|
270
|
+
metrics: Array<{
|
|
271
|
+
name: string;
|
|
272
|
+
version: string;
|
|
273
|
+
monthlyDownloads: number;
|
|
274
|
+
score: number;
|
|
275
|
+
license: string;
|
|
276
|
+
hasTypes: boolean;
|
|
277
|
+
}>;
|
|
224
278
|
}
|
|
225
279
|
```
|
|
226
280
|
|
|
227
|
-
#### npmMaintainers
|
|
281
|
+
#### 9. `npmMaintainers`
|
|
228
282
|
```typescript
|
|
229
283
|
interface NpmMaintainersInput {
|
|
230
284
|
packages: string[];
|
|
285
|
+
ignoreCache?: boolean;
|
|
231
286
|
}
|
|
232
287
|
|
|
233
|
-
interface
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
[packageName: string]: Maintainer[];
|
|
288
|
+
interface NpmMaintainersResult {
|
|
289
|
+
packageInput: string;
|
|
290
|
+
packageName: string;
|
|
291
|
+
status: 'success' | 'error';
|
|
292
|
+
data?: {
|
|
293
|
+
maintainers: Array<{ name: string; email?: string; url?: string }>;
|
|
294
|
+
};
|
|
241
295
|
}
|
|
242
296
|
```
|
|
243
297
|
|
|
244
|
-
#### npmScore
|
|
298
|
+
#### 10. `npmScore`
|
|
245
299
|
```typescript
|
|
246
300
|
interface NpmScoreInput {
|
|
247
301
|
packages: string[];
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
status: 'success' | 'error' | 'success_cache';
|
|
263
|
-
error: string | null;
|
|
264
|
-
data: {
|
|
265
|
-
analyzedAt: string;
|
|
266
|
-
versionInScore: string;
|
|
267
|
-
score: {
|
|
268
|
-
final: number;
|
|
269
|
-
detail: {
|
|
270
|
-
quality: number;
|
|
271
|
-
popularity: number;
|
|
272
|
-
maintenance: number;
|
|
273
|
-
};
|
|
274
|
-
};
|
|
275
|
-
packageInfoFromScore: {
|
|
276
|
-
name: string;
|
|
277
|
-
version: string;
|
|
278
|
-
description: string | null;
|
|
279
|
-
};
|
|
280
|
-
npmStats: {
|
|
281
|
-
downloadsLastMonth: number;
|
|
282
|
-
starsCount: number;
|
|
283
|
-
};
|
|
284
|
-
githubStats: {
|
|
285
|
-
starsCount: number;
|
|
286
|
-
forksCount: number;
|
|
287
|
-
subscribersCount: number;
|
|
288
|
-
issues: {
|
|
289
|
-
count: number;
|
|
290
|
-
openCount: number;
|
|
291
|
-
};
|
|
292
|
-
} | null;
|
|
293
|
-
scorecard?: {
|
|
294
|
-
overallScore: number;
|
|
295
|
-
checks: Array<{ name: string; score: number; reason: string }>;
|
|
296
|
-
};
|
|
297
|
-
};
|
|
298
|
-
message: string;
|
|
299
|
-
}>;
|
|
300
|
-
message: string;
|
|
302
|
+
ignoreCache?: boolean;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
interface NpmScoreResult {
|
|
306
|
+
packageInput: string;
|
|
307
|
+
packageName: string;
|
|
308
|
+
status: 'success' | 'error';
|
|
309
|
+
data?: {
|
|
310
|
+
finalScore: number;
|
|
311
|
+
quality: number;
|
|
312
|
+
popularity: number;
|
|
313
|
+
maintenance: number;
|
|
314
|
+
scorecard?: any;
|
|
315
|
+
};
|
|
301
316
|
}
|
|
302
317
|
```
|
|
303
318
|
|
|
304
|
-
#### npmPackageReadme
|
|
319
|
+
#### 11. `npmPackageReadme`
|
|
305
320
|
```typescript
|
|
306
321
|
interface NpmPackageReadmeInput {
|
|
307
322
|
packages: string[];
|
|
323
|
+
ignoreCache?: boolean;
|
|
308
324
|
}
|
|
309
325
|
|
|
310
|
-
interface
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
326
|
+
interface NpmPackageReadmeResult {
|
|
327
|
+
packageInput: string;
|
|
328
|
+
packageName: string;
|
|
329
|
+
status: 'success' | 'error';
|
|
330
|
+
data?: {
|
|
331
|
+
readme: string;
|
|
315
332
|
};
|
|
316
333
|
}
|
|
317
334
|
```
|
|
318
335
|
|
|
319
|
-
#### npmSearch
|
|
336
|
+
#### 12. `npmSearch`
|
|
320
337
|
```typescript
|
|
321
338
|
interface NpmSearchInput {
|
|
322
339
|
query: string;
|
|
323
340
|
limit?: number;
|
|
324
341
|
}
|
|
325
342
|
|
|
326
|
-
interface
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
query: string;
|
|
336
|
-
results: SearchResultPackage[];
|
|
337
|
-
totalResults?: number;
|
|
343
|
+
interface NpmSearchResult {
|
|
344
|
+
total: number;
|
|
345
|
+
results: Array<{
|
|
346
|
+
name: string;
|
|
347
|
+
version: string;
|
|
348
|
+
description: string;
|
|
349
|
+
score: number;
|
|
350
|
+
keywords: string[];
|
|
351
|
+
}>;
|
|
338
352
|
}
|
|
339
353
|
```
|
|
340
354
|
|
|
341
|
-
#### npmLicenseCompatibility
|
|
355
|
+
#### 13. `npmLicenseCompatibility`
|
|
342
356
|
```typescript
|
|
343
357
|
interface NpmLicenseCompatibilityInput {
|
|
344
358
|
packages: string[];
|
|
345
|
-
|
|
359
|
+
ignoreCache?: boolean;
|
|
346
360
|
}
|
|
347
361
|
|
|
348
|
-
interface
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
issues?: string[];
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
interface NpmLicenseCompatibilityResponse {
|
|
356
|
-
[packageName: string]: LicenseInfo;
|
|
357
|
-
compatibilitySummary?: string;
|
|
362
|
+
interface NpmLicenseCompatibilityResult {
|
|
363
|
+
packagesAnalysed: Array<{ name: string; license: string }>;
|
|
364
|
+
isCompatible: boolean;
|
|
365
|
+
compatibilityDetails: string;
|
|
358
366
|
}
|
|
359
367
|
```
|
|
360
368
|
|
|
361
|
-
#### npmRepoStats
|
|
369
|
+
#### 14. `npmRepoStats`
|
|
362
370
|
```typescript
|
|
363
371
|
interface NpmRepoStatsInput {
|
|
364
372
|
packages: string[];
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
checks: Array<{ name: string; score: number; reason: string }>;
|
|
373
|
+
ignoreCache?: boolean;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
interface NpmRepoStatsResult {
|
|
377
|
+
packageInput: string;
|
|
378
|
+
packageName: string;
|
|
379
|
+
status: 'success' | 'error';
|
|
380
|
+
data?: {
|
|
381
|
+
stars: number;
|
|
382
|
+
forks: number;
|
|
383
|
+
openIssues: number;
|
|
384
|
+
scorecard?: {
|
|
385
|
+
overallScore: number;
|
|
386
|
+
checks: Array<{ name: string; score: number }>;
|
|
387
|
+
};
|
|
381
388
|
};
|
|
382
389
|
}
|
|
383
|
-
|
|
384
|
-
interface NpmRepoStatsResponse {
|
|
385
|
-
queryPackages: string[];
|
|
386
|
-
results: Array<{
|
|
387
|
-
packageInput: string;
|
|
388
|
-
packageName: string;
|
|
389
|
-
status: 'success' | 'error' | 'success_cache';
|
|
390
|
-
error: string | null;
|
|
391
|
-
data: RepoStats;
|
|
392
|
-
message: string;
|
|
393
|
-
}>;
|
|
394
|
-
}
|
|
395
390
|
```
|
|
396
391
|
|
|
397
|
-
#### npmDeprecated
|
|
392
|
+
#### 15. `npmDeprecated`
|
|
398
393
|
```typescript
|
|
399
394
|
interface NpmDeprecatedInput {
|
|
400
395
|
packages: string[];
|
|
396
|
+
ignoreCache?: boolean;
|
|
401
397
|
}
|
|
402
398
|
|
|
403
|
-
interface
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
399
|
+
interface NpmDeprecatedResult {
|
|
400
|
+
packageInput: string;
|
|
401
|
+
packageName: string;
|
|
402
|
+
status: 'success' | 'error';
|
|
403
|
+
data?: {
|
|
404
|
+
isDeprecated: boolean;
|
|
405
|
+
deprecationReason: string | null;
|
|
406
|
+
};
|
|
411
407
|
}
|
|
412
408
|
```
|
|
413
409
|
|
|
414
|
-
#### npmChangelogAnalysis
|
|
410
|
+
#### 16. `npmChangelogAnalysis`
|
|
415
411
|
```typescript
|
|
416
412
|
interface NpmChangelogAnalysisInput {
|
|
417
413
|
packages: string[];
|
|
418
|
-
|
|
419
|
-
sinceVersion?: string;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
interface ChangelogEntry {
|
|
423
|
-
version: string;
|
|
424
|
-
date?: string;
|
|
425
|
-
summary?: string;
|
|
426
|
-
changes?: { type: 'added' | 'fixed' | 'changed' | 'removed'; description: string }[];
|
|
414
|
+
ignoreCache?: boolean;
|
|
427
415
|
}
|
|
428
416
|
|
|
429
|
-
interface
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
417
|
+
interface NpmChangelogAnalysisResult {
|
|
418
|
+
packageInput: string;
|
|
419
|
+
packageName: string;
|
|
420
|
+
status: 'success' | 'error';
|
|
421
|
+
data?: {
|
|
422
|
+
hasChangelog: boolean;
|
|
423
|
+
releases: Array<{ tag_name: string; name: string; published_at: string; source: string }>;
|
|
434
424
|
};
|
|
435
425
|
}
|
|
436
426
|
```
|
|
437
427
|
|
|
438
|
-
#### npmAlternatives
|
|
428
|
+
#### 17. `npmAlternatives`
|
|
439
429
|
```typescript
|
|
440
430
|
interface NpmAlternativesInput {
|
|
441
431
|
packages: string[];
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
432
|
+
ignoreCache?: boolean;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Filter Algorithm:
|
|
437
|
+
* 1. Extracts functional domain keywords (excluding brand keywords).
|
|
438
|
+
* 2. Queries registry by domain keywords.
|
|
439
|
+
* 3. Applies strict candidate filter (excludes same package, @types/, ecosystem plugins prefixed with name).
|
|
440
|
+
* 4. Returns top 5 distinct alternative packages.
|
|
441
|
+
*/
|
|
442
|
+
interface NpmAlternativesResult {
|
|
443
|
+
packageInput: string;
|
|
444
|
+
packageName: string;
|
|
445
|
+
status: 'success' | 'no_alternatives_found' | 'error';
|
|
446
|
+
data?: {
|
|
447
|
+
originalPackageStats: { name: string; monthlyDownloads: number; keywords: string[] };
|
|
448
|
+
alternatives: Array<{
|
|
449
|
+
name: string;
|
|
450
|
+
description: string | null;
|
|
451
|
+
version: string;
|
|
452
|
+
monthlyDownloads: number;
|
|
453
|
+
score: number;
|
|
454
|
+
repositoryUrl: string | null;
|
|
455
|
+
keywords: string[];
|
|
456
|
+
}>;
|
|
453
457
|
};
|
|
454
458
|
}
|
|
455
459
|
```
|
|
456
460
|
|
|
457
|
-
#### npmQuality
|
|
461
|
+
#### 18. `npmQuality`
|
|
458
462
|
```typescript
|
|
459
463
|
interface NpmQualityInput {
|
|
460
464
|
packages: string[];
|
|
465
|
+
ignoreCache?: boolean;
|
|
461
466
|
}
|
|
462
467
|
|
|
463
|
-
interface
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
npmsMaintenanceScore?: number;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
interface NpmQualityResponse {
|
|
474
|
-
[packageName: string]: QualityMetrics;
|
|
468
|
+
interface NpmQualityResult {
|
|
469
|
+
packageInput: string;
|
|
470
|
+
packageName: string;
|
|
471
|
+
status: 'success' | 'error';
|
|
472
|
+
data?: {
|
|
473
|
+
qualityScore: number;
|
|
474
|
+
};
|
|
475
475
|
}
|
|
476
476
|
```
|
|
477
477
|
|
|
478
|
-
#### npmMaintenance
|
|
478
|
+
#### 19. `npmMaintenance`
|
|
479
479
|
```typescript
|
|
480
480
|
interface NpmMaintenanceInput {
|
|
481
481
|
packages: string[];
|
|
482
|
+
ignoreCache?: boolean;
|
|
482
483
|
}
|
|
483
484
|
|
|
484
|
-
interface
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
interface NpmMaintenanceResponse {
|
|
493
|
-
[packageName: string]: MaintenanceMetrics;
|
|
485
|
+
interface NpmMaintenanceResult {
|
|
486
|
+
packageInput: string;
|
|
487
|
+
packageName: string;
|
|
488
|
+
status: 'success' | 'error';
|
|
489
|
+
data?: {
|
|
490
|
+
maintenanceScore: number;
|
|
491
|
+
};
|
|
494
492
|
}
|
|
495
493
|
```
|
|
496
494
|
|
|
497
|
-
|
|
495
|
+
---
|
|
498
496
|
|
|
499
|
-
|
|
500
|
-
// When an error occurs, the standard MCP response 'content' object will have 'isError: true'.
|
|
501
|
-
// The 'text' field of that content object will contain a JSON stringified MCPError object, as defined below.
|
|
502
|
-
```typescript
|
|
503
|
-
interface MCPError {
|
|
504
|
-
error: {
|
|
505
|
-
code: number;
|
|
506
|
-
message: string;
|
|
507
|
-
data?: {
|
|
508
|
-
details: string;
|
|
509
|
-
packageName?: string;
|
|
510
|
-
context?: any;
|
|
511
|
-
};
|
|
512
|
-
};
|
|
513
|
-
}
|
|
514
|
-
```
|
|
497
|
+
## Streamable HTTP (POST) & Cloudflare Workers Integration
|
|
515
498
|
|
|
516
|
-
|
|
517
|
-
1000: Invalid package name (Rejected by security validation filter due to restricted characters or format)
|
|
518
|
-
1001: Package not found
|
|
519
|
-
1002: Version not found
|
|
520
|
-
1003: Rate limit exceeded
|
|
521
|
-
1004: Network error
|
|
522
|
-
1005: Analysis failed
|
|
523
|
-
2000: Internal server error
|
|
524
|
-
|
|
525
|
-
## Security Considerations
|
|
526
|
-
|
|
527
|
-
### Data Protection
|
|
528
|
-
- All data is processed locally
|
|
529
|
-
- No sensitive information is stored
|
|
530
|
-
- Secure communication channels
|
|
531
|
-
|
|
532
|
-
### Input Validation
|
|
533
|
-
- Strict Regex-based allowlist for package names
|
|
534
|
-
- Prevents Path Traversal (`../`)
|
|
535
|
-
- Prevents Command Injection (`&`, `;`, `|`)
|
|
536
|
-
- Prevents SSRF attacks
|
|
537
|
-
|
|
538
|
-
### Rate Limiting
|
|
539
|
-
- Implements fair usage policies
|
|
540
|
-
- Respects NPM registry limits
|
|
541
|
-
- Prevents abuse
|
|
542
|
-
|
|
543
|
-
### Authentication
|
|
544
|
-
- Supports npm token authentication
|
|
545
|
-
- Validates package access
|
|
546
|
-
- Manages credentials securely
|
|
547
|
-
|
|
548
|
-
## Integration Guide
|
|
549
|
-
|
|
550
|
-
### Docker Configuration
|
|
551
|
-
The server can be run in a Docker container with directory mounting to `/projects`. This allows for secure access to files while maintaining isolation.
|
|
552
|
-
|
|
553
|
-
#### Build
|
|
554
|
-
```bash
|
|
555
|
-
# Build the Docker image
|
|
556
|
-
docker build -t nekzus/npm-sentinel-mcp .
|
|
557
|
-
```
|
|
499
|
+
The `@nekzus/mcp-server/http` module exports `handleStreamableHttpRequest` for stateless serverless deployments (Cloudflare Workers, Express, Fastify, Next.js API routes) requiring Streamable HTTP POST transport under MCP v2:
|
|
558
500
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
{
|
|
562
|
-
"mcpServers": {
|
|
563
|
-
"npm-sentinel-mcp": {
|
|
564
|
-
"command": "docker",
|
|
565
|
-
"args": [
|
|
566
|
-
"run",
|
|
567
|
-
"-i",
|
|
568
|
-
"--rm",
|
|
569
|
-
"-w", "/projects",
|
|
570
|
-
"--mount", "type=bind,src=${PWD},dst=/projects",
|
|
571
|
-
"nekzus/npm-sentinel-mcp",
|
|
572
|
-
"node",
|
|
573
|
-
"dist/index.js"
|
|
574
|
-
]
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
```
|
|
501
|
+
```typescript
|
|
502
|
+
import { handleStreamableHttpRequest } from '@nekzus/mcp-server/http';
|
|
579
503
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
{
|
|
583
|
-
|
|
584
|
-
"npm-sentinel-mcp": {
|
|
585
|
-
"command": "docker",
|
|
586
|
-
"args": [
|
|
587
|
-
"run",
|
|
588
|
-
"-i",
|
|
589
|
-
"--rm",
|
|
590
|
-
"-w", "/projects",
|
|
591
|
-
"--mount", "type=bind,src=/path/to/workspace,dst=/projects/workspace",
|
|
592
|
-
"--mount", "type=bind,src=/path/to/other/dir,dst=/projects/other/dir,ro",
|
|
593
|
-
"nekzus/npm-sentinel-mcp",
|
|
594
|
-
"node",
|
|
595
|
-
"dist/index.js"
|
|
596
|
-
]
|
|
504
|
+
export default {
|
|
505
|
+
async fetch(request: Request): Promise<Response> {
|
|
506
|
+
if (request.method !== 'POST') {
|
|
507
|
+
return new Response('NPM Sentinel MCP v2 Streamable HTTP Server', { status: 200 });
|
|
597
508
|
}
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
```
|
|
601
509
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
- Add `,ro` flag for read-only access
|
|
606
|
-
- Working directory is set to `/projects`
|
|
607
|
-
- Container runs in interactive mode with auto-removal
|
|
510
|
+
try {
|
|
511
|
+
const payload = await request.json();
|
|
512
|
+
const mcpResponse = await handleStreamableHttpRequest(payload);
|
|
608
513
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
"command": "npx",
|
|
616
|
-
"args": ["-y", "@nekzus/mcp-server"]
|
|
514
|
+
return new Response(mcpResponse.body, {
|
|
515
|
+
status: mcpResponse.status,
|
|
516
|
+
headers: mcpResponse.headers,
|
|
517
|
+
});
|
|
518
|
+
} catch {
|
|
519
|
+
return new Response(JSON.stringify({ error: 'Invalid JSON-RPC payload' }), { status: 400 });
|
|
617
520
|
}
|
|
618
|
-
}
|
|
619
|
-
}
|
|
521
|
+
},
|
|
522
|
+
};
|
|
620
523
|
```
|
|
621
524
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
const client = await MCPClient.connect("npm-sentinel-mcp");
|
|
626
|
-
|
|
627
|
-
// Analyze package
|
|
628
|
-
const result = await client.invoke("npmVersions", {
|
|
629
|
-
packages: ["react"]
|
|
630
|
-
});
|
|
631
|
-
|
|
632
|
-
// Subscribe to updates
|
|
633
|
-
const unsubscribe = await client.subscribe("npm://registry", {
|
|
634
|
-
package: "react",
|
|
635
|
-
onUpdate: (data) => console.log(data)
|
|
636
|
-
});
|
|
637
|
-
```
|
|
525
|
+
---
|
|
526
|
+
|
|
527
|
+
## Technical Support & License
|
|
638
528
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
### Resource Usage
|
|
642
|
-
1. Subscribe to resources for real-time updates
|
|
643
|
-
2. Implement caching for frequently accessed data
|
|
644
|
-
3. Use batch operations when possible
|
|
645
|
-
4. Handle rate limits gracefully
|
|
646
|
-
|
|
647
|
-
### Error Handling
|
|
648
|
-
1. Implement proper error recovery
|
|
649
|
-
2. Provide meaningful error messages
|
|
650
|
-
3. Log errors for debugging
|
|
651
|
-
4. Handle timeout scenarios
|
|
652
|
-
|
|
653
|
-
### Performance
|
|
654
|
-
1. Use connection pooling
|
|
655
|
-
2. Implement request queuing
|
|
656
|
-
3. Cache responses
|
|
657
|
-
4. Handle concurrent requests
|
|
529
|
+
- **License**: MIT
|
|
530
|
+
- **Repository**: https://github.com/Nekzus/npm-sentinel-mcp
|