Skip to content

fix: use ENTRYPOINT and CMD for proper argument handling #454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

JAORMX
Copy link
Contributor

@JAORMX JAORMX commented May 30, 2025

Problem

The current Dockerfile uses CMD ["./github-mcp-server", "stdio"] which causes issues when container orchestration tools try to append additional arguments. This results in the entire CMD being replaced rather than arguments being appended.

Root Cause

When using only CMD, container runtimes replace the entire command when additional arguments are provided. This breaks argument passing in tools like ToolHive, Kubernetes, and other container orchestrators.

Solution

Implement Docker best practices by using:

  • ENTRYPOINT for the executable that should always run
  • CMD for default arguments that can be overridden/appended to

Changes

Before:

CMD ["./github-mcp-server", "stdio"]

After:

ENTRYPOINT ["./github-mcp-server"]
CMD ["stdio"]

Benefits

  1. Proper argument handling: Additional arguments are appended to the default stdio argument instead of replacing the entire command
  2. Container orchestration compatibility: Works correctly with Kubernetes, Docker Compose, and other tools
  3. Backward compatibility: Default behavior remains the same when no arguments are provided
  4. Docker best practices: Follows recommended patterns for containerized applications

Testing

This change maintains backward compatibility:

  • docker run github-mcp-server → runs ./github-mcp-server stdio (same as before)
  • docker run github-mcp-server --toolsets all → runs ./github-mcp-server --toolsets all (new capability)

Related Issues

This fixes argument passing issues reported in container orchestration tools where additional arguments couldn't be properly passed to the MCP server.

- Change from CMD to ENTRYPOINT + CMD pattern for better Docker practices
- ENTRYPOINT sets the executable that always runs
- CMD provides default arguments that can be overridden
- This allows container runtimes to properly append additional arguments
- Fixes issues with argument passing in container orchestration tools

Before: CMD ["./github-mcp-server", "stdio"]
After: ENTRYPOINT ["./github-mcp-server"] + CMD ["stdio"]
@Copilot Copilot AI review requested due to automatic review settings May 30, 2025 08:14
@JAORMX JAORMX requested a review from a team as a code owner May 30, 2025 08:14
Copy link
Contributor

@Copilot 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

Switch from a single CMD to using ENTRYPOINT plus a default CMD in the Dockerfile to enable proper argument appending.

  • Introduce ENTRYPOINT for the server binary
  • Keep default stdio argument in CMD
  • Update comments to reflect the change

@SamMorrowDrums
Copy link
Collaborator

This is great, would you mind updating the README.me so that any suggested commands are correct for this change?

@JAORMX
Copy link
Contributor Author

JAORMX commented May 30, 2025

@SamMorrowDrums can you explain a little more? I'm not sure anything would need to change from the README

@SamMorrowDrums
Copy link
Collaborator

I haven't double checked, if we don't suggest anything that would need to change that's no problem.

@JAORMX
Copy link
Contributor Author

JAORMX commented May 30, 2025

@SamMorrowDrums right! the idea is that nothing changes. But this enables for orchestration platforms to actually be able to pass parameters in an easier way. This wasn't part of the README before, so there was nothing to change.

@SamMorrowDrums
Copy link
Collaborator

The kind of things I was think were additional arguments in the docs like --export-translations which would change from be ./github-mcp-server stdio --export-translations to stdio --export-translations if I understand correctly?

Maybe we don't explicitly spell any of them out. I've definitely provided such commands via issues, but that's all I wanted to ensure. I think fortunately the docs are lacking enough that you don't have anything to update.

@JAORMX
Copy link
Contributor Author

JAORMX commented Jun 2, 2025

@SamMorrowDrums I can check out the README to add/modify examples. Mind if I do that in a separate PR?

@JAORMX
Copy link
Contributor Author

JAORMX commented Jun 2, 2025

@SamMorrowDrums for now, without this fix, we can't pass command line arguments to the GitHub MCP server with ToolHive and Kubernetes.

@SamMorrowDrums SamMorrowDrums merged commit 63d3d8c into github:main Jun 2, 2025
9 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.

2 participants