@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.
Files changed (56) hide show
  1. package/README.md +183 -277
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/index.d.ts +7 -53
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +242 -602
  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 +145 -0
  36. package/dist/src/schemas.d.ts.map +1 -0
  37. package/dist/src/schemas.js +201 -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 +23 -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 +407 -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 +350 -477
  56. 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: 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
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
- ### 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.
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 Protocol| Server[NPM Sentinel Server]
23
- Server -->|Fetch| NPM[NPM Registry]
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 Resources
28
- NPM
29
- Security
30
- Stats
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 Tools
34
- Analysis[Package Analysis]
35
- TypeScript[TS Support]
36
- Performance[Performance]
37
- Trends[Trend Analysis]
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
- ## Resources
41
+ ## Features & Capabilities
42
42
 
43
- ### npm://registry
44
- Content-Type: application/json
45
- Methods: GET, SUBSCRIBE
46
- Update Frequency: Real-time
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
- ### npm://security
51
- Content-Type: application/json
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
- ### npm://metrics
58
- Content-Type: application/json
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
- ## Tool Specifications
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
- // Note: For all tools below, the response payload, typically as described by its `XYZResponse` interface
67
- // (or a textual summary if the response is simpler), is JSON stringified and placed within the `text` field
68
- // of the standard MCP content object: {"type": "text", "text": "...", "isError": boolean}.
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
- #### npmVersions
71
- ```typescript
72
- interface NpmVersionsInput {
73
- packages: string[];
74
- }
66
+ ---
75
67
 
76
- interface VersionInfo {
77
- version: string;
78
- releaseDate: string;
79
- deprecated?: boolean;
80
- description?: string;
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
- interface NpmVersionsResponse {
84
- [packageName: string]: VersionInfo[];
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
- #### npmLatest
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
- interface LatestInfo {
95
- version: string;
96
- releaseDate: string;
97
- changelog?: string;
135
+ #### 2. `npmVersions`
136
+ ```typescript
137
+ interface NpmVersionsInput {
138
+ packages: string[];
139
+ ignoreCache?: boolean;
98
140
  }
99
141
 
100
- interface NpmLatestResponse {
101
- [packageName: string]: LatestInfo;
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
- interface DependencyNode {
112
- name: string;
113
- version: string;
114
- dependencies?: { [dependencyName: string]: string };
115
- }
116
-
117
- interface NpmDepsResponse {
118
- [packageName: string]: {
119
- dependencyTree?: DependencyNode;
120
- analysisSummary?: string;
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
- interface TypeSupport {
132
- hasTypes: boolean;
133
- bundled: boolean;
134
- definitelyTyped: boolean;
135
- typeVersion?: string;
136
- }
137
-
138
- interface NpmTypesResponse {
139
- [packageName: string]: TypeSupport;
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 SizeMetrics {
150
- size: number;
151
- gzip: number;
152
- dependenciesCount: number;
153
- treeshakeable?: boolean;
154
- assetSizes?: { assetName: string; size: number }[];
155
- }
156
-
157
- interface NpmSizeResponse {
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 Vulnerability {
169
- severity: 'low' | 'medium' | 'high' | 'critical' | 'unknown';
170
- title: string;
171
- description: string;
172
- affectedVersions: string;
173
- recommendation?: string;
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 NpmVulnerabilitiesResponse {
179
- [packageName: string]: Vulnerability[];
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: 'last-day' | 'last-week' | 'last-month' | 'last-year';
188
- }
189
-
190
- interface TrendDataPoint {
191
- date: string;
192
- downloads: number;
193
- }
194
-
195
- interface TrendMetrics {
196
- period: string;
197
- downloads: TrendDataPoint[];
198
- growth?: number;
199
- popularityScore?: number;
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
- interface ComparisonAspects {
214
- latestVersion?: string;
215
- size?: SizeMetrics;
216
- vulnerabilitiesCount?: number;
217
- averageDownloads?: number;
218
- qualityScore?: number;
219
- }
220
-
221
- interface NpmCompareResponse {
222
- [packageName: string]: ComparisonAspects;
223
- comparisonSummary?: string;
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 Maintainer {
234
- name: string;
235
- email?: string;
236
- githubUsername?: string;
237
- }
238
-
239
- interface NpmMaintainersResponse {
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
- interface ScoreDetails {
251
- quality: number;
252
- popularity: number;
253
- maintenance: number;
254
- final: number;
255
- }
256
-
257
- interface NpmScoreResponse {
258
- queryPackages: string[];
259
- results: Array<{
260
- packageInput: string;
261
- packageName: string;
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 NpmPackageReadmeResponse {
311
- [packageName: string]: {
312
- content: string;
313
- format: 'markdown' | 'text';
314
- error?: string;
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 SearchResultPackage {
327
- name: string;
328
- version: string;
329
- description?: string;
330
- keywords?: string[];
331
- score?: ScoreDetails;
332
- }
333
-
334
- interface NpmSearchResponse {
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
- projectLicense?: string;
359
+ ignoreCache?: boolean;
346
360
  }
347
361
 
348
- interface LicenseInfo {
349
- spdxId: string;
350
- name: string;
351
- isCompatible?: boolean;
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
- interface RepoStats {
368
- githubRepoUrl: string;
369
- stars: number;
370
- forks: number;
371
- openIssues: number;
372
- watchers: number;
373
- createdAt: string | null;
374
- updatedAt: string | null;
375
- defaultBranch: string | null;
376
- hasWiki: boolean | null;
377
- topics: string[];
378
- scorecard?: {
379
- overallScore: number;
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 DeprecationInfo {
404
- isDeprecated: boolean;
405
- message?: string;
406
- alternative?: string;
407
- }
408
-
409
- interface NpmDeprecatedResponse {
410
- [packageName: string]: DeprecationInfo;
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
- targetVersion?: string;
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 NpmChangelogAnalysisResponse {
430
- [packageName: string]: {
431
- changelogUrl?: string;
432
- entries?: ChangelogEntry[];
433
- 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 }>;
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
- interface AlternativePackageInfo {
445
- name: string;
446
- reason?: string;
447
- score?: ScoreDetails;
448
- }
449
-
450
- interface NpmAlternativesResponse {
451
- [packageName: string]: {
452
- alternatives: AlternativePackageInfo[];
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 QualityMetrics {
464
- codeComplexity?: number;
465
- testCoverage?: number;
466
- documentationScore?: number;
467
- communityEngagement?: number;
468
- npmsQualityScore?: number;
469
- npmsPopularityScore?: number;
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 MaintenanceMetrics {
485
- lastPublishDate?: string;
486
- commitFrequency?: string;
487
- openIssuesRatio?: number;
488
- timeSinceLastCommit?: string;
489
- npmsMaintenanceScore?: number;
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
- ## Error Handling
495
+ ---
498
496
 
499
- ### Standard Error Format
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
- ### Error Codes
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
- #### Basic Usage
560
- ```json
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
- #### Multi-Directory Configuration
581
- ```json
582
- {
583
- "mcpServers": {
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
- #### Mount Guidelines
603
- - Mount all directories under `/projects`
604
- - Use absolute paths for source directories
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
- ### Standard Configuration
610
- ```json
611
- {
612
- "mcpServers": {
613
- "npm-sentinel-mcp": {
614
- "transport": "stdio",
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
- ### Basic Usage
623
- ```typescript
624
- // Initialize client
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
- ## Best Practices
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