Skip to content

feat: make MCP server publishable as standalone npm package#212

Merged
purupurupu merged 4 commits into
mainfrom
feature/mcp_server_package
Mar 25, 2026
Merged

feat: make MCP server publishable as standalone npm package#212
purupurupu merged 4 commits into
mainfrom
feature/mcp_server_package

Conversation

@purupurupu

Copy link
Copy Markdown
Owner

Summary

  • Add tsup build config to bundle the MCP server (rules engine + e2e helpers) into a self-contained dist/index.js while keeping runtime deps (playwright, @modelcontextprotocol/sdk, zod) external
  • Configure package.json for npm publish: bin, exports, files, engines, prepublishOnly
  • Detect missing Playwright browser and show helpful install instructions
  • Add shutdown guard to prevent resource leaks during in-flight tool calls
  • Inject package version at build time via tsup define
  • Rewrite README with npx usage, Claude Code / Cursor setup, and prerequisites

Closes #208

Verification

Check Result
pnpm build (root) Pass — extension + MCP server
pnpm test 1001 tests pass
pnpm lint / pnpm fmt Clean
MCP initialize response version: "0.0.1" correctly injected
list_rules tool call All 48 rules returned
npm pack --dry-run 3 files, 21.5 KB gzipped
Bundle contains all rules 49 registerRule calls, 44 rule IDs confirmed

Test plan

  • pnpm build from root builds both extension and MCP server
  • node mcp-server/dist/index.js starts and responds to MCP initialize
  • list_rules returns all registered rules
  • npm pack --dry-run in mcp-server/ shows only dist/, README.md, package.json
  • Verify npx playwright install chromium message appears when browser is missing

Enable the MCP server to be published as a standalone npm package
(css-noop-checker-mcp) runnable via npx. Bundle workspace imports
(rules engine, e2e helpers) into a self-contained dist/index.js
while keeping runtime deps external.

- Add tsup.config.ts with noExternal for workspace paths
- Remove "private: true", add bin/exports/files/engines fields
- Add prepublishOnly script to prevent publishing without build
- Inject package version at build time via define
Prepare the MCP server entry point for npx execution outside
the monorepo with better error handling and lifecycle management.

- Detect missing Playwright browser and show install instructions
- Add shutdown guard in getBrowser() to prevent resource leaks
- Inject version from package.json via __PKG_VERSION__ define
- Consolidate SIGINT/SIGTERM handlers to reduce duplication
- Skip grace period in shutdown when browser was never launched
- Move shuttingDown declaration above functions that reference it
Add comprehensive documentation for standalone npx usage including
Claude Code and Cursor setup instructions. Include root build script
integration so pnpm build from the monorepo also builds the MCP server.

- Add Prerequisites, Quick Start, and IDE setup sections
- Explain stdio server behavior for users new to MCP
- Chain MCP server build into root build script
Match the root package version since both share the same rules engine.
@purupurupu
purupurupu merged commit 71c5cad into main Mar 25, 2026
2 checks passed
@purupurupu
purupurupu deleted the feature/mcp_server_package branch March 25, 2026 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: make MCP server publishable as standalone npm package for npx usage

1 participant