Skip to main content

NPM Publishing Guide

This document explains how to publish the MCP ADR Analysis Server to npmjs.com using the automated GitHub Actions workflow.

๐Ÿš€ Quick Startโ€‹

  1. Create a version tag:

    git tag v1.0.1
    git push origin v1.0.1
  2. The GitHub Actions workflow will automatically:

    • Run all tests and linting
    • Build the project
    • Test MCP server functionality
    • Publish to npmjs.com
    • Create a GitHub release

Manual Publishingโ€‹

  1. Test the package locally:

    npm run test:package
  2. Publish manually:

    npm publish

๐Ÿ“‹ Prerequisitesโ€‹

NPM Token Setupโ€‹

  1. Create an NPM account at https://www.npmjs.com/

  2. Generate an access token:

  3. Add token to GitHub Secrets:

    • Go to your repository settings
    • Navigate to "Secrets and variables" โ†’ "Actions"
    • Add a new secret named NPM_TOKEN
    • Paste your NPM token as the value

๐Ÿ”ง Publishing Workflow Featuresโ€‹

Automated Quality Checksโ€‹

  • โœ… ESLint code quality validation
  • โœ… Jest test suite execution
  • โœ… TypeScript compilation verification
  • โœ… MCP server functionality testing
  • โœ… Package structure validation

Version Managementโ€‹

  • Tag-based publishing: Push a version tag to trigger publishing
  • Manual versioning: Use workflow dispatch with version input
  • Automatic version updates: Updates package.json version

Package Optimizationโ€‹

  • Selective file inclusion: Only includes necessary files
  • Size optimization: ~173 KB optimized package
  • Binary setup: Includes CLI binary for global installation

๐Ÿ“ฆ Package Informationโ€‹

Installationโ€‹

# Global installation
npm install -g mcp-adr-analysis-server

# Local installation
npm install mcp-adr-analysis-server

Usageโ€‹

# Run as CLI tool
mcp-adr-analysis-server

# Or use as Node.js module
node node_modules/mcp-adr-analysis-server/dist/src/index.js

Package Contentsโ€‹

  • Main entry: dist/src/index.js
  • Binary: mcp-adr-analysis-server command
  • Documentation: README.md and ../../LICENSE
  • Type definitions: Full TypeScript support

๐Ÿ”„ Version Managementโ€‹

Semantic Versioningโ€‹

  • Patch (1.0.1): Bug fixes and minor updates
  • Minor (1.1.0): New features, backward compatible
  • Major (2.0.0): Breaking changes

Publishing Commandsโ€‹

# Patch version (1.0.0 โ†’ 1.0.1)
git tag v1.0.1 && git push origin v1.0.1

# Minor version (1.0.0 โ†’ 1.1.0)
git tag v1.1.0 && git push origin v1.1.0

# Major version (1.0.0 โ†’ 2.0.0)
git tag v2.0.0 && git push origin v2.0.0

Manual Workflow Dispatchโ€‹

You can also trigger publishing manually:

  1. Go to GitHub Actions tab
  2. Select "Publish to NPM" workflow
  3. Click "Run workflow"
  4. Choose version type (patch/minor/major/prerelease)

๐Ÿ›ก๏ธ Security & Best Practicesโ€‹

Token Securityโ€‹

  • โœ… NPM token stored as GitHub secret
  • โœ… Token only accessible to authorized workflows
  • โœ… Automatic token rotation recommended

Quality Gatesโ€‹

  • โœ… All tests must pass before publishing
  • โœ… Linting must pass before publishing
  • โœ… Build must succeed before publishing
  • โœ… MCP server functionality verified

Package Integrityโ€‹

  • โœ… Package contents verified before publishing
  • โœ… Main entry point validated
  • โœ… Binary accessibility confirmed
  • โœ… Size optimization applied

๐Ÿ“Š Monitoring & Maintenanceโ€‹

NPM Package Statsโ€‹

GitHub Releasesโ€‹

  • Automatic releases: Created for each published version
  • Release notes: Generated with feature highlights
  • Asset downloads: Package tarballs available

๐Ÿ”ง Troubleshootingโ€‹

Common Issuesโ€‹

  1. NPM Token Invalid

    • Regenerate token on npmjs.com
    • Update GitHub secret
  2. Tests Failing

    • Check test output in GitHub Actions
    • Fix issues locally and push
  3. Package Size Too Large

    • Review .npmignore file
    • Remove unnecessary files
  4. Binary Not Working

    • Verify package.json bin configuration
    • Test locally with npm run test:package

Supportโ€‹

For issues with the publishing process, check:

  • GitHub Actions logs
  • NPM package page
  • Repository issues section