Skip to content

Commit 7e3b60c

Browse files
committed
first commit
0 parents  commit 7e3b60c

52 files changed

Lines changed: 18713 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# User session data (mounted via volume, not needed in build context)
2+
user_data/
3+
4+
# Git files
5+
.git/
6+
.gitignore
7+
.gitattributes
8+
9+
# Python cache and virtual environments
10+
__pycache__/
11+
*.py[cod]
12+
*$py.class
13+
*.so
14+
.Python
15+
.venv/
16+
venv/
17+
ENV/
18+
env/
19+
*.egg-info/
20+
dist/
21+
build/
22+
23+
# IDE and editor files
24+
.idea/
25+
.vscode/
26+
.vs_code/
27+
*.swp
28+
*.swo
29+
*~
30+
.DS_Store
31+
32+
# Testing and coverage
33+
.pytest_cache/
34+
.coverage
35+
.coverage.*
36+
htmlcov/
37+
.tox/
38+
.mypy_cache/
39+
.ruff_cache/
40+
41+
# Documentation
42+
docs/
43+
*.md
44+
!README.md
45+
46+
# Config files with secrets (mounted via volume)
47+
config.json
48+
49+
# Excel templates (mounted via volume)
50+
excel_templates/*.xlsx
51+
excel_templates/templates.json
52+
53+
# Docker files
54+
docker-compose.yml
55+
Dockerfile
56+
.dockerignore
57+
58+
# Other artifacts
59+
context/
60+
AI_CHANGELOG.md
61+
CLAUDE.md
62+
.aider*
63+
notebooks/
64+
jupyter/
65+
mcp-chart-python/
66+
67+
# Build artifacts
68+
_build/
69+
*.log
70+

.github/workflows/tests.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Code Quality Checks
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
checks:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
13+
- name: Set up Python
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: '3.12'
17+
18+
- name: Install uv
19+
run: pip install uv
20+
21+
- name: Install dependencies
22+
run: |
23+
uv pip compile pyproject.toml -o requirements.txt
24+
uv pip compile pyproject.toml --extra dev -o requirements-dev.txt
25+
uv venv
26+
uv pip sync requirements.txt requirements-dev.txt
27+
28+
- name: Determine module name
29+
id: module
30+
run: |
31+
if [ -d "src" ]; then
32+
echo "name=src" >> $GITHUB_OUTPUT
33+
else
34+
MODULE_NAME=$(basename $(find . -maxdepth 1 -type d -not -path "*/\.*" -not -path "./tests" -not -path "./scripts" -not -path "./docker" -not -path "." | sort | head -1))
35+
echo "name=$MODULE_NAME" >> $GITHUB_OUTPUT
36+
fi
37+
38+
- name: Run Linter
39+
run: uv run -m ruff check --fix ${{ steps.module.outputs.name }}
40+
41+
- name: Run Formatter
42+
run: uv run -m ruff format ${{ steps.module.outputs.name }}
43+
44+
- name: Run Tests
45+
run: uv run -m pytest tests --cov=${{ steps.module.outputs.name }} --cov-report=term-missing --cov-report=xml
46+
47+
- name: Run MyPy
48+
run: uv run -m mypy ${{ steps.module.outputs.name }}
49+
50+
- name: Upload coverage to Codecov
51+
uses: codecov/codecov-action@v3
52+
continue-on-error: true
53+
with:
54+
files: coverage.xml
55+
fail_ci_if_error: false

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.DS_Store
2+
.idea/
3+
.venv/
4+
_build/
5+
notebooks/
6+
setup
7+
conf.py
8+
index.rst
9+
.coverage
10+
*.pyc
11+
setup_mac.sh
12+
docker/.env
13+
.vs_code/*
14+
.mypy_cache/*
15+
.pytest_cache/*
16+
.ruff_cache/*
17+
.aider*
18+
CLAUDE.md
19+
docs/**
20+
jupyter/
21+
mcp-chart-python/
22+
23+
# AI conversation artifacts
24+
context/**
25+
AI_CHANGELOG.md
26+
27+
# User session data (created by MCP server for each chat session)
28+
user_data/*
29+
!user_data/.gitkeep
30+
31+
# Config with secrets (use config.example.json as template)
32+
config.json
33+
34+
# Excel templates (binary files and actual config)
35+
excel_templates/*.xlsx
36+
excel_templates/templates.json
37+

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: lint
5+
name: Run Linter
6+
entry: make lint
7+
language: system
8+
always_run: true
9+
pass_filenames: false
10+
- id: format
11+
name: Run Formatter
12+
entry: make format
13+
language: system
14+
always_run: true
15+
pass_filenames: false
16+
- id: test
17+
name: Run Tests
18+
entry: make test
19+
language: system
20+
always_run: true
21+
pass_filenames: false
22+
- id: mypy
23+
name: Run MyPy
24+
entry: make mypy
25+
language: system
26+
always_run: true
27+
pass_filenames: false

Dockerfile

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# MCP Filesystem Server with Python & Node.js Runtime
2+
#
3+
# This unified container provides:
4+
# - MCP Filesystem Server
5+
# - Python 3.12 with data science libraries
6+
# - Node.js 20 with serve for frontend preview
7+
#
8+
# Build: docker build -t mcp-filesystem .
9+
# Run: docker run -p 18089:18089 -v ./user_data:/user_data mcp-filesystem
10+
11+
FROM python:3.12-slim
12+
13+
LABEL maintainer="MCP Filesystem Team"
14+
LABEL description="MCP Filesystem Server with Python 3.12 and Node.js 20"
15+
LABEL version="1.0.0"
16+
17+
# ============================================
18+
# Environment Variables
19+
# ============================================
20+
ENV PYTHONUNBUFFERED=1
21+
ENV PYTHONDONTWRITEBYTECODE=1
22+
ENV PYTHONIOENCODING=utf-8
23+
ENV LANG=C.UTF-8
24+
ENV LC_ALL=C.UTF-8
25+
26+
# Node.js version
27+
ENV NODE_VERSION=20
28+
29+
# MCP Server default settings (can be overridden by docker-compose environment)
30+
# FASTMCP_* are the actual variables used by the server
31+
ENV FASTMCP_HOST=0.0.0.0
32+
ENV FASTMCP_PORT=18089
33+
ENV MCP_WORKSPACES_DIR=/user_data
34+
35+
# Matplotlib backend for headless operation
36+
ENV MPLBACKEND=Agg
37+
38+
# ============================================
39+
# System Dependencies
40+
# ============================================
41+
RUN apt-get update && apt-get install -y --no-install-recommends \
42+
# Basic tools
43+
curl \
44+
wget \
45+
git \
46+
unzip \
47+
# Build tools (needed for some Python packages)
48+
build-essential \
49+
# OCR support
50+
tesseract-ocr \
51+
tesseract-ocr-chi-sim \
52+
tesseract-ocr-chi-tra \
53+
tesseract-ocr-eng \
54+
# Image processing dependencies
55+
libgl1 \
56+
libglib2.0-0 \
57+
libsm6 \
58+
libxext6 \
59+
libxrender-dev \
60+
libgomp1 \
61+
# Fonts
62+
fonts-liberation \
63+
fonts-noto-cjk \
64+
# Process utilities
65+
procps \
66+
# Clean up
67+
&& apt-get clean \
68+
&& rm -rf /var/lib/apt/lists/*
69+
70+
# ============================================
71+
# Node.js 20
72+
# ============================================
73+
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - \
74+
&& apt-get install -y nodejs \
75+
&& apt-get clean \
76+
&& rm -rf /var/lib/apt/lists/*
77+
78+
# Verify Node.js installation
79+
RUN node --version && npm --version
80+
81+
# ============================================
82+
# Node.js Global Packages
83+
# ============================================
84+
# Only install serve for frontend preview (keep it minimal)
85+
RUN npm install -g serve \
86+
&& npm cache clean --force
87+
88+
# ============================================
89+
# Python Dependencies
90+
# ============================================
91+
WORKDIR /app
92+
93+
# Copy requirements first for better caching
94+
COPY requirements.txt /app/
95+
96+
# Install Python dependencies
97+
RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
98+
99+
# Install Playwright Chromium (crawl4ai 依赖浏览器)
100+
RUN python -m playwright install --with-deps chromium
101+
102+
# ============================================
103+
# MCP Server Application
104+
# ============================================
105+
# Copy application code
106+
COPY pyproject.toml README.md /app/
107+
COPY mcp_filesystem/ /app/mcp_filesystem/
108+
109+
# Install the MCP server package
110+
RUN pip install --no-cache-dir -e .
111+
112+
# Copy configuration (if exists)
113+
COPY config.example.json /app/config.json
114+
115+
# ============================================
116+
# User Data Directory
117+
# ============================================
118+
RUN mkdir -p /user_data \
119+
&& chmod 755 /user_data
120+
121+
# ============================================
122+
# Security: Create non-root user for command execution
123+
# ============================================
124+
RUN useradd -m -s /bin/bash -u 1000 sandbox \
125+
&& chown -R sandbox:sandbox /user_data
126+
127+
# ============================================
128+
# Health Check
129+
# ============================================
130+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
131+
CMD curl -f http://localhost:${FASTMCP_PORT}/ || exit 1
132+
133+
# ============================================
134+
# Expose Ports
135+
# ============================================
136+
# MCP Server
137+
EXPOSE 18089
138+
139+
# Frontend Preview (range)
140+
EXPOSE 7000-7100
141+
142+
# ============================================
143+
# Startup
144+
# ============================================
145+
WORKDIR /app
146+
147+
# Run as root to allow resource limit setting for child processes
148+
# Command execution uses the sandbox user when needed
149+
# Host/port configured via FASTMCP_HOST and FASTMCP_PORT environment variables
150+
CMD ["python", "-m", "mcp_filesystem"]
151+
152+

0 commit comments

Comments
 (0)