Skip to main content
Glama
NPM Publisher MCP Server

NPM Publisher MCP Server

by GiDanis
README.md
# NPM Publisher MCP Server

šŸš€ **Automate NPM package publishing with GitHub Copilot CLI**

A Model Context Protocol (MCP) server that streamlines NPM package publishing workflows by integrating version management, Git operations, and NPM publishing into GitHub Copilot CLI.

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Node.js Version](https://img.shields.io/badge/node-%3E%3D16.0.0-brightgreen)](https://nodejs.org/)

## Features

- šŸ” **Package Validation** - Comprehensive checks for package.json and prerequisites
- šŸ“¦ **Version Management** - Automated version bumping (semantic versioning)
- šŸ·ļø **Git Integration** - Automatic tagging, committing, and pushing
- šŸš€ **NPM Publishing** - One-command publishing with safety checks
- šŸ”„ **Complete Workflow** - End-to-end automation from version bump to publish
- šŸ¤– **Copilot Integration** - Natural language commands via GitHub Copilot CLI
- šŸ’» **Standalone CLI** - Use without Copilot for manual operations

## Quick Start

### Installation

```bash
# Clone the repository
git clone https://github.com/GiDanis/copilot-npm-publisher.git
cd copilot-npm-publisher

# Install dependencies
npm install

# Run setup wizard
npm run setup
```

### Usage with GitHub Copilot CLI

Once configured, use natural language commands:

```bash
gh copilot chat

# Then ask:
"Check if my package is ready to publish"
"Bump the version to a minor release"
"Publish my package to NPM"
"Run the complete publish workflow with a patch version"
```

### Standalone CLI Usage

```bash
# Validate package
npm-publisher validate

# Bump version
npm-publisher bump patch

# Publish to NPM
npm-publisher publish --access public

# Complete workflow
npm-publisher workflow minor

# Check status
npm-publisher status
```

## MCP Tools

The server provides these tools to GitHub Copilot:

| Tool | Description |
|------|-------------|
| `npm_validate` | Validate package.json and check prerequisites |
| `npm_login_status` | Check NPM authentication status |
| `npm_version_bump` | Bump package version (patch/minor/major) |
| `npm_check_published` | Check if version exists on NPM |
| `npm_publish` | Publish package to NPM registry |
| `git_status` | Check Git repository status |
| `git_create_tag` | Create Git tags for releases |
| `git_commit_and_push` | Commit and push changes |
| `publish_workflow` | Complete automated workflow |

## Documentation

- šŸ“– [Installation Guide](docs/installation.md)
- šŸŽÆ [Usage Guide](docs/usage.md)
- šŸ”§ [API Reference](docs/api.md)
- šŸ”’ [Security](SECURITY.md)
- šŸ¤ [Contributing](CONTRIBUTING.md)

## Requirements

- **Node.js**: >= 16.0.0
- **NPM Account**: With publishing permissions
- **Git**: Installed and configured
- **GitHub Copilot CLI**: (Optional) For natural language interface

## Configuration

### NPM Authentication

```bash
# Login to NPM
npm login

# Or set NPM_TOKEN environment variable
export NPM_TOKEN="your_npm_token_here"
```

### GitHub Copilot Integration

The setup wizard automatically configures Copilot CLI, or manually add to `~/.config/github-copilot/apps.json`:

```json
{
  "mcpServers": {
    "npm-publisher": {
      "command": "node",
      "args": ["/path/to/copilot-npm-publisher/src/index.js"],
      "env": {
        "NPM_TOKEN": "optional_token_here"
      }
    }
  }
}
```

## Examples

### Complete Publishing Workflow

```bash
# Using CLI
npm-publisher workflow patch

# Using Copilot
gh copilot chat
> "Run a complete publish workflow with a patch version bump"
```

This will:
1. āœ… Check for uncommitted changes
2. šŸ“¦ Bump version (1.0.0 → 1.0.1)
3. šŸ’¾ Commit changes to Git
4. šŸ·ļø Create version tag (v1.0.1)
5. ā¬†ļø Push to remote repository
6. šŸš€ Publish to NPM

### Publish Beta Version

```bash
# Bump to prerelease
npm-publisher bump prepatch --preid beta

# Publish with beta tag
npm-publisher publish --tag beta --access public
```

### Dry Run

Test without making changes:

```bash
npm-publisher publish --dry-run
```

## Workflow Examples

### Standard Release

```bash
# 1. Validate
npm-publisher validate

# 2. Run workflow
npm-publisher workflow patch

# Package is now published! šŸŽ‰
```

### Prerelease

```bash
npm version prepatch --preid alpha --no-git-tag-version
git add package.json
git commit -m "chore: bump to alpha"
git push
npm publish --tag alpha
```

## Project Structure

```
copilot-npm-publisher/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ index.js          # MCP server implementation
│   └── cli.js            # Standalone CLI
ā”œā”€ā”€ setup/
│   └── config-wizard.js  # Interactive setup
ā”œā”€ā”€ docs/
│   ā”œā”€ā”€ installation.md   # Installation guide
│   ā”œā”€ā”€ usage.md          # Usage guide
│   └── api.md            # API reference
ā”œā”€ā”€ .github/
│   └── workflows/
│       ā”œā”€ā”€ ci.yml        # CI pipeline
│       └── publish.yml   # Auto-publish on tags
ā”œā”€ā”€ package.json
ā”œā”€ā”€ README.md
ā”œā”€ā”€ LICENSE
ā”œā”€ā”€ SECURITY.md
└── CONTRIBUTING.md
```

## Troubleshooting

### Not logged in to NPM

```bash
npm login
# Or set NPM_TOKEN environment variable
```

### Working directory has uncommitted changes

```bash
git status
git add .
git commit -m "Your changes"
# Or use git stash
```

### Version already published

Bump the version first:
```bash
npm-publisher bump patch
```

### Git remote not configured

```bash
git remote add origin https://github.com/username/repo.git
```

## Security

- Never commit `.npmrc` files containing authentication tokens
- Use environment variables for sensitive data
- Review changes before publishing
- Use `--dry-run` to test without publishing

See [SECURITY.md](SECURITY.md) for more details.

## Contributing

Contributions are welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

## License

MIT Ā© Giuseppe Danise

See [LICENSE](LICENSE) for details.

## Links

- **GitHub**: https://github.com/GiDanis/copilot-npm-publisher
- **NPM**: (Coming soon)
- **Issues**: https://github.com/GiDanis/copilot-npm-publisher/issues
- **MCP Specification**: https://modelcontextprotocol.io/

## Support

- šŸ“§ Report issues: [GitHub Issues](https://github.com/GiDanis/copilot-npm-publisher/issues)
- šŸ’¬ Discussions: [GitHub Discussions](https://github.com/GiDanis/copilot-npm-publisher/discussions)
- šŸ“– Documentation: [docs/](docs/)

---

Made with ā¤ļø by [Giuseppe Danise](https://github.com/GiDanis)

TDQS

B3.4/5.0

Scored across 9 tools

Disambiguation4/5

Each tool targets a distinct step (validate, login status, version bump, publish check, publish, git status, tag, commit/push). The only boundary blur is publish_workflow, which chains together npm_version_bump, git_commit_and_push, git_create_tag, and npm_publish that already exist as standalone tools, so an agent must decide between the composite and the granular path.

Naming Consistency4/5

Tools follow a clear prefix_action convention with npm_ and git_ namespaces, which makes resource grouping obvious. The lone outlier is publish_workflow, which drops the prefix pattern, though its meaning remains clear.

Tool Count5/5

Nine tools is well-scoped for a publish-workflow server, with each tool earning its place across npm and git concerns. Adding more would likely introduce redundancy rather than coverage.

Completeness4/5

The lifecycle is largely covered: validation, auth check, version check, bump, tag, commit/push, publish, plus a one-shot workflow. Minor gaps exist around unpublish, dist-tag/latest management, and scoped/registry selection, but agents can work around these.

Maintenance

ActivityInactive
ResponsivenessSyncing