Skip to content

feat: add in-process execution mode with --no-mcp - #527

Merged
xhd0728 merged 12 commits into
mainfrom
codex/no-mcp
Nov 7, 2026
Merged

xhd0728 merged 12 commits into
mainfrom
codex/no-mcp

Conversation

@xhd0728

@xhd0728 xhd0728 commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Add optional in-process execution for local UltraRAG services through --no-mcp on build, run, and show ui, and no_mcp=False in the Python API. Existing YAML, parameters, aliases, and UI workflows are preserved; remote MCP services can still participate in mixed pipelines. MCP remains the default execution mode and is installed through the optional mcp extra.

Registration and I/O metadata are shared by local and MCP adapters. Local execution validates arguments, copies JSON inputs/outputs, preserves prompt messages, isolates service-owned imports, and manages lifespans and cleanup. UI requests have independent input files and parameter overrides; API initialization/shutdown and concurrent calls have explicit lifecycle handling.

Maintenance dependency upgrade

Dependency Previous lock Current lock
FastMCP / fastmcp-slim 3.4.0 3.4.11
MCP SDK 1.29.0 1.30.0
MinerU 3.4.4 with core 3.4.5 with pipeline,vlm
Starlette 0.52.1 1.10.0
certifi 2026.7.22 2026.10.23
AnyIO 4.14.2 4.16.0

Keep FastMCP below 4 and MCP below 2 to preserve the supported adapter API. Remove the unused MinerU Gradio extra, which imposed a conflicting Starlette upper bound, while retaining both parsing backends. Add a certifi security floor, use uv 0.13.7 in CI/Docker and documented installation, and pin the remote bridge's top-level npm package to [email protected].

Regression work also exposed an existing stdio cleanup gap: exiting a single-server FastMCP context could leave its subprocess alive. The client factory now sets keep_alive=False on a copy of stdio configurations. Nested contexts retain their process until the outer exit, and direct HTTP configurations are unchanged. New tests assert actual PID termination and lifespan completion for one and two servers; the new regression fails before the fix and passes afterward.

Current validation (2026-11-07)

  • 104 tests passed, zero failed or skipped, on Windows / Python 3.12.16 with the new lock. This includes 7 generation backend tests and real stdio, HTTP, pinned npx bridge, same-origin redirect, argument/result, loop/branch, snapshot, API/UI concurrency, cancellation, and shutdown coverage.
  • 41/41 non-UI experiments build in both modes, and all 41 complete merged server and parameter configurations are identical.
  • Independent core-only installation: CLI build/run, API, UI HTTP and missing-extra diagnostics pass; guards record zero MCP import attempts and zero service subprocess attempts. Actual build/run probes also confirm MCP child processes exit while the calling process remains alive.
  • Six representative pipelines execute in both modes against the supplied real generation/embedding service: indexing, search, vanilla LLM, vanilla RAG, loop RAG, and branch RAG. Runs use all 10 repository NQ records and a labelled 15-passage fixture corpus with original iteration counts. Live model text and some retrieval ordering vary, so these runs are execution checks rather than claims of byte-for-byte model output equality.
  • Four strict real-response replay comparisons pass: vanilla RAG (8 steps), loop RAG (20), vanilla LLM (6), and branch RAG (38). Local execution records 86 unique real upstream responses and reuses them for repeated identical requests; all 176 MCP requests strictly replay the matching canonical hashes. Request multisets, final results, and every memory snapshot match without answer substitution or normalization. An unknown-request negative check confirms replay never silently forwards to the upstream service.
  • Eight index configurations pass in both modes: FAISS CPU/IP; Milvus Lite/IP,COSINE,L2; Qdrant local/Cosine,Dot,Euclid,Manhattan. Six operations per configuration cover insert, self-retrieval, upsert, large top-k, reload, and overwrite; retrieved contents match between modes.
  • A real 10-page MinerU CPU PDF parse succeeds in both modes with no Gradio installed; all page markers, output text, and SHA256 match. The parser reuses an existing CPU MinerU 3.4.5 environment, while orchestration uses the new MCP environment.
  • uv lock --check, environment dependency consistency, changed-code Ruff checks, and git diff --check pass. Linux all-extras frozen installation-plan validation passes locally.

The current commit is 226bacb. CI Smoke Checks #269 passes all six jobs for this commit: Python 3.11/3.12 regression and dependency resolution, frontend build, and an actual CPU Docker build with both pipeline modes and an HTTP route check. Python and JavaScript/TypeScript CodeQL checks also pass. All commit checks are complete: eight successes and one skipped Mintlify deployment, with no failures or pending checks.

Compatibility and coverage limits

  • Default installation is lean; default MCP execution and remote services require ultrarag[mcp].
  • Local mode supports UltraRAG-registered tools, prompts and supported lifecycles. Pure FastMCP scripts, Context, resources, authentication and middleware require MCP mode; unsupported behavioral options fail explicitly.
  • Service-owned imports are isolated, but third-party process globals remain shared. Synchronous local work finishes before cancellation cleanup and cannot be forcibly terminated like a subprocess.
  • This is functional validation, not full paper-dataset reproduction or a throughput/quality benchmark. GPU FAISS, standalone database clusters and MinerU VLM/formula/table execution remain outside current runtime coverage. An all-extras dry-run is dependency validation, not a GPU runtime test.
  • The index fixture preloads native libraries before MCP startup. The actual retriever path is additionally exercised by the real model pipelines. Milvus Lite and PyArrow are test-only additions to that backend environment.
  • Earlier October experiment/model integration evidence remains historical. Current detailed scripts, results and logs are retained in ignored output/mcp-upgrade-20261107/; credentials and runtime artifacts are not committed.

Comment thread src/ultrarag/api.py Fixed
Comment thread src/ultrarag/mcp_server.py Fixed
Comment thread src/ultrarag/mcp_server.py Fixed
Comment thread src/ultrarag/mcp_server.py Fixed
Comment thread src/ultrarag/mcp_server.py Fixed
@xhd0728 xhd0728 self-assigned this Sep 29, 2026
# event loop starts can hang the loader (also reached by BM25/Milvus).
# Keep these optional imports outside the MCP event loop.
try:
import scipy.linalg # noqa: F401
Comment thread servers/retriever/src/retriever.py Fixed
Comment on lines +1151 to +1156
from chonkie import ( # noqa: F401
RecursiveChunker,
RecursiveRules,
SentenceChunker,
TokenChunker,
)
if os.name == "nt":
# Load optional native libraries before the Windows stdio event loop.
try:
import sentence_transformers # noqa: F401
except ImportError:
pass
try:
import sentencepiece # noqa: F401
Comment thread servers/corpus/src/corpus.py Fixed
Comment thread servers/reranker/src/reranker.py Fixed
Comment thread servers/reranker/src/reranker.py Fixed
Comment thread src/ultrarag/api.py
if _pending_shutdown is not None:
pending = _pending_shutdown
_pending_shutdown = None
await pending
Comment thread src/ultrarag/api.py
if _pending_shutdown is not None:
pending = _pending_shutdown
_pending_shutdown = None
await pending
pending = asyncio.create_task(client.call_tool("wait", {}))
await asyncio.sleep(0.05)
assert not pending.done()
await pending
assert not task.done()
release.set()
with pytest.raises(asyncio.CancelledError):
await task
finally:
(chat_pipeline.parent / "waiting.release").touch()
assert await call == {"ans_ls": ["gate|1"]}
await closing

def _process_is_alive(pid: int) -> bool:
if sys.platform == "win32":
import ctypes
@xhd0728
xhd0728 marked this pull request as ready for review November 7, 2026 04:59
@xhd0728
xhd0728 merged commit a9c82a1 into main Nov 7, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant