Skip to content

feat(mcp): warn on hidden whitespace in MCP config values (Claude Code v2.1.219-inspired) - #75736

Merged
teknium1 merged 1 commit into
mainfrom
claude-code-inspired/mcp-config-whitespace-warning
Aug 1, 2026
Merged

feat(mcp): warn on hidden whitespace in MCP config values (Claude Code v2.1.219-inspired)#75736
teknium1 merged 1 commit into
mainfrom
claude-code-inspired/mcp-config-whitespace-warning

Conversation

@teknium1

@teknium1 teknium1 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

MCP server config values with hidden leading/trailing whitespace (a token pasted with a trailing newline, a URL copied with a leading space) now produce a startup warning naming the server and the exact dotted key path — instead of surfacing later as an opaque 401 or connect failure.

Inspired by Claude Code v2.1.219: "a warning for MCP config values with hidden leading or trailing whitespace" (changelog).

How Claude Code does it vs. our adaptation

Claude Code Hermes
Trigger claude mcp list / /mcp / startup _load_mcp_config() — every discovery pass, deduped to once per process per (server, key path)
Scope MCP config values Full server config tree: nested dicts, list items (args[1]), env maps — checked after ${VAR} interpolation so whitespace inside a referenced env var is caught too
Secrets Values are never logged; only the key path is named
Mutation Advisory only — values pass through byte-identical (whitespace in an arg could be intentional)

Changes

  • tools/mcp_tool.py: new _warn_hidden_whitespace() helper + call in _load_mcp_config() after env interpolation; process-level dedupe set.
  • tests/tools/test_mcp_config_whitespace_warning.py: 11 tests (flag paths, nesting, list indexing, secret non-leakage, non-mutation, dedupe, E2E through _load_mcp_config).

Validation

Check Result
New tests 11/11 pass
Full MCP tool suite (test_mcp_tool.py + new) 99/99 pass
E2E (real imports, temp HERMES_HOME, real config.yaml) Warning fires once, secret not logged, clean server silent, value unmutated
ruff + py_compile clean

Infographic

MCP config hidden-whitespace warning

Inspired by Claude Code v2.1.219: MCP config string values with hidden
leading/trailing whitespace (pasted tokens with trailing newlines, URLs
with leading spaces) now trigger a startup warning naming the server and
the dotted key path, instead of failing later as an opaque auth/connect
error.

Advisory only: values are never mutated, secrets are never logged (only
key paths), and warnings dedupe to once per process per (server, path).
Checked after ${VAR} interpolation so whitespace inside referenced env
vars is caught too.
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on 1dac21a

ℹ️ Info

Desktop E2E visual evidence · View test artifacts · View job

3 visual diffs.

inline evidence upload failed.

Failed to upload diff-1508682a2ae8-boot-ready-diff.png with gh image (exit code 1): Error uploading /home/runner/work/_temp/e2e-evidence/diff-1508682a2ae8-boot-ready-diff.png: step 0 (get upload token): uploadToken not found on repo page — do you have write access to NousResearch/hermes-agent? (or, if NousResearch enforces SAML SSO, authorize at https://github.com/orgs/NousResearch/sso)

@alt-glitch alt-glitch added type/feature New feature or request tool/mcp MCP client and OAuth area/config Config system, migrations, profiles P3 Low — cosmetic, nice to have sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Aug 1, 2026
@teknium1
teknium1 merged commit 89f9209 into main Aug 1, 2026
41 checks passed
@teknium1
teknium1 deleted the claude-code-inspired/mcp-config-whitespace-warning branch August 1, 2026 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles P3 Low — cosmetic, nice to have sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades tool/mcp MCP client and OAuth type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants