Add MCP-style API server (OpenAPI) alongside WebUI
- New mcp_server.py: FastAPI app for LLMs to upload audio and get transcript JSON. - Added process_mcp_transcribe_task Celery task. - Updated __main__.py: WebUI always runs; MCP server runs in parallel when MCP_SERVER_ENABLED=true.
This commit is contained in:
+31
-1
@@ -3,10 +3,40 @@ Entrypoint for running ScrAIbe as a module:
|
||||
|
||||
python -m scraibe
|
||||
|
||||
Always launches the Web GUI (Gradio), never the CLI.
|
||||
Always launches the Web GUI (Gradio).
|
||||
Optionally launches an MCP-style API server in parallel.
|
||||
"""
|
||||
|
||||
import os
|
||||
import threading
|
||||
|
||||
from .webui import create_app
|
||||
|
||||
|
||||
def _run_mcp_server():
|
||||
"""
|
||||
Run MCP server in a separate thread.
|
||||
"""
|
||||
import uvicorn
|
||||
from . import mcp_server
|
||||
|
||||
host = os.getenv("MCP_SERVER_HOST", "0.0.0.0")
|
||||
port = int(os.getenv("MCP_SERVER_PORT", "8000"))
|
||||
|
||||
uvicorn.run(
|
||||
mcp_server.app,
|
||||
host=host,
|
||||
port=port,
|
||||
log_level="info",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Optionally start MCP server in background
|
||||
mcp_enabled = os.getenv("MCP_SERVER_ENABLED", "false").strip().lower() in ("true", "1", "yes")
|
||||
if mcp_enabled:
|
||||
t = threading.Thread(target=_run_mcp_server, daemon=True)
|
||||
t.start()
|
||||
|
||||
# Always start WebUI (Gradio)
|
||||
create_app()
|
||||
|
||||
Reference in New Issue
Block a user