npm-run-mcp-server 0.2.11 β†’ 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +74 -257
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,121 +2,35 @@
2
2
 
3
3
  <div align="center">
4
4
 
5
- *A Model Context Protocol (MCP) server that exposes your project's `package.json` scripts as tools for AI agents.*
5
+ *Give your AI Agent the power to build, test, and deploy your project using your existing package.json scripts.*
6
6
 
7
7
  [![Test](https://github.com/fstubner/npm-run-mcp-server/workflows/Test/badge.svg)](https://github.com/fstubner/npm-run-mcp-server/actions/workflows/test.yml)
8
8
  [![Build & Publish](https://github.com/fstubner/npm-run-mcp-server/workflows/Build%20&%20Publish/badge.svg)](https://github.com/fstubner/npm-run-mcp-server/actions/workflows/build-and-publish.yml)
9
9
  [![NPM Version](https://img.shields.io/npm/v/npm-run-mcp-server.svg)](https://www.npmjs.com/package/npm-run-mcp-server)
10
- [![NPM Installs](https://img.shields.io/npm/dt/npm-run-mcp-server.svg)](https://www.npmjs.com/package/npm-run-mcp-server)
10
+ [![MCP Registry](https://img.shields.io/badge/MCP%20Registry-Listed-blue)](https://modelcontextprotocol.io/registry)
11
11
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
12
12
 
13
13
  </div>
14
14
 
15
+ **npm-run-mcp-server** is a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server that automatically bridges your project's `npm` scripts to your AI assistant.
15
16
 
17
+ - πŸ” **Auto-detects** your project's `package.json` (no hardcoded paths).
18
+ - πŸ“¦ **Works with everything**: npm, pnpm, yarn, and bun.
19
+ - πŸ”’ **Safe & Configurable**: Whitelist specific scripts to prevent accidental execution.
20
+ - ⚑ **Zero-config**: Works out of the box, but scales with detailed config.
16
21
 
17
- ## Table of Contents
22
+ ---
18
23
 
19
- - [Install](#install)
20
- - [Usage](#usage)
21
- - [As an MCP Server](#as-an-mcp-server)
22
- - [As a CLI Tool](#as-a-cli-tool)
23
- - [Configuration](#configuration)
24
- - [GitHub Copilot (VS Code)](#github-copilot-vs-code)
25
- - [Cursor](#cursor)
26
- - [Claude Code](#claude-code)
27
- - [Multi-Project Workflow](#multi-project-workflow)
28
- - [Auto-Restart on Script Changes](#auto-restart-on-script-changes)
29
- - [Script Exposure Config](#script-exposure-config)
30
- - [Install from source](#install-from-source)
31
- - [Testing with MCP Inspector](#testing-with-mcp-inspector)
32
- - [CLI Options](#cli-options)
33
- - [Contributing](#contributing)
34
- - [Reporting Issues](#reporting-issues)
35
- - [Submitting Changes](#submitting-changes)
36
- - [Development Setup](#development-setup)
37
- - [License](#license)
24
+ ## ⚑ Quick Start
38
25
 
39
- ## Install
26
+ Connect your agent to your scripts in seconds. No global installation requiredβ€”just let `npx` handle it.
40
27
 
41
- Installation options.
42
-
43
- ```bash
44
- npm i -D npm-run-mcp-server
45
- # or globally
46
- npm i -g npm-run-mcp-server
47
- # ad-hoc
48
- npx npm-run-mcp-server
49
- ```
50
-
51
- ## Usage
52
-
53
- MCP server and CLI tool usage.
54
-
55
- ### As an MCP Server
56
-
57
- Add this server to your MCP host configuration. It uses stdio and automatically detects your project's `package.json` using workspace environment variables or by walking up from the current working directory.
58
-
59
- **Key Features:**
60
- - **Automatic Workspace Detection**: Works seamlessly across different projects without configuration changes
61
- - **Smart Tool Names**: Script names with colons (like `test:unit`) are automatically converted to valid tool names (`test_unit`)
62
- - **Rich Descriptions**: Each tool includes the actual script command in its description
63
- - **Package Manager Detection**: Automatically detects npm, pnpm, yarn, or bun
64
- - **Optional Arguments**: Each tool accepts optional `args` (`string` or `string[]`) appended after `--` when running the script
65
- - **Auto-Restart on Changes**: Automatically restarts when `package.json` or config changes, ensuring tools are always up-to-date
66
-
67
- Note: scripts run inside the target project. If they rely on local dependencies (eslint, vitest, tsc), install them first (for example, `npm install`).
68
-
69
- ### As a CLI Tool
70
-
71
- You can also use this package directly from the command line:
72
-
73
- ```bash
74
- # List available scripts in current directory
75
- npx npm-run-mcp-server --list-scripts
76
-
77
- # Run with verbose output
78
- npx npm-run-mcp-server --verbose
79
-
80
- # Specify a different working directory
81
- npx npm-run-mcp-server --cwd /path/to/project --list-scripts
82
-
83
- # Override package manager detection
84
- npx npm-run-mcp-server --pm yarn --list-scripts
85
-
86
- # Use an explicit config file (relative to the project directory, or absolute)
87
- npx npm-run-mcp-server --cwd /path/to/project --config npm-run-mcp.config.json --verbose
88
- ```
89
-
90
- ## Configuration
91
-
92
- Setup instructions for AI agents.
93
-
94
- ### GitHub Copilot (VS Code)
95
-
96
- #### Via UI
97
- 1. Open VS Code settings
98
- 2. Search for "MCP"
99
- 3. Add server configuration in settings.json
100
-
101
- #### Via Config File
102
- Option A β€” per-workspace via `.vscode/mcp.json` (recommended for multi-project use):
103
-
104
- ```json
105
- {
106
- "servers": {
107
- "npm-scripts": {
108
- "command": "npx",
109
- "args": ["-y", "npm-run-mcp-server"]
110
- }
111
- }
112
- }
113
- ```
114
-
115
- Option B β€” user settings (`settings.json`):
28
+ ### Claude Desktop
29
+ Add this to your `claude_desktop_config.json`:
116
30
 
117
31
  ```json
118
32
  {
119
- "mcp.servers": {
33
+ "mcpServers": {
120
34
  "npm-scripts": {
121
35
  "command": "npx",
122
36
  "args": ["-y", "npm-run-mcp-server"]
@@ -125,47 +39,21 @@ Option B β€” user settings (`settings.json`):
125
39
  }
126
40
  ```
127
41
 
128
- Then open Copilot Chat, switch to Agent mode, and start the `npm-scripts` server from the tools panel.
129
-
130
42
  ### Cursor
43
+ 1. Go to **Settings** > **Features** > **MCP Servers**.
44
+ 2. Click **+ Add New MCP Server**.
45
+ 3. Enter the details:
46
+ - **Type**: `command`
47
+ - **Name**: `npm-scripts`
48
+ - **Command**: `npx`
49
+ - **Args**: `-y npm-run-mcp-server`
131
50
 
132
- #### Via UI
133
- 1. Open Settings -> MCP Servers -> Add MCP Server
134
- 2. Type: NPX Package
135
- 3. Command: `npx`
136
- 4. Arguments: `-y npm-run-mcp-server`
137
- 5. Save and start the server from the tools list
138
-
139
- #### Via Config File
140
- Add to Cursor's MCP configuration:
141
-
142
- ```json
143
- {
144
- "servers": {
145
- "npm-scripts": {
146
- "command": "npx",
147
- "args": ["-y", "npm-run-mcp-server"]
148
- }
149
- }
150
- }
151
- ```
152
-
153
- ### Claude Code
154
-
155
- #### Via Terminal
156
- ```bash
157
- claude mcp add npm-scripts npx -y npm-run-mcp-server
158
- ```
159
-
160
- #### Via Config File
161
- Add to Claude Code's config file:
162
- - Windows: `%APPDATA%/Claude/claude_desktop_config.json`
163
- - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
164
- - Linux: `~/.config/Claude/claude_desktop_config.json`
51
+ ### VS Code (GitHub Copilot)
52
+ Add this to your workspace `.vscode/settings.json`:
165
53
 
166
54
  ```json
167
55
  {
168
- "mcpServers": {
56
+ "github.copilot.chat.mcpServers": {
169
57
  "npm-scripts": {
170
58
  "command": "npx",
171
59
  "args": ["-y", "npm-run-mcp-server"]
@@ -174,44 +62,24 @@ Add to Claude Code's config file:
174
62
  }
175
63
  ```
176
64
 
177
- Restart Claude Code after editing the config.
178
-
179
- ### Multi-Project Workflow
180
-
181
- The MCP server automatically detects your project's `package.json` using workspace environment variables or by walking up from the current working directory. No hardcoded paths needed - it works seamlessly across all your projects.
182
-
183
- ### Auto-Restart on Script Changes
184
-
185
- The server automatically monitors your `package.json` file (and `npm-run-mcp.config.json` if present) for changes. When you modify scripts or config, the server gracefully exits to allow the MCP client to restart with updated tools.
65
+ ---
186
66
 
187
- ### Script Exposure Config
67
+ ## πŸ› οΈ Configuration
188
68
 
189
- You can make the tool surface more deterministic by explicitly choosing which scripts are exposed and by defining per-script tool metadata.
69
+ While `npm-run-mcp-server` works instantly, you might not want your AI to have access to *every* script (like `eject` or `publish`). You can control this by creating an `npm-run-mcp.config.json` file in your project root.
190
70
 
191
- Create `npm-run-mcp.config.json` (or `.npm-run-mcp.json`) next to your project's `package.json`:
71
+ ### Example Config
72
+ Create `npm-run-mcp.config.json` next to your `package.json`:
192
73
 
193
74
  ```json
194
75
  {
195
- "include": ["build", "lint", "test:unit"],
196
- "exclude": ["dev", "test:e2e"],
76
+ "include": ["test", "lint", "build", "start"],
197
77
  "scripts": {
198
- "test:unit": {
199
- "toolName": "test_unit",
200
- "description": "Run unit tests",
78
+ "test": {
79
+ "description": "Run the test suite. Use --watch for interactive mode.",
201
80
  "inputSchema": {
202
- "type": "object",
203
81
  "properties": {
204
- "watch": { "type": "boolean" },
205
- "run": { "type": "boolean" }
206
- }
207
- }
208
- },
209
- "lint": {
210
- "description": "Lint the codebase",
211
- "inputSchema": {
212
- "type": "object",
213
- "properties": {
214
- "fix": { "type": "boolean" }
82
+ "watch": { "type": "boolean", "description": "Watch files for changes" }
215
83
  }
216
84
  }
217
85
  }
@@ -219,117 +87,66 @@ Create `npm-run-mcp.config.json` (or `.npm-run-mcp.json`) next to your project's
219
87
  }
220
88
  ```
221
89
 
222
- Notes:
223
- - `include` and `exclude` are exact script names.
224
- - `toolName` lets you resolve naming collisions after sanitization.
225
- - `inputSchema` extends the default input model (and `args` is always available).
226
- - Tool input fields (other than `args`) are converted to CLI flags, e.g. `{ "watch": true }` becomes `--watch` and `{ "port": 3000 }` becomes `--port 3000`.
227
- - If filters result in zero tools, the server logs a warning so misconfigurations are easy to spot.
228
- - Config files support JSONC (comments + trailing commas). A JSON Schema is published as `npm-run-mcp.config.schema.json`.
90
+ ### Configuration Options
229
91
 
230
- ### Install from source (for testing in another project)
92
+ | Field | Type | Description |
93
+ |-------|------|-------------|
94
+ | `include` | `string[]` | Whitelist of script names to expose. If omitted, *all* scripts are exposed. |
95
+ | `exclude` | `string[]` | Blacklist of script names to hide. |
96
+ | `scripts` | `object` | Detailed configuration for specific scripts. |
231
97
 
232
- Clone, build, and link globally:
98
+ #### Per-Script Options
99
+ Inside the `scripts` object, you can map a script name to:
233
100
 
234
- ```bash
235
- git clone https://github.com/your-org-or-user/npm-run-mcp-server.git
236
- cd npm-run-mcp-server
237
- npm install
238
- npm run build
239
- npm link
240
- ```
101
+ - `toolName`: Override the tool name seen by the AI (e.g., rename `test:unit` to `run_unit_tests`).
102
+ - `description`: Provide a custom description to help the AI understand when to use this script.
103
+ - `inputSchema`: Define strictly typed arguments that the AI can pass (mapped to CLI flags).
241
104
 
242
- In your other project, either reference the global binary or the built file directly:
243
-
244
- - Using the linked binary:
245
-
246
- ```json
247
- {
248
- "servers": {
249
- "npm-scripts": {
250
- "command": "npm-run-mcp-server"
251
- }
252
- }
253
- }
254
- ```
105
+ ---
255
106
 
256
- - Using an explicit Node command (no global link needed):
107
+ ## πŸ“– How It Works
257
108
 
258
- ```json
259
- {
260
- "servers": {
261
- "npm-scripts": {
262
- "command": "node",
263
- "args": ["/absolute/path/to/npm-run-mcp-server/dist/index.js"]
264
- }
265
- }
266
- }
267
- ```
109
+ 1. **Auto-Detection**: When the server starts, it looks for a `package.json` in your current workspace. It supports standard formatting as well as `npm`, `pnpm`, `yarn`, and `bun` conventions.
110
+ 2. **Tool Creation**: It converts your scripts into MCP Tools.
111
+ - Scripts like `test:unit` become tools like `test_unit`.
112
+ - The tool description includes the actual command (e.g., `vitest run`) so the AI knows what it's running.
113
+ 3. **Execution**: When the AI calls a tool, the server executes the script in your project's root directory using the detected package manager.
268
114
 
269
- Optional CLI flags you can pass in `args`:
270
- - `--cwd /path/to/project` to choose which project to read `package.json` from (rarely needed - server auto-detects by default)
271
- - `--pm npm|pnpm|yarn|bun` to override package manager detection
115
+ ---
272
116
 
273
- ## Testing with MCP Inspector
117
+ ## πŸ”§ Advanced / CLI Usage
274
118
 
275
- Test the server locally.
119
+ You can run the server manually for debugging or if you need to pass specific flags.
276
120
 
277
121
  ```bash
278
- # Start MCP Inspector
279
- npx @modelcontextprotocol/inspector
280
-
281
- # In the Inspector UI:
282
- # 1. Transport Type: STDIO
283
- # 2. Command: npx
284
- # 3. Arguments: npm-run-mcp-server --cwd /path/to/your/project --verbose
285
- # 4. Click "Connect"
286
- ```
287
-
288
- You should see your package.json scripts listed as available tools. Try running one - it executes the script and returns the output.
289
-
290
- ## CLI Options
291
-
292
- Command-line flags.
293
-
294
- - `--cwd <path>` - Specify working directory (defaults to current directory)
295
- - `--config <path>` - Use an explicit config file path (relative to the project directory, or absolute)
296
- - `--pm <manager>` - Override package manager detection (npm|pnpm|yarn|bun)
297
- - `--verbose` - Enable detailed logging to stderr
298
- - `--list-scripts` - List available scripts and exit
299
-
300
- ## Contributing
301
-
302
- Contributions welcome! How to help with development, reporting issues, and submitting changes.
303
-
304
- ### Reporting Issues
122
+ # Run directly
123
+ npx npm-run-mcp-server --list-scripts
305
124
 
306
- - Use the [issue tracker](https://github.com/fstubner/npm-run-mcp-server/issues) to report bugs
307
- - Include your Node.js version, package manager, and operating system
308
- - Provide a minimal reproduction case when possible
125
+ # Run in a specific directory
126
+ npx npm-run-mcp-server --cwd /path/to/project
309
127
 
310
- ### Submitting Changes
128
+ # Force a specific package manager
129
+ npx npm-run-mcp-server --pm pnpm
130
+ ```
311
131
 
312
- 1. **Fork** the repository
313
- 2. **Create** a feature branch: `git checkout -b feature/amazing-feature`
314
- 3. **Make** your changes and add tests if applicable
315
- 4. **Test** your changes: `npm run build && npm run test`
316
- 5. **Commit** your changes: `git commit -m 'Add amazing feature'`
317
- 6. **Push** to the branch: `git push origin feature/amazing-feature`
318
- 7. **Submit** a pull request
132
+ ### CLI Flags
133
+ - `--cwd <path>`: Manually set the working directory.
134
+ - `--pm <npm|pnpm|yarn|bun>`: Force a specific package manager.
135
+ - `--config <path>`: Path to a specific JSON config file.
136
+ - `--verbose`: Print debug logs to stderr.
319
137
 
320
- ### Development Setup
138
+ ---
321
139
 
322
- ```bash
323
- git clone https://github.com/fstubner/npm-run-mcp-server.git
324
- cd npm-run-mcp-server
325
- npm install
326
- npm run build
327
- npm run test
328
- ```
140
+ ## 🀝 Contributing
329
141
 
330
- The project uses a custom build script located in `scripts/build.cjs` that handles TypeScript compilation and shebang injection for the executable.
142
+ Contributions are welcome! Please feel free to submit a Pull Request.
331
143
 
144
+ 1. Fork the repo.
145
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`).
146
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`).
147
+ 4. Push to the branch (`git push origin feature/amazing-feature`).
148
+ 5. Open a Pull Request.
332
149
 
333
150
  ## License
334
151
 
335
- MIT License.
152
+ MIT Β© [fstubner](https://github.com/fstubner)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-run-mcp-server",
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
4
4
  "mcpName": "io.github.fstubner/npm-run-mcp-server",
5
5
  "description": "An MCP server that exposes package.json scripts as tools for agents.",
6
6
  "bin": {