@nekzus/mcp-server 1.7.9 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3070,297 +3070,320 @@ export async function handleNpmAlternatives(args) {
3070
3070
  }
3071
3071
  }
3072
3072
  // Get __dirname in an ES module environment
3073
- const __filename = fileURLToPath(import.meta.url);
3074
- const __dirname = path.dirname(__filename);
3075
- // The package root will be one level above __dirname (which is 'dist/' after compilation)
3076
- const packageRoot = path.join(__dirname, '..');
3077
- // Create server instance
3078
- const server = new McpServer({
3079
- name: 'npm-sentinel-mcp',
3080
- version: '1.7.9',
3081
- capabilities: {
3082
- resources: {},
3083
- },
3084
- });
3085
- // Update paths to be relative to the package
3086
- const README_PATH = path.join(packageRoot, 'README.md');
3087
- const LLMS_FULL_TEXT_PATH = path.join(packageRoot, 'llms-full.txt');
3088
- // Register README.md resource
3089
- server.resource('serverReadme', 'doc://server/readme', {
3090
- name: 'Server README',
3091
- description: 'Main documentation and usage guide for this NPM Info Server.',
3092
- mimeType: 'text/markdown',
3093
- }, async (uri) => {
3094
- try {
3095
- const readmeContent = fs.readFileSync(README_PATH, 'utf-8');
3096
- return {
3097
- contents: [
3098
- {
3099
- uri: uri.href,
3100
- text: readmeContent,
3101
- mimeType: 'text/markdown',
3102
- },
3103
- ],
3104
- };
3105
- }
3106
- catch (error) {
3107
- console.error(`Error reading README.md for resource ${uri.href}:`, error.message);
3108
- throw {
3109
- code: -32002,
3110
- message: `Resource not found or unreadable: ${uri.href}`,
3111
- data: { uri: uri.href, cause: error.message },
3112
- };
3113
- }
3114
- });
3115
- // Register llms-full.txt resource (MCP Specification)
3116
- server.resource('mcpSpecification', 'doc://mcp/specification', {
3117
- name: 'MCP Full Specification',
3118
- description: 'The llms-full.txt content providing a comprehensive overview of the Model Context Protocol.',
3119
- mimeType: 'text/plain',
3120
- }, async (uri) => {
3073
+ // Define session configuration schema (empty for now, can be extended later)
3074
+ export const configSchema = z.object({});
3075
+ // Create server function for Smithery CLI
3076
+ export default function createServer({ config, }) {
3077
+ // Handle both ESM and CJS environments
3078
+ let __filename;
3079
+ let __dirname;
3121
3080
  try {
3122
- const specContent = fs.readFileSync(LLMS_FULL_TEXT_PATH, 'utf-8');
3123
- return {
3124
- contents: [
3125
- {
3126
- uri: uri.href,
3127
- text: specContent,
3128
- mimeType: 'text/plain',
3129
- },
3130
- ],
3131
- };
3081
+ __filename = fileURLToPath(import.meta.url);
3082
+ __dirname = path.dirname(__filename);
3132
3083
  }
3133
3084
  catch (error) {
3134
- console.error(`Error reading llms-full.txt for resource ${uri.href}:`, error.message);
3135
- throw {
3136
- code: -32002,
3137
- message: `Resource not found or unreadable: ${uri.href}`,
3138
- data: { uri: uri.href, cause: error.message },
3139
- };
3085
+ // Fallback for CJS environment (Smithery HTTP build)
3086
+ __filename = process.argv[1] || '.';
3087
+ __dirname = path.dirname(__filename);
3140
3088
  }
3141
- });
3142
- // Add NPM tools - Ensuring each tool registration is complete and correct
3143
- server.tool('npmVersions', 'Get all available versions of an NPM package', {
3144
- packages: z.array(z.string()).describe('List of package names to get versions for'),
3145
- }, {
3146
- title: 'Get All Package Versions',
3147
- readOnlyHint: true,
3148
- openWorldHint: true,
3149
- idempotentHint: true,
3150
- }, async (args) => {
3151
- return await handleNpmVersions(args);
3152
- });
3153
- server.tool('npmLatest', 'Get the latest version and changelog of an NPM package', {
3154
- packages: z.array(z.string()).describe('List of package names to get latest versions for'),
3155
- }, {
3156
- title: 'Get Latest Package Information',
3157
- readOnlyHint: true,
3158
- openWorldHint: true,
3159
- idempotentHint: true, // Result for 'latest' tag can change, but call itself is idempotent
3160
- }, async (args) => {
3161
- return await handleNpmLatest(args);
3162
- });
3163
- server.tool('npmDeps', 'Analyze dependencies and devDependencies of an NPM package', {
3164
- packages: z.array(z.string()).describe('List of package names to analyze dependencies for'),
3165
- }, {
3166
- title: 'Get Package Dependencies',
3167
- readOnlyHint: true,
3168
- openWorldHint: true,
3169
- idempotentHint: true,
3170
- }, async (args) => {
3171
- return await handleNpmDeps(args);
3172
- });
3173
- server.tool('npmTypes', 'Check TypeScript types availability and version for a package', {
3174
- packages: z.array(z.string()).describe('List of package names to check types for'),
3175
- }, {
3176
- title: 'Check TypeScript Type Availability',
3177
- readOnlyHint: true,
3178
- openWorldHint: true,
3179
- idempotentHint: true,
3180
- }, async (args) => {
3181
- return await handleNpmTypes(args);
3182
- });
3183
- server.tool('npmSize', 'Get package size information including dependencies and bundle size', {
3184
- packages: z.array(z.string()).describe('List of package names to get size information for'),
3185
- }, {
3186
- title: 'Get Package Size (Bundlephobia)',
3187
- readOnlyHint: true,
3188
- openWorldHint: true,
3189
- idempotentHint: true,
3190
- }, async (args) => {
3191
- return await handleNpmSize(args);
3192
- });
3193
- server.tool('npmVulnerabilities', 'Check for known vulnerabilities in packages', {
3194
- packages: z.array(z.string()).describe('List of package names to check for vulnerabilities'),
3195
- }, {
3196
- title: 'Check Package Vulnerabilities (OSV.dev)',
3197
- readOnlyHint: true,
3198
- openWorldHint: true,
3199
- idempotentHint: false, // Vulnerability data can change frequently
3200
- }, async (args) => {
3201
- return await handleNpmVulnerabilities(args);
3202
- });
3203
- server.tool('npmTrends', 'Get download trends and popularity metrics for packages', {
3204
- packages: z.array(z.string()).describe('List of package names to get trends for'),
3205
- period: z
3206
- .enum(['last-week', 'last-month', 'last-year'])
3207
- .describe('Time period for trends. Options: "last-week", "last-month", "last-year"')
3208
- .optional()
3209
- .default('last-month'),
3210
- }, {
3211
- title: 'Get NPM Package Download Trends',
3212
- readOnlyHint: true,
3213
- openWorldHint: true,
3214
- idempotentHint: true, // Trends for a fixed past period are idempotent
3215
- }, async (args) => {
3216
- return await handleNpmTrends(args);
3217
- });
3218
- server.tool('npmCompare', 'Compare multiple NPM packages based on various metrics', {
3219
- packages: z.array(z.string()).describe('List of package names to compare'),
3220
- }, {
3221
- title: 'Compare NPM Packages',
3222
- readOnlyHint: true,
3223
- openWorldHint: true,
3224
- idempotentHint: true,
3225
- }, async (args) => {
3226
- return await handleNpmCompare(args);
3227
- });
3228
- server.tool('npmMaintainers', 'Get maintainers information for NPM packages', {
3229
- packages: z.array(z.string()).describe('List of package names to get maintainers for'),
3230
- }, {
3231
- title: 'Get NPM Package Maintainers',
3232
- readOnlyHint: true,
3233
- openWorldHint: true,
3234
- idempotentHint: true,
3235
- }, async (args) => {
3236
- return await handleNpmMaintainers(args);
3237
- });
3238
- server.tool('npmScore', 'Get consolidated package score based on quality, maintenance, and popularity metrics', {
3239
- packages: z.array(z.string()).describe('List of package names to get scores for'),
3240
- }, {
3241
- title: 'Get NPM Package Score (NPMS.io)',
3242
- readOnlyHint: true,
3243
- openWorldHint: true,
3244
- idempotentHint: true, // Score for a version is stable, for 'latest' can change
3245
- }, async (args) => {
3246
- return await handleNpmScore(args);
3247
- });
3248
- server.tool('npmPackageReadme', 'Get the README content for NPM packages', {
3249
- packages: z.array(z.string()).describe('List of package names to get READMEs for'),
3250
- }, {
3251
- title: 'Get NPM Package README',
3252
- readOnlyHint: true,
3253
- openWorldHint: true,
3254
- idempotentHint: true,
3255
- }, async (args) => {
3256
- return await handleNpmPackageReadme(args);
3257
- });
3258
- server.tool('npmSearch', 'Search for NPM packages with optional limit', {
3259
- query: z.string().describe('Search query for packages'),
3260
- limit: z
3261
- .number()
3262
- .min(1)
3263
- .max(50)
3264
- .optional()
3265
- .describe('Maximum number of results to return (default: 10)'),
3266
- }, {
3267
- title: 'Search NPM Packages',
3268
- readOnlyHint: true,
3269
- openWorldHint: true,
3270
- idempotentHint: false, // Search results can change
3271
- }, async (args) => {
3272
- return await handleNpmSearch(args);
3273
- });
3274
- server.tool('npmLicenseCompatibility', 'Check license compatibility between multiple packages', {
3275
- packages: z
3276
- .array(z.string())
3277
- .min(1)
3278
- .describe('List of package names to check for license compatibility'),
3279
- }, {
3280
- title: 'Check NPM License Compatibility',
3281
- readOnlyHint: true,
3282
- openWorldHint: true,
3283
- idempotentHint: true,
3284
- }, async (args) => {
3285
- return await handleNpmLicenseCompatibility(args);
3286
- });
3287
- server.tool('npmRepoStats', 'Get repository statistics for NPM packages', {
3288
- packages: z.array(z.string()).describe('List of package names to get repository stats for'),
3289
- }, {
3290
- title: 'Get NPM Package Repository Stats (GitHub)',
3291
- readOnlyHint: true,
3292
- openWorldHint: true,
3293
- idempotentHint: true, // Stats for a repo at a point in time, though they change over time
3294
- }, async (args) => {
3295
- return await handleNpmRepoStats(args);
3296
- });
3297
- server.tool('npmDeprecated', 'Check if packages are deprecated', {
3298
- packages: z.array(z.string()).describe('List of package names to check for deprecation'),
3299
- }, {
3300
- title: 'Check NPM Package Deprecation Status',
3301
- readOnlyHint: true,
3302
- openWorldHint: true,
3303
- idempotentHint: true, // Deprecation status is generally stable for a version
3304
- }, async (args) => {
3305
- return await handleNpmDeprecated(args);
3306
- });
3307
- server.tool('npmChangelogAnalysis', 'Analyze changelog and release history of packages', {
3308
- packages: z.array(z.string()).describe('List of package names to analyze changelogs for'),
3309
- }, {
3310
- title: 'Analyze NPM Package Changelog (GitHub)',
3311
- readOnlyHint: true,
3312
- openWorldHint: true,
3313
- idempotentHint: true,
3314
- }, async (args) => {
3315
- return await handleNpmChangelogAnalysis(args);
3316
- });
3317
- server.tool('npmAlternatives', 'Find alternative packages with similar functionality', {
3318
- packages: z.array(z.string()).describe('List of package names to find alternatives for'),
3319
- }, {
3320
- title: 'Find NPM Package Alternatives',
3321
- readOnlyHint: true,
3322
- openWorldHint: true,
3323
- idempotentHint: false, // Search-based, results can change
3324
- }, async (args) => {
3325
- return await handleNpmAlternatives(args);
3326
- });
3327
- server.tool('npmQuality', 'Analyze package quality metrics', {
3328
- packages: z.array(z.string()).describe('List of package names to analyze'),
3329
- }, {
3330
- title: 'Analyze NPM Package Quality (NPMS.io)',
3331
- readOnlyHint: true,
3332
- openWorldHint: true,
3333
- idempotentHint: true, // Score for a version is stable, for 'latest' can change
3334
- }, async (args) => {
3335
- return await handleNpmQuality(args);
3336
- });
3337
- server.tool('npmMaintenance', 'Analyze package maintenance metrics', {
3338
- packages: z.array(z.string()).describe('List of package names to analyze'),
3339
- }, {
3340
- title: 'Analyze NPM Package Maintenance (NPMS.io)',
3341
- readOnlyHint: true,
3342
- openWorldHint: true,
3343
- idempotentHint: true, // Score for a version is stable, for 'latest' can change
3344
- }, async (args) => {
3345
- return await handleNpmMaintenance(args);
3346
- });
3347
- // Start receiving messages on stdin and sending messages on stdout
3348
- const transport = new StdioServerTransport();
3349
- await server.connect(transport);
3350
- process.stdin.on('close', () => {
3351
- server.close();
3352
- });
3353
- // Handle uncaught errors
3354
- process.on('uncaughtException', (error) => {
3355
- console.error('Fatal error:', error);
3356
- server.close();
3357
- process.exit(1);
3358
- });
3359
- process.on('unhandledRejection', (error) => {
3360
- console.error('Unhandled rejection:', error);
3361
- server.close();
3362
- process.exit(1);
3363
- });
3089
+ // The package root will be one level above __dirname (which is 'dist/' after compilation)
3090
+ const packageRoot = path.join(__dirname, '..');
3091
+ // Create server instance
3092
+ const server = new McpServer({
3093
+ name: 'npm-sentinel-mcp',
3094
+ version: '1.8.1',
3095
+ capabilities: {
3096
+ resources: {},
3097
+ },
3098
+ });
3099
+ // Update paths to be relative to the package
3100
+ const README_PATH = path.join(packageRoot, 'README.md');
3101
+ const LLMS_FULL_TEXT_PATH = path.join(packageRoot, 'llms-full.txt');
3102
+ // Register README.md resource
3103
+ server.resource('serverReadme', 'doc://server/readme', {
3104
+ name: 'Server README',
3105
+ description: 'Main documentation and usage guide for this NPM Info Server.',
3106
+ mimeType: 'text/markdown',
3107
+ }, async (uri) => {
3108
+ try {
3109
+ const readmeContent = fs.readFileSync(README_PATH, 'utf-8');
3110
+ return {
3111
+ contents: [
3112
+ {
3113
+ uri: uri.href,
3114
+ text: readmeContent,
3115
+ mimeType: 'text/markdown',
3116
+ },
3117
+ ],
3118
+ };
3119
+ }
3120
+ catch (error) {
3121
+ console.error(`Error reading README.md for resource ${uri.href}:`, error.message);
3122
+ throw {
3123
+ code: -32002,
3124
+ message: `Resource not found or unreadable: ${uri.href}`,
3125
+ data: { uri: uri.href, cause: error.message },
3126
+ };
3127
+ }
3128
+ });
3129
+ // Register llms-full.txt resource (MCP Specification)
3130
+ server.resource('mcpSpecification', 'doc://mcp/specification', {
3131
+ name: 'MCP Full Specification',
3132
+ description: 'The llms-full.txt content providing a comprehensive overview of the Model Context Protocol.',
3133
+ mimeType: 'text/plain',
3134
+ }, async (uri) => {
3135
+ try {
3136
+ const specContent = fs.readFileSync(LLMS_FULL_TEXT_PATH, 'utf-8');
3137
+ return {
3138
+ contents: [
3139
+ {
3140
+ uri: uri.href,
3141
+ text: specContent,
3142
+ mimeType: 'text/plain',
3143
+ },
3144
+ ],
3145
+ };
3146
+ }
3147
+ catch (error) {
3148
+ console.error(`Error reading llms-full.txt for resource ${uri.href}:`, error.message);
3149
+ throw {
3150
+ code: -32002,
3151
+ message: `Resource not found or unreadable: ${uri.href}`,
3152
+ data: { uri: uri.href, cause: error.message },
3153
+ };
3154
+ }
3155
+ });
3156
+ // Add NPM tools - Ensuring each tool registration is complete and correct
3157
+ server.tool('npmVersions', 'Get all available versions of an NPM package', {
3158
+ packages: z.array(z.string()).describe('List of package names to get versions for'),
3159
+ }, {
3160
+ title: 'Get All Package Versions',
3161
+ readOnlyHint: true,
3162
+ openWorldHint: true,
3163
+ idempotentHint: true,
3164
+ }, async (args) => {
3165
+ return await handleNpmVersions(args);
3166
+ });
3167
+ server.tool('npmLatest', 'Get the latest version and changelog of an NPM package', {
3168
+ packages: z.array(z.string()).describe('List of package names to get latest versions for'),
3169
+ }, {
3170
+ title: 'Get Latest Package Information',
3171
+ readOnlyHint: true,
3172
+ openWorldHint: true,
3173
+ idempotentHint: true, // Result for 'latest' tag can change, but call itself is idempotent
3174
+ }, async (args) => {
3175
+ return await handleNpmLatest(args);
3176
+ });
3177
+ server.tool('npmDeps', 'Analyze dependencies and devDependencies of an NPM package', {
3178
+ packages: z.array(z.string()).describe('List of package names to analyze dependencies for'),
3179
+ }, {
3180
+ title: 'Get Package Dependencies',
3181
+ readOnlyHint: true,
3182
+ openWorldHint: true,
3183
+ idempotentHint: true,
3184
+ }, async (args) => {
3185
+ return await handleNpmDeps(args);
3186
+ });
3187
+ server.tool('npmTypes', 'Check TypeScript types availability and version for a package', {
3188
+ packages: z.array(z.string()).describe('List of package names to check types for'),
3189
+ }, {
3190
+ title: 'Check TypeScript Type Availability',
3191
+ readOnlyHint: true,
3192
+ openWorldHint: true,
3193
+ idempotentHint: true,
3194
+ }, async (args) => {
3195
+ return await handleNpmTypes(args);
3196
+ });
3197
+ server.tool('npmSize', 'Get package size information including dependencies and bundle size', {
3198
+ packages: z.array(z.string()).describe('List of package names to get size information for'),
3199
+ }, {
3200
+ title: 'Get Package Size (Bundlephobia)',
3201
+ readOnlyHint: true,
3202
+ openWorldHint: true,
3203
+ idempotentHint: true,
3204
+ }, async (args) => {
3205
+ return await handleNpmSize(args);
3206
+ });
3207
+ server.tool('npmVulnerabilities', 'Check for known vulnerabilities in packages', {
3208
+ packages: z.array(z.string()).describe('List of package names to check for vulnerabilities'),
3209
+ }, {
3210
+ title: 'Check Package Vulnerabilities (OSV.dev)',
3211
+ readOnlyHint: true,
3212
+ openWorldHint: true,
3213
+ idempotentHint: false, // Vulnerability data can change frequently
3214
+ }, async (args) => {
3215
+ return await handleNpmVulnerabilities(args);
3216
+ });
3217
+ server.tool('npmTrends', 'Get download trends and popularity metrics for packages', {
3218
+ packages: z.array(z.string()).describe('List of package names to get trends for'),
3219
+ period: z
3220
+ .enum(['last-week', 'last-month', 'last-year'])
3221
+ .describe('Time period for trends. Options: "last-week", "last-month", "last-year"')
3222
+ .optional()
3223
+ .default('last-month'),
3224
+ }, {
3225
+ title: 'Get NPM Package Download Trends',
3226
+ readOnlyHint: true,
3227
+ openWorldHint: true,
3228
+ idempotentHint: true, // Trends for a fixed past period are idempotent
3229
+ }, async (args) => {
3230
+ return await handleNpmTrends(args);
3231
+ });
3232
+ server.tool('npmCompare', 'Compare multiple NPM packages based on various metrics', {
3233
+ packages: z.array(z.string()).describe('List of package names to compare'),
3234
+ }, {
3235
+ title: 'Compare NPM Packages',
3236
+ readOnlyHint: true,
3237
+ openWorldHint: true,
3238
+ idempotentHint: true,
3239
+ }, async (args) => {
3240
+ return await handleNpmCompare(args);
3241
+ });
3242
+ server.tool('npmMaintainers', 'Get maintainers information for NPM packages', {
3243
+ packages: z.array(z.string()).describe('List of package names to get maintainers for'),
3244
+ }, {
3245
+ title: 'Get NPM Package Maintainers',
3246
+ readOnlyHint: true,
3247
+ openWorldHint: true,
3248
+ idempotentHint: true,
3249
+ }, async (args) => {
3250
+ return await handleNpmMaintainers(args);
3251
+ });
3252
+ server.tool('npmScore', 'Get consolidated package score based on quality, maintenance, and popularity metrics', {
3253
+ packages: z.array(z.string()).describe('List of package names to get scores for'),
3254
+ }, {
3255
+ title: 'Get NPM Package Score (NPMS.io)',
3256
+ readOnlyHint: true,
3257
+ openWorldHint: true,
3258
+ idempotentHint: true, // Score for a version is stable, for 'latest' can change
3259
+ }, async (args) => {
3260
+ return await handleNpmScore(args);
3261
+ });
3262
+ server.tool('npmPackageReadme', 'Get the README content for NPM packages', {
3263
+ packages: z.array(z.string()).describe('List of package names to get READMEs for'),
3264
+ }, {
3265
+ title: 'Get NPM Package README',
3266
+ readOnlyHint: true,
3267
+ openWorldHint: true,
3268
+ idempotentHint: true,
3269
+ }, async (args) => {
3270
+ return await handleNpmPackageReadme(args);
3271
+ });
3272
+ server.tool('npmSearch', 'Search for NPM packages with optional limit', {
3273
+ query: z.string().describe('Search query for packages'),
3274
+ limit: z
3275
+ .number()
3276
+ .min(1)
3277
+ .max(50)
3278
+ .optional()
3279
+ .describe('Maximum number of results to return (default: 10)'),
3280
+ }, {
3281
+ title: 'Search NPM Packages',
3282
+ readOnlyHint: true,
3283
+ openWorldHint: true,
3284
+ idempotentHint: false, // Search results can change
3285
+ }, async (args) => {
3286
+ return await handleNpmSearch(args);
3287
+ });
3288
+ server.tool('npmLicenseCompatibility', 'Check license compatibility between multiple packages', {
3289
+ packages: z
3290
+ .array(z.string())
3291
+ .min(1)
3292
+ .describe('List of package names to check for license compatibility'),
3293
+ }, {
3294
+ title: 'Check NPM License Compatibility',
3295
+ readOnlyHint: true,
3296
+ openWorldHint: true,
3297
+ idempotentHint: true,
3298
+ }, async (args) => {
3299
+ return await handleNpmLicenseCompatibility(args);
3300
+ });
3301
+ server.tool('npmRepoStats', 'Get repository statistics for NPM packages', {
3302
+ packages: z.array(z.string()).describe('List of package names to get repository stats for'),
3303
+ }, {
3304
+ title: 'Get NPM Package Repository Stats (GitHub)',
3305
+ readOnlyHint: true,
3306
+ openWorldHint: true,
3307
+ idempotentHint: true, // Stats for a repo at a point in time, though they change over time
3308
+ }, async (args) => {
3309
+ return await handleNpmRepoStats(args);
3310
+ });
3311
+ server.tool('npmDeprecated', 'Check if packages are deprecated', {
3312
+ packages: z.array(z.string()).describe('List of package names to check for deprecation'),
3313
+ }, {
3314
+ title: 'Check NPM Package Deprecation Status',
3315
+ readOnlyHint: true,
3316
+ openWorldHint: true,
3317
+ idempotentHint: true, // Deprecation status is generally stable for a version
3318
+ }, async (args) => {
3319
+ return await handleNpmDeprecated(args);
3320
+ });
3321
+ server.tool('npmChangelogAnalysis', 'Analyze changelog and release history of packages', {
3322
+ packages: z.array(z.string()).describe('List of package names to analyze changelogs for'),
3323
+ }, {
3324
+ title: 'Analyze NPM Package Changelog (GitHub)',
3325
+ readOnlyHint: true,
3326
+ openWorldHint: true,
3327
+ idempotentHint: true,
3328
+ }, async (args) => {
3329
+ return await handleNpmChangelogAnalysis(args);
3330
+ });
3331
+ server.tool('npmAlternatives', 'Find alternative packages with similar functionality', {
3332
+ packages: z.array(z.string()).describe('List of package names to find alternatives for'),
3333
+ }, {
3334
+ title: 'Find NPM Package Alternatives',
3335
+ readOnlyHint: true,
3336
+ openWorldHint: true,
3337
+ idempotentHint: false, // Search-based, results can change
3338
+ }, async (args) => {
3339
+ return await handleNpmAlternatives(args);
3340
+ });
3341
+ server.tool('npmQuality', 'Analyze package quality metrics', {
3342
+ packages: z.array(z.string()).describe('List of package names to analyze'),
3343
+ }, {
3344
+ title: 'Analyze NPM Package Quality (NPMS.io)',
3345
+ readOnlyHint: true,
3346
+ openWorldHint: true,
3347
+ idempotentHint: true, // Score for a version is stable, for 'latest' can change
3348
+ }, async (args) => {
3349
+ return await handleNpmQuality(args);
3350
+ });
3351
+ server.tool('npmMaintenance', 'Analyze package maintenance metrics', {
3352
+ packages: z.array(z.string()).describe('List of package names to analyze'),
3353
+ }, {
3354
+ title: 'Analyze NPM Package Maintenance (NPMS.io)',
3355
+ readOnlyHint: true,
3356
+ openWorldHint: true,
3357
+ idempotentHint: true, // Score for a version is stable, for 'latest' can change
3358
+ }, async (args) => {
3359
+ return await handleNpmMaintenance(args);
3360
+ });
3361
+ return server.server;
3362
+ }
3363
+ // STDIO compatibility for backward compatibility
3364
+ async function main() {
3365
+ // Create server with empty configuration
3366
+ const server = createServer({
3367
+ config: {},
3368
+ });
3369
+ // Start receiving messages on stdin and sending messages on stdout
3370
+ const transport = new StdioServerTransport();
3371
+ await server.connect(transport);
3372
+ process.stdin.on('close', () => {
3373
+ server.close();
3374
+ });
3375
+ // Handle uncaught errors
3376
+ process.on('uncaughtException', (error) => {
3377
+ console.error('Fatal error:', error);
3378
+ server.close();
3379
+ process.exit(1);
3380
+ });
3381
+ process.on('unhandledRejection', (error) => {
3382
+ console.error('Unhandled rejection:', error);
3383
+ server.close();
3384
+ process.exit(1);
3385
+ });
3386
+ }
3364
3387
  // Type guard for NpmPackageVersionSchema
3365
3388
  function isNpmPackageVersionData(data) {
3366
3389
  try {
@@ -3373,4 +3396,9 @@ function isNpmPackageVersionData(data) {
3373
3396
  return false;
3374
3397
  }
3375
3398
  }
3399
+ // Run STDIO server when executed directly (for backward compatibility)
3400
+ main().catch((error) => {
3401
+ console.error('Server error:', error);
3402
+ process.exit(1);
3403
+ });
3376
3404
  //# sourceMappingURL=index.js.map