Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
d022492
feat: add Rust MCP runtime prototype
crivetimihai Mar 9, 2026
ef0a054
feat: integrate experimental Rust MCP runtime
crivetimihai Mar 9, 2026
0b56743
fix: complete Rust MCP compose parity
crivetimihai Mar 9, 2026
a7d7d17
test: improve Rust MCP runtime observability
crivetimihai Mar 9, 2026
e008800
docs: add Rust MCP runtime status report
crivetimihai Mar 9, 2026
ad2474e
fix: harden Rust MCP parity coverage
crivetimihai Mar 9, 2026
9277f17
perf: streamline Rust MCP proxy path
crivetimihai Mar 9, 2026
f4bb34e
perf: streamline server-scoped Rust MCP proxying
crivetimihai Mar 9, 2026
684de3b
perf: narrow Rust MCP sidecar dispatch
crivetimihai Mar 9, 2026
dd1f207
perf: trim trusted Rust MCP dispatch overhead
crivetimihai Mar 9, 2026
43459c9
perf: specialize Rust MCP tools list dispatch
crivetimihai Mar 9, 2026
faf3b25
perf: optimize Rust MCP tools call hot path
crivetimihai Mar 10, 2026
b60f659
perf: validate Rust MCP benchmark curve
crivetimihai Mar 10, 2026
8ccd2a2
perf: add Rust MCP tuning knobs
crivetimihai Mar 10, 2026
1d03649
docs: record Rust MCP load-testing updates
crivetimihai Mar 10, 2026
2ecbf17
feat: expand Rust MCP transport parity
crivetimihai Mar 10, 2026
1c9f6f3
feat: expose active MCP runtime mode
crivetimihai Mar 10, 2026
18c2c68
feat: narrow more MCP methods through Rust runtime
crivetimihai Mar 10, 2026
4d13e0b
feat: narrow more MCP methods through Rust runtime
crivetimihai Mar 10, 2026
39ebc2e
feat: wire Rust MCP rmcp runtime into compose
crivetimihai Mar 10, 2026
f03df41
docs: refresh Rust MCP runtime README
crivetimihai Mar 11, 2026
bf5bbc7
feat: add Rust MCP session core slice
crivetimihai Mar 11, 2026
ca9926d
feat: add Rust MCP event store session core
crivetimihai Mar 11, 2026
fb78b0c
feat: move MCP replay resume path into Rust
crivetimihai Mar 11, 2026
eaf158f
feat: move MCP live streaming into Rust
crivetimihai Mar 11, 2026
303be70
feat: simplify Rust MCP build and runtime UX
crivetimihai Mar 11, 2026
9a766bb
feat: add Rust MCP affinity core slice
crivetimihai Mar 11, 2026
2519bd8
perf: reuse auth cache on MCP transport path
crivetimihai Mar 12, 2026
1c1da1b
perf: move MCP read paths and auth cache hot path
crivetimihai Mar 12, 2026
ff75f38
fix: restore RPC permission and server scope semantics
crivetimihai Mar 12, 2026
a6bd2c4
fix: resolve flake8 and bandit findings
crivetimihai Mar 12, 2026
9d87968
fix: satisfy pylint checks
crivetimihai Mar 12, 2026
03591b0
fix: align RPC permission tests and docstrings
crivetimihai Mar 12, 2026
62f40ac
test: raise diff coverage for Rust MCP paths
crivetimihai Mar 12, 2026
a0b3ef5
perf: route public MCP ingress directly to Rust
crivetimihai Mar 12, 2026
fb0a0bc
feat: add Rust MCP benchmark targets and safe fallback
crivetimihai Mar 13, 2026
33fea06
feat: clarify Rust MCP mode workflow
crivetimihai Mar 13, 2026
d43deca
test: add MCP session isolation coverage
crivetimihai Mar 13, 2026
ee32597
docs: add Rust MCP follow-up tracker and quick reference
crivetimihai Mar 13, 2026
95683d2
test: raise Rust MCP diff coverage to 100 percent
crivetimihai Mar 13, 2026
5b84061
test: stabilize logger capture assertions
crivetimihai Mar 13, 2026
f4181ae
test: improve Rust MCP runtime coverage and tooling
crivetimihai Mar 14, 2026
132b3ee
test: expand Rust MCP runtime unit coverage
crivetimihai Mar 14, 2026
d0a8e5d
refactor: clean up Rust MCP runtime lint issues
crivetimihai Mar 14, 2026
1c4ca54
perf: reduce Rust MCP RMCP and header overhead
crivetimihai Mar 14, 2026
8c2f9a8
docs: document Rust MCP runtime architecture
crivetimihai Mar 14, 2026
5debdeb
docs: improve Rust MCP runtime code documentation
crivetimihai Mar 14, 2026
88e3d00
docs: refresh Rust MCP runtime guides
crivetimihai Mar 14, 2026
0a0c3cd
docs: add Rust MCP follow-up checklist
crivetimihai Mar 14, 2026
a3c31e9
test: isolate Rust-only MCP E2E coverage
crivetimihai Mar 14, 2026
6b3313f
feat: show MCP runtime mode in admin UI
crivetimihai Mar 14, 2026
3bbb710
fix: harden auth service and test stack startup
crivetimihai Mar 15, 2026
34526f1
fix: harden Rust MCP public ingress
crivetimihai Mar 15, 2026
bda7b83
fix: redact Rust MCP transport errors
crivetimihai Mar 15, 2026
60633d2
feat: add optional Postgres TLS for Rust MCP runtime
crivetimihai Mar 15, 2026
ed0cef4
test: extend Rust MCP isolation validation
crivetimihai Mar 15, 2026
66d9200
fix: handle ambiguous MCP resource reads cleanly
crivetimihai Mar 15, 2026
e124e1b
test: add Rust MCP access matrix coverage
crivetimihai Mar 15, 2026
f4d20a1
fix: tighten Rust MCP response shaping
crivetimihai Mar 15, 2026
aa7f411
test: expand Rust MCP runtime unit coverage
crivetimihai Mar 15, 2026
ea187ab
fix: clean up Rust MCP helper plumbing
crivetimihai Mar 15, 2026
47dc6b8
fix: normalize Rust MCP resource fallback payloads
crivetimihai Mar 15, 2026
5fb7961
test: add MCP plugin parity coverage
crivetimihai Mar 15, 2026
bb1d252
test: gate MCP prompt and plugin parity
crivetimihai Mar 15, 2026
783077e
docs: expand Rust MCP release checklist
crivetimihai Mar 15, 2026
6d04fb0
test: finalize Rust MCP release validation
crivetimihai Mar 15, 2026
254e5b9
docs: add modular runtime specification
crivetimihai Mar 15, 2026
9f1b414
docs: document implemented MCP module
crivetimihai Mar 15, 2026
270db5e
test: harden Rust runtime coverage
crivetimihai Mar 15, 2026
46ef080
fix: harden Rust runtime fail-closed handling
crivetimihai Mar 16, 2026
d6c2335
fix: harden internal MCP trust boundaries
crivetimihai Mar 16, 2026
4fe2815
fix: tolerate string auth secrets in MCP trust helpers
crivetimihai Mar 16, 2026
a43a746
test: skip parity E2Es without parity config
crivetimihai Mar 16, 2026
e2e68d9
fix: stabilize minikube release validation
crivetimihai Mar 16, 2026
4aff597
fix: record rust tools call metrics
crivetimihai Mar 16, 2026
1ac45fc
fix: satisfy metrics buffer lint
crivetimihai Mar 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,50 @@ OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
# MCP_SESSION_POOL_ENABLED=false
# ANYIO_CANCEL_DELIVERY_PATCH_ENABLED=false

# Rust MCP (simple)
# RUST_MCP_BUILD=false # build the Rust MCP runtime into Containerfile.lite images
# RUST_MCP_MODE=off # off | shadow | edge | full
# RUST_MCP_LOG=warn # default Rust sidecar log filter for the simple mode flow
#
# RUST_MCP_MODE=shadow -> Rust sidecar enabled, but public /mcp stays on Python for safe fallback
# RUST_MCP_MODE=edge -> direct public /mcp on Rust with managed UDS sidecar defaults
# RUST_MCP_MODE=full -> edge + Rust session/event-store/resume/live-stream/affinity cores
#
# Advanced Rust MCP overrides
# RUST_MCP_SESSION_AUTH_REUSE=false # advanced override for the fast direct public Rust session-auth path; prefer RUST_MCP_MODE presets above
# EXPERIMENTAL_RUST_MCP_RUNTIME_ENABLED=
# EXPERIMENTAL_RUST_MCP_RUNTIME_URL=http://127.0.0.1:8787
# EXPERIMENTAL_RUST_MCP_RUNTIME_UDS=/tmp/contextforge-mcp-rust.sock
# EXPERIMENTAL_RUST_MCP_RUNTIME_TIMEOUT_SECONDS=30
# EXPERIMENTAL_RUST_MCP_SESSION_CORE_ENABLED= # enable Rust-owned MCP session metadata/lifecycle increment
# EXPERIMENTAL_RUST_MCP_EVENT_STORE_ENABLED= # enable Rust-owned resumable event-store backend
# EXPERIMENTAL_RUST_MCP_RESUME_CORE_ENABLED= # enable Rust-owned public GET /mcp replay/resume path
# EXPERIMENTAL_RUST_MCP_LIVE_STREAM_CORE_ENABLED= # enable Rust-owned public GET /mcp live SSE path
# EXPERIMENTAL_RUST_MCP_AFFINITY_CORE_ENABLED= # enable Rust-owned session-affinity forwarding path
# EXPERIMENTAL_RUST_MCP_SESSION_AUTH_REUSE_ENABLED= # enable Rust-owned session-bound auth-context reuse
# EXPERIMENTAL_RUST_MCP_RUNTIME_MANAGED= # launcher env, not a Pydantic setting
# ENABLE_RUST_MCP_RMCP_BUILD= # container build arg override for rmcp-enabled Rust MCP binary
# MCP_RUST_USE_RMCP_UPSTREAM_CLIENT= # runtime override for official rust-sdk upstream tools/call client
# MCP_RUST_LISTEN_HTTP=127.0.0.1:8787 # runtime env for bundled Rust sidecar
# MCP_RUST_LISTEN_UDS=/tmp/contextforge-mcp-rust.sock
# MCP_RUST_SESSION_CORE_ENABLED= # explicit sidecar env; defaults from EXPERIMENTAL_RUST_MCP_SESSION_CORE_ENABLED
# MCP_RUST_SESSION_TTL_SECONDS=3600
# MCP_RUST_EVENT_STORE_ENABLED= # explicit sidecar env; defaults from EXPERIMENTAL_RUST_MCP_EVENT_STORE_ENABLED
# MCP_RUST_RESUME_CORE_ENABLED= # explicit sidecar env; defaults from EXPERIMENTAL_RUST_MCP_RESUME_CORE_ENABLED
# MCP_RUST_LIVE_STREAM_CORE_ENABLED= # explicit sidecar env; defaults from EXPERIMENTAL_RUST_MCP_LIVE_STREAM_CORE_ENABLED
# MCP_RUST_AFFINITY_CORE_ENABLED= # explicit sidecar env; defaults from EXPERIMENTAL_RUST_MCP_AFFINITY_CORE_ENABLED
# MCP_RUST_SESSION_AUTH_REUSE_ENABLED= # explicit sidecar env; defaults from EXPERIMENTAL_RUST_MCP_SESSION_AUTH_REUSE_ENABLED
# MCP_RUST_SESSION_AUTH_REUSE_TTL_SECONDS=30
# MCP_RUST_EVENT_STORE_MAX_EVENTS_PER_STREAM=100
# MCP_RUST_EVENT_STORE_TTL_SECONDS=3600
# MCP_RUST_EVENT_STORE_POLL_INTERVAL_MS=250
# MCP_RUST_LOG= # advanced runtime log override for the bundled Rust sidecar
# MCP_RUST_BACKEND_RPC_URL=http://127.0.0.1:4444/_internal/mcp/rpc
# MCP_RUST_REDIS_URL=redis://redis:6379/0
# MCP_RUST_CACHE_PREFIX=mcpgw:
# MCP_RUST_DATABASE_URL=postgresql://postgres:mysecretpassword@pgbouncer:6432/mcp
# MCP_RUST_DB_POOL_MAX_SIZE=20

# =============================================================================
# Performance Tuning (quick reference)
# =============================================================================
Expand Down Expand Up @@ -1773,16 +1817,20 @@ OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
# =============================================================================
# Caches authentication data (user, team, revocation) to reduce database queries
# Uses Redis when available, falls back to in-memory cache
# Applies to both Python MCP and Rust MCP because public MCP auth still runs in Python first

# Enable Redis/in-memory caching for authentication data (default: true)
# Significantly reduces database queries during authentication
# Disabling this also disables the shared auth cache benefit for RUST_MCP_MODE=edge/full
# AUTH_CACHE_ENABLED=true

# TTL in seconds for cached user data (default: 60, range: 10-300)
# Also affects MCP Streamable HTTP auth, including Rust-fronted MCP requests
# AUTH_CACHE_USER_TTL=60

# TTL in seconds for token revocation cache (default: 30, range: 5-120)
# Security-critical: keep short to limit exposure window for revoked tokens
# Also affects MCP auth on both Python and Rust runtime modes
# AUTH_CACHE_REVOCATION_TTL=30

# TTL in seconds for team membership cache (default: 60, range: 10-300)
Expand All @@ -1794,6 +1842,7 @@ OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317

# Enable caching for get_user_teams() (default: true)
# Set to false to disable teams list caching (useful for debugging)
# Also affects session-token MCP auth on Python and Rust modes
# AUTH_CACHE_TEAMS_ENABLED=true

# TTL in seconds for user teams list cache (default: 60, range: 10-300)
Expand All @@ -1802,6 +1851,7 @@ OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317

# Batch auth DB queries into single call (default: true)
# Reduces 3 separate queries to 1, improving performance under load
# Streamable HTTP MCP auth uses this too before falling back to per-query checks
# AUTH_CACHE_BATCH_QUERIES=true

# Registry Cache Configuration
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ TODO.md
FIXMEs

# Upgrade validation outputs
artifacts/
artifacts/upgrade-validation*/

# Debug & profiling artifacts
Expand Down Expand Up @@ -354,6 +355,12 @@ docs/docs/test/license-check-report.json
nginx.conf
docker-compose.perf.yml

# Rust MCP runtime profiling artifacts
tools_rust/mcp_runtime/profiles/
tools_rust/mcp_runtime/flamegraph*.svg
tools_rust/mcp_runtime/flamegraph*.html
tools_rust/mcp_runtime/perf.data*

# JMeter test results and local installation
tests/jmeter/results/*.jtl
tests/jmeter/results/*/
Expand Down
32 changes: 30 additions & 2 deletions Containerfile.lite
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# Python major.minor series to track
ARG PYTHON_VERSION=3.12
ARG ENABLE_RUST=false
ARG ENABLE_RUST_MCP_RMCP=false
# Enable profiling tools (memray, py-spy) - off by default for smaller images
# To enable: docker build --build-arg ENABLE_PROFILING=true -f Containerfile.lite .
# Usage after enabling:
Expand All @@ -36,14 +37,19 @@ ARG ENABLE_PROFILING=false
###############################################################################
FROM quay.io/pypa/manylinux2014:2026.03.06-3 AS rust-builder-base
ARG ENABLE_RUST
ARG ENABLE_RUST_MCP_RMCP

# Set shell with pipefail for safety
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Only build if ENABLE_RUST=true
RUN if [ "$ENABLE_RUST" != "true" ]; then \
echo "⏭️ Rust builds disabled (set --build-arg ENABLE_RUST=true to enable)"; \
mkdir -p /build/rust-wheels; \
mkdir -p /build/rust-wheels /build/tools_rust/mcp_runtime/target/release; \
printf '#!/usr/bin/env sh\n' > /build/tools_rust/mcp_runtime/target/release/contextforge-mcp-runtime; \
printf 'echo "Rust MCP runtime not built into this image. Rebuild with --build-arg ENABLE_RUST=true." >&2\n' >> /build/tools_rust/mcp_runtime/target/release/contextforge-mcp-runtime; \
printf 'exit 1\n' >> /build/tools_rust/mcp_runtime/target/release/contextforge-mcp-runtime; \
chmod +x /build/tools_rust/mcp_runtime/target/release/contextforge-mcp-runtime; \
exit 0; \
fi

Expand All @@ -55,8 +61,9 @@ ENV PATH="/root/.cargo/bin:$PATH"

WORKDIR /build

# Copy only Rust plugin files (only if ENABLE_RUST=true)
# Copy only Rust plugin/runtime files (only if ENABLE_RUST=true)
COPY plugins_rust/ /build/plugins_rust/
COPY tools_rust/mcp_runtime/ /build/tools_rust/mcp_runtime/

# Build each Rust plugin independently using Python 3.12 from manylinux image
RUN if [ "$ENABLE_RUST" = "true" ]; then \
Expand All @@ -74,6 +81,21 @@ RUN if [ "$ENABLE_RUST" = "true" ]; then \
echo "⏭️ Skipping Rust plugin build"; \
fi

WORKDIR /build/tools_rust/mcp_runtime

# Build the experimental Rust MCP runtime binary (only if ENABLE_RUST=true)
RUN if [ "$ENABLE_RUST" = "true" ]; then \
if [ "$ENABLE_RUST_MCP_RMCP" = "true" ]; then \
cargo build --release --features rmcp-upstream-client; \
else \
cargo build --release; \
fi && \
cp target/release/contextforge_mcp_runtime target/release/contextforge-mcp-runtime && \
echo "βœ… Rust MCP runtime built successfully"; \
else \
echo "⏭️ Skipping Rust MCP runtime build"; \
fi

FROM rust-builder-base AS rust-builder

###########################
Expand Down Expand Up @@ -127,6 +149,7 @@ COPY pyproject.toml /app/
# Copy Rust plugin wheels from rust-builder stage (if any exist)
# ----------------------------------------------------------------------------
COPY --from=rust-builder /build/rust-wheels/ /tmp/rust-wheels/
COPY --from=rust-builder /build/tools_rust/mcp_runtime/target/release/contextforge-mcp-runtime /app/bin/contextforge-mcp-runtime

# ----------------------------------------------------------------------------
# Create and populate virtual environment
Expand All @@ -139,6 +162,7 @@ COPY --from=rust-builder /build/rust-wheels/ /tmp/rust-wheels/
# - Remove build caches and build artifacts
# ----------------------------------------------------------------------------
ARG ENABLE_RUST=false
ARG ENABLE_RUST_MCP_RMCP=false
ARG ENABLE_PROFILING=false
RUN set -euo pipefail \
&& . /etc/profile.d/use-openssl.sh \
Expand Down Expand Up @@ -219,6 +243,8 @@ RUN chown -R 1001:0 /app \
FROM registry.access.redhat.com/ubi10/ubi-minimal:10.1-1772441549 AS runtime

ARG PYTHON_VERSION=3.12
ARG ENABLE_RUST=false
ARG ENABLE_RUST_MCP_RMCP=false
ARG ENABLE_PROFILING=false

# ----------------------------------------------------------------------------
Expand Down Expand Up @@ -285,6 +311,8 @@ COPY --from=builder --chown=1001:0 /app /app
# - Disable pip version check to reduce startup time
# ----------------------------------------------------------------------------
ENV PATH="/app/.venv/bin:${PATH}" \
CONTEXTFORGE_ENABLE_RUST_BUILD=${ENABLE_RUST} \
CONTEXTFORGE_ENABLE_RUST_MCP_RMCP_BUILD=${ENABLE_RUST_MCP_RMCP} \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
Expand Down
Loading
Loading