Skip to content
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

Deployment: Dockerfile and Smithery config #3

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by https://smithery.ai. See: https://smithery.ai/docs/config#dockerfile
# Use a Node.js image with a specific version that supports TypeScript
FROM node:18-alpine AS builder

# Create app directory
WORKDIR /usr/src/app

# Copy package.json and package-lock.json for dependency installation
COPY package.json package-lock.json ./

# Install the dependencies
RUN npm install

# Copy the rest of the application code
COPY . .

# Build the TypeScript code
RUN npm run build

# Use a smaller Node.js image to reduce the size of the final image
FROM node:18-alpine AS release

# Create app directory
WORKDIR /usr/src/app

# Copy the compiled code from the builder stage
COPY --from=builder /usr/src/app/dist ./dist
COPY package.json ./

# Install only production dependencies
RUN npm install --production

# Specify the command to run the MCP server
ENTRYPOINT ["node", "dist/index.js"]
Comment on lines +1 to +34
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add security and best practices to Dockerfile.

Consider the following improvements:

  1. Create a non-root user for security
  2. Add health check
  3. Clean npm cache
  4. Add .dockerignore
 FROM node:18-alpine AS builder
+# Add non-root user
+RUN addgroup -S appgroup && adduser -S appuser -G appgroup
 
 WORKDIR /usr/src/app
+USER appuser
 
 COPY package.json package-lock.json ./
 
-RUN npm install
+RUN npm ci && npm cache clean --force
 
 COPY . .
 
 RUN npm run build
 
 FROM node:18-alpine AS release
+# Add non-root user
+RUN addgroup -S appgroup && adduser -S appuser -G appgroup
 
 WORKDIR /usr/src/app
+USER appuser
 
 COPY --from=builder /usr/src/app/dist ./dist
 COPY package.json ./
 
-RUN npm install --production
+RUN npm ci --only=production && npm cache clean --force
 
+# Add health check
+HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
+  CMD node -e "require('http').get('http://localhost:${PORT}/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1))"
+
 ENTRYPOINT ["node", "dist/index.js"]

Also create a .dockerignore file:

node_modules
npm-debug.log
Dockerfile
.dockerignore
.git
.gitignore
README.md

Committable suggestion skipped: line range outside the PR's diff.

9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue.svg)](https://www.typescriptlang.org/)
[![Model Context Protocol](https://img.shields.io/badge/MCP-Compatible-green.svg)](https://github.com/modelcontextprotocol)
[![smithery badge](https://smithery.ai/badge/@tokenizin/mcp-npx-fetch)](https://smithery.ai/server/@tokenizin/mcp-npx-fetch)

A powerful MCP server for fetching and transforming web content into various formats (HTML, JSON, Markdown, Plain Text) with ease.

Expand All @@ -32,6 +33,14 @@ A powerful MCP server for fetching and transforming web content into various for

## 📦 Installation

### Installing via Smithery

To install NPX Fetch for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@tokenizin/mcp-npx-fetch):

```bash
npx -y @smithery/cli install @tokenizin/mcp-npx-fetch --client claude
```

### NPM Global Installation

```bash
Expand Down
11 changes: 11 additions & 0 deletions smithery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Smithery configuration file: https://smithery.ai/docs/config#smitheryyaml

startCommand:
type: stdio
configSchema:
# JSON Schema defining the configuration options for the MCP.
type: object
Comment on lines +5 to +7
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance config schema with required properties and validation.

The current schema is too basic. Consider adding:

  • Required properties for configuration
  • Property types and validation rules
  • Environment variable validation

Example schema:

  configSchema:
    type: object
+   required: []
+   properties:
+     port:
+       type: number
+       description: "Port to run the server on"
+       default: 3000
+     logLevel:
+       type: string
+       enum: ["debug", "info", "warn", "error"]
+       default: "info"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
configSchema:
# JSON Schema defining the configuration options for the MCP.
type: object
configSchema:
# JSON Schema defining the configuration options for the MCP.
type: object
required: []
properties:
port:
type: number
description: "Port to run the server on"
default: 3000
logLevel:
type: string
enum: ["debug", "info", "warn", "error"]
default: "info"

commandFunction:
# A function that produces the CLI command to start the MCP on stdio.
|-
config => ({command: 'node', args: ['dist/index.js']})