From b25a03bf7e9129d6393a7682980a77b2d9627fb0 Mon Sep 17 00:00:00 2001 From: lucarlig Date: Mon, 13 Apr 2026 19:05:16 +0100 Subject: [PATCH] fix: remove hardcoded home paths Signed-off-by: lucarlig --- TESTING.md | 2 +- crates/mcp_runtime/FOLLOWUPS.md | 12 ++++----- crates/mcp_runtime/TESTING-DESIGN.md | 10 ++++---- .../manage/observability/observability.md | 2 +- mcp-servers/python/mcp-rss-search/Makefile | 3 ++- mcp-servers/python/mcp-rss-search/README.md | 2 +- .../python/mcp-rss-search/test_live.sh | 8 +++++- .../output_schema_test_server/TESTING.md | 2 +- tests/performance/utils/setup-auth.sh | 10 ++++++-- tests/unit/test_no_machine_specific_paths.py | 25 +++++++++++++++++++ 10 files changed, 57 insertions(+), 19 deletions(-) create mode 100644 tests/unit/test_no_machine_specific_paths.py diff --git a/TESTING.md b/TESTING.md index 4278289b02..7c4c8e49c7 100644 --- a/TESTING.md +++ b/TESTING.md @@ -210,7 +210,7 @@ pytest -n auto tests/unit/ ```bash # Test a specific file with coverage -. /home/cmihai/.venv/mcpgateway/bin/activate +. .venv/bin/activate pytest --cov-report=annotate tests/unit/mcpgateway/test_translate.py # Test with detailed output diff --git a/crates/mcp_runtime/FOLLOWUPS.md b/crates/mcp_runtime/FOLLOWUPS.md index 42af33c1ca..65e41f34c1 100644 --- a/crates/mcp_runtime/FOLLOWUPS.md +++ b/crates/mcp_runtime/FOLLOWUPS.md @@ -259,7 +259,7 @@ Status: Observed behavior: - The compose testing stack enables the plugin framework with `PLUGINS_ENABLED=true`. -- However, the default [plugins/config.yaml](/home/cmihai/agents2/pr/mcp-context-forge/plugins/config.yaml) keeps built-in plugins such as `PIIFilterPlugin` in `mode: "disabled"`, so the current Rust MCP end-to-end battery does not exercise live plugin enforcement or transformation behavior. +- However, the default [plugins/config.yaml](../../plugins/config.yaml) keeps built-in plugins such as `PIIFilterPlugin` in `mode: "disabled"`, so the current Rust MCP end-to-end battery does not exercise live plugin enforcement or transformation behavior. - Manual spot checks with temporary plugin enablement showed: - `resource_post_fetch` parity for `resources/read` using `LicenseHeaderInjector` - `prompt_pre_fetch` is reached on Rust full mode using `DenyListPlugin` @@ -268,7 +268,7 @@ Observed behavior: - `tool_pre_invoke` / `tool_post_invoke` - `prompt_pre_fetch` / `prompt_post_fetch` - `resource_pre_fetch` / `resource_post_fetch` -- In Rust full mode, the direct fast paths in [lib.rs](/home/cmihai/agents2/pr/mcp-context-forge/crates/mcp_runtime/src/lib.rs) serve several of those methods directly: +- In Rust full mode, the direct fast paths in [lib.rs](src/lib.rs) serve several of those methods directly: - `direct_server_tools_list(...)` - `direct_server_resources_list(...)` - `direct_server_resource_templates_list(...)` @@ -289,10 +289,10 @@ Why this matters: `prompts/get` happy path. Likely area: -- [tool_service.py](/home/cmihai/agents2/pr/mcp-context-forge/mcpgateway/services/tool_service.py) -- [prompt_service.py](/home/cmihai/agents2/pr/mcp-context-forge/mcpgateway/services/prompt_service.py) -- [resource_service.py](/home/cmihai/agents2/pr/mcp-context-forge/mcpgateway/services/resource_service.py) -- [lib.rs](/home/cmihai/agents2/pr/mcp-context-forge/crates/mcp_runtime/src/lib.rs) +- [tool_service.py](../../mcpgateway/services/tool_service.py) +- [prompt_service.py](../../mcpgateway/services/prompt_service.py) +- [resource_service.py](../../mcpgateway/services/resource_service.py) +- [lib.rs](src/lib.rs) Recommended next step: - Keep `make test-mcp-plugin-parity` green in both Python mode and Rust full mode using `tests/e2e/plugin_parity_config.yaml`. diff --git a/crates/mcp_runtime/TESTING-DESIGN.md b/crates/mcp_runtime/TESTING-DESIGN.md index 621879880f..2a48db4494 100644 --- a/crates/mcp_runtime/TESTING-DESIGN.md +++ b/crates/mcp_runtime/TESTING-DESIGN.md @@ -62,7 +62,7 @@ This design covers: - safe fallback behavior in `RUST_MCP_MODE=shadow` It assumes the compose-backed environment from -[docker-compose.yml](/home/cmihai/agents2/pr/mcp-context-forge/docker-compose.yml), +[docker-compose.yml](../../docker-compose.yml), which uses PostgreSQL and Redis. ## Why this matters @@ -107,10 +107,10 @@ The following invariants should stay explicit and testable: Useful existing coverage already lives in: -- [tests/e2e/test_mcp_rbac_transport.py](/home/cmihai/agents2/pr/mcp-context-forge/tests/e2e/test_mcp_rbac_transport.py) -- [tests/integration/test_streamable_http_redis.py](/home/cmihai/agents2/pr/mcp-context-forge/tests/integration/test_streamable_http_redis.py) -- [tests/e2e/test_session_pool_e2e.py](/home/cmihai/agents2/pr/mcp-context-forge/tests/e2e/test_session_pool_e2e.py) -- [tests/loadtest/locustfile_mcp_protocol.py](/home/cmihai/agents2/pr/mcp-context-forge/tests/loadtest/locustfile_mcp_protocol.py) +- [tests/e2e/test_mcp_rbac_transport.py](../../tests/e2e/test_mcp_rbac_transport.py) +- [tests/integration/test_streamable_http_redis.py](../../tests/integration/test_streamable_http_redis.py) +- [tests/e2e/test_session_pool_e2e.py](../../tests/e2e/test_session_pool_e2e.py) +- [tests/loadtest/locustfile_mcp_protocol.py](../../tests/loadtest/locustfile_mcp_protocol.py) These are useful, but they are not enough on their own for Rust session-auth reuse. diff --git a/docs/docs/manage/observability/observability.md b/docs/docs/manage/observability/observability.md index 8a86379817..c2ba406e9f 100644 --- a/docs/docs/manage/observability/observability.md +++ b/docs/docs/manage/observability/observability.md @@ -427,7 +427,7 @@ Use the trace generator helper to verify your observability backend is working: ```bash # Activate virtual environment if needed -. /home/cmihai/.venv/mcpgateway/bin/activate +. .venv/bin/activate # Run the trace generator python tests/integration/helpers/trace_generator.py diff --git a/mcp-servers/python/mcp-rss-search/Makefile b/mcp-servers/python/mcp-rss-search/Makefile index 267fcedb28..c4a35e8acf 100644 --- a/mcp-servers/python/mcp-rss-search/Makefile +++ b/mcp-servers/python/mcp-rss-search/Makefile @@ -3,7 +3,8 @@ .PHONY: help install dev-install format lint test dev serve-http serve-sse test-http mcp-info clean PYTHON ?= python3 -VENV ?= /home/cmihai/.venv/mcpgateway +MAKEFILE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) +VENV ?= $(abspath $(MAKEFILE_DIR)/../../../.venv) HTTP_PORT ?= 9100 HTTP_HOST ?= 0.0.0.0 diff --git a/mcp-servers/python/mcp-rss-search/README.md b/mcp-servers/python/mcp-rss-search/README.md index d55bb19742..ac608bcfb5 100644 --- a/mcp-servers/python/mcp-rss-search/README.md +++ b/mcp-servers/python/mcp-rss-search/README.md @@ -974,7 +974,7 @@ make test lint format **Solution**: Make sure the virtual environment is activated and the package is installed: ```bash -. /home/cmihai/.venv/mcpgateway/bin/activate +. .venv/bin/activate cd mcp-servers/python/mcp-rss-search pip install -e . ``` diff --git a/mcp-servers/python/mcp-rss-search/test_live.sh b/mcp-servers/python/mcp-rss-search/test_live.sh index 499ab1f017..28ca643afb 100755 --- a/mcp-servers/python/mcp-rss-search/test_live.sh +++ b/mcp-servers/python/mcp-rss-search/test_live.sh @@ -7,7 +7,13 @@ echo "🚀 Starting MCP RSS Search Server..." echo "" # Activate virtual environment and start server in background -. /home/cmihai/.venv/mcpgateway/bin/activate +if [ -n "${VIRTUAL_ENV:-}" ] && [ -f "$VIRTUAL_ENV/bin/activate" ]; then + # shellcheck disable=SC1090 + . "$VIRTUAL_ENV/bin/activate" +elif [ -f "../../../.venv/bin/activate" ]; then + # shellcheck disable=SC1091 + . "../../../.venv/bin/activate" +fi python3 -m mcp_rss_search.server_fastmcp --transport http --host 127.0.0.1 --port 9100 > /tmp/rss_server.log 2>&1 & SERVER_PID=$! diff --git a/mcp-servers/python/output_schema_test_server/TESTING.md b/mcp-servers/python/output_schema_test_server/TESTING.md index 07eb5d6238..6e4865667a 100644 --- a/mcp-servers/python/output_schema_test_server/TESTING.md +++ b/mcp-servers/python/output_schema_test_server/TESTING.md @@ -12,7 +12,7 @@ This document provides step-by-step instructions for testing the `outputSchema` 2. **Start ContextForge** (in separate terminal): ```bash - cd /home/cmihai/github/mcp-context-forge + cd /path/to/mcp-context-forge make dev ``` diff --git a/tests/performance/utils/setup-auth.sh b/tests/performance/utils/setup-auth.sh index 8d74213115..3fda1dd610 100755 --- a/tests/performance/utils/setup-auth.sh +++ b/tests/performance/utils/setup-auth.sh @@ -51,9 +51,15 @@ fi cd "$PROJECT_ROOT" || exit 1 # Activate virtual environment if available -if [ -f "/home/cmihai/.venv/mcpgateway/bin/activate" ]; then +if [ -n "${VIRTUAL_ENV:-}" ] && [ -f "$VIRTUAL_ENV/bin/activate" ]; then + # shellcheck disable=SC1090 + source "$VIRTUAL_ENV/bin/activate" +elif [ -f "$PROJECT_ROOT/.venv/bin/activate" ]; then # shellcheck disable=SC1091 - source /home/cmihai/.venv/mcpgateway/bin/activate + source "$PROJECT_ROOT/.venv/bin/activate" +elif [ -f "$HOME/.venv/mcpgateway/bin/activate" ]; then + # shellcheck disable=SC1091 + source "$HOME/.venv/mcpgateway/bin/activate" fi # Generate token diff --git a/tests/unit/test_no_machine_specific_paths.py b/tests/unit/test_no_machine_specific_paths.py new file mode 100644 index 0000000000..10bd076916 --- /dev/null +++ b/tests/unit/test_no_machine_specific_paths.py @@ -0,0 +1,25 @@ +from pathlib import Path + + +def test_repository_does_not_include_machine_specific_home_paths() -> None: + repo_root = Path(__file__).resolve().parents[2] + machine_specific_home = "/home/" + "cmihai" + offenders: list[str] = [] + + for path in repo_root.rglob("*"): + if not path.is_file(): + continue + if ".git" in path.parts: + continue + if path.suffix.lower() in {".png", ".jpg", ".jpeg", ".gif", ".ico", ".pdf", ".pyc"}: + continue + + try: + content = path.read_text(encoding="utf-8") + except (OSError, UnicodeDecodeError): + continue + + if machine_specific_home in content: + offenders.append(str(path.relative_to(repo_root))) + + assert offenders == []