Merge pull request #227 from krewi1/dev

feat: add support to run on different path prefix
This commit is contained in:
Tim Jaeryang Baek
2025-10-14 15:20:14 -05:00
committed by GitHub
3 changed files with 19 additions and 0 deletions
+12
View File
@@ -74,6 +74,18 @@ Thats it. Your MCP tool is now available at http://localhost:8000 with a gene
🤝 **To integrate with Open WebUI after launching the server, check our [docs](https://docs.openwebui.com/openapi-servers/open-webui/).**
### 🌐 Serving Under a Subpath (`--root-path`)
If you need to serve mcpo behind a reverse proxy or under a subpath (e.g., `/api/mcpo`), use the `--root-path` argument:
```bash
mcpo --port 8000 --root-path "/api/mcpo" --api-key "top-secret" -- your_mcp_server_command
```
All routes will be served under the specified root path, e.g. `http://localhost:8000/api/mcpo/memory`.
### 🔄 Using a Config File
You can serve multiple MCP tools via a single config file that follows the [Claude Desktop](https://modelcontextprotocol.io/quickstart/user) format.
+4
View File
@@ -60,6 +60,9 @@ def main(
ssl_keyfile: Annotated[
Optional[str], typer.Option("--ssl-keyfile", "-K", help="SSL keyfile")
] = None,
root_path: Annotated[
Optional[str], typer.Option("--root-path", help="Root path")
] = "",
path_prefix: Annotated[
Optional[str], typer.Option("--path-prefix", help="URL prefix")
] = None,
@@ -146,6 +149,7 @@ def main(
ssl_certfile=ssl_certfile,
ssl_keyfile=ssl_keyfile,
path_prefix=path_prefix,
root_path=root_path,
headers=headers,
hot_reload=hot_reload,
)
+3
View File
@@ -611,6 +611,7 @@ async def run(
ssl_certfile = kwargs.get("ssl_certfile")
ssl_keyfile = kwargs.get("ssl_keyfile")
path_prefix = kwargs.get("path_prefix") or "/"
root_path = kwargs.get("root_path") or ""
# Configure logging based on LOG_LEVEL environment variable
log_level = os.getenv("LOG_LEVEL", "INFO").upper()
@@ -649,6 +650,7 @@ async def run(
if ssl_keyfile:
logger.info(f" SSL Key File: {ssl_keyfile}")
logger.info(f" Path Prefix: {path_prefix}")
logger.info(f" Root Path: {root_path}")
# Create shutdown handler
shutdown_handler = GracefulShutdown()
@@ -657,6 +659,7 @@ async def run(
title=name,
description=description,
version=version,
root_path=root_path,
ssl_certfile=ssl_certfile,
ssl_keyfile=ssl_keyfile,
lifespan=lifespan,