Skip to content

Commit ad4b139

Browse files
authored
Merge pull request #1 from Wh1isper/main
feat: Implement mcp server
2 parents 69f32ce + 3147045 commit ad4b139

File tree

19 files changed

+1831
-1
lines changed

19 files changed

+1831
-1
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: "Setup Python Environment"
2+
description: "Set up Python environment for the given Python version"
3+
4+
inputs:
5+
python-version:
6+
description: "Python version to use"
7+
required: true
8+
default: "3.12"
9+
uv-version:
10+
description: "uv version to use"
11+
required: true
12+
default: "0.6.2"
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: ${{ inputs.python-version }}
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v5
23+
with:
24+
version: ${{ inputs.uv-version }}
25+
enable-cache: 'true'
26+
cache-suffix: ${{ matrix.python-version }}
27+
28+
- name: Install Python dependencies
29+
run: uv sync --frozen
30+
shell: bash

.github/workflows/main.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened, ready_for_review]
9+
10+
jobs:
11+
quality:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out
15+
uses: actions/checkout@v4
16+
17+
- uses: actions/cache@v4
18+
with:
19+
path: ~/.cache/pre-commit
20+
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
21+
22+
- name: Set up the environment
23+
uses: ./.github/actions/setup-python-env
24+
25+
- name: Run checks
26+
run: make check
27+
28+
tests-and-type-check:
29+
runs-on: ubuntu-latest
30+
strategy:
31+
matrix:
32+
python-version: ["3.10", "3.11", "3.12", "3.13"]
33+
fail-fast: false
34+
env:
35+
UV_PYTHON: ${{ inputs.python-version }}
36+
defaults:
37+
run:
38+
shell: bash
39+
steps:
40+
- name: Check out
41+
uses: actions/checkout@v4
42+
43+
- name: Set up the environment
44+
uses: ./.github/actions/setup-python-env
45+
with:
46+
python-version: ${{ matrix.python-version }}
47+
48+
- name: Run tests
49+
run: uv run python -m pytest tests --cov --cov-config=pyproject.toml --cov-report=xml

.github/workflows/on-release-main.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: release-main
2+
3+
permissions:
4+
contents: write
5+
packages: write
6+
7+
on:
8+
release:
9+
types: [published]
10+
11+
jobs:
12+
set-version:
13+
runs-on: ubuntu-24.04
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Export tag
18+
id: vars
19+
run: echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT
20+
if: ${{ github.event_name == 'release' }}
21+
22+
- name: Update project version
23+
run: |
24+
sed -i "s/^version = \".*\"/version = \"$RELEASE_VERSION\"/" pyproject.toml
25+
env:
26+
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
27+
if: ${{ github.event_name == 'release' }}
28+
29+
- name: Upload updated pyproject.toml
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: pyproject-toml
33+
path: pyproject.toml
34+
35+
publish:
36+
runs-on: ubuntu-latest
37+
needs: [set-version]
38+
steps:
39+
- name: Check out
40+
uses: actions/checkout@v4
41+
42+
- name: Set up the environment
43+
uses: ./.github/actions/setup-python-env
44+
45+
- name: Download updated pyproject.toml
46+
uses: actions/download-artifact@v4
47+
with:
48+
name: pyproject-toml
49+
50+
- name: Build package
51+
run: uv build
52+
53+
- name: Publish package
54+
run: uv publish
55+
env:
56+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
57+
58+
- name: Upload dists to release
59+
uses: svenstaro/upload-release-action@v2
60+
with:
61+
repo_token: ${{ secrets.GITHUB_TOKEN }}
62+
file: dist/*
63+
file_glob: true
64+
tag: ${{ github.ref }}
65+
overwrite: true
66+
67+
68+
push-image:
69+
runs-on: ubuntu-latest
70+
needs: [set-version]
71+
steps:
72+
- uses: actions/checkout@v4
73+
- name: Export tag
74+
id: vars
75+
run: echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT
76+
if: ${{ github.event_name == 'release' }}
77+
- name: Set up QEMU
78+
uses: docker/setup-qemu-action@v3
79+
- name: Set up Docker Buildx
80+
uses: docker/setup-buildx-action@v3
81+
- name: Login to Github Container Registry
82+
uses: docker/login-action@v3
83+
with:
84+
registry: ghcr.io
85+
username: pymupdf
86+
password: ${{ secrets.GITHUB_TOKEN }}
87+
- name: Build and push image
88+
id: docker_build_publish
89+
uses: docker/build-push-action@v5
90+
with:
91+
context: .
92+
platforms: linux/amd64,linux/arm64/v8
93+
cache-from: type=gha
94+
cache-to: type=gha,mode=max
95+
file: ./Dockerfile
96+
push: true
97+
tags: |
98+
ghcr.io/pymupdf/pymupdf4llm-mcp:${{ steps.vars.outputs.tag }}
99+
ghcr.io/pymupdf/pymupdf4llm-mcp:latest

.gitignore

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
docs/source
2+
3+
# From https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore
4+
5+
# Byte-compiled / optimized / DLL files
6+
__pycache__/
7+
*.py[cod]
8+
*$py.class
9+
10+
# C extensions
11+
*.so
12+
13+
# Distribution / packaging
14+
.Python
15+
build/
16+
develop-eggs/
17+
dist/
18+
downloads/
19+
eggs/
20+
.eggs/
21+
lib/
22+
lib64/
23+
parts/
24+
sdist/
25+
var/
26+
wheels/
27+
share/python-wheels/
28+
*.egg-info/
29+
.installed.cfg
30+
*.egg
31+
MANIFEST
32+
33+
# PyInstaller
34+
# Usually these files are written by a python script from a template
35+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
36+
*.manifest
37+
*.spec
38+
39+
# Installer logs
40+
pip-log.txt
41+
pip-delete-this-directory.txt
42+
43+
# Unit test / coverage reports
44+
htmlcov/
45+
.tox/
46+
.nox/
47+
.coverage
48+
.coverage.*
49+
.cache
50+
nosetests.xml
51+
coverage.xml
52+
*.cover
53+
*.py,cover
54+
.hypothesis/
55+
.pytest_cache/
56+
cover/
57+
58+
# Translations
59+
*.mo
60+
*.pot
61+
62+
# Django stuff:
63+
*.log
64+
local_settings.py
65+
db.sqlite3
66+
db.sqlite3-journal
67+
68+
# Flask stuff:
69+
instance/
70+
.webassets-cache
71+
72+
# Scrapy stuff:
73+
.scrapy
74+
75+
# Sphinx documentation
76+
docs/_build/
77+
78+
# PyBuilder
79+
.pybuilder/
80+
target/
81+
82+
# Jupyter Notebook
83+
.ipynb_checkpoints
84+
85+
# IPython
86+
profile_default/
87+
ipython_config.py
88+
89+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
90+
__pypackages__/
91+
92+
# Celery stuff
93+
celerybeat-schedule
94+
celerybeat.pid
95+
96+
# SageMath parsed files
97+
*.sage.py
98+
99+
# Environments
100+
.env
101+
.venv
102+
env/
103+
venv/
104+
ENV/
105+
env.bak/
106+
venv.bak/
107+
108+
# Spyder project settings
109+
.spyderproject
110+
.spyproject
111+
112+
# Rope project settings
113+
.ropeproject
114+
115+
# mkdocs documentation
116+
/site
117+
118+
# mypy
119+
.mypy_cache/
120+
.dmypy.json
121+
dmypy.json
122+
123+
# Pyre type checker
124+
.pyre/
125+
126+
# pytype static type analyzer
127+
.pytype/
128+
129+
# Cython debug symbols
130+
cython_debug/
131+
132+
# Vscode config files
133+
# .vscode/
134+
135+
# PyCharm
136+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
137+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
138+
# and can be added to the global gitignore or merged into this file. For a more nuclear
139+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
140+
#.idea/

.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: https://github.com/pre-commit/pre-commit-hooks
3+
rev: "v5.0.0"
4+
hooks:
5+
- id: check-case-conflict
6+
- id: check-merge-conflict
7+
- id: check-toml
8+
- id: check-yaml
9+
- id: check-json
10+
exclude: ^.devcontainer/devcontainer.json
11+
- id: pretty-format-json
12+
exclude: ^.devcontainer/devcontainer.json
13+
args: [--autofix]
14+
- id: end-of-file-fixer
15+
- id: trailing-whitespace
16+
- repo: https://github.com/executablebooks/mdformat
17+
rev: 0.7.22
18+
hooks:
19+
- id: mdformat
20+
additional_dependencies:
21+
[mdformat-gfm, mdformat-frontmatter, mdformat-footnote]
22+
- repo: https://github.com/astral-sh/ruff-pre-commit
23+
rev: "v0.11.6"
24+
hooks:
25+
- id: ruff
26+
args: [--exit-non-zero-on-fix]
27+
- id: ruff-format

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python"
3+
}

0 commit comments

Comments
 (0)