- npm account: Create an account at npmjs.com
- Update package.json: Replace placeholders with your actual information:
{ "name": "@your-username/postgres-mcp-server", "author": { "name": "Your Name", "email": "your.email@example.com", "url": "https://github.com/your-username" }, "repository": { "type": "git", "url": "git+https://github.com/your-username/postgres-mcp-server.git" } }
-
Login to npm:
npm login
-
Build the project:
npm run build
-
Test the package locally (optional):
npm pack # This creates a .tgz file you can test with: npm install ./package.tgz -
Publish to npm:
npm publish --access public
Note: Use
--access publicfor scoped packages (@your-username/package-name)
If you prefer an unscoped package name (easier for users), change the package name to:
{
"name": "postgres-mcp-server-cli", // or another unique name
}Then publish with:
npm publishUsers can install globally and run from anywhere:
# Install globally
npm install -g @your-username/postgres-mcp-server
# Run from anywhere
postgres-mcp --connection-string "postgresql://user:pass@localhost:5432/db"Users can run directly without installing:
npx @your-username/postgres-mcp-server --connection-string "postgresql://user:pass@localhost:5432/db"After publishing, users can configure their MCP clients:
{
"mcpServers": {
"postgresql-mcp": {
"command": "npx",
"args": [
"@your-username/postgres-mcp-server",
"--connection-string", "postgresql://user:password@host:port/database"
]
}
}
}Or with global installation:
{
"mcpServers": {
"postgresql-mcp": {
"command": "postgres-mcp",
"args": [
"--connection-string", "postgresql://user:password@host:port/database"
]
}
}
}Update version in package.json and publish:
# Patch version (1.0.0 -> 1.0.1)
npm version patch
# Minor version (1.0.0 -> 1.1.0)
npm version minor
# Major version (1.0.0 -> 2.0.0)
npm version major
# Then publish
npm publishCreate .github/workflows/publish.yml:
name: Publish to npm
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run build
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}Test the built package locally:
# Build
npm run build
# Test CLI directly
node build/index.js --help
# Test with sample connection (use your actual DB)
node build/index.js --connection-string "postgresql://localhost/test"-
Install locally in test project:
npm pack npm install -g ./postgres-mcp-server-1.0.0.tgz
-
Configure MCP client and test tools
-
Uninstall test version:
npm uninstall -g @your-username/postgres-mcp-server
- Update
package.jsonwith your details - Ensure all placeholder names are replaced
- Build succeeds without errors:
npm run build - CLI works:
node build/index.js --help - All dependencies are correct
- README.md is updated
- License is appropriate
- Version number is correct
- Never commit connection strings to git
- Review dependencies for security vulnerabilities:
npm audit npm audit fix
- Use environment variables for sensitive data
- Consider scoped packages for namespace control
- Check npm statistics:
npm view @your-username/postgres-mcp-server - Monitor downloads and issues
- Update documentation based on user feedback
- Keep dependencies updated
- Respond to GitHub issues
- Follow semantic versioning for updates
- Consider setting up automated security updates
# Check what will be published
npm pack --dry-run
# View published package info
npm view @your-username/postgres-mcp-server
# Check package size
npm pack && du -h *.tgz
# Test installation
npm install -g @your-username/postgres-mcp-server
# Uninstall
npm uninstall -g @your-username/postgres-mcp-serverHappy publishing! 🎉