Skip to content

Fix npx command execution by correcting bin entry point#30

Merged
a-25 merged 4 commits intomainfrom
copilot/fix-28-2
Sep 21, 2025
Merged

Fix npx command execution by correcting bin entry point#30
a-25 merged 4 commits intomainfrom
copilot/fix-28-2

Conversation

Copy link
Contributor

Copilot AI commented Sep 21, 2025

Fix for Server Not Starting When Used as MCP Server

The bin field in package.json was incorrectly pointing to dist/index.js (the MCP server entry point) instead of dist/cli/index.js (the CLI entry point). This caused the shell to try interpreting ES module import statements as shell commands when users ran npx ios-mcp-code-quality-server server, resulting in errors like:

/opt/homebrew/bin/ios-mcp-code-quality-server: line 1: import: command not found
/opt/homebrew/bin/ios-mcp-code-quality-server: line 2: import: command not found
...

The fix changes the bin field to point to the correct CLI entry point that can parse commands and route to the appropriate functionality:

"bin": {
  "ios-mcp-code-quality-server": "dist/cli/index.js"
}

This ensures that npx ios-mcp-code-quality-server server properly starts the MCP server through the CLI command parser, while maintaining backward compatibility with direct execution of node dist/index.js.

Changes Made:

  • Analyze the issue and understand the codebase
  • Update package.json bin field to point to correct CLI entry point (dist/cli/index.js)
  • Update version to 0.1.3 in package.json, package-lock.json, CLI source code, and tests
  • Test the fix by running the command locally - no more "import: command not found" errors
  • Validate that both CLI and server modes work correctly
  • Run existing tests to ensure no regression - all 183 tests pass

Verification:

  • ios-mcp-code-quality-server --help shows CLI help
  • ios-mcp-code-quality-server server --help shows server command help
  • ios-mcp-code-quality-server server starts the MCP server successfully
  • ios-mcp-code-quality-server --version shows version 0.1.3
  • ✅ Original MCP server entry point node dist/index.js still works
  • ✅ All existing tests continue to pass (183 tests)

Fixes #28.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits September 21, 2025 17:41
Co-authored-by: a-25 <6087455+a-25@users.noreply.github.com>
Co-authored-by: a-25 <6087455+a-25@users.noreply.github.com>
Copilot AI changed the title [WIP] Server does not start when used as MCP server Fix npx command execution by correcting bin entry point Sep 21, 2025
Copilot AI requested a review from a-25 September 21, 2025 17:46
{
"name": "ios-mcp-code-quality-server",
"version": "0.1.1",
"version": "0.1.2",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot: fix this version to 0.1.3. Fix the same version to package.json file as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated version to 0.1.3 in both package.json and package-lock.json, as well as in the CLI source code and tests. The fix is in commit 43fc15d.

@a-25
Copy link
Owner

a-25 commented Sep 21, 2025

@copilot: prove that the fix is working. Build the app, start it as server, catch output, check that localhost:3000 port is working, kill the process and check that it was killed.

…e, and tests

Co-authored-by: a-25 <6087455+a-25@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Sep 21, 2025

@copilot: prove that the fix is working. Build the app, start it as server, catch output, check that localhost:3000 port is working, kill the process and check that it was killed.

Fix verified working successfully:

Build: npm run build completed successfully ✓

Server startup: node dist/cli/index.js server --port 3000 started successfully ✓

  • Server logs: "Starting MCP server..." and "MCP Server started successfully"
  • Running on port 3000 in development mode

Port verification:

  • Port 3000 responding: HTTP 400 (expected MCP protocol response) ✓
  • Process listening: tcp6 :::3000 (PID 3361) ✓
  • MCP endpoint: Returns proper JSON-RPC error for missing session ID ✓

Process termination:

  • Server stopped gracefully with Ctrl+C ✓
  • Process no longer running: ps aux | grep returns nothing ✓
  • Port 3000 no longer listening ✓

CLI functionality:

  • --help shows proper CLI usage (no "import: command not found" errors) ✓
  • --version shows "0.1.3" ✓

The fix completely resolves the original npx execution issue. The bin field now correctly points to dist/cli/index.js which properly handles CLI commands including the server command.

@a-25 a-25 marked this pull request as ready for review September 21, 2025 19:32
Copilot AI review requested due to automatic review settings September 21, 2025 19:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Fixes the npx command execution by correcting the bin entry point from dist/index.js to dist/cli/index.js, which was causing "import: command not found" errors when users tried to run the CLI tool.

Key Changes:

  • Updated package.json bin field to point to the correct CLI entry point
  • Bumped version to 0.1.3 across the codebase
  • Updated corresponding test assertions to match the new version

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
package.json Corrected bin entry point from dist/index.js to dist/cli/index.js and bumped version to 0.1.3
src/cli/index.ts Updated CLI version string to match new package version
src/tests/cliIntegration.test.ts Updated test assertions to expect version 0.1.3 instead of 0.1.1

@a-25 a-25 merged commit c8b7294 into main Sep 21, 2025
5 checks passed
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.

Server does not start when used as MCP server

3 participants