Skip to content

fix(config): preserve loaded MCP settings - #2193

Merged
assafelovic merged 1 commit into
assafelovic:mainfrom
imharjot:fix/preserve-mcp-configuration
Oct 10, 2026
Merged

assafelovic merged 1 commit into
assafelovic:mainfrom
imharjot:fix/preserve-mcp-configuration

Conversation

@imharjot

@imharjot imharjot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Config loads MCP_SERVERS and MCP_ALLOWED_ROOT_PATHS, then replaces both with empty lists. This makes the stored settings disappear and get_mcp_server_config() return {} for a configured server.

Keep the loaded values and shallow-copy the two lists so modifying one default Config instance still cannot affect another instance or DEFAULT_CONFIG. Nine regressions cover file/env loading and precedence, explicit empty overrides, named lookup, malformed rows, default-list isolation and the public GPTResearcher.cfg path.

Fixes #2192.

Validation:

  • Python 3.12.15 and 3.13.16: 560 passed, 2 skipped, 4 deselected each.
  • Python 3.14.5: 562 passed, 1 skipped, 4 deselected.
  • Full collection, public package import, all 125 available submodules and ASGI app import pass. Azure remains the optional import exception listed in CI.
  • On unchanged main, the nine new cases give 5 failures and 4 passing controls; all nine pass with the fix.

The offline suite used the repository's current command, with its network guard enabled:

GPTR_BLOCK_NETWORK=1 python -m pytest tests/ \
  --forked --timeout=60 -p no:warnings \
  --deselect tests/test_researcher_logging.py \
  --deselect tests/test_logging_output.py \
  --deselect tests/test_mcp.py

On macOS with Homebrew Python 3.14, this command also needed process-only NO_PROXY='*': the same three existing Nebius constructor tests crash after fork on unchanged main without it. No test or CI flags were changed. Python 3.12/3.13 skip the existing PDF module when WeasyPrint native libraries are unavailable; Python 3.14 runs those cases. The remaining skip is the upstream obsolete security-helper suite, and the four deselections are the existing CI live cases.

Live MCP connections and model research were not run; this change restores stored configuration and lookup, without changing automatic server connection or root-path enforcement.

@assafelovic
assafelovic merged commit ba8dbca into assafelovic:main Oct 10, 2026
menotbobbybrown pushed a commit to menotbobbybrown/gpt-researcher that referenced this pull request Oct 11, 2026
load_config returned DEFAULT_CONFIG itself (or a shallow copy), so dict and list defaults were shared across every Config. GPTResearcher calls cfg.set_verbose() on init, which wrote {'verbose': ...} into the process-wide DEFAULT_CONFIG['LLM_KWARGS'], leaking one run's setting into all later runs. load_config now returns a deep copy, which also makes the per-list MCP copies from assafelovic#2193 unnecessary.

Co-authored-by: Cursor <[email protected]>
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.

MCP configuration lists are reset during Config initialization

2 participants