diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..05384e6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +dist +node_modules +.vscode +.github +.git +# Environment variables +.env + +tests +coverage +scripts diff --git a/.smithery/Dockerfile b/.smithery/Dockerfile new file mode 100644 index 0000000..f34e2ab --- /dev/null +++ b/.smithery/Dockerfile @@ -0,0 +1,30 @@ +# Generated by https://smithery.ai. See: https://smithery.ai/docs/config#dockerfile +# ----- Build Stage ----- +FROM node:lts-alpine AS builder +WORKDIR /app + +# Copy package and configuration +COPY ../package.json ../package-lock.json ../tsconfig.json ../tsconfig.build.json ./ + +# Copy source code +COPY ../src ./src + +# Install dependencies and build +RUN npm ci && npm run build + +# ----- Production Stage ----- +FROM node:lts-alpine + +# Copy built artifacts +COPY --from=builder /app/dist ./dist + +# Copy package.json for production install +COPY ../package.json package-lock.json ./ + +# Install only production dependencies +RUN npm ci --production --ignore-scripts + +# Expose no ports (stdio only) + +# Default command +CMD ["node", "dist/index.js"] diff --git a/.smithery/smithery.yaml b/.smithery/smithery.yaml new file mode 100644 index 0000000..e7de81b --- /dev/null +++ b/.smithery/smithery.yaml @@ -0,0 +1,63 @@ +# Smithery.ai configuration +build: + dockerfile: Dockerfile + dockerBuildPath: ../ +startCommand: + type: stdio + configSchema: + type: object + properties: + atlasClientId: + type: string + title: Atlas Client Id + description: Atlas API client ID for authentication. Required for running Atlas tools. + atlasClientSecret: + type: string + title: Atlas Client Secret + description: Atlas API client secret for authentication. Required for running Atlas tools. + connectionString: + type: string + title: MongoDB Connection string + description: MongoDB connection string for direct database connections. Optional, if not set, you'll need to call the `connect` tool before interacting with MongoDB data. + readOnly: + type: boolean + title: Read-only + description: When set to true, only allows read and metadata operation types, disabling create/update/delete operations. + default: false + exampleConfig: + atlasClientId: YOUR_ATLAS_CLIENT_ID + atlasClientSecret: YOUR_ATLAS_CLIENT_SECRET + connectionString: mongodb+srv://USERNAME:PASSWORD@YOUR_CLUSTER.mongodb.net + readOnly: true + + commandFunction: + # A function that produces the CLI command to start the MCP on stdio. + |- + (config) => { + const args = ['dist/index.js']; + if (config) { + if (config.atlasClientId) { + args.push('--apiClientId'); + args.push(config.atlasClientId); + } + + if (config.atlasClientSecret) { + args.push('--apiClientSecret'); + args.push(config.atlasClientSecret); + } + + if (config.readOnly) { + args.push('--readOnly'); + } + + if (config.connectionString) { + args.push('--connectionString'); + args.push(config.connectionString); + } + } + + return { + command: "node", + args + }; + } diff --git a/README.md b/README.md index 3783d3e..4364dbc 100644 --- a/README.md +++ b/README.md @@ -253,15 +253,15 @@ The MongoDB MCP Server can be configured using multiple methods, with the follow ### Configuration Options -| Option | Description | -| ------------------ | --------------------------------------------------------------------------------------------------------------------- | -| `apiClientId` | Atlas API client ID for authentication | -| `apiClientSecret` | Atlas API client secret for authentication | -| `connectionString` | MongoDB connection string for direct database connections (optional users may choose to inform it on every tool call) | -| `logPath` | Folder to store logs | -| `disabledTools` | An array of tool names, operation types, and/or categories of tools that will be disabled | -| `readOnly` | When set to true, only allows read and metadata operation types, disabling create/update/delete operations | -| `telemetry` | When set to disabled, disables telemetry collection | +| Option | Description | +| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `apiClientId` | Atlas API client ID for authentication. Required for running Atlas tools. | +| `apiClientSecret` | Atlas API client secret for authentication. Required for running Atlas tools. | +| `connectionString` | MongoDB connection string for direct database connections. Optional, if not set, you'll need to call the `connect` tool before interacting with MongoDB data. | +| `logPath` | Folder to store logs. | +| `disabledTools` | An array of tool names, operation types, and/or categories of tools that will be disabled. | +| `readOnly` | When set to true, only allows read and metadata operation types, disabling create/update/delete operations. | +| `telemetry` | When set to disabled, disables telemetry collection. | #### Log Path