Skip to content

fix(mcp): make the docstring budget test environment-independent, trim get_change_risk#955

Merged
RaghavChamadiya merged 1 commit into
mainfrom
fix/docstring-budget-mcp-version
Jul 20, 2026
Merged

fix(mcp): make the docstring budget test environment-independent, trim get_change_risk#955
RaghavChamadiya merged 1 commit into
mainfrom
fix/docstring-budget-mcp-version

Conversation

@RaghavChamadiya

Copy link
Copy Markdown
Member

main is currently red on test_every_tool_docstring_fits_the_schema_budget, reporting get_change_risk at 1669 chars against a 1600 ceiling.

The test's verdict depended on a transitive dependency

It measured fn.__doc__ straight off the registered tool, and @mcp.tool() does not return the same string on every version of the mcp package:

mcp 1.26.0 (pinned in uv.lock, so what CI installs) mcp 1.27.1
fn.__doc__ raw, each line's source indentation attached: 1669 run through inspect.cleandoc: 1576

On a long docstring that is roughly a 90 char swing. The result: the budget passed for anyone whose environment had drifted ahead of the lock, and failed in CI, from byte-identical source. Any local run was systematically more lenient than CI.

The test now dedents before measuring, so it scores the prose an agent actually reads rather than the dependency's normalizing behaviour, and no environment can score more leniently than CI.

Normalizing alone would have hidden a real overage

Under the locked version the schema genuinely was shipping 1669 chars, about 417 tokens against the ~400 the budget exists to enforce. So get_change_risk also loses the sentence describing extensions and exclude_patterns, which restated what its own Args block says two paragraphs later.

Measured from source under both behaviours:

BEFORE (main) raw=1669 FAIL | dedented=1576 pass
AFTER  (fix)  raw=1578 pass | dedented=1489 pass

Every registered tool now fits under either interpretation; get_change_risk is the largest remaining at 1578 raw.

Scope

The docstring crossed the limit in #946, and this is not a regression from the two changes that landed after it. docs/MCP_TOOLS.md does not duplicate the removed sentence, and no other test pins it.

Worth deciding separately: uv.lock pins mcp 1.26.0 while newer environments install 1.27.x. Closing that drift deliberately would prevent the next version-dependent surprise.

Testing

26 tests across the docstring, change-risk, tool-selection, tool-table-drift and prior-fixes suites pass.

…m get_change_risk

The budget test measured `fn.__doc__` straight off the registered tool, and
`@mcp.tool()` does not return the same string on every version of the `mcp`
package. 1.27 runs the docstring through `inspect.cleandoc`; 1.26, which is
the version in uv.lock and therefore the one CI installs, leaves each line's
source indentation attached. On a long docstring that is a ~90 char swing,
enough for `get_change_risk` to measure 1576 locally and 1669 in CI from
identical source. The test passed for anyone whose environment had drifted
ahead of the lock and failed on main.

The test now dedents before measuring, so it scores the prose an agent reads
rather than the dependency's normalizing behaviour, and no local environment
can be more lenient than CI.

Normalizing alone would have hidden a real overage, since under the locked
version the schema genuinely shipped 1669 chars. `get_change_risk` also loses
the sentence describing `extensions` and `exclude_patterns`, which restated
what its own Args block says two paragraphs later. Raw is now 1578 and
dedented 1489, so it fits under either version's behaviour.
@repowise-bot

repowise-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

✅ Health: 7.5 (unchanged)

📋 At a glance
1 hotspot touched · 1 file with recent fix history. Scoped to packages.

📌 Before you merge

  • Run .../mcp/test_change_risk.py, .../mcp/test_prior_fixes.py: they depend on the changed files
  • Docs that usually track this code: docs/MCP_TOOLS.md

🗺️ Change map

flowchart LR
  subgraph PR ["Changed in this PR (1 with dependents)"]
    f_packages_server_src_repowise_server_mcp_server_tool_change_risk_py[".../mcp_server/tool_change_risk.py 🔥"]:::changed
  end
  f_packages_server_src_repowise_server_mcp_server___init___py[".../mcp_server/__init__.py"]
  f_packages_server_src_repowise_server_mcp_server_tool_change_risk_py --> f_packages_server_src_repowise_server_mcp_server___init___py
  t_tests_unit_server_mcp_test_change_risk_py(["✅ .../mcp/test_change_risk.py"]):::guard
  t_tests_unit_server_mcp_test_change_risk_py -.-> f_packages_server_src_repowise_server_mcp_server_tool_change_risk_py
  classDef changed fill:#dbeafe,stroke:#1d4ed8,color:#1e3a5f
  classDef warn fill:#fef3c7,stroke:#b45309,color:#78350f
  classDef guard fill:#dcfce7,stroke:#15803d,color:#14532d
Loading

Solid arrows: code that imports the changed files (1 direct dependent, from the last indexed snapshot). Dashed: history/tests.

🩹 Review priority (files here with the most recent bug-fix history — defects cluster, so review these first)

🔎 More signals (1)

🔥 Hotspot touched (1)

  • .../mcp_server/tool_change_risk.py — 4 commits/90d, 3 dependents

📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-07-20 08:39 UTC
Silence on a single PR with [skip repowise] in the title · Per-repo toggle on repowise.dev/settings?tab=bot

@RaghavChamadiya
RaghavChamadiya merged commit f000d4c into main Jul 20, 2026
7 checks passed
@RaghavChamadiya
RaghavChamadiya deleted the fix/docstring-budget-mcp-version branch July 20, 2026 08:40
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.

2 participants