Skip to content

lint: lint every server in an MCP client config - #178

Open
abu-tahir-0 wants to merge 1 commit into
patsypppe:mainfrom
abu-tahir-0:feat/lint-client-config
Open

abu-tahir-0 wants to merge 1 commit into
patsypppe:mainfrom
abu-tahir-0:feat/lint-client-config

Conversation

@abu-tahir-0

Copy link
Copy Markdown

What

lint --command handles one server. Most people already have a dozen configured in a client, so toolgauge lint --client-config PATH now walks the file and lints each enabled server.

  • New harness/src/toolgauge/client_config.py reads both layouts: mcpServers (Claude Desktop, Claude Code, Cursor) and servers (VS Code). Entries become:
    • StdioServer(command, args, env) when command is present,
    • HttpServer(url) when only url is present.
    • "disabled": true entries are skipped; anything with neither command nor url is an error rather than silently ignored.
    • Malformed args/env, a missing/!object table, invalid JSON, unreadable files and configs with no enabled servers all raise ClientConfigError, which the CLI prints without a traceback and exits 2.
  • CLI wiring:
    • Exactly one of --command, --endpoint, --client-config is required.
    • Each stdio server reuses one borrowed Probe for all lint rules (same as --command).
    • Output is labelled per server: == name (stdio) == for text, ## name for markdown, and an aggregated {"clientConfig", "servers": [{"name", "kind", "report"|"error"}]} for JSON. SARIF/JUnit/HTML are rejected for multi-server output with a clear message.
    • One server failing to start does not stop the rest; it is recorded with its error and the run exits 1.
  • Env values never printed: they go only to the child process. Exception text is passed through redact_env (longest value first), and the integration test configures SECRET=hunter2 then asserts it is absent from both stdout and stderr.
  • README documents the new flag next to --command.

Verification

  • uv run pytest tests/harness/test_client_config.py tests/harness/test_lint_client_config.py tests/harness/test_stdio_lint.py -q — 17 passed (spawns real subprocess servers; both children proved they received the configured env)
  • uv run pytest tests -m unit -q -n auto (with localhost NO_PROXY) — 407 passed; 4 failures are the known flaky graybox/population/fleet dashboard tests, unrelated to this change
  • uv run mypy — clean (57 files)
  • uv run ruff check . — clean

Closes #143

Add --client-config for Claude Desktop, Claude Code, Cursor and VS Code
files (mcpServers or servers), starting each enabled stdio server with
its command, args and env, and linting url entries as endpoints. One
report per server, with text, markdown and an aggregated JSON shape.
Env values are only passed to the child; error text is redacted and a
test asserts a configured secret never reaches stdout or stderr.

This branch has not been deployed

No deployments
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.

lint: read MCP client config files and lint every configured server

1 participant