deploy-your-own-server.mdโข4.55 kB
# 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
### Automatic Publishing (Recommended)
1. **Create a version tag:**
```bash
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:**
```bash
npm run test:package
```
2. **Publish manually:**
```bash
npm publish
```
## ๐ Prerequisites
### NPM Token Setup
1. **Create an NPM account** at https://www.npmjs.com/
2. **Generate an access token:**
- Go to https://www.npmjs.com/settings/tokens
- Click "Generate New Token"
- Choose "Automation" type
- Copy the 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
```bash
# Global installation
npm install -g mcp-adr-analysis-server
# Local installation
npm install mcp-adr-analysis-server
```
### Usage
```bash
# 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
```bash
# 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
- **Package page**: https://www.npmjs.com/package/mcp-adr-analysis-server
- **Download stats**: Available on NPM package page
- **Version history**: Tracked in NPM registry
### 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