@nekzus/mcp-server 1.23.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 +180 -275
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/index.d.ts +7 -55
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +242 -609
  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 +347 -478
  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,651 +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.
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 Protocol| Server[NPM Sentinel Server]
27
- Server -->|Fetch| NPM[NPM Registry]
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 Resources
32
- NPM
33
- Security
34
- 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]
35
30
  end
36
31
 
37
- subgraph Tools
38
- Analysis[Package Analysis]
39
- TypeScript[TS Support]
40
- Performance[Performance]
41
- 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]
42
38
  end
43
39
  ```
44
40
 
45
- ## Resources
41
+ ## Features & Capabilities
46
42
 
47
- ### npm://registry
48
- Content-Type: application/json
49
- Methods: GET, SUBSCRIBE
50
- Update Frequency: Real-time
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
- ### npm://security
55
- Content-Type: application/json
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
- ### npm://metrics
62
- Content-Type: application/json
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
- ## 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.
69
59
 
70
- // Note: For all tools below, the response payload, typically as described by its `XYZResponse` interface
71
- // (or a textual summary if the response is simpler), is JSON stringified and placed within the `text` field
72
- // 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.
73
65
 
74
- #### npmVersions
75
- ```typescript
76
- interface NpmVersionsInput {
77
- packages: string[];
78
- }
66
+ ---
79
67
 
80
- interface VersionInfo {
81
- version: string;
82
- releaseDate: string;
83
- deprecated?: boolean;
84
- description?: string;
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
- interface NpmVersionsResponse {
88
- [packageName: string]: VersionInfo[];
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
- #### npmLatest
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
- interface LatestInfo {
99
- version: string;
100
- releaseDate: string;
101
- changelog?: string;
135
+ #### 2. `npmVersions`
136
+ ```typescript
137
+ interface NpmVersionsInput {
138
+ packages: string[];
139
+ ignoreCache?: boolean;
102
140
  }
103
141
 
104
- interface NpmLatestResponse {
105
- [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
+ };
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
- interface DependencyNode {
116
- name: string;
117
- version: string;
118
- dependencies?: { [dependencyName: string]: string };
119
- }
120
-
121
- interface NpmDepsResponse {
122
- [packageName: string]: {
123
- dependencyTree?: DependencyNode;
124
- 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[];
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
- interface TypeSupport {
136
- hasTypes: boolean;
137
- bundled: boolean;
138
- definitelyTyped: boolean;
139
- typeVersion?: string;
140
- }
141
-
142
- interface NpmTypesResponse {
143
- [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
+ };
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 SizeMetrics {
154
- size: number;
155
- gzip: number;
156
- dependenciesCount: number;
157
- treeshakeable?: boolean;
158
- assetSizes?: { assetName: string; size: number }[];
159
- }
160
-
161
- interface NpmSizeResponse {
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 Vulnerability {
173
- severity: 'low' | 'medium' | 'high' | 'critical' | 'unknown';
174
- title: string;
175
- description: string;
176
- affectedVersions: string;
177
- recommendation?: string;
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 NpmVulnerabilitiesResponse {
183
- [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
+ };
184
238
  }
185
239
  ```
186
240
 
187
- #### npmTrends
241
+ #### 7. `npmTrends`
188
242
  ```typescript
189
243
  interface NpmTrendsInput {
190
244
  packages: string[];
191
- period: 'last-day' | 'last-week' | 'last-month' | 'last-year';
192
- }
193
-
194
- interface TrendDataPoint {
195
- date: string;
196
- downloads: number;
197
- }
198
-
199
- interface TrendMetrics {
200
- period: string;
201
- downloads: TrendDataPoint[];
202
- growth?: number;
203
- popularityScore?: number;
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
- interface ComparisonAspects {
218
- latestVersion?: string;
219
- size?: SizeMetrics;
220
- vulnerabilitiesCount?: number;
221
- averageDownloads?: number;
222
- qualityScore?: number;
223
- }
224
-
225
- interface NpmCompareResponse {
226
- [packageName: string]: ComparisonAspects;
227
- 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
+ }>;
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 Maintainer {
238
- name: string;
239
- email?: string;
240
- githubUsername?: string;
241
- }
242
-
243
- interface NpmMaintainersResponse {
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
- interface ScoreDetails {
255
- quality: number;
256
- popularity: number;
257
- maintenance: number;
258
- final: number;
259
- }
260
-
261
- interface NpmScoreResponse {
262
- queryPackages: string[];
263
- results: Array<{
264
- packageInput: string;
265
- packageName: string;
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 NpmPackageReadmeResponse {
315
- [packageName: string]: {
316
- content: string;
317
- format: 'markdown' | 'text';
318
- error?: string;
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 SearchResultPackage {
331
- name: string;
332
- version: string;
333
- description?: string;
334
- keywords?: string[];
335
- score?: ScoreDetails;
336
- }
337
-
338
- interface NpmSearchResponse {
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
- projectLicense?: string;
350
- }
351
-
352
- interface LicenseInfo {
353
- spdxId: string;
354
- name: string;
355
- isCompatible?: boolean;
356
- issues?: string[];
359
+ ignoreCache?: boolean;
357
360
  }
358
361
 
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
- interface RepoStats {
372
- githubRepoUrl: string;
373
- stars: number;
374
- forks: number;
375
- openIssues: number;
376
- watchers: number;
377
- createdAt: string | null;
378
- updatedAt: string | null;
379
- defaultBranch: string | null;
380
- hasWiki: boolean | null;
381
- topics: string[];
382
- scorecard?: {
383
- overallScore: number;
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 DeprecationInfo {
408
- isDeprecated: boolean;
409
- message?: string;
410
- alternative?: string;
411
- }
412
-
413
- interface NpmDeprecatedResponse {
414
- [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
+ };
415
407
  }
416
408
  ```
417
409
 
418
- #### npmChangelogAnalysis
410
+ #### 16. `npmChangelogAnalysis`
419
411
  ```typescript
420
412
  interface NpmChangelogAnalysisInput {
421
413
  packages: string[];
422
- targetVersion?: string;
423
- sinceVersion?: string;
424
- }
425
-
426
- interface ChangelogEntry {
427
- version: string;
428
- date?: string;
429
- summary?: string;
430
- changes?: { type: 'added' | 'fixed' | 'changed' | 'removed'; description: string }[];
414
+ ignoreCache?: boolean;
431
415
  }
432
416
 
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
- interface AlternativePackageInfo {
449
- name: string;
450
- reason?: string;
451
- score?: ScoreDetails;
452
- }
453
-
454
- interface NpmAlternativesResponse {
455
- [packageName: string]: {
456
- 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
+ }>;
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 QualityMetrics {
468
- codeComplexity?: number;
469
- testCoverage?: number;
470
- documentationScore?: number;
471
- communityEngagement?: number;
472
- npmsQualityScore?: number;
473
- npmsPopularityScore?: number;
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 MaintenanceMetrics {
489
- lastPublishDate?: string;
490
- commitFrequency?: string;
491
- openIssuesRatio?: number;
492
- timeSinceLastCommit?: string;
493
- npmsMaintenanceScore?: number;
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
- ## Error Handling
495
+ ---
502
496
 
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
- ```typescript
507
- interface MCPError {
508
- error: {
509
- code: number;
510
- message: string;
511
- data?: {
512
- details: string;
513
- packageName?: string;
514
- context?: any;
515
- };
516
- };
517
- }
518
- ```
497
+ ## Streamable HTTP (POST) & Cloudflare Workers Integration
519
498
 
520
- ### Error Codes
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
- ```
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:
562
500
 
563
- #### Basic Usage
564
- ```json
565
- {
566
- "mcpServers": {
567
- "npm-sentinel-mcp": {
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
- }
582
- ```
501
+ ```typescript
502
+ import { handleStreamableHttpRequest } from '@nekzus/mcp-server/http';
583
503
 
584
- #### Multi-Directory Configuration
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
- ]
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 });
601
508
  }
602
- }
603
- }
604
- ```
605
509
 
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
510
+ try {
511
+ const payload = await request.json();
512
+ const mcpResponse = await handleStreamableHttpRequest(payload);
612
513
 
613
- ### Standard Configuration
614
- ```json
615
- {
616
- "mcpServers": {
617
- "npm-sentinel-mcp": {
618
- "transport": "stdio",
619
- "command": "npx",
620
- "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 });
621
520
  }
622
- }
623
- }
521
+ },
522
+ };
624
523
  ```
625
524
 
626
- ### Basic Usage
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
- ```
525
+ ---
526
+
527
+ ## Technical Support & License
642
528
 
643
- ## Best Practices
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
529
+ - **License**: MIT
530
+ - **Repository**: https://github.com/Nekzus/npm-sentinel-mcp