# Ensure everything builds successfully
npm run build
# Run type checking
npm run typecheck
# Test the package locally
npm pack
# This creates doc-mcp-1.0.0.tgz# If you don't have an npm account, create one at https://www.npmjs.com/signup
# Login to npm
npm login
# Enter your username, password, and emailBefore publishing, update package.json:
{
"name": "doc-mcp",
"version": "1.0.0",
"author": "Your Name <your.email@example.com>",
"repository": {
"type": "git",
"url": "https://github.com/yourusername/doc-mcp.git"
},
"bugs": {
"url": "https://github.com/yourusername/doc-mcp/issues"
},
"homepage": "https://github.com/yourusername/doc-mcp#readme"
}# See what will be published
npm pack --dry-run
# Should include:
# - dist/ (compiled code)
# - README.md
# - LICENSE
# - package.json# For first-time publish
npm publish
# For scoped packages (e.g., @yourorg/doc-mcp)
npm publish --access public# Check your package page
# https://www.npmjs.com/package/doc-mcp
# Test installation in a new directory
mkdir test-doc-mcp
cd test-doc-mcp
npm init -y
npm install doc-mcp# Update version in package.json (follow semver)
npm version patch # 1.0.0 -> 1.0.1 (bug fixes)
npm version minor # 1.0.0 -> 1.1.0 (new features)
npm version major # 1.0.0 -> 2.0.0 (breaking changes)
# Rebuild and publish
npm run build
npm publish- All code builds without errors
- TypeScript types are generated
- README.md is complete and accurate
- LICENSE file is present
- package.json has correct metadata
- Examples work correctly
- Version number follows semantic versioning
- Unnecessary files are excluded (.gitignore, .npmignore)
{
"scripts": {
"build": "tsup",
"prepublishOnly": "npm run build",
"typecheck": "tsc --noEmit"
}
}The prepublishOnly script ensures the package is always built before publishing.
- Always test locally first with
npm linkornpm pack - Use semantic versioning (major.minor.patch)
- Tag releases in git:
git tag v1.0.0 && git push --tags - Maintain changelog for version history
- Consider beta releases for major changes:
npm publish --tag beta
# Check if name is available
npm search doc-mcp
# Use a scoped package
# Update package.json: "name": "@yourorg/doc-mcp"# Re-login to npm
npm logout
npm login# Create .npmignore or use "files" in package.json
echo "src/" >> .npmignore
echo "examples/" >> .npmignore
echo "tsconfig.json" >> .npmignore