Skip to content

fix: pin mcp[cli] below 2.0 in pyproject.toml too - #35

Merged
nileshsimaria merged 3 commits into
Juniper:mainfrom
vishalhabib99:fix/pyproject-mcp-cap
Nov 2, 2026
Merged

nileshsimaria merged 3 commits into
Juniper:mainfrom
vishalhabib99:fix/pyproject-mcp-cap

Conversation

@vishalhabib99

Copy link
Copy Markdown
Contributor

Problem

The commit "fix: pin mcp[cli] below 2.0 to unbreak CI" capped mcp[cli] in requirements.txt (>=1.12.2,<2.0, with the comment that mcp 2.0 removed ServerSessionT / streamablehttp_client). pyproject.toml still asks for mcp[cli]>=1.12.2.

The README and the Dockerfile install from requirements.txt, and uv run uses uv.lock (1.12.2), so those paths are fine. But pyproject.toml defines the junos-mcp-server console script, and installing the package itself resolves fresh:

resolves mcp to (uv pip compile, Python 3.12)
pyproject.toml on main 2.3.0, so the server fails at @app.call_tool() (jmcp.py:1792), because the low-level Server decorators are gone in 2.x
this branch 1.30.0

That covers pip install git+https://github.com/Juniper/junos-mcp-server and uvx --from git+https://github.com/Juniper/junos-mcp-server junos-mcp-server.

Change

mcp[cli]>=1.12.2,<2.0 in pyproject.toml, the same bound requirements.txt already has. uv.lock changes only its matching requires-dist line: no locked versions change, and uv lock --check passes.

Checked

  • The resolutions in the table above.
  • uv lock --check passes.
  • No code changes.

requirements.txt already caps mcp[cli] at <2.0 (mcp 2.0 removed the APIs
jmcp.py uses), but pyproject.toml still asked for >=1.12.2, so installing the
package itself (pip install git+..., uvx --from git+... junos-mcp-server)
resolves mcp 2.3.0 and the server fails at @app.call_tool(). Match the cap;
uv.lock only changes its requires-dist line.
@nileshsimaria

Copy link
Copy Markdown
Collaborator

Thanks for the fix. The two changed lines are correct: I verified uv lock --check passes on the branch, a fresh uv pip compile of this pyproject.toml resolves mcp==1.30.0 (main resolves 2.3.0), and every mcp import in jmcp.py and the tests works on 1.30.0.

A few things before merge, and some optional follow-ups.

Please address in this PR

  1. paramiko has the same drift. requirements.txt has paramiko>=3.5.1,<4.0 (added in c206abb), but pyproject.toml still has paramiko>=3.5.1. The install paths this PR targets (pip install git+..., uvx --from git+...) resolve paramiko 5.1.0. Can you add the <4.0 cap to pyproject.toml too so the two files actually match?

  2. Mirror the comment. requirements.txt explains the cap (# mcp 2.0 removed ServerSessionT / streamablehttp_client; stay on 1.x until migrated). pyproject.toml now has the bare <2.0 with no reason. TOML allows inline # comments in the array; please add the same one-liner so nobody lifts the cap later thinking it is stale.

Optional, but worth considering here or in a follow-up

  1. The >=1.12.2 floor is not installable by itself. mcp==1.12.2 allows current pydantic, but on pydantic 2.14.x from mcp.server.lowlevel import Server fails with ImportError: cannot import name 'eval_type_backport' from 'pydantic._internal._typing_extra'. It only works today because uv.lock also pins pydantic 2.11.7. Either raise the floor to the lowest mcp that imports on current pydantic, or bump the lock (see 4).

  2. Lock vs fresh resolve now differ by 18 minor versions. uv run uses the locked 1.12.2, pip install . / uvx resolve 1.30.0, and CI (pip install -r requirements.txt) gets a third resolution. Running uv lock --upgrade-package mcp in this PR would converge them and also clear the pydantic issue in 3.

  3. Root cause. We have two hand-maintained dependency lists and CI only installs from requirements.txt, so this drift will recur silently. Longer term: generate requirements.txt from pyproject (uv export --format requirements-txt --no-hashes -o requirements.txt), or add a CI step that runs pip install . / uv lock --check and fails if the specifier lists diverge. Happy to take this as a separate PR if you would rather keep this one small.

…lock mcp

Matches requirements.txt. uv lock --upgrade-package mcp (plus pydantic,
pydantic-core, starlette) moves the lock from mcp 1.12.2 to 1.30.0 so uv
run, pip install . and uvx resolve the same mcp, and the lock no longer
depends on pydantic 2.11.x for mcp to import.
@vishalhabib99

Copy link
Copy Markdown
Contributor Author

Thanks @nileshsimaria, very thorough review. Pushed 69dface:

  1. paramiko: pyproject.toml now has paramiko>=3.5.1,<4.0, the same as requirements.txt.
  2. Comment: the requirements.txt one-liner is now above the mcp cap in pyproject.toml.
    3–4. Lock: ran uv lock --upgrade-package mcp. On its own that split pydantic into two versions by Python version, so I also upgraded pydantic, pydantic-core and starlette. The lock now has mcp 1.30.0 and a single pydantic 2.14.1, so uv run, pip install . and uvx all resolve the same mcp. Starlette still forks on Python 3.10 (1.10 needs 3.11 or later). uv lock --check passes, from mcp.server.lowlevel import Server imports, and all 85 tests pass on Python 3.10 and 3.12. I left the >=1.12.2 floor as it is. Happy to raise it if you'd rather.
  3. CI drift check: I'll leave that to you as a separate PR, as you offered.

@vishalhabib99

Copy link
Copy Markdown
Contributor Author

Hi @nileshsimaria, when you have a moment, could you take another look? Everything from your "please address in this PR" list is in 69dface (paramiko cap, comment placement, refreshed lock). The branch is still mergeable.

@nileshsimaria

Copy link
Copy Markdown
Collaborator

Thanks for the fix. The pyproject.toml change itself looks right and I'm happy to take it. A few things before merge:

  1. The uv.lock regeneration in 69dface goes beyond what the description says. "No locked versions change" was true for 37a33f2, but the second commit bumps mcp 1.12.2 -> 1.30.0, starlette 0.47.2 -> 1.7.0/1.10.0, pydantic 2.11.7 -> 2.14.1, pydantic-core 2.33.2 -> 2.50.1, and adds pyjwt. CI and the Dockerfile install from requirements.txt, so none of that is tested anywhere, and the starlette major bump touches code paths we rely on (BaseHTTPMiddleware, Mount, lifespan). Could you revert uv.lock to only the requires-dist line change, as in your first commit? If you want to upgrade the locked versions, please do it in a separate PR so we can test it on its own.

  2. The lock header moved from revision 2 to revision 5 and gained Python 3.14 markers, so it was written by a newer uv than most of us are on. Anyone on uv 0.7/0.8 will get a large spurious lock rewrite on their next uv sync. Reverting the lock as above resolves this. Also, which uv version did you use? Worth noting in the PR.

  3. The paramiko>=3.5.1,<4.0 cap is new and isn't mentioned in the title or description, and unlike the mcp cap it has no comment. Is there a known breakage with paramiko 4 on this code path? If so, please add a one-line comment saying what; if not, I'd rather drop the cap.

Separately, and not blocking this PR: the underlying problem is that pyproject.toml and requirements.txt are hand-synced, and CI only exercises requirements.txt. I'd welcome a follow-up that either adds a pip install . step to CI or generates requirements.txt from pyproject via uv export.

Per review: the lock goes back to the 37a33f2 state (mcp 1.12.2 and the other
pins unchanged, original lock revision), so the only lock change is the mcp
requires-dist line. The paramiko <4 cap is dropped from pyproject.toml.
@vishalhabib99

Copy link
Copy Markdown
Contributor Author

Thanks for the careful review. All three are done in 1eee572:

  1. uv.lock is back to the 37a33f2 state. Against main, the only lock change is the mcp requires-dist line, so no locked versions move. I'll leave upgrading the locked versions to a separate PR if you want one.
  2. That's also why the lock header went from revision 2 to 5: I used uv 0.13.0. With the revert, the header and markers are unchanged. uv lock --check on 0.13.0 passes without rewriting the file.
  3. I don't know of any breakage with paramiko 4 on this code path. I only mirrored the <4.0 that requirements.txt has had since c206abb, so I dropped it from pyproject.toml.

The PR is now just the pyproject.toml mcp cap (plus its one-line comment) and the matching lock line, as the description says. I'm happy to send the CI follow-up separately (a pip install . step, or requirements.txt generated with uv export). Let me know which you'd prefer.

@nileshsimaria

Copy link
Copy Markdown
Collaborator

Thanks for your contribution. The patch looks great.

@nileshsimaria
nileshsimaria merged commit 2fb721a into Juniper:main Nov 2, 2026
@vishalhabib99

Copy link
Copy Markdown
Contributor Author

Thanks for the careful review and the merge, @nileshsimaria. The lockfile and paramiko points were fair catches. If you'd like the follow-up you mentioned (a pip install . step in CI, or generating requirements.txt from pyproject.toml with uv export), I'm happy to send it.

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