mcp 2.0.0 removed `mcp.server.fastmcp`; the `<2` ceiling in 23c7a3d
stopped the bleeding but left this server on the previous major.
Ports to the 2.x API, following the same shape seed-mcp shipped.
- requirements.txt: `mcp[fastmcp]>=1.0.0,<2` -> `mcp>=2,<3` (2.x has
no [fastmcp] extra)
- server.py: FastMCP -> mcp.server.mcpserver.MCPServer; `mcp.settings`
is gone, so host/port/stateless_http/transport_security are now
run() kwargs
- stateless_http is gated to streamable-http. Under 1.x it was a
constructor arg and so applied to sse too; sse is a dev-only path
here, and this matches seed-mcp.
- CI: both workflows now run `python -c "import docs_mcp.server"`
against the built image before pushing it. This is the durable
half — a green build can no longer ship a non-importing image.
- CLAUDE.md / README.md: correct the FastMCP references. PLAN.md is
left alone; it tracks the upstream template, not this repo.
Verification (mcp 1.27.1 -> 2.2.0):
- tools/list dumped in wire format is byte-for-byte identical,
md5 cea0326f59b55abbbf47c9679252d38f both sides. All 5 tools
(search_docs, get_page, list_versions, corpus_status,
crop_chem_api_lessons) unchanged, so routing is unaffected.
- streamable-http: `initialize` -> 200, no mcp-session-id header
(stateless_http confirmed active); tools/list and a real
tools/call over the wire both succeed.
- stdio: initialize + tools/list both fine.
- Image built; the new CI smoke command passes against it.
corpus_status reads the baked indexes (4,164 labels / 216,467
chunks) and a live `search_docs` returns hits with mode=hybrid-rrf
against Ollama on .0.125.
No eval numbers: this touches transport and packaging only. The
chunker, embedder, Chroma/BM25 stores, RRF and the reranker are all
untouched, and the live search above confirms retrieval still runs.
Note: `serverInfo.version` now reports "" instead of the SDK version
(2.x behaviour for an unversioned server). Cosmetic, but visible to
clients. httpx2 + opentelemetry-api come in as 2.x deps and coexist
with the existing httpx 0.28.1 pin, as expected.
Closes #4
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FFBDnRWHispovmJVK9rXc9
138 lines
5.2 KiB
YAML
138 lines
5.2 KiB
YAML
name: Image rebuild (skip scrape)
|
|
|
|
# Fast path for code-only changes. Skips the scrape and goes straight
|
|
# to: rebuild indexes (from corpus already committed on main) + image
|
|
# build + push. Runtime ~10 min vs ~9 h for the full monthly refresh.
|
|
#
|
|
# Use when a PR only changes code/config — anything where the upstream
|
|
# corpus hasn't moved but we want the new Python in the running image.
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- "docs_mcp/**"
|
|
- "rag/**"
|
|
- "scrape/**"
|
|
- "requirements.txt"
|
|
- "Dockerfile"
|
|
- "sources.json"
|
|
|
|
# If multiple pushes land in quick succession, cancel the older one
|
|
# rather than queueing both — each run is ~90 min and the older
|
|
# commit's image just gets overwritten by the newer one anyway.
|
|
concurrency:
|
|
group: image-only
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
REGISTRY_PUSH: 192.168.0.2:1234
|
|
REGISTRY_PULL: git.jpaul.io
|
|
IMAGE: ${{ github.repository }}
|
|
OLLAMA_URL: http://192.168.0.2:11434,http://192.168.0.2:11435,http://192.168.0.125:11434
|
|
EMBED_MODEL: nomic-embed-text
|
|
PRODUCT_NAME: crop_chem
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: docker
|
|
container:
|
|
image: catthehacker/ubuntu:act-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Verify image name resolves
|
|
# ${{ github.event.repository.name }} silently resolves to EMPTY on
|
|
# schedule events (Gitea >=1.27), which built the tag
|
|
# "192.168.0.2:1234/<owner>/:latest" and failed the build only AFTER
|
|
# the full scrape. IMAGE now comes from github.repository; this step
|
|
# fails in seconds if it ever goes empty again.
|
|
run: |
|
|
echo "IMAGE=${IMAGE}"
|
|
case "${IMAGE}" in
|
|
*/?*) ;;
|
|
*) echo "ERROR: IMAGE did not resolve to owner/repo"; exit 1 ;;
|
|
esac
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install -q --upgrade pip
|
|
python -m pip install -q -r requirements.txt
|
|
|
|
- name: Verify committed corpus is present
|
|
run: |
|
|
test -d corpus || { echo "ERROR: corpus/ missing on this ref"; exit 1; }
|
|
n_md=$(find corpus -name '*.md' | wc -l)
|
|
n_json=$(find corpus -name '*.json' | wc -l)
|
|
echo "corpus: $(du -sh corpus | cut -f1) on disk, ${n_md} .md / ${n_json} .json"
|
|
test "$n_md" -gt 100 || { echo "ERROR: corpus has fewer than 100 labels — was the rename committed?"; exit 1; }
|
|
|
|
- name: Rebuild indexes from committed corpus
|
|
run: python -m rag.index --rebuild
|
|
|
|
- name: Log in to Gitea container registry
|
|
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "${REGISTRY_PUSH}" -u "${{ github.repository_owner }}" --password-stdin
|
|
|
|
- name: Build & push image
|
|
run: |
|
|
SHA_TAG=$(echo "$GITHUB_SHA" | cut -c1-12)
|
|
CORPUS_TAG="corpus-$(date -u +%Y.%m.%d)"
|
|
docker build \
|
|
-t "${REGISTRY_PUSH}/${IMAGE}:latest" \
|
|
-t "${REGISTRY_PUSH}/${IMAGE}:${SHA_TAG}" \
|
|
-t "${REGISTRY_PUSH}/${IMAGE}:${CORPUS_TAG}" \
|
|
.
|
|
# Smoke: the image must at least import its server module before we
|
|
# publish it. mcp 2.x renamed mcp.server.fastmcp -> mcp.server.mcpserver,
|
|
# so an unpinned dep produced a green build that crash-looped in prod.
|
|
# Import is side-effect-free here (lazy singletons), so this needs no
|
|
# Ollama/Chroma.
|
|
docker run --rm --entrypoint python \
|
|
"${REGISTRY_PUSH}/${IMAGE}:latest" -c "import docs_mcp.server"
|
|
docker push "${REGISTRY_PUSH}/${IMAGE}:latest"
|
|
docker push "${REGISTRY_PUSH}/${IMAGE}:${SHA_TAG}"
|
|
docker push "${REGISTRY_PUSH}/${IMAGE}:${CORPUS_TAG}"
|
|
|
|
- name: Link container package to this repo
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
|
run: |
|
|
OWNER="${{ github.repository_owner }}"
|
|
PKG="${GITHUB_REPOSITORY##*/}"
|
|
BODY=$(mktemp)
|
|
CODE=$(curl -sS -o "$BODY" -w "%{http_code}" -X POST \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
"https://${REGISTRY_PULL}/api/v1/packages/${OWNER}/container/${PKG}/-/link/${PKG}")
|
|
echo "link http=$CODE body=$(cat "$BODY")"
|
|
case "$CODE" in
|
|
201) echo "linked package to ${OWNER}/${PKG}" ;;
|
|
400) echo "already linked — ok" ;;
|
|
*) echo "unexpected status $CODE"; exit 1 ;;
|
|
esac
|
|
|
|
- name: Prune old container versions
|
|
# GC requires broader scope than REGISTRY_TOKEN's push perms
|
|
# (got HTTP 403 enumerating /packages/.../versions on run #122).
|
|
# Non-critical — housekeeping only. Don't fail the whole run.
|
|
# TODO: issue a separate PAT with admin:package scope and set
|
|
# as PACKAGES_ADMIN_TOKEN, then use it here.
|
|
continue-on-error: true
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
|
run: |
|
|
python scripts/registry_gc.py \
|
|
--owner "${{ github.repository_owner }}" \
|
|
--package "${GITHUB_REPOSITORY##*/}" \
|
|
--keep-days 180 \
|
|
--keep-latest 6
|