Skip to content

Deployment: Dockerfile and Smithery config #3

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 5, 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
23 changes: 13 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
# Generated by https://smithery.ai. See: https://smithery.ai/docs/config#dockerfile
FROM golang:1.23-alpine AS builder
FROM golang:alpine AS builder

# Install git for module fetching
RUN apk add --no-cache git

WORKDIR /app

# Copy go.mod and go.sum first for caching dependencies
# Cache Go modules
COPY go.mod go.sum ./

# Download dependencies
RUN go mod download

# Copy the source code
COPY . .

# Build the application
RUN go build -ldflags="-s -w" -o server .
# Build the MCP server binary
RUN go build -o mcp-filesystem-server main.go

FROM alpine:latest

WORKDIR /app

# Copy the built binary from the builder stage
COPY --from=builder /app/server ./
COPY --from=builder /app/mcp-filesystem-server ./

# Create a directory that will be used as allowed directory
RUN mkdir -p /app

# The container will by default pass '/app' as the allowed directory if no other command line arguments are provided
ENTRYPOINT ["./server"]
CMD ["/app"]
# CMD to run the MCP server
CMD ["./mcp-filesystem-server"]
27 changes: 17 additions & 10 deletions smithery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,28 @@ startCommand:
# JSON Schema defining the configuration options for the MCP.
type: object
required:
- allowedDirectory
- allowedDirectories
properties:
allowedDirectory:
type: string
description: The absolute path to an allowed directory for the filesystem
server. For example, in the Docker container '/app' is a good default.
additionalDirectories:
allowedDirectories:
type: array
items:
type: string
description: Optional additional allowed directories.
description: List of allowed directories that the MCP server is permitted to access.
default:
allowedDirectories:
- /app
description: Configuration for allowed directories to access by the filesystem
MCP server.
commandFunction:
# A JS function that produces the CLI command based on the given config to start the MCP on stdio.
|-
(config) => { const args = [config.allowedDirectory]; if (config.additionalDirectories && Array.isArray(config.additionalDirectories)) { args.push(...config.additionalDirectories); } return { command: './server', args: args }; }
(config) => {
// Build the command to run the filesystem MCP server using allowed directories that exist in the container.
return {
command: './mcp-filesystem-server',
args: config.allowedDirectories
};
}
exampleConfig:
allowedDirectory: /app
additionalDirectories: []
allowedDirectories:
- /app