@nekzus/mcp-server 1.19.0-alpha.2 → 1.19.0-alpha.20

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