Skip to content

Dockerise the MCP Run Python server (#1837) #2090

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rohit133
Copy link

Summary

This adds Docker support for the MCP Run Python server and sets up automated Docker image publishing via GitHub Actions.

Changes

Dockerfile:
  • Adds a Dockerfile to run the MCP Run Python server using the official Deno image.
  • Default command runs the server in SSE mode on port 3101, suitable for MCP client integration.

GitHub Actions Workflow:

  • Adds docker-publish.yml to build and publish the Docker image to Docker Hub (or another registry) on push to main.
  • Requires DOCKERHUB_USERNAME and DOCKERHUB_TOKEN secrets to be set in the repository.

Test Client:

  • Adds test_mcp_client.py to verify the server is running and can execute Python code via the MCP protocol.

How to test

  1. Build and run the Docker image:
docker build -t mcp-run-python ./mcp-run-python
docker run -d -p 3101:3101 mcp-run-python
  1. Run the test client:
python3 mcp-run-python/test_mcp_client.py

You should see:

<status>success</status>
<output>
   hello world
</output>

@rohit133 rohit133 changed the title Dockerise the MCP Run Python server (#1837) Dockerise the MCP Run Python server (#1837)[https://github.com/pydantic/pydantic-ai/issues/1837] Jun 27, 2025
@rohit133 rohit133 changed the title Dockerise the MCP Run Python server (#1837)[https://github.com/pydantic/pydantic-ai/issues/1837] Dockerise the MCP Run Python server (#1837) Jun 27, 2025
@Kludex
Copy link
Member

Kludex commented Jun 27, 2025

I think we can publish the images on github instead of dockerhub.

@rohit133
Copy link
Author

I think we can publish the images on github instead of dockerhub.

I have updated it to publish the images on GitHub.

@Kludex Kludex requested a review from Copilot July 15, 2025 11:46
Copy link

@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

Adds Docker support and CI workflow for the MCP Run Python server and introduces an integration test client.

  • Introduces a Dockerfile to containerize the MCP Run Python server using the official Deno image.
  • Adds a GitHub Actions workflow to build and publish the Docker image on push to main.
  • Adds an integration test client (test_mcp_client.py) to verify the server functionality.

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

File Description
mcp-run-python/test_mcp_client.py Adds a simple client script to verify server SSE endpoint behavior
mcp-run-python/deno.json Updates nodeModulesDir configuration value
mcp-run-python/Dockerfile New Dockerfile for building and running the server container
.github/workflows/docker-publish.yml Workflow to build and push the Docker image
Comments suppressed due to low confidence (3)

.github/workflows/docker-publish.yml:19

  • The workflow logs in to GitHub Container Registry but tags the image for Docker Hub. Replace this step with a Docker Hub login using docker/login-action and the DOCKERHUB_USERNAME and DOCKERHUB_TOKEN secrets.
      - name: Login to GitHub Container Registry

.github/workflows/docker-publish.yml:30

  • The tag yourdockerhubuser/mcp-run-python:latest is a placeholder. Update this to use your actual Docker Hub namespace or use a matrix/secret to avoid manual edits.
          tags: yourdockerhubuser/mcp-run-python:latest

mcp-run-python/test_mcp_client.py:14

  • The test client only prints the output instead of asserting the expected values. Consider adding assertions (e.g., using assert content.text == 'hello world') so failures are detected automatically.
                print(content.text)

EXPOSE 3101

# Default command: run MCP Run Python server in SSE mode with health check endpoint
CMD ["run", "-N", "-R=node_modules", "-W=node_modules", "--node-modules-dir=auto", "jsr:@pydantic/mcp-run-python", "sse", "--port=3101"]
Copy link
Preview

Copilot AI Jul 15, 2025

Choose a reason for hiding this comment

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

The Deno server needs explicit network permissions to serve requests. Add --allow-net=0.0.0.0:3101 (or --allow-net) to the run command so the container can accept incoming connections.

Suggested change
CMD ["run", "-N", "-R=node_modules", "-W=node_modules", "--node-modules-dir=auto", "jsr:@pydantic/mcp-run-python", "sse", "--port=3101"]
CMD ["run", "--allow-net=0.0.0.0:3101", "-N", "-R=node_modules", "-W=node_modules", "--node-modules-dir=auto", "jsr:@pydantic/mcp-run-python", "sse", "--port=3101"]

Copilot uses AI. Check for mistakes.

WORKDIR /app

# Copy all files into the container
COPY . .
Copy link
Preview

Copilot AI Jul 15, 2025

Choose a reason for hiding this comment

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

[nitpick] Copying the entire context can bloat the image. Consider adding a .dockerignore to exclude unnecessary files (e.g., tests, local configs) and reduce build time and image size.

Copilot uses AI. Check for mistakes.

- Add --allow-net to Dockerfile CMD for Deno network access
- Add .dockerignore to reduce image size and exclude unneeded files
- Update GitHub Actions workflow to publish to GitHub Container Registry (GHCR)
- Improve integration test client with assertions for automated validation
@rohit133 rohit133 force-pushed the dockerize-mcp-run-python branch from f6f4739 to e6c0fd6 Compare July 21, 2025 06:29
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