@nekzus/mcp-server 1.23.0 → 1.24.1
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 +171 -275
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +7 -55
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +254 -610
- 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 +13 -0
- package/dist/src/http.d.ts.map +1 -0
- package/dist/src/http.js +31 -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 +339 -479
- package/package.json +15 -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,651 +11,511 @@ 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
|
-
### Smart SemVer Version Resolution
|
|
15
|
-
All package version querying tools (`npmDeprecated`, `npmLatest`, `npmDeps`, `npmTypes`, `npmPackageReadme`, `npmCompare`, `npmChangelogAnalysis`) implement 4-step SemVer resolution:
|
|
16
|
-
- 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.
|
|
17
|
-
- Avoids registry 404 errors when an exact SemVer string is omitted.
|
|
18
|
-
|
|
19
14
|
### Batch Rate Limits & Input Sanitization
|
|
20
15
|
- **Batch Size Capping**: All 18 multi-package analysis tools enforce a maximum limit of 25 package names per request (`PackageListSchema`).
|
|
21
16
|
- **Search Query Sanitization**: `npmSearch` enforces a 100-character cap on `query` (`SearchQuerySchema`) and filters control characters (`\0`, `\r`, `\n`, `\t`).
|
|
22
17
|
|
|
23
|
-
## Architecture
|
|
18
|
+
## Modular Architecture (`src/`)
|
|
24
19
|
```mermaid
|
|
25
20
|
flowchart TD
|
|
26
|
-
Client[MCP Client] <-->|MCP
|
|
27
|
-
|
|
28
|
-
Server -->|Analysis| Security[Security DB]
|
|
29
|
-
Server -->|Metrics| Stats[Download Stats]
|
|
21
|
+
Client[MCP v2 Client] <-->|MCP JSON-RPC| Transport[Stdio / HTTP Transport]
|
|
22
|
+
Transport <--> Server[src/server.ts createServer]
|
|
30
23
|
|
|
31
|
-
subgraph
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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]
|
|
35
30
|
end
|
|
36
31
|
|
|
37
|
-
subgraph
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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]
|
|
42
38
|
end
|
|
43
39
|
```
|
|
44
40
|
|
|
45
|
-
##
|
|
41
|
+
## Features & Capabilities
|
|
46
42
|
|
|
47
|
-
###
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
Rate Limits: Follows npm registry limits
|
|
52
|
-
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`.
|
|
53
47
|
|
|
54
|
-
###
|
|
55
|
-
|
|
56
|
-
Methods: GET
|
|
57
|
-
Update Frequency: Daily
|
|
58
|
-
Severity Levels: Low, Medium, High, Critical
|
|
59
|
-
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.
|
|
60
50
|
|
|
61
|
-
###
|
|
62
|
-
|
|
63
|
-
Methods: GET, SUBSCRIBE
|
|
64
|
-
Update Frequency: Real-time
|
|
65
|
-
Metrics Types: Downloads, Stars, Issues, Updates
|
|
66
|
-
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.
|
|
67
53
|
|
|
68
|
-
|
|
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.
|
|
69
59
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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.
|
|
73
65
|
|
|
74
|
-
|
|
75
|
-
```typescript
|
|
76
|
-
interface NpmVersionsInput {
|
|
77
|
-
packages: string[];
|
|
78
|
-
}
|
|
66
|
+
---
|
|
79
67
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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.
|
|
86
74
|
|
|
87
|
-
|
|
88
|
-
|
|
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.
|
|
79
|
+
|
|
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."
|
|
89
104
|
}
|
|
90
105
|
```
|
|
91
106
|
|
|
92
|
-
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
#### 1. `npmLatest`
|
|
93
110
|
```typescript
|
|
94
111
|
interface NpmLatestInput {
|
|
95
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
|
+
};
|
|
96
132
|
}
|
|
133
|
+
```
|
|
97
134
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
135
|
+
#### 2. `npmVersions`
|
|
136
|
+
```typescript
|
|
137
|
+
interface NpmVersionsInput {
|
|
138
|
+
packages: string[];
|
|
139
|
+
ignoreCache?: boolean;
|
|
102
140
|
}
|
|
103
141
|
|
|
104
|
-
interface
|
|
105
|
-
|
|
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
|
+
};
|
|
106
151
|
}
|
|
107
152
|
```
|
|
108
153
|
|
|
109
|
-
#### npmDeps
|
|
154
|
+
#### 3. `npmDeps`
|
|
110
155
|
```typescript
|
|
111
156
|
interface NpmDepsInput {
|
|
112
157
|
packages: string[];
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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[];
|
|
125
171
|
};
|
|
126
172
|
}
|
|
127
173
|
```
|
|
128
174
|
|
|
129
|
-
#### npmTypes
|
|
175
|
+
#### 4. `npmTypes`
|
|
130
176
|
```typescript
|
|
131
177
|
interface NpmTypesInput {
|
|
132
178
|
packages: string[];
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
+
};
|
|
144
192
|
}
|
|
145
193
|
```
|
|
146
194
|
|
|
147
|
-
#### npmSize
|
|
195
|
+
#### 5. `npmSize`
|
|
148
196
|
```typescript
|
|
149
197
|
interface NpmSizeInput {
|
|
150
198
|
packages: string[];
|
|
199
|
+
ignoreCache?: boolean;
|
|
151
200
|
}
|
|
152
201
|
|
|
153
|
-
interface
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
[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
|
+
};
|
|
163
211
|
}
|
|
164
212
|
```
|
|
165
213
|
|
|
166
|
-
#### npmVulnerabilities
|
|
214
|
+
#### 6. `npmVulnerabilities`
|
|
167
215
|
```typescript
|
|
168
216
|
interface NpmVulnerabilitiesInput {
|
|
169
217
|
packages: string[];
|
|
218
|
+
ignoreCache?: boolean;
|
|
170
219
|
}
|
|
171
220
|
|
|
172
|
-
interface
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
cvssScore?: number;
|
|
179
|
-
url?: string;
|
|
221
|
+
interface VulnerabilityAdvisory {
|
|
222
|
+
id: string;
|
|
223
|
+
summary: string;
|
|
224
|
+
details: string;
|
|
225
|
+
severity: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
|
|
226
|
+
aliases: string[];
|
|
180
227
|
}
|
|
181
228
|
|
|
182
|
-
interface
|
|
183
|
-
|
|
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
|
+
};
|
|
184
238
|
}
|
|
185
239
|
```
|
|
186
240
|
|
|
187
|
-
#### npmTrends
|
|
241
|
+
#### 7. `npmTrends`
|
|
188
242
|
```typescript
|
|
189
243
|
interface NpmTrendsInput {
|
|
190
244
|
packages: string[];
|
|
191
|
-
period
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
interface NpmTrendsResponse {
|
|
207
|
-
[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
|
+
};
|
|
208
258
|
}
|
|
209
259
|
```
|
|
210
260
|
|
|
211
|
-
#### npmCompare
|
|
261
|
+
#### 8. `npmCompare`
|
|
212
262
|
```typescript
|
|
213
263
|
interface NpmCompareInput {
|
|
214
264
|
packages: string[];
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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
|
+
}>;
|
|
228
278
|
}
|
|
229
279
|
```
|
|
230
280
|
|
|
231
|
-
#### npmMaintainers
|
|
281
|
+
#### 9. `npmMaintainers`
|
|
232
282
|
```typescript
|
|
233
283
|
interface NpmMaintainersInput {
|
|
234
284
|
packages: string[];
|
|
285
|
+
ignoreCache?: boolean;
|
|
235
286
|
}
|
|
236
287
|
|
|
237
|
-
interface
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
[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
|
+
};
|
|
245
295
|
}
|
|
246
296
|
```
|
|
247
297
|
|
|
248
|
-
#### npmScore
|
|
298
|
+
#### 10. `npmScore`
|
|
249
299
|
```typescript
|
|
250
300
|
interface NpmScoreInput {
|
|
251
301
|
packages: string[];
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
status: 'success' | 'error' | 'success_cache';
|
|
267
|
-
error: string | null;
|
|
268
|
-
data: {
|
|
269
|
-
analyzedAt: string;
|
|
270
|
-
versionInScore: string;
|
|
271
|
-
score: {
|
|
272
|
-
final: number;
|
|
273
|
-
detail: {
|
|
274
|
-
quality: number;
|
|
275
|
-
popularity: number;
|
|
276
|
-
maintenance: number;
|
|
277
|
-
};
|
|
278
|
-
};
|
|
279
|
-
packageInfoFromScore: {
|
|
280
|
-
name: string;
|
|
281
|
-
version: string;
|
|
282
|
-
description: string | null;
|
|
283
|
-
};
|
|
284
|
-
npmStats: {
|
|
285
|
-
downloadsLastMonth: number;
|
|
286
|
-
starsCount: number;
|
|
287
|
-
};
|
|
288
|
-
githubStats: {
|
|
289
|
-
starsCount: number;
|
|
290
|
-
forksCount: number;
|
|
291
|
-
subscribersCount: number;
|
|
292
|
-
issues: {
|
|
293
|
-
count: number;
|
|
294
|
-
openCount: number;
|
|
295
|
-
};
|
|
296
|
-
} | null;
|
|
297
|
-
scorecard?: {
|
|
298
|
-
overallScore: number;
|
|
299
|
-
checks: Array<{ name: string; score: number; reason: string }>;
|
|
300
|
-
};
|
|
301
|
-
};
|
|
302
|
-
message: string;
|
|
303
|
-
}>;
|
|
304
|
-
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
|
+
};
|
|
305
316
|
}
|
|
306
317
|
```
|
|
307
318
|
|
|
308
|
-
#### npmPackageReadme
|
|
319
|
+
#### 11. `npmPackageReadme`
|
|
309
320
|
```typescript
|
|
310
321
|
interface NpmPackageReadmeInput {
|
|
311
322
|
packages: string[];
|
|
323
|
+
ignoreCache?: boolean;
|
|
312
324
|
}
|
|
313
325
|
|
|
314
|
-
interface
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
326
|
+
interface NpmPackageReadmeResult {
|
|
327
|
+
packageInput: string;
|
|
328
|
+
packageName: string;
|
|
329
|
+
status: 'success' | 'error';
|
|
330
|
+
data?: {
|
|
331
|
+
readme: string;
|
|
319
332
|
};
|
|
320
333
|
}
|
|
321
334
|
```
|
|
322
335
|
|
|
323
|
-
#### npmSearch
|
|
336
|
+
#### 12. `npmSearch`
|
|
324
337
|
```typescript
|
|
325
338
|
interface NpmSearchInput {
|
|
326
339
|
query: string;
|
|
327
340
|
limit?: number;
|
|
328
341
|
}
|
|
329
342
|
|
|
330
|
-
interface
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
query: string;
|
|
340
|
-
results: SearchResultPackage[];
|
|
341
|
-
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
|
+
}>;
|
|
342
352
|
}
|
|
343
353
|
```
|
|
344
354
|
|
|
345
|
-
#### npmLicenseCompatibility
|
|
355
|
+
#### 13. `npmLicenseCompatibility`
|
|
346
356
|
```typescript
|
|
347
357
|
interface NpmLicenseCompatibilityInput {
|
|
348
358
|
packages: string[];
|
|
349
|
-
|
|
359
|
+
ignoreCache?: boolean;
|
|
350
360
|
}
|
|
351
361
|
|
|
352
|
-
interface
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
issues?: string[];
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
interface NpmLicenseCompatibilityResponse {
|
|
360
|
-
[packageName: string]: LicenseInfo;
|
|
361
|
-
compatibilitySummary?: string;
|
|
362
|
+
interface NpmLicenseCompatibilityResult {
|
|
363
|
+
packagesAnalysed: Array<{ name: string; license: string }>;
|
|
364
|
+
isCompatible: boolean;
|
|
365
|
+
compatibilityDetails: string;
|
|
362
366
|
}
|
|
363
367
|
```
|
|
364
368
|
|
|
365
|
-
#### npmRepoStats
|
|
369
|
+
#### 14. `npmRepoStats`
|
|
366
370
|
```typescript
|
|
367
371
|
interface NpmRepoStatsInput {
|
|
368
372
|
packages: string[];
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
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
|
+
};
|
|
385
388
|
};
|
|
386
389
|
}
|
|
387
|
-
|
|
388
|
-
interface NpmRepoStatsResponse {
|
|
389
|
-
queryPackages: string[];
|
|
390
|
-
results: Array<{
|
|
391
|
-
packageInput: string;
|
|
392
|
-
packageName: string;
|
|
393
|
-
status: 'success' | 'error' | 'success_cache';
|
|
394
|
-
error: string | null;
|
|
395
|
-
data: RepoStats;
|
|
396
|
-
message: string;
|
|
397
|
-
}>;
|
|
398
|
-
}
|
|
399
390
|
```
|
|
400
391
|
|
|
401
|
-
#### npmDeprecated
|
|
392
|
+
#### 15. `npmDeprecated`
|
|
402
393
|
```typescript
|
|
403
394
|
interface NpmDeprecatedInput {
|
|
404
395
|
packages: string[];
|
|
396
|
+
ignoreCache?: boolean;
|
|
405
397
|
}
|
|
406
398
|
|
|
407
|
-
interface
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
399
|
+
interface NpmDeprecatedResult {
|
|
400
|
+
packageInput: string;
|
|
401
|
+
packageName: string;
|
|
402
|
+
status: 'success' | 'error';
|
|
403
|
+
data?: {
|
|
404
|
+
isDeprecated: boolean;
|
|
405
|
+
deprecationReason: string | null;
|
|
406
|
+
};
|
|
415
407
|
}
|
|
416
408
|
```
|
|
417
409
|
|
|
418
|
-
#### npmChangelogAnalysis
|
|
410
|
+
#### 16. `npmChangelogAnalysis`
|
|
419
411
|
```typescript
|
|
420
412
|
interface NpmChangelogAnalysisInput {
|
|
421
413
|
packages: string[];
|
|
422
|
-
|
|
423
|
-
sinceVersion?: string;
|
|
414
|
+
ignoreCache?: boolean;
|
|
424
415
|
}
|
|
425
416
|
|
|
426
|
-
interface
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
interface NpmChangelogAnalysisResponse {
|
|
434
|
-
[packageName: string]: {
|
|
435
|
-
changelogUrl?: string;
|
|
436
|
-
entries?: ChangelogEntry[];
|
|
437
|
-
analysisSummary?: string;
|
|
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 }>;
|
|
438
424
|
};
|
|
439
425
|
}
|
|
440
426
|
```
|
|
441
427
|
|
|
442
|
-
#### npmAlternatives
|
|
428
|
+
#### 17. `npmAlternatives`
|
|
443
429
|
```typescript
|
|
444
430
|
interface NpmAlternativesInput {
|
|
445
431
|
packages: string[];
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
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
|
+
}>;
|
|
457
457
|
};
|
|
458
458
|
}
|
|
459
459
|
```
|
|
460
460
|
|
|
461
|
-
#### npmQuality
|
|
461
|
+
#### 18. `npmQuality`
|
|
462
462
|
```typescript
|
|
463
463
|
interface NpmQualityInput {
|
|
464
464
|
packages: string[];
|
|
465
|
+
ignoreCache?: boolean;
|
|
465
466
|
}
|
|
466
467
|
|
|
467
|
-
interface
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
npmsMaintenanceScore?: number;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
interface NpmQualityResponse {
|
|
478
|
-
[packageName: string]: QualityMetrics;
|
|
468
|
+
interface NpmQualityResult {
|
|
469
|
+
packageInput: string;
|
|
470
|
+
packageName: string;
|
|
471
|
+
status: 'success' | 'error';
|
|
472
|
+
data?: {
|
|
473
|
+
qualityScore: number;
|
|
474
|
+
};
|
|
479
475
|
}
|
|
480
476
|
```
|
|
481
477
|
|
|
482
|
-
#### npmMaintenance
|
|
478
|
+
#### 19. `npmMaintenance`
|
|
483
479
|
```typescript
|
|
484
480
|
interface NpmMaintenanceInput {
|
|
485
481
|
packages: string[];
|
|
482
|
+
ignoreCache?: boolean;
|
|
486
483
|
}
|
|
487
484
|
|
|
488
|
-
interface
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
interface NpmMaintenanceResponse {
|
|
497
|
-
[packageName: string]: MaintenanceMetrics;
|
|
485
|
+
interface NpmMaintenanceResult {
|
|
486
|
+
packageInput: string;
|
|
487
|
+
packageName: string;
|
|
488
|
+
status: 'success' | 'error';
|
|
489
|
+
data?: {
|
|
490
|
+
maintenanceScore: number;
|
|
491
|
+
};
|
|
498
492
|
}
|
|
499
493
|
```
|
|
500
494
|
|
|
501
|
-
|
|
495
|
+
---
|
|
496
|
+
|
|
497
|
+
## Web Standard Streamable HTTP & Cloudflare Workers Integration
|
|
498
|
+
|
|
499
|
+
The `@nekzus/mcp-server/http` module exports `createMcpHttpHandler` and `WebStandardStreamableHTTPServerTransport` for serverless deployments (Cloudflare Workers, Hono, Express, Fastify, Next.js API routes) requiring official Web Standard Streamable HTTP transport under MCP v2:
|
|
502
500
|
|
|
503
|
-
### Standard Error Format
|
|
504
|
-
// When an error occurs, the standard MCP response 'content' object will have 'isError: true'.
|
|
505
|
-
// The 'text' field of that content object will contain a JSON stringified MCPError object, as defined below.
|
|
506
501
|
```typescript
|
|
507
|
-
|
|
508
|
-
error: {
|
|
509
|
-
code: number;
|
|
510
|
-
message: string;
|
|
511
|
-
data?: {
|
|
512
|
-
details: string;
|
|
513
|
-
packageName?: string;
|
|
514
|
-
context?: any;
|
|
515
|
-
};
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
```
|
|
502
|
+
import { createMcpHttpHandler } from '@nekzus/mcp-server/http';
|
|
519
503
|
|
|
520
|
-
|
|
521
|
-
1000: Invalid package name (Rejected by security validation filter due to restricted characters or format)
|
|
522
|
-
1001: Package not found
|
|
523
|
-
1002: Version not found
|
|
524
|
-
1003: Rate limit exceeded
|
|
525
|
-
1004: Network error
|
|
526
|
-
1005: Analysis failed
|
|
527
|
-
2000: Internal server error
|
|
528
|
-
|
|
529
|
-
## Security Considerations
|
|
530
|
-
|
|
531
|
-
### Data Protection
|
|
532
|
-
- All data is processed locally
|
|
533
|
-
- No sensitive information is stored
|
|
534
|
-
- Secure communication channels
|
|
535
|
-
|
|
536
|
-
### Input Validation
|
|
537
|
-
- Strict Regex-based allowlist for package names
|
|
538
|
-
- Prevents Path Traversal (`../`)
|
|
539
|
-
- Prevents Command Injection (`&`, `;`, `|`)
|
|
540
|
-
- Prevents SSRF attacks
|
|
541
|
-
|
|
542
|
-
### Rate Limiting
|
|
543
|
-
- Implements fair usage policies
|
|
544
|
-
- Respects NPM registry limits
|
|
545
|
-
- Prevents abuse
|
|
546
|
-
|
|
547
|
-
### Authentication
|
|
548
|
-
- Supports npm token authentication
|
|
549
|
-
- Validates package access
|
|
550
|
-
- Manages credentials securely
|
|
551
|
-
|
|
552
|
-
## Integration Guide
|
|
553
|
-
|
|
554
|
-
### Docker Configuration
|
|
555
|
-
The server can be run in a Docker container with directory mounting to `/projects`. This allows for secure access to files while maintaining isolation.
|
|
556
|
-
|
|
557
|
-
#### Build
|
|
558
|
-
```bash
|
|
559
|
-
# Build the Docker image
|
|
560
|
-
docker build -t nekzus/npm-sentinel-mcp .
|
|
561
|
-
```
|
|
504
|
+
const handleMcpRequest = createMcpHttpHandler();
|
|
562
505
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
"command": "docker",
|
|
569
|
-
"args": [
|
|
570
|
-
"run",
|
|
571
|
-
"-i",
|
|
572
|
-
"--rm",
|
|
573
|
-
"-w", "/projects",
|
|
574
|
-
"--mount", "type=bind,src=${PWD},dst=/projects",
|
|
575
|
-
"nekzus/npm-sentinel-mcp",
|
|
576
|
-
"node",
|
|
577
|
-
"dist/index.js"
|
|
578
|
-
]
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
}
|
|
506
|
+
export default {
|
|
507
|
+
async fetch(request: Request): Promise<Response> {
|
|
508
|
+
return handleMcpRequest(request);
|
|
509
|
+
},
|
|
510
|
+
};
|
|
582
511
|
```
|
|
583
512
|
|
|
584
|
-
|
|
585
|
-
```json
|
|
586
|
-
{
|
|
587
|
-
"mcpServers": {
|
|
588
|
-
"npm-sentinel-mcp": {
|
|
589
|
-
"command": "docker",
|
|
590
|
-
"args": [
|
|
591
|
-
"run",
|
|
592
|
-
"-i",
|
|
593
|
-
"--rm",
|
|
594
|
-
"-w", "/projects",
|
|
595
|
-
"--mount", "type=bind,src=/path/to/workspace,dst=/projects/workspace",
|
|
596
|
-
"--mount", "type=bind,src=/path/to/other/dir,dst=/projects/other/dir,ro",
|
|
597
|
-
"nekzus/npm-sentinel-mcp",
|
|
598
|
-
"node",
|
|
599
|
-
"dist/index.js"
|
|
600
|
-
]
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
```
|
|
513
|
+
**100% MCP v2 Compliance**: Powered by `WebStandardStreamableHTTPServerTransport`, this handler natively activates all 3 MCP primitives (**Tools**, **Resources**, and **Prompts**) with SSE streaming, protocol negotiation, and Web Standard `Request` $\rightarrow$ `Response` compatibility.
|
|
605
514
|
|
|
606
|
-
#### Mount Guidelines
|
|
607
|
-
- Mount all directories under `/projects`
|
|
608
|
-
- Use absolute paths for source directories
|
|
609
|
-
- Add `,ro` flag for read-only access
|
|
610
|
-
- Working directory is set to `/projects`
|
|
611
|
-
- Container runs in interactive mode with auto-removal
|
|
612
515
|
|
|
613
|
-
|
|
614
|
-
```json
|
|
615
|
-
{
|
|
616
|
-
"mcpServers": {
|
|
617
|
-
"npm-sentinel-mcp": {
|
|
618
|
-
"transport": "stdio",
|
|
619
|
-
"command": "npx",
|
|
620
|
-
"args": ["-y", "@nekzus/mcp-server"]
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
```
|
|
516
|
+
---
|
|
625
517
|
|
|
626
|
-
|
|
627
|
-
```typescript
|
|
628
|
-
// Initialize client
|
|
629
|
-
const client = await MCPClient.connect("npm-sentinel-mcp");
|
|
630
|
-
|
|
631
|
-
// Analyze package
|
|
632
|
-
const result = await client.invoke("npmVersions", {
|
|
633
|
-
packages: ["react"]
|
|
634
|
-
});
|
|
635
|
-
|
|
636
|
-
// Subscribe to updates
|
|
637
|
-
const unsubscribe = await client.subscribe("npm://registry", {
|
|
638
|
-
package: "react",
|
|
639
|
-
onUpdate: (data) => console.log(data)
|
|
640
|
-
});
|
|
641
|
-
```
|
|
518
|
+
## Technical Support & License
|
|
642
519
|
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
### Resource Usage
|
|
646
|
-
1. Subscribe to resources for real-time updates
|
|
647
|
-
2. Implement caching for frequently accessed data
|
|
648
|
-
3. Use batch operations when possible
|
|
649
|
-
4. Handle rate limits gracefully
|
|
650
|
-
|
|
651
|
-
### Error Handling
|
|
652
|
-
1. Implement proper error recovery
|
|
653
|
-
2. Provide meaningful error messages
|
|
654
|
-
3. Log errors for debugging
|
|
655
|
-
4. Handle timeout scenarios
|
|
656
|
-
|
|
657
|
-
### Performance
|
|
658
|
-
1. Use connection pooling
|
|
659
|
-
2. Implement request queuing
|
|
660
|
-
3. Cache responses
|
|
661
|
-
4. Handle concurrent requests
|
|
520
|
+
- **License**: MIT
|
|
521
|
+
- **Repository**: https://github.com/Nekzus/npm-sentinel-mcp
|