You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+8-44Lines changed: 8 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ For domain-specific guidance, see subdirectory AGENTS.md files:
8
8
-`charts/AGENTS.md` - Helm chart operations
9
9
-`docs/AGENTS.md` - Documentation authoring
10
10
-`mcp-servers/AGENTS.md` - MCP server implementation
11
-
-`tools_rust/mcp_runtime/DEVELOPING.md` - Rust MCP runtime development workflows, command matrix, and validation
11
+
-`crates/mcp_runtime/DEVELOPING.md` - Rust MCP runtime development workflows, command matrix, and validation
12
12
13
13
**Note:** The `llms/` directory contains guidance for LLMs *using* ContextForge solution (end-user runtime guidance), not for code agents working on this codebase.
14
14
@@ -38,7 +38,7 @@ charts/ # Helm charts (see charts/AGENTS.md)
38
38
docs/ # Architecture and usage documentation (see docs/AGENTS.md)
39
39
a2a-agents/ # A2A agent implementations (used for testing/examples)
40
40
mcp-servers/ # MCP server templates (see mcp-servers/AGENTS.md)
41
-
tools_rust/ # Rust utilities and MCP runtime (see tools_rust/mcp_runtime/DEVELOPING.md)
41
+
crates/ # Direct Rust crate folders (runtime and wrapper)
42
42
llms/ # End-user LLM guidance (not for code agents)
**Pattern**: Follows existing SQL instrumentation approach in `instrumentation/sqlalchemy.py:58-87`
166
-
167
-
**Middleware**: `ObservabilityMiddleware` no longer creates `request.state.db`. Each observability operation creates its own short-lived session.
168
-
169
-
**Security**: Query operations use request-scoped sessions for RBAC/token scoping. Write operations are not RBAC-protected (observability visibility is platform-wide).
170
-
171
-
**Connection Pool Sizing**: The separate session pattern creates 4-6 independent database sessions per traced request (trace start/end, span start/end, metrics, events). Default configuration (`DB_POOL_SIZE=200`, `DB_MAX_OVERFLOW=10`) provides 210 total connections, supporting ~35 concurrent traced requests. This is adequate for typical deployments. High-traffic production systems (>50 req/sec sustained) should increase pool size via environment variables: `DB_POOL_SIZE=500`, `DB_MAX_OVERFLOW=100` to support 80+ concurrent requests. Monitor for "QueuePool limit exceeded" errors and adjust pool sizing accordingly. Note: SQLite connections are capped at 50 due to file-based limitations.
172
-
173
138
## Key Environment Variables
174
139
175
140
Defaults come from `mcpgateway/config.py`. `.env.example` intentionally overrides a few for local/dev convenience.
@@ -368,6 +333,5 @@ When posting PR reviews, issue comments, or any public-facing text on GitHub, us
368
333
369
334
-`gh` for GitHub operations
370
335
-`make` for build/test automation
371
-
-`uv` for virtual environment management and for `uv tool run` linter invocations
372
-
- Dev-group tools installed in the venv: `pytest`, `mypy`, `bandit`, `pre-commit`, `prospector`, etc. (see `pyproject.toml``[dependency-groups]`)
373
-
- Formatters and linters (`black`, `isort`, `ruff`, `pylint`, `vulture`, `interrogate`, `radon`, `yamllint`, `tomlcheck`) are pinned in the `Makefile` and invoked on demand via `uv tool run`; always prefer the Makefile targets (`make black`, `make ruff`, `make pylint`, etc.) over calling the underlying tools directly
336
+
-`uv` for virtual environment management
337
+
- Standard tools: pytest, black, isort, ruff, pylint
Copy file name to clipboardExpand all lines: CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,11 @@ conditions:
68
68
69
69
**Rollback**: Keep configuration backups. Restore previous `plugins/config.yaml` if issues arise.
70
70
71
+
### Changed
72
+
73
+
- Consolidated the repository-owned Rust workspace under `crates/`, kept root-level `cargo build` / `cargo test` / `cargo check` support, and documented that `mcp-servers/rust/` stays outside the shared workspace for now. ([#4087](https://github.com/IBM/mcp-context-forge/pull/4087))
74
+
- Added workspace-level Rust policy notes for contributors, tracked `cargo-vet` exemption reduction in [#4173](https://github.com/IBM/mcp-context-forge/issues/4173), and tracked Rust CI workflow factoring in [#4174](https://github.com/IBM/mcp-context-forge/issues/4174).
**Pre-commit Security Gates**: Before any code reaches our repository, it must pass through rigorous pre-commit hooks that include multiple security scanners like Bandit for common security issues, Semgrep for semantic pattern matching, Dodgy for hardcoded secrets detection, and detect-private-key for catching committed private keys, along with type checking and code quality enforcement. Pre-commit hooks also enforce **AI content integrity** (preventing AI-generated artifacts such as hallucinated citations, stock phrases, and malformed code fences) and **Unicode safety** (fixing smart quotes, ligatures, and forbidding BiDi control characters to prevent [trojan-source attacks](https://trojansource.codes/)). Developers can run `make security-all` or `make pre-commit bandit semgrep dodgy lint` locally to execute these same security checks before pushing code.
95
95
96
-
**Continuous Integration Security**: Our GitHub Actions workflows implement automated security scanning on every pull request and commit, with **40+ security scans**triggering automatically on every PR, including Semgrep for semantic analysis, Gitleaks for secret detection, comprehensive dependency vulnerability scanning with pip-audit, npm audit, and cargo audit, SBOM generation, and Hadolint-style linting where configured, IaC scanning with Checkov and kube-linter, GitHub Actions security linting with Zizmor, and multi-language static analysis across Python, Go, Rust, Shell, and JavaScript.
96
+
**Continuous Integration Security**: Our GitHub Actions workflows implement automated security scanning on pull requests and commits, with **40+ security scans**across the full CI suite, including Semgrep for semantic analysis, Gitleaks for secret detection, comprehensive dependency vulnerability scanning with pip-audit, npm audit, cargo-deny advisories, and cargo-vet, SBOM generation, and Hadolint-style linting where configured, IaC scanning with Checkov and kube-linter, GitHub Actions security linting with Zizmor, and multi-language static analysis across Python, Go, Rust, Shell, and JavaScript. Some language-specific security jobs, including the Rust policy pipeline, are path-filtered to Rust-relevant files rather than running on every repository change.
97
97
98
98
**Code Review Security**: All code changes undergo mandatory peer review with security-focused review criteria, ensuring that security considerations are evaluated by human experts in addition to automated tooling.
99
99
@@ -109,12 +109,12 @@ Our security toolchain includes **40+ different security and quality tools**, ea
109
109
110
110
-**Static Analysis Security Testing (SAST)**: CodeQL, Bandit, Semgrep, DevSkim (Microsoft security anti-patterns), and multiple type checkers
111
111
-**Secret Detection**: Gitleaks for git history scanning, Dodgy for hardcoded secrets in code, detect-private-key for committed private keys, and Snyk custom rules for hardcoded JWT secrets and credentials (CWE-798)
112
-
-**Dependency Vulnerability Scanning**: OSV-Scanner, pip-audit, npm audit, cargo audit (Rust), govulncheck (Go), and GitHub dependency review with license policy enforcement
112
+
-**Dependency Vulnerability Scanning**: OSV-Scanner, pip-audit, npm audit, cargo-deny advisories (Rust), govulncheck (Go), and GitHub dependency review with license policy enforcement
113
113
-**Container Security**: Dockerfile linting, SBOM generation, and Dockle where used
114
114
-**Infrastructure as Code (IaC) Security**: Checkov for IaC security scanning (Dockerfiles, Helm charts, docker-compose), kube-linter for Kubernetes/Helm manifest best practices
115
115
-**CI/CD Pipeline Security**: Zizmor for GitHub Actions workflow security linting, actionlint for workflow syntax validation
116
116
-**Go Security**: gosec for Go static security analysis, golangci-lint with security rules, govulncheck for Go vulnerability database checking
117
-
-**Rust Security**: cargo audit for Rust dependency vulnerability scanning, cargo clippy for Rust linting
117
+
-**Rust Security**: cargo-deny for Rust dependency policy and advisory scanning, cargo-vet for supply-chain trust enforcement, cargo clippy for Rust linting
118
118
-**Shell Security**: shellcheck for shell script security and correctness linting
119
119
-**Web & Frontend Security**: ESLint, HTMLHint, Stylelint, retire.js for known-vulnerable JS library detection, nodejsscan for JavaScript/Node.js security vulnerability scanning, npm audit for package vulnerabilities
120
120
-**Code Quality & Best Practices**: Prospector comprehensive analysis, Interrogate for docstring coverage
# ADR-0041: Top-Level Rust Workspace (Cargo.toml at Repository Root)
2
2
3
-
-*Status:*Partially superseded — `plugins_rust/` was removed when in-tree Rust plugins migrated to standalone PyPI packages (`cpex-*`). The remaining Rust workspace members (`tools_rust/`, etc.) are unaffected.
3
+
-*Status:*Accepted
4
4
-*Date:* 2026-02-26
5
5
-*Deciders:* Core Engineering Team
6
6
@@ -13,30 +13,34 @@ The repository is primarily Python-based with some Rust usage (e.g. plugins, too
13
13
Adopt **Option 1: workspace at repository root**.
14
14
15
15
- Add a root `Cargo.toml` defining a Rust workspace.
16
-
- Include Rust crates as workspace members at the repository root. At the time of the decision that meant `mcpgateway_rust/`, `tools_rust/`, and `plugins_rust/`. After the plugin extraction, only the remaining in-repo Rust crates (for example `tools_rust/`) still participate in this workspace.
17
-
- Keep the existing directory layout: Python in `mcpgateway/`, `plugins/`, etc.; Rust crates remain where they are and are referenced from the root workspace.
16
+
- Keep the root workspace member policy simple: workspace-owned crates live under `crates/`, and the root manifest includes them via `crates/*`.
17
+
- Keep the existing directory layout: Python stays in `mcpgateway/`, `plugins/`, and related top-level folders; the Rust workspace-owned crates live in `crates/`.
18
+
- Keep `mcp-servers/rust/` out of the shared workspace. Those sample/test servers remain separately managed and can move out of the repository later if we give them a plugin-like distribution path.
18
19
- PyO3/maturin bindings and CI for Rust builds and tests follow this workspace (see [#3027](https://github.com/IBM/mcp-context-forge/issues/3027) for make targets and acceptance criteria).
19
20
20
21
## Consequences
21
22
22
23
### Positive
23
24
24
25
- Single `cargo build` / `cargo test` / `maturin build` at repo root for all Rust code.
26
+
- Clear placement rule for future workspace crates: if it belongs to the shared root workspace, it goes under `crates/`.
25
27
- Centralized dependency management and simpler CI.
26
28
- Easier cross-crate refactors; natural place to add future Rust components.
27
29
-**Maturin** (by default with a top-level workspace) uses the root `.venv` instead of creating venvs at lower levels—one shared Python environment and simpler dev setup.
28
30
29
31
### Negative
30
32
31
33
- Rust and Python directories live side-by-side at root; language boundary is less visually isolated than a dedicated `rust/` folder.
34
+
- Rust sample/test servers outside `crates/` need their own packaging and release handling until they move to a separate distribution model.
32
35
33
36
## Alternatives Considered
34
37
35
-
-**Option 2 (dedicated `mcpgateway_rust/` as workspace root)**: Clearer language boundary but extra `cd`/Make indirection and, at the time, no single root-level workspace for plugins.
38
+
-**Option 2 (dedicated `mcpgateway_rust/` as workspace root)**: Clearer language boundary but extra `cd`/Make indirection andno single root-level workspace.
36
39
-**Option 3 (hybrid `rust/` folder with gateway_core boundary)**: Deferred; can be revisited if we want a stricter FFI boundary.
37
40
-**Option 4+ (Rust as services / split repos / full rewrite)**: Out of scope for this decision.
-**Supersedes** (build layout): [ADR-0039](039-adopt-fully-independent-plugin-crates-architecture.md)—plugin crates remained independent per ADR-0039, and while they were still in this repo they also participated in the top-level workspace.
45
+
- Follow-up: [#4174](https://github.com/IBM/mcp-context-forge/issues/4174) tracks factoring the large Rust CI workflow into reusable building blocks.
46
+
-**Supersedes** (build layout): [ADR-0039](039-adopt-fully-independent-plugin-crates-architecture.md) for the internal workspace-owned Rust layout. Independent Rust packages can still live outside the workspace when they need separate release metadata or lifecycles.
Copy file name to clipboardExpand all lines: docs/docs/architecture/adr/042-enforce-rust-in-build-process.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -125,4 +125,4 @@ Making Rust mandatory in the build affects **new and existing contributors** who
125
125
-[Open PRs with `rust` label](https://github.com/IBM/mcp-context-forge/pulls?q=is%3Aopen+is%3Apr+label%3Arust) — examples of main Rust components being implemented
Copy file name to clipboardExpand all lines: docs/docs/architecture/explorer.html
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -4821,10 +4821,11 @@ <h3>Testing Matrix</h3>
4821
4821
{name:"Docker Security Scan",file:"docker-scan.yml",desc:"Build locally, generate SBOM with Syft, upload artifact.",triggers:["push","PR"]},
4822
4822
{name:"Helm Chart Publish",file:"helm-publish.yml",desc:"Lint mcp-stack chart, publish to OCI registry on release.",triggers:["push","PR","release"]},
4823
4823
{name:"Python Package Build",file:"python-package.yml",desc:"Build sdist and wheel (make dist) on code changes.",triggers:["push","PR"]},
4824
+
{name:"Pytest With Rust",file:"pytest-rust.yml",desc:"Full pytest suite with Rust build/install enabled for Rust-owned changes.",triggers:["push","PR"]},
4824
4825
{name:"JavaScript Tests (Vitest)",file:"vitest.yml",desc:"Vitest unit tests for browser JavaScript (jsdom environment).",triggers:["push","PR"]},
4825
4826
{name:"Web Lint",file:"lint-web.yml",desc:"ESLint, HTMLHint, Stylelint in separate matrix jobs.",triggers:["push","PR"]},
4826
4827
{name:"Playwright CI Smoke",file:"playwright.yml",desc:"UI automation smoke tests against live gateway.",triggers:["push","PR","manual"]},
4827
-
{name:"Rust Tools CI/CD",file:"rust-tools.yml",desc:"Cargo test and clippy for tools_rust/ and mcp-servers/rust/.",triggers:["push"]},
4828
+
{name:"Rust CI",file:"rust.yml",desc:"Unified Rust workspace CI for build, lint, tests, wheels, audit, coverage, and docs.",triggers:["push","PR","manual"]},
4828
4829
{name:"Alembic Upgrade Validation",file:"alembic-upgrade-validation.yml",desc:"Validate DB migration paths (upgrade testing).",triggers:["PR","push","manual"]},
4829
4830
{name:"License Check",file:"license-check.yml",desc:"Scan for license compliance on dependency changes.",triggers:["push","PR"]},
4830
4831
{name:"Full Linting",file:"linting-full.yml",desc:"Comprehensive linting pass on main branch.",triggers:["push","manual"]},
0 commit comments