Skip to content

Commit 3b30c99

Browse files
authored
Merge pull request #8 from Kitware/feature/uv-support-and-api-updates
Switch to hatchling, uv sources, and from_artifact() APIs
2 parents 0bc1fb9 + 41efa30 commit 3b30c99

15 files changed

Lines changed: 261 additions & 142 deletions

File tree

.github/workflows/ci.yml

Lines changed: 41 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,39 @@ name: CI/CD Pipeline
22

33
on:
44
push:
5-
branches: [ master, release ]
5+
branches: [master, release]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88
release:
9-
types: [ published ]
9+
types: [published]
1010

1111
env:
1212
REGISTRY: ghcr.io
1313
IMAGE_NAME: ${{ github.repository }}
1414

1515
jobs:
1616
lint:
17-
name: Code Style & Linting
17+
name: Lint
1818
runs-on: ubuntu-latest
1919
steps:
20-
- name: Checkout code
21-
uses: actions/checkout@v4
20+
- uses: actions/checkout@v4
2221

23-
- name: Set up Python
24-
uses: actions/setup-python@v5
22+
- uses: actions/setup-python@v5
2523
with:
26-
python-version: '3.12'
27-
28-
- name: Create virtual environment
29-
run: python -m venv venv
24+
python-version: "3.12"
3025

3126
- name: Install dependencies
3227
run: |
33-
source venv/bin/activate
34-
pip install --upgrade pip
35-
pip install black flake8
36-
pip install -e .
28+
pip install \
29+
"git+https://github.com/vicentebolea/vtk-knowledge" \
30+
"git+https://github.com/vicentebolea/vtk-validate"
31+
pip install -e ".[dev]"
3732
38-
- name: Run Black
39-
run: |
40-
source venv/bin/activate
41-
black --check --diff src/ tests/
33+
- name: ruff lint
34+
run: ruff check src/vtk_mcp/
4235

43-
- name: Run Flake8
44-
run: |
45-
source venv/bin/activate
46-
flake8 src/
36+
- name: ruff format check
37+
run: ruff format --check src/vtk_mcp/
4738

4839
actionlint:
4940
runs-on: ubuntu-latest
@@ -52,53 +43,56 @@ jobs:
5243

5344
- name: Install actionlint
5445
run: |
55-
# Download and install actionlint
5646
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
5747
echo "${PWD}" >> "$GITHUB_PATH"
5848
5949
- name: Run actionlint
6050
run: actionlint
6151

6252
test:
63-
name: Run Tests
53+
name: Test (Python ${{ matrix.python-version }})
6454
runs-on: ubuntu-latest
6555
needs: [lint, actionlint]
6656
strategy:
6757
matrix:
68-
python-version: ['3.10', '3.11', '3.12']
58+
python-version: ["3.10", "3.11", "3.12"]
6959

7060
steps:
71-
- name: Checkout code
72-
uses: actions/checkout@v4
61+
- uses: actions/checkout@v4
7362

74-
- name: Set up Python ${{ matrix.python-version }}
75-
uses: actions/setup-python@v5
63+
- uses: actions/setup-python@v5
7664
with:
7765
python-version: ${{ matrix.python-version }}
7866

79-
- name: Create virtual environment
80-
run: python -m venv venv
81-
8267
- name: Install dependencies
8368
run: |
84-
source venv/bin/activate
85-
pip install --upgrade pip
86-
pip install -e ".[test]"
69+
pip install \
70+
"git+https://github.com/vicentebolea/vtk-knowledge" \
71+
"git+https://github.com/vicentebolea/vtk-validate"
72+
pip install -e ".[dev]"
8773
8874
- name: Run unit tests
89-
run: |
90-
source venv/bin/activate
91-
pytest -m unit -v
75+
run: pytest -m unit -v
9276

9377
- name: Run client tests
94-
run: |
95-
source venv/bin/activate
96-
pytest tests/test_client_no_server.py -v
78+
run: pytest tests/test_client_no_server.py -v
9779

9880
- name: Run integration tests
99-
run: |
100-
source venv/bin/activate
101-
pytest -m integration -v
81+
run: pytest -m integration -v
82+
83+
uv-smoke:
84+
name: uv smoke test
85+
runs-on: ubuntu-latest
86+
steps:
87+
- uses: actions/checkout@v4
88+
89+
- uses: astral-sh/setup-uv@v5
90+
91+
- name: uv sync resolves all dependencies
92+
run: uv sync --extra dev
93+
94+
- name: Import check
95+
run: uv run python -c "from vtk_mcp.config import Settings; Settings()"
10296

10397
docker-deploy:
10498
name: Build and Push Deployment Image
@@ -109,8 +103,7 @@ jobs:
109103
contents: read
110104
packages: write
111105
steps:
112-
- name: Checkout code
113-
uses: actions/checkout@v4
106+
- uses: actions/checkout@v4
114107
with:
115108
submodules: recursive
116109

Dockerfile

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,51 @@
1-
FROM python:3.11-slim
1+
FROM python:3.12-slim
22

33
LABEL org.opencontainers.image.title="VTK MCP Gateway"
44
LABEL org.opencontainers.image.description="Production MCP gateway for VTK LLM tooling"
5-
LABEL org.opencontainers.image.source="https://github.com/kitware/vtk-mcp"
5+
LABEL org.opencontainers.image.source="https://github.com/Kitware/vtk-mcp"
66
LABEL org.opencontainers.image.licenses="MIT"
77

88
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
99
PIP_NO_CACHE_DIR=1 \
1010
PYTHONDONTWRITEBYTECODE=1 \
1111
PYTHONUNBUFFERED=1
1212

13-
WORKDIR /app
14-
15-
# Install runtime dependencies — no VTK runtime, no LiteLLM
16-
RUN pip install vtk-knowledge vtk-validate vtk-mcp
17-
18-
# Bundle the knowledge artifact (built separately and passed at build time)
13+
# VTK version to pre-cache at image build time
1914
ARG VTK_VERSION=9.3.0
20-
ARG KNOWLEDGE_ARTIFACT_URL=""
21-
RUN if [ -n "$KNOWLEDGE_ARTIFACT_URL" ]; then \
22-
curl -fSL "$KNOWLEDGE_ARTIFACT_URL" -o /app/data/vtk-knowledge.jsonl; \
23-
fi
15+
ENV VTK_MCP_VTK_VERSION=${VTK_VERSION}
2416

25-
COPY data/ /app/data/
17+
WORKDIR /app
18+
19+
# Install uv for fast dependency installation
20+
RUN pip install uv
21+
22+
# Install vtk-* sibling packages from GitHub (not on PyPI)
23+
RUN uv pip install --system \
24+
"git+https://github.com/vicentebolea/vtk-knowledge" \
25+
"git+https://github.com/vicentebolea/vtk-validate"
26+
27+
# Install vtk-mcp with optional retrieval support
28+
COPY . /app/
29+
RUN uv pip install --system -e ".[retrieval]"
30+
31+
# Pre-download the vtk-knowledge JSONL artifact and vtk-index embedded
32+
# Qdrant storage so the image is ready to serve without network access.
33+
RUN python - <<'EOF'
34+
import logging
35+
logging.basicConfig(level=logging.INFO)
36+
import os
37+
vtk_version = os.environ["VTK_MCP_VTK_VERSION"]
38+
from vtk_knowledge import VTKAPIIndex
39+
VTKAPIIndex.from_artifact(vtk_version)
40+
try:
41+
from vtk_index import Retriever
42+
Retriever.from_artifact(vtk_version)
43+
except Exception as e:
44+
logging.warning("vtk-index embedded storage skipped: %s", e)
45+
EOF
2646

27-
ENV VTK_MCP_KNOWLEDGE_ARTIFACT_PATH=/app/data/vtk-knowledge.jsonl
28-
ENV VTK_MCP_VTK_VERSION=${VTK_VERSION}
2947
ENV VTK_MCP_TRANSPORT=stdio
48+
ENV VTK_MCP_ENABLE_VALIDATION=true
49+
ENV VTK_MCP_ENABLE_RETRIEVAL=true
3050

3151
ENTRYPOINT ["python", "-m", "vtk_mcp"]

deploy.Dockerfile

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,51 @@
1-
LABEL org.opencontainers.image.title="VTK MCP Server with Embeddings"
2-
LABEL org.opencontainers.image.description="Model Context Protocol server for VTK with vector search embeddings"
3-
LABEL org.opencontainers.image.source="https://github.com/kitware/vtk-mcp"
4-
LABEL org.opencontainers.image.authors="Vicente Adolfo Bolea Sanchez <vicente.bolea@kitware.com>"
5-
LABEL org.opencontainers.image.licenses="MIT"
6-
LABEL org.opencontainers.image.documentation="https://github.com/kitware/vtk-mcp/blob/main/README.md"
7-
8-
FROM python:3.12-slim AS embeddings
9-
10-
# Download embeddings database from GHCR
11-
COPY --from=ghcr.io/kitware/vtk-mcp/embeddings-database:latest /vtk-examples-embeddings.tar.gz /tmp/
12-
13-
# Extract the database
14-
RUN mkdir -p /app/db && \
15-
tar -xzf /tmp/vtk-examples-embeddings.tar.gz -C /app/db && \
16-
rm /tmp/vtk-examples-embeddings.tar.gz
17-
181
FROM python:3.12-slim
192

3+
LABEL org.opencontainers.image.title="VTK MCP Gateway"
4+
LABEL org.opencontainers.image.description="Production MCP gateway for VTK LLM tooling"
5+
LABEL org.opencontainers.image.source="https://github.com/Kitware/vtk-mcp"
6+
LABEL org.opencontainers.image.licenses="MIT"
7+
208
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
219
PIP_NO_CACHE_DIR=1 \
2210
PYTHONDONTWRITEBYTECODE=1 \
2311
PYTHONUNBUFFERED=1
2412

25-
# Install system dependencies for VTK
26-
RUN apt update && \
27-
apt install --no-install-recommends --no-install-suggests -y \
28-
libgl1-mesa-dev \
29-
libxrender-dev/stable \
30-
git && \
31-
rm -rf /var/lib/apt/lists/*
13+
# VTK version to pre-cache at image build time
14+
ARG VTK_VERSION=9.3.0
15+
ENV VTK_MCP_VTK_VERSION=${VTK_VERSION}
3216

3317
WORKDIR /app
3418

35-
# Copy application code
36-
COPY . .
37-
38-
# Copy embeddings database from first stage
39-
COPY --from=embeddings /app/db /app/db
40-
41-
# Install Python dependencies (including RAG dependencies)
42-
RUN pip install --upgrade pip && \
43-
pip install --verbose .
44-
45-
# Start server with database path configured
46-
CMD ["vtk-mcp-server", "--transport", "http", "--host", "0.0.0.0", "--port", "8000", "--database-path", "/app/db/vtk-examples"]
19+
# Install uv for fast dependency installation
20+
RUN pip install uv
21+
22+
# Install vtk-* sibling packages from GitHub (not on PyPI)
23+
RUN uv pip install --system \
24+
"git+https://github.com/vicentebolea/vtk-knowledge" \
25+
"git+https://github.com/vicentebolea/vtk-validate"
26+
27+
# Install vtk-mcp with optional retrieval support
28+
COPY . /app/
29+
RUN uv pip install --system -e ".[retrieval]"
30+
31+
# Pre-download the vtk-knowledge JSONL artifact and vtk-index embedded
32+
# Qdrant storage so the image is ready to serve without network access.
33+
RUN python - <<'EOF'
34+
import logging
35+
logging.basicConfig(level=logging.INFO)
36+
import os
37+
vtk_version = os.environ["VTK_MCP_VTK_VERSION"]
38+
from vtk_knowledge import VTKAPIIndex
39+
VTKAPIIndex.from_artifact(vtk_version)
40+
try:
41+
from vtk_index import Retriever
42+
Retriever.from_artifact(vtk_version)
43+
except Exception as e:
44+
logging.warning("vtk-index embedded storage skipped: %s", e)
45+
EOF
46+
47+
ENV VTK_MCP_TRANSPORT=stdio
48+
ENV VTK_MCP_ENABLE_VALIDATION=true
49+
ENV VTK_MCP_ENABLE_RETRIEVAL=true
50+
51+
ENTRYPOINT ["python", "-m", "vtk_mcp"]

pyproject.toml

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
15
[project]
26
name = "vtk-mcp"
37
version = "1.0.0"
@@ -37,31 +41,34 @@ vtk-mcp = "vtk_mcp.__main__:main"
3741
retrieval = [
3842
"vtk-index>=1.0.0",
3943
]
40-
test = [
44+
dev = [
4145
"pytest>=7.0.0",
4246
"pytest-asyncio>=0.21.0",
4347
"pytest-mock>=3.10.0",
4448
"responses>=0.23.0",
4549
"httpx>=0.24.0",
50+
"ruff>=0.8.0",
4651
]
4752

4853
[project.urls]
49-
Homepage = "https://github.com/kitware/vtk-mcp"
50-
Repository = "https://github.com/kitware/vtk-mcp"
51-
Issues = "https://github.com/kitware/vtk-mcp/issues"
54+
Homepage = "https://github.com/Kitware/vtk-mcp"
55+
Repository = "https://github.com/Kitware/vtk-mcp"
56+
Issues = "https://github.com/Kitware/vtk-mcp/issues"
5257

53-
[build-system]
54-
requires = ["setuptools>=61.0"]
55-
build-backend = "setuptools.build_meta"
58+
[tool.hatch.build.targets.wheel]
59+
packages = ["src/vtk_mcp"]
5660

57-
[tool.setuptools.packages.find]
58-
where = ["src"]
61+
[tool.uv.sources]
62+
vtk-knowledge = { git = "https://github.com/vicentebolea/vtk-knowledge" }
63+
vtk-validate = { git = "https://github.com/vicentebolea/vtk-validate" }
64+
vtk-index = { git = "https://github.com/vicentebolea/vtk-index" }
5965

6066
[tool.pytest.ini_options]
6167
testpaths = ["tests"]
62-
python_files = "test_*.py"
63-
python_classes = "Test*"
64-
python_functions = "test_*"
68+
python_files = ["test_*.py"]
69+
python_classes = ["Test*"]
70+
python_functions = ["test_*"]
71+
pythonpath = ["src"]
6572
addopts = [
6673
"-v",
6774
"--tb=short",
@@ -79,3 +86,14 @@ filterwarnings = [
7986
"ignore::DeprecationWarning",
8087
"ignore::PendingDeprecationWarning",
8188
]
89+
90+
[tool.ruff]
91+
line-length = 120
92+
target-version = "py310"
93+
94+
[tool.ruff.lint]
95+
select = ["E", "F", "I", "W"]
96+
ignore = ["E501"]
97+
98+
[tool.ruff.lint.isort]
99+
known-first-party = ["vtk_mcp"]

0 commit comments

Comments
 (0)