Skip to content

Commit 8c8a35e

Browse files
authored
Merge pull request #42 from open-webui/dev
0.0.9
2 parents f1b5fbd + 8330223 commit 8c8a35e

File tree

8 files changed

+326
-55
lines changed

8 files changed

+326
-55
lines changed

.github/workflows/docker-build.yaml

+165
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
name: Create and publish Docker images with specific build args
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
- dev
9+
tags:
10+
- v*
11+
12+
env:
13+
REGISTRY: ghcr.io
14+
15+
jobs:
16+
build-main-image:
17+
runs-on: ${{ matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
18+
permissions:
19+
contents: read
20+
packages: write
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
platform:
25+
- linux/amd64
26+
- linux/arm64
27+
28+
steps:
29+
# GitHub Packages requires the entire repository name to be in lowercase
30+
# although the repository owner has a lowercase username, this prevents some people from running actions after forking
31+
- name: Set repository and image name to lowercase
32+
run: |
33+
echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
34+
echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
35+
env:
36+
IMAGE_NAME: "${{ github.repository }}"
37+
38+
- name: Prepare
39+
run: |
40+
platform=${{ matrix.platform }}
41+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
42+
43+
- name: Checkout repository
44+
uses: actions/checkout@v4
45+
46+
- name: Set up QEMU
47+
uses: docker/setup-qemu-action@v3
48+
49+
- name: Set up Docker Buildx
50+
uses: docker/setup-buildx-action@v3
51+
52+
- name: Log in to the Container registry
53+
uses: docker/login-action@v3
54+
with:
55+
registry: ${{ env.REGISTRY }}
56+
username: ${{ github.actor }}
57+
password: ${{ secrets.GITHUB_TOKEN }}
58+
59+
- name: Extract metadata for Docker images (default latest tag)
60+
id: meta
61+
uses: docker/metadata-action@v5
62+
with:
63+
images: ${{ env.FULL_IMAGE_NAME }}
64+
tags: |
65+
type=ref,event=branch
66+
type=ref,event=tag
67+
type=sha,prefix=git-
68+
type=semver,pattern={{version}}
69+
type=semver,pattern={{major}}.{{minor}}
70+
flavor: |
71+
latest=${{ github.ref == 'refs/heads/main' }}
72+
73+
- name: Extract metadata for Docker cache
74+
id: cache-meta
75+
uses: docker/metadata-action@v5
76+
with:
77+
images: ${{ env.FULL_IMAGE_NAME }}
78+
tags: |
79+
type=ref,event=branch
80+
${{ github.ref_type == 'tag' && 'type=raw,value=main' || '' }}
81+
flavor: |
82+
prefix=cache-${{ matrix.platform }}-
83+
latest=false
84+
85+
- name: Build Docker image (latest)
86+
uses: docker/build-push-action@v5
87+
id: build
88+
with:
89+
context: .
90+
push: true
91+
platforms: ${{ matrix.platform }}
92+
labels: ${{ steps.meta.outputs.labels }}
93+
outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
94+
cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }}
95+
cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
96+
build-args: |
97+
BUILD_HASH=${{ github.sha }}
98+
99+
- name: Export digest
100+
run: |
101+
mkdir -p /tmp/digests
102+
digest="${{ steps.build.outputs.digest }}"
103+
touch "/tmp/digests/${digest#sha256:}"
104+
105+
- name: Upload digest
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: digests-main-${{ env.PLATFORM_PAIR }}
109+
path: /tmp/digests/*
110+
if-no-files-found: error
111+
retention-days: 1
112+
113+
merge-main-images:
114+
runs-on: ubuntu-latest
115+
needs: [build-main-image]
116+
steps:
117+
# GitHub Packages requires the entire repository name to be in lowercase
118+
# although the repository owner has a lowercase username, this prevents some people from running actions after forking
119+
- name: Set repository and image name to lowercase
120+
run: |
121+
echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV}
122+
echo "FULL_IMAGE_NAME=ghcr.io/${IMAGE_NAME,,}" >>${GITHUB_ENV}
123+
env:
124+
IMAGE_NAME: "${{ github.repository }}"
125+
126+
- name: Download digests
127+
uses: actions/download-artifact@v4
128+
with:
129+
pattern: digests-main-*
130+
path: /tmp/digests
131+
merge-multiple: true
132+
133+
- name: Set up Docker Buildx
134+
uses: docker/setup-buildx-action@v3
135+
136+
- name: Log in to the Container registry
137+
uses: docker/login-action@v3
138+
with:
139+
registry: ${{ env.REGISTRY }}
140+
username: ${{ github.actor }}
141+
password: ${{ secrets.GITHUB_TOKEN }}
142+
143+
- name: Extract metadata for Docker images (default latest tag)
144+
id: meta
145+
uses: docker/metadata-action@v5
146+
with:
147+
images: ${{ env.FULL_IMAGE_NAME }}
148+
tags: |
149+
type=ref,event=branch
150+
type=ref,event=tag
151+
type=sha,prefix=git-
152+
type=semver,pattern={{version}}
153+
type=semver,pattern={{major}}.{{minor}}
154+
flavor: |
155+
latest=${{ github.ref == 'refs/heads/main' }}
156+
157+
- name: Create manifest list and push
158+
working-directory: /tmp/digests
159+
run: |
160+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
161+
$(printf '${{ env.FULL_IMAGE_NAME }}@sha256:%s ' *)
162+
163+
- name: Inspect image
164+
run: |
165+
docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ steps.meta.outputs.version }}

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.0.9] - 2025-04-06
9+
10+
### Added
11+
12+
- 🧭 **Clearer Docs Navigation with Path Awareness**: Optimized the /docs and /[tool]/docs pages to clearly display full endpoint paths when using mcpo --config, making it obvious where each tool is hosted—no more guessing or confusion when running multiple tools under different routes.
13+
- 🛤️ **New --path-prefix Option for Precise Routing Control**: Introduced optional --path-prefix flag allowing you to customize the route prefix for all mounted tools—great for integrating mcpo into existing infrastructures, reverse proxies, or multi-service APIs without route collisions.
14+
- 🐳 **Official Dockerfile for Easy Deployment**: Added a first-party Dockerfile so you can containerize mcpo in seconds—perfect for deploying to production, shipping models with standardized dependencies, and running anywhere with a consistent environment.
15+
816
## [0.0.8] - 2025-04-03
917

1018
### Added

Dockerfile

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
FROM python:3.12-slim-bookworm
2+
3+
# Install uv (from official binary), nodejs, npm, and git
4+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
5+
6+
RUN apt-get update && apt-get install -y --no-install-recommends \
7+
git \
8+
curl \
9+
ca-certificates \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
# Install Node.js and npm via NodeSource
13+
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
14+
&& apt-get install -y nodejs \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
# Confirm npm and node versions (optional debugging info)
18+
RUN node -v && npm -v
19+
20+
# Copy your mcpo source code (assuming in src/mcpo)
21+
COPY . /app
22+
WORKDIR /app
23+
24+
# Create virtual environment explicitly in known location
25+
ENV VIRTUAL_ENV=/app/.venv
26+
RUN uv venv "$VIRTUAL_ENV"
27+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
28+
29+
# Install mcpo (assuming pyproject.toml is properly configured)
30+
RUN uv pip install . && rm -rf ~/.cache
31+
32+
# Verify mcpo installed correctly
33+
RUN which mcpo
34+
35+
# Expose port (optional but common default)
36+
EXPOSE 8000
37+
38+
# Entrypoint set for easy container invocation
39+
ENTRYPOINT ["mcpo"]
40+
41+
# Default help CMD (can override at runtime)
42+
CMD ["--help"]

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ pip install mcpo
4040
mcpo --port 8000 --api-key "top-secret" -- your_mcp_server_command
4141
```
4242

43+
You can also run mcpo via Docker with no installation:
44+
45+
```bash
46+
docker run -p 8000:8000 ghcr.io/open-webui/mcpo:main --api-key "top-secret" -- your_mcp_server_command
47+
```
48+
4349
Example:
4450

4551
```bash

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "mcpo"
3-
version = "0.0.8"
3+
version = "0.0.9"
44
description = "A simple, secure MCP-to-OpenAPI proxy server"
55
authors = [
66
{ name = "Timothy Jaeryang Baek", email = "[email protected]" }
@@ -12,6 +12,7 @@ dependencies = [
1212
"fastapi>=0.115.12",
1313
"mcp>=1.6.0",
1414
"passlib[bcrypt]>=1.7.4",
15+
"pydantic>=2.11.1",
1516
"pyjwt[crypto]>=2.10.1",
1617
"typer>=0.15.2",
1718
"uvicorn>=0.34.0",

src/mcpo/__init__.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ def main(
4545
Optional[str], typer.Option("--ssl-certfile", "-t", help="SSL certfile")
4646
] = None,
4747
ssl_keyfile: Annotated[
48-
Optional[str], typer.Option("--ssl-keyfile", "-k", help="SSL keyfile")
48+
Optional[str], typer.Option("--ssl-keyfile", "-k", help="SSL keyfile")
49+
] = None,
50+
path_prefix: Annotated[
51+
Optional[str], typer.Option("--path-prefix", help="URL prefix")
4952
] = None,
5053
):
5154
server_command = None
@@ -81,6 +84,17 @@ def main(
8184
for key, value in env_dict.items():
8285
os.environ[key] = value
8386

87+
# Whatever the prefix is, make sure it starts and ends with a /
88+
if path_prefix is None:
89+
# Set default value
90+
path_prefix = "/"
91+
# if prefix doesn't end with a /, add it
92+
if not path_prefix.endswith("/"):
93+
path_prefix = f"{path_prefix}/"
94+
# if prefix doesn't start with a /, add it
95+
if not path_prefix.startswith("/"):
96+
path_prefix = f"/{path_prefix}"
97+
8498
# Run your async run function from mcpo.main
8599
asyncio.run(
86100
run(
@@ -95,6 +109,7 @@ def main(
95109
server_command=server_command,
96110
ssl_certfile=ssl_certfile,
97111
ssl_keyfile=ssl_keyfile,
112+
path_prefix=path_prefix,
98113
)
99114
)
100115

0 commit comments

Comments
 (0)