Skip to content

Add local docker container support to smithery.yaml configuration #22

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

Merged
merged 3 commits into from
Mar 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY src/ /app/src

# Set environment variables for MySQL (these can be overwritten with `docker run -e`)
ENV MYSQL_HOST=localhost
ENV MYSQL_HOST=host.docker.internal
ENV MYSQL_PORT=3306
ENV MYSQL_USER=your_username
ENV MYSQL_PASSWORD=your_password
ENV MYSQL_DATABASE=your_database
ENV PYTHONPATH=/app/src

# Command to run the server
CMD ["python", "-m", "mysql_mcp_server"]
CMD ["python", "-m", "mysql_mcp_server.server"]
29 changes: 23 additions & 6 deletions smithery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,41 @@ startCommand:
# JSON Schema defining the configuration options for the MCP.
type: object
required:
- mysqlHost
- mysqlUser
- mysqlPassword
- mysqlDatabase
properties:
mysqlHost:
type: string
description: The hostname of the MySQL server.
description: "The hostname of the MySQL server. Use localhost for local connections or a specific address for remote databases. For Docker, host.docker.internal allows accessing the host machine."
default: "host.docker.internal"
mysqlPort:
type: number
description: "The port of the MySQL server (default: 3306)."
default: 3306
mysqlUser:
type: string
description: The username for MySQL authentication.
description: "The username for MySQL authentication."
mysqlPassword:
type: string
description: The password for MySQL authentication.
description: "The password for MySQL authentication."
mysqlDatabase:
type: string
description: The database to connect to.
description: "The database to connect to."
commandFunction:
# A function that produces the CLI command to start the MCP on stdio.
|-
(config) => ({ command: 'python', args: ['-m', 'mysql_mcp_server'], env: { MYSQL_HOST: config.mysqlHost, MYSQL_USER: config.mysqlUser, MYSQL_PASSWORD: config.mysqlPassword, MYSQL_DATABASE: config.mysqlDatabase } })
(config) => ({
command: 'docker',
args: [
'run',
'-i',
'--rm',
'-e', `MYSQL_HOST=${config.mysqlHost}`,
'-e', `MYSQL_PORT=${config.mysqlPort}`,
'-e', `MYSQL_USER=${config.mysqlUser}`,
'-e', `MYSQL_PASSWORD=${config.mysqlPassword}`,
'-e', `MYSQL_DATABASE=${config.mysqlDatabase}`,
'smithery/mysql-mcp-server:latest'
]
})