Skip to content

[MCP] Follow nextCursor when listing tools in MCPClient - #4960

Merged
hanouticelina merged 2 commits into
huggingface:mainfrom
Kayvan-Zahiri:mcp-list-tools-pagination
Sep 22, 2026
Merged

hanouticelina merged 2 commits into
huggingface:mainfrom
Kayvan-Zahiri:mcp-list-tools-pagination

Conversation

@Kayvan-Zahiri

@Kayvan-Zahiri Kayvan-Zahiri commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4956.

Summary

  • MCPClient.add_mcp_server() called session.list_tools() once and ignored nextCursor, so a server that paginates tools/list only had its first page registered.
  • The first call is still a plain list_tools(), so servers that don't paginate behave exactly as before. While nextCursor is set, it keeps calling list_tools(cursor=...).
  • The mcp extra's floor goes from 1.8.0 to 1.9.4, because that's the first release where list_tools(cursor=...) actually paginates. I checked each version by installing it: 1.8.0's list_tools() takes no cursor at all, and 1.9.0 accepts it but puts it on the request instead of in params, so the server never sees it and a paginating server returns page one forever. From 1.9.4 on, it sends PaginatedRequestParams(cursor=...). (Thanks to Bugbot for catching this; my first version called list_tools(cursor=None) unconditionally and would have broken 1.8.x.)

The reproducer from the issue (a real stdio server returning search_docs on page 1 and fetch_doc on page 2):

# main
allowed_tools=None -> tools=['search_docs'] sessions=['search_docs']
allowed_tools=['fetch_doc'] -> tools=[] sessions=[]

# this branch, mcp 1.9.4 and mcp 1.30.0 (same output on both)
allowed_tools=None -> tools=['search_docs', 'fetch_doc'] sessions=['fetch_doc', 'search_docs']
allowed_tools=['fetch_doc'] -> tools=['fetch_doc'] sessions=['fetch_doc']

I didn't add a test file: there are no MCP tests in tests/ today and mcp isn't in the testing extra, so it would be skipped in CI. Happy to add one if you'd like a pattern for it. make style, make quality and mypy on the file all pass.

add_mcp_server called list_tools() once, so tools past a server's first
tools/list page were never registered, and allowed_tools could filter
down to nothing. Page through with the cursor until nextCursor is empty.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit bf99263. Configure here.

tools.extend(response.tools)
cursor = response.nextCursor
if not cursor:
break

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pagination breaks older allowed mcp

Low Severity

The pagination loop always calls list_tools with cursor=, but that argument does not exist in mcp 1.8.x and is sent incorrectly in 1.9.0. Those versions are still allowed by the extra, so add_mcp_server can raise TypeError or spin forever against a paginating server.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit bf99263. Configure here.

….9.4

mcp 1.8.x's list_tools() takes no cursor at all, and before 1.9.4 the cursor
is sent outside params, so a paginating server returns page one forever.
Call list_tools() plainly first so non-paginated servers behave as before,
and raise the extra's floor to the first release that paginates correctly.
@Kayvan-Zahiri

Copy link
Copy Markdown
Contributor Author

Bugbot was right about older mcp: 1.8.0's list_tools() has no cursor parameter, and 1.9.0 sends it outside params, so my first version would have broken 1.8.x and looped on 1.9.0 with a paginating server. Fixed in 8fc922f: the first call is a plain list_tools() again, and the extra now requires mcp>=1.9.4, the first release that paginates correctly. Reran the reproducer on 1.9.4 and 1.30.0, and both return both tools. I've updated the description.

@bot-ci-comment

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@hanouticelina hanouticelina left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the fix looks good to me, thank you!
note that this part of the library is no longer actively maintained.

@hanouticelina
hanouticelina merged commit 7025391 into huggingface:main Sep 22, 2026
16 of 21 checks passed
Wauplin added a commit that referenced this pull request Sep 22, 2026
* [HfFileSystem] Make lpath optional in get_file (fsspec>=2026.9.0) (#4951)

* [HfFileSystem] Make `lpath` optional in `get_file` (fsspec>=2026.9.0)

fsspec 2026.9.0 made `lpath` optional in `AbstractFileSystem.get_file`
(it can be omitted when `outfile` is provided). Our override kept it
required, which the latest `ty` flags as an invalid method override and
fails CI.

Make `lpath=None` in the signature and raise a clear ValueError if
neither `lpath` nor `outfile` is provided. No behavior change otherwise.

* fix get_file branching to match fsspec

---------

Co-authored-by: Celina Hanouti <hanouticelina@gmail.com>

* Fix `format_timesince` showing "60 seconds ago" / "60 minutes ago" / "24 hours ago" instead of rolling over (#4943)

* Roll `format_timesince` over to the next unit at the boundary

`format_timesince` showed "60 seconds ago", "60 minutes ago" and "24 hours ago"
at the exact unit boundaries instead of rolling over to the next unit, because
the per-unit max values were 60/60/24 rather than 59/59/23. Days (6 -> 1 week)
and months (11 -> 1 year) already rolled correctly; this brings seconds,
minutes and hours in line. Adds the boundary cases to the test.

* Update src/huggingface_hub/utils/_parsing.py

---------

Co-authored-by: célina <hanouticelina@gmail.com>

* Fix Windows conftest erroring test subsets on lazy-loaded file_download submodule (#4945)

* Fix Windows conftest failing on lazy-loaded `file_download` submodule

The `disable_symlinks_on_windows_ci` autouse fixture (active on Windows via
`DISABLE_SYMLINKS_IN_WINDOWS_TESTS=1` in pyproject.toml) accesses
`huggingface_hub.file_download` as a monkeypatch target. Since the package
loads submodules lazily, this attribute only exists if something else already
imported the submodule. Running a test subset that doesn't (e.g.
`pytest tests/test_utils_headers.py`) errors every test at setup with
`AttributeError: No huggingface_hub attribute file_download`.

Use the string-target form of `monkeypatch.setattr`, which imports the
submodule itself.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* Update tests/conftest.py

---------

Co-authored-by: dltsum <dltsum@users.noreply.github.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: célina <hanouticelina@gmail.com>

* [Webhooks] Allow `bucket` as a watched item type (#4958)

The Hub accepts buckets as watched items, but `hf webhooks create
--watch bucket:...` fails client-side because the CLI derives its valid
types from `WebhookWatchedItem.type`, which lacked "bucket".


Claude-Session: https://claude.ai/code/session_015YLK3QPDdiiZGuDxoFrEag

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* [MCP] Follow nextCursor when listing tools in MCPClient (#4960)

* [MCP] Follow nextCursor when listing tools in MCPClient

add_mcp_server called list_tools() once, so tools past a server's first
tools/list page were never registered, and allowed_tools could filter
down to nothing. Page through with the cursor until nextCursor is empty.

* [MCP] Keep the first list_tools() call cursor-free and require mcp>=1.9.4

mcp 1.8.x's list_tools() takes no cursor at all, and before 1.9.4 the cursor
is sent outside params, so a paginating server returns page one forever.
Call list_tools() plainly first so non-paginated servers behave as before,
and raise the extra's floor to the first release that paginates correctly.

* Align the `hf` package's python_requires with huggingface_hub (#4959)

* [CLI] Align the `hf` package's python_requires with huggingface_hub

`huggingface_hub` moved to `python_requires=">=3.10.0"` in #4856, but
`utils/hf/setup.py` was left at `">=3.9.0"`. The `hf` package is only a console
script that imports `huggingface_hub` and pins `huggingface_hub=={version}`, so
the published metadata now contradicts itself: PyPI shows `hf` 1.32.0 as
`Requires-Python: >=3.9.0` while the `huggingface_hub==1.32.0` it depends on is
`>=3.10.0`.

On Python 3.9 that resolves two ways, both wrong:

    $ pip install hf
    Successfully installed hf-1.8.0 huggingface_hub-1.8.0   # silently 24 versions stale

    $ pip install hf==1.32.0
    ERROR: Could not find a version that satisfies the requirement
      huggingface_hub==1.32.0 (from hf)
    ERROR: No matching distribution found for huggingface_hub==1.32.0

The first is the damaging one: `uvx hf`, the usage the README documents, reports
version 1.8.0 on a 3.9 interpreter with no error and no warning, so a user can
be years out of date without any signal.

Set `python_requires` to match the root setup.py and add a test asserting the
two stay equal, since the root cause is that they are edited independently and
nothing tied them together.

Verification:
  $ python -m build --wheel   # in utils/hf
  Requires-Python: >=3.10.0
  Requires-Dist: huggingface_hub==1.33.0.dev0
Signed-off-by: Sharvil Saxena <sharvil.saxena@gmail.com>

* no need to add tests

* Update utils/hf/setup.py

---------

Signed-off-by: Sharvil Saxena <sharvil.saxena@gmail.com>
Co-authored-by: célina <hanouticelina@gmail.com>

* Remove dots from allowed characters in job labels. (#4962)

* [CLI] Honor `CLAUDE_CONFIG_DIR` in `hf skills add -g --claude` (#4957)

* [CLI] Honor CLAUDE_CONFIG_DIR in hf skills add -g --claude

* remove test

* [CLI] Always install skills for Claude Code, deprecate --claude (#4967)

* [CLI] Always install skills for Claude Code, deprecate --claude

* show --claude as deprecated in help instead of hiding it

* remove test

---------

Signed-off-by: Sharvil Saxena <sharvil.saxena@gmail.com>
Co-authored-by: Assaf Vayner <assaf@huggingface.co>
Co-authored-by: Celina Hanouti <hanouticelina@gmail.com>
Co-authored-by: Sreekant Baheti <60787859+Sreekant13@users.noreply.github.com>
Co-authored-by: DltsumCtnori <lllalllbpear@gmail.com>
Co-authored-by: dltsum <dltsum@users.noreply.github.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Daniel van Strien <davanstrien@users.noreply.github.com>
Co-authored-by: Kayvan Zahiri <123409429+Kayvan-Zahiri@users.noreply.github.com>
Co-authored-by: Sharvil Saxena <97365286+sharziki@users.noreply.github.com>
Co-authored-by: shaun smith <1936278+evalstate@users.noreply.github.com>
Wauplin added a commit that referenced this pull request Sep 23, 2026
* [HfFileSystem] Make lpath optional in get_file (fsspec>=2026.9.0) (#4951)

* [HfFileSystem] Make `lpath` optional in `get_file` (fsspec>=2026.9.0)

fsspec 2026.9.0 made `lpath` optional in `AbstractFileSystem.get_file`
(it can be omitted when `outfile` is provided). Our override kept it
required, which the latest `ty` flags as an invalid method override and
fails CI.

Make `lpath=None` in the signature and raise a clear ValueError if
neither `lpath` nor `outfile` is provided. No behavior change otherwise.

* fix get_file branching to match fsspec

---------

Co-authored-by: Celina Hanouti <hanouticelina@gmail.com>

* Fix `format_timesince` showing "60 seconds ago" / "60 minutes ago" / "24 hours ago" instead of rolling over (#4943)

* Roll `format_timesince` over to the next unit at the boundary

`format_timesince` showed "60 seconds ago", "60 minutes ago" and "24 hours ago"
at the exact unit boundaries instead of rolling over to the next unit, because
the per-unit max values were 60/60/24 rather than 59/59/23. Days (6 -> 1 week)
and months (11 -> 1 year) already rolled correctly; this brings seconds,
minutes and hours in line. Adds the boundary cases to the test.

* Update src/huggingface_hub/utils/_parsing.py

---------

Co-authored-by: célina <hanouticelina@gmail.com>

* Fix Windows conftest erroring test subsets on lazy-loaded file_download submodule (#4945)

* Fix Windows conftest failing on lazy-loaded `file_download` submodule

The `disable_symlinks_on_windows_ci` autouse fixture (active on Windows via
`DISABLE_SYMLINKS_IN_WINDOWS_TESTS=1` in pyproject.toml) accesses
`huggingface_hub.file_download` as a monkeypatch target. Since the package
loads submodules lazily, this attribute only exists if something else already
imported the submodule. Running a test subset that doesn't (e.g.
`pytest tests/test_utils_headers.py`) errors every test at setup with
`AttributeError: No huggingface_hub attribute file_download`.

Use the string-target form of `monkeypatch.setattr`, which imports the
submodule itself.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* Update tests/conftest.py

---------

Co-authored-by: dltsum <dltsum@users.noreply.github.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: célina <hanouticelina@gmail.com>

* [Webhooks] Allow `bucket` as a watched item type (#4958)

The Hub accepts buckets as watched items, but `hf webhooks create
--watch bucket:...` fails client-side because the CLI derives its valid
types from `WebhookWatchedItem.type`, which lacked "bucket".


Claude-Session: https://claude.ai/code/session_015YLK3QPDdiiZGuDxoFrEag

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* [MCP] Follow nextCursor when listing tools in MCPClient (#4960)

* [MCP] Follow nextCursor when listing tools in MCPClient

add_mcp_server called list_tools() once, so tools past a server's first
tools/list page were never registered, and allowed_tools could filter
down to nothing. Page through with the cursor until nextCursor is empty.

* [MCP] Keep the first list_tools() call cursor-free and require mcp>=1.9.4

mcp 1.8.x's list_tools() takes no cursor at all, and before 1.9.4 the cursor
is sent outside params, so a paginating server returns page one forever.
Call list_tools() plainly first so non-paginated servers behave as before,
and raise the extra's floor to the first release that paginates correctly.

* Align the `hf` package's python_requires with huggingface_hub (#4959)

* [CLI] Align the `hf` package's python_requires with huggingface_hub

`huggingface_hub` moved to `python_requires=">=3.10.0"` in #4856, but
`utils/hf/setup.py` was left at `">=3.9.0"`. The `hf` package is only a console
script that imports `huggingface_hub` and pins `huggingface_hub=={version}`, so
the published metadata now contradicts itself: PyPI shows `hf` 1.32.0 as
`Requires-Python: >=3.9.0` while the `huggingface_hub==1.32.0` it depends on is
`>=3.10.0`.

On Python 3.9 that resolves two ways, both wrong:

    $ pip install hf
    Successfully installed hf-1.8.0 huggingface_hub-1.8.0   # silently 24 versions stale

    $ pip install hf==1.32.0
    ERROR: Could not find a version that satisfies the requirement
      huggingface_hub==1.32.0 (from hf)
    ERROR: No matching distribution found for huggingface_hub==1.32.0

The first is the damaging one: `uvx hf`, the usage the README documents, reports
version 1.8.0 on a 3.9 interpreter with no error and no warning, so a user can
be years out of date without any signal.

Set `python_requires` to match the root setup.py and add a test asserting the
two stay equal, since the root cause is that they are edited independently and
nothing tied them together.

Verification:
  $ python -m build --wheel   # in utils/hf
  Requires-Python: >=3.10.0
  Requires-Dist: huggingface_hub==1.33.0.dev0
Signed-off-by: Sharvil Saxena <sharvil.saxena@gmail.com>

* no need to add tests

* Update utils/hf/setup.py

---------

Signed-off-by: Sharvil Saxena <sharvil.saxena@gmail.com>
Co-authored-by: célina <hanouticelina@gmail.com>

* Remove dots from allowed characters in job labels. (#4962)

* [CLI] Honor `CLAUDE_CONFIG_DIR` in `hf skills add -g --claude` (#4957)

* [CLI] Honor CLAUDE_CONFIG_DIR in hf skills add -g --claude

* remove test

* [CLI] Always install skills for Claude Code, deprecate --claude (#4967)

* [CLI] Always install skills for Claude Code, deprecate --claude

* show --claude as deprecated in help instead of hiding it

* remove test

* [Buckets] Raise when a batch reports failed operations (#4954)

* [Buckets] Raise when a batch reports failed operations

* fix pickling of BucketBatchError

* keep only the main test

* Update src/huggingface_hub/hf_api.py

Co-authored-by: Lucain <lucain@huggingface.co>

* fix missing parenthesis

* use a real test against staging

* keep sending chunks after a failure

* fold batch tests into one

---------

Co-authored-by: Lucain <lucain@huggingface.co>

* [Download] Extend tmp .incomplete path on Windows when too long (#4978)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Fix HfFileSystem.get_file with a bare local filename (#4981)

`os.path.dirname("file.txt")` is "", and `os.makedirs("")` raises
FileNotFoundError. Fall back to the current directory, matching fsspec's
base `get_file` and gcsfs (fsspec/gcsfs#618).

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Scope GITHUB_TOKEN permissions per job (#4982)

A job with no `permissions:` block inherits whatever the repository
hands out. Each block added here grants what that job's own steps
need and nothing more.

Co-authored-by: hf-security-analysis[bot] <265538906+hf-security-analysis[bot]@users.noreply.github.com>

* Send PrivateLink config under privateService in create_inference_endpoint (#4966)

* Send PrivateLink config under privateService in create_inference_endpoint

* [Inference] Keep account_id compatible for endpoint creation

* [Inference] Remove account_id compatibility test

---------

Co-authored-by: Lucain Pouget <lucainp@gmail.com>

---------

Signed-off-by: Sharvil Saxena <sharvil.saxena@gmail.com>
Co-authored-by: Assaf Vayner <assaf@huggingface.co>
Co-authored-by: Celina Hanouti <hanouticelina@gmail.com>
Co-authored-by: Sreekant Baheti <60787859+Sreekant13@users.noreply.github.com>
Co-authored-by: DltsumCtnori <lllalllbpear@gmail.com>
Co-authored-by: dltsum <dltsum@users.noreply.github.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Daniel van Strien <davanstrien@users.noreply.github.com>
Co-authored-by: Kayvan Zahiri <123409429+Kayvan-Zahiri@users.noreply.github.com>
Co-authored-by: Sharvil Saxena <97365286+sharziki@users.noreply.github.com>
Co-authored-by: shaun smith <1936278+evalstate@users.noreply.github.com>
Co-authored-by: hf-security-analysis[bot] <265538906+hf-security-analysis[bot]@users.noreply.github.com>
Co-authored-by: Corentin REGAL <corentin@huggingface.co>
@huggingface-hub-bot

Copy link
Copy Markdown
Contributor

This PR has been shipped as part of the v1.33.0 release.

Wauplin added a commit that referenced this pull request Sep 24, 2026
* [hfh 2.x] Remove deprecated APIs (#4955)

* [hfh 2.x] Remove deprecated APIs

* [hfh 2.x] Keep deprecation helpers and legacy-argument shim

Restore `utils/_deprecation.py` (`_deprecate_arguments`, `_deprecate_method`,
`_deprecate_positional_args`) and its tests: they are unused now that the
deprecated APIs are gone, but we want them ready for the next deprecation cycle.
The `@pytest.mark.deprecated` harness (`expect_deprecation_marker` fixture) is
kept alongside them for the same reason.

Also restore `smoothly_deprecate_legacy_arguments` and its call in
`validate_hf_hub_args`, so `proxies`, `resume_download`, `force_filename` and
`local_dir_use_symlinks` keep being ignored with a warning instead of raising.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* [Inference] Resolve endpoint token before creating clients

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* [hfh 2.x] Merge main into v2.0 dev branch (#4971)

* [HfFileSystem] Make lpath optional in get_file (fsspec>=2026.9.0) (#4951)

* [HfFileSystem] Make `lpath` optional in `get_file` (fsspec>=2026.9.0)

fsspec 2026.9.0 made `lpath` optional in `AbstractFileSystem.get_file`
(it can be omitted when `outfile` is provided). Our override kept it
required, which the latest `ty` flags as an invalid method override and
fails CI.

Make `lpath=None` in the signature and raise a clear ValueError if
neither `lpath` nor `outfile` is provided. No behavior change otherwise.

* fix get_file branching to match fsspec

---------

Co-authored-by: Celina Hanouti <hanouticelina@gmail.com>

* Fix `format_timesince` showing "60 seconds ago" / "60 minutes ago" / "24 hours ago" instead of rolling over (#4943)

* Roll `format_timesince` over to the next unit at the boundary

`format_timesince` showed "60 seconds ago", "60 minutes ago" and "24 hours ago"
at the exact unit boundaries instead of rolling over to the next unit, because
the per-unit max values were 60/60/24 rather than 59/59/23. Days (6 -> 1 week)
and months (11 -> 1 year) already rolled correctly; this brings seconds,
minutes and hours in line. Adds the boundary cases to the test.

* Update src/huggingface_hub/utils/_parsing.py

---------

Co-authored-by: célina <hanouticelina@gmail.com>

* Fix Windows conftest erroring test subsets on lazy-loaded file_download submodule (#4945)

* Fix Windows conftest failing on lazy-loaded `file_download` submodule

The `disable_symlinks_on_windows_ci` autouse fixture (active on Windows via
`DISABLE_SYMLINKS_IN_WINDOWS_TESTS=1` in pyproject.toml) accesses
`huggingface_hub.file_download` as a monkeypatch target. Since the package
loads submodules lazily, this attribute only exists if something else already
imported the submodule. Running a test subset that doesn't (e.g.
`pytest tests/test_utils_headers.py`) errors every test at setup with
`AttributeError: No huggingface_hub attribute file_download`.

Use the string-target form of `monkeypatch.setattr`, which imports the
submodule itself.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* Update tests/conftest.py

---------

Co-authored-by: dltsum <dltsum@users.noreply.github.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: célina <hanouticelina@gmail.com>

* [Webhooks] Allow `bucket` as a watched item type (#4958)

The Hub accepts buckets as watched items, but `hf webhooks create
--watch bucket:...` fails client-side because the CLI derives its valid
types from `WebhookWatchedItem.type`, which lacked "bucket".


Claude-Session: https://claude.ai/code/session_015YLK3QPDdiiZGuDxoFrEag

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* [MCP] Follow nextCursor when listing tools in MCPClient (#4960)

* [MCP] Follow nextCursor when listing tools in MCPClient

add_mcp_server called list_tools() once, so tools past a server's first
tools/list page were never registered, and allowed_tools could filter
down to nothing. Page through with the cursor until nextCursor is empty.

* [MCP] Keep the first list_tools() call cursor-free and require mcp>=1.9.4

mcp 1.8.x's list_tools() takes no cursor at all, and before 1.9.4 the cursor
is sent outside params, so a paginating server returns page one forever.
Call list_tools() plainly first so non-paginated servers behave as before,
and raise the extra's floor to the first release that paginates correctly.

* Align the `hf` package's python_requires with huggingface_hub (#4959)

* [CLI] Align the `hf` package's python_requires with huggingface_hub

`huggingface_hub` moved to `python_requires=">=3.10.0"` in #4856, but
`utils/hf/setup.py` was left at `">=3.9.0"`. The `hf` package is only a console
script that imports `huggingface_hub` and pins `huggingface_hub=={version}`, so
the published metadata now contradicts itself: PyPI shows `hf` 1.32.0 as
`Requires-Python: >=3.9.0` while the `huggingface_hub==1.32.0` it depends on is
`>=3.10.0`.

On Python 3.9 that resolves two ways, both wrong:

    $ pip install hf
    Successfully installed hf-1.8.0 huggingface_hub-1.8.0   # silently 24 versions stale

    $ pip install hf==1.32.0
    ERROR: Could not find a version that satisfies the requirement
      huggingface_hub==1.32.0 (from hf)
    ERROR: No matching distribution found for huggingface_hub==1.32.0

The first is the damaging one: `uvx hf`, the usage the README documents, reports
version 1.8.0 on a 3.9 interpreter with no error and no warning, so a user can
be years out of date without any signal.

Set `python_requires` to match the root setup.py and add a test asserting the
two stay equal, since the root cause is that they are edited independently and
nothing tied them together.

Verification:
  $ python -m build --wheel   # in utils/hf
  Requires-Python: >=3.10.0
  Requires-Dist: huggingface_hub==1.33.0.dev0
Signed-off-by: Sharvil Saxena <sharvil.saxena@gmail.com>

* no need to add tests

* Update utils/hf/setup.py

---------

Signed-off-by: Sharvil Saxena <sharvil.saxena@gmail.com>
Co-authored-by: célina <hanouticelina@gmail.com>

* Remove dots from allowed characters in job labels. (#4962)

* [CLI] Honor `CLAUDE_CONFIG_DIR` in `hf skills add -g --claude` (#4957)

* [CLI] Honor CLAUDE_CONFIG_DIR in hf skills add -g --claude

* remove test

* [CLI] Always install skills for Claude Code, deprecate --claude (#4967)

* [CLI] Always install skills for Claude Code, deprecate --claude

* show --claude as deprecated in help instead of hiding it

* remove test

---------

Signed-off-by: Sharvil Saxena <sharvil.saxena@gmail.com>
Co-authored-by: Assaf Vayner <assaf@huggingface.co>
Co-authored-by: Celina Hanouti <hanouticelina@gmail.com>
Co-authored-by: Sreekant Baheti <60787859+Sreekant13@users.noreply.github.com>
Co-authored-by: DltsumCtnori <lllalllbpear@gmail.com>
Co-authored-by: dltsum <dltsum@users.noreply.github.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Daniel van Strien <davanstrien@users.noreply.github.com>
Co-authored-by: Kayvan Zahiri <123409429+Kayvan-Zahiri@users.noreply.github.com>
Co-authored-by: Sharvil Saxena <97365286+sharziki@users.noreply.github.com>
Co-authored-by: shaun smith <1936278+evalstate@users.noreply.github.com>

* [CLI] Remove deprecated --claude option in 2.x (#4970)

* [hfh 2.x] Merge main after PrivateLink update (#4985)

* [HfFileSystem] Make lpath optional in get_file (fsspec>=2026.9.0) (#4951)

* [HfFileSystem] Make `lpath` optional in `get_file` (fsspec>=2026.9.0)

fsspec 2026.9.0 made `lpath` optional in `AbstractFileSystem.get_file`
(it can be omitted when `outfile` is provided). Our override kept it
required, which the latest `ty` flags as an invalid method override and
fails CI.

Make `lpath=None` in the signature and raise a clear ValueError if
neither `lpath` nor `outfile` is provided. No behavior change otherwise.

* fix get_file branching to match fsspec

---------

Co-authored-by: Celina Hanouti <hanouticelina@gmail.com>

* Fix `format_timesince` showing "60 seconds ago" / "60 minutes ago" / "24 hours ago" instead of rolling over (#4943)

* Roll `format_timesince` over to the next unit at the boundary

`format_timesince` showed "60 seconds ago", "60 minutes ago" and "24 hours ago"
at the exact unit boundaries instead of rolling over to the next unit, because
the per-unit max values were 60/60/24 rather than 59/59/23. Days (6 -> 1 week)
and months (11 -> 1 year) already rolled correctly; this brings seconds,
minutes and hours in line. Adds the boundary cases to the test.

* Update src/huggingface_hub/utils/_parsing.py

---------

Co-authored-by: célina <hanouticelina@gmail.com>

* Fix Windows conftest erroring test subsets on lazy-loaded file_download submodule (#4945)

* Fix Windows conftest failing on lazy-loaded `file_download` submodule

The `disable_symlinks_on_windows_ci` autouse fixture (active on Windows via
`DISABLE_SYMLINKS_IN_WINDOWS_TESTS=1` in pyproject.toml) accesses
`huggingface_hub.file_download` as a monkeypatch target. Since the package
loads submodules lazily, this attribute only exists if something else already
imported the submodule. Running a test subset that doesn't (e.g.
`pytest tests/test_utils_headers.py`) errors every test at setup with
`AttributeError: No huggingface_hub attribute file_download`.

Use the string-target form of `monkeypatch.setattr`, which imports the
submodule itself.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* Update tests/conftest.py

---------

Co-authored-by: dltsum <dltsum@users.noreply.github.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: célina <hanouticelina@gmail.com>

* [Webhooks] Allow `bucket` as a watched item type (#4958)

The Hub accepts buckets as watched items, but `hf webhooks create
--watch bucket:...` fails client-side because the CLI derives its valid
types from `WebhookWatchedItem.type`, which lacked "bucket".


Claude-Session: https://claude.ai/code/session_015YLK3QPDdiiZGuDxoFrEag

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* [MCP] Follow nextCursor when listing tools in MCPClient (#4960)

* [MCP] Follow nextCursor when listing tools in MCPClient

add_mcp_server called list_tools() once, so tools past a server's first
tools/list page were never registered, and allowed_tools could filter
down to nothing. Page through with the cursor until nextCursor is empty.

* [MCP] Keep the first list_tools() call cursor-free and require mcp>=1.9.4

mcp 1.8.x's list_tools() takes no cursor at all, and before 1.9.4 the cursor
is sent outside params, so a paginating server returns page one forever.
Call list_tools() plainly first so non-paginated servers behave as before,
and raise the extra's floor to the first release that paginates correctly.

* Align the `hf` package's python_requires with huggingface_hub (#4959)

* [CLI] Align the `hf` package's python_requires with huggingface_hub

`huggingface_hub` moved to `python_requires=">=3.10.0"` in #4856, but
`utils/hf/setup.py` was left at `">=3.9.0"`. The `hf` package is only a console
script that imports `huggingface_hub` and pins `huggingface_hub=={version}`, so
the published metadata now contradicts itself: PyPI shows `hf` 1.32.0 as
`Requires-Python: >=3.9.0` while the `huggingface_hub==1.32.0` it depends on is
`>=3.10.0`.

On Python 3.9 that resolves two ways, both wrong:

    $ pip install hf
    Successfully installed hf-1.8.0 huggingface_hub-1.8.0   # silently 24 versions stale

    $ pip install hf==1.32.0
    ERROR: Could not find a version that satisfies the requirement
      huggingface_hub==1.32.0 (from hf)
    ERROR: No matching distribution found for huggingface_hub==1.32.0

The first is the damaging one: `uvx hf`, the usage the README documents, reports
version 1.8.0 on a 3.9 interpreter with no error and no warning, so a user can
be years out of date without any signal.

Set `python_requires` to match the root setup.py and add a test asserting the
two stay equal, since the root cause is that they are edited independently and
nothing tied them together.

Verification:
  $ python -m build --wheel   # in utils/hf
  Requires-Python: >=3.10.0
  Requires-Dist: huggingface_hub==1.33.0.dev0
Signed-off-by: Sharvil Saxena <sharvil.saxena@gmail.com>

* no need to add tests

* Update utils/hf/setup.py

---------

Signed-off-by: Sharvil Saxena <sharvil.saxena@gmail.com>
Co-authored-by: célina <hanouticelina@gmail.com>

* Remove dots from allowed characters in job labels. (#4962)

* [CLI] Honor `CLAUDE_CONFIG_DIR` in `hf skills add -g --claude` (#4957)

* [CLI] Honor CLAUDE_CONFIG_DIR in hf skills add -g --claude

* remove test

* [CLI] Always install skills for Claude Code, deprecate --claude (#4967)

* [CLI] Always install skills for Claude Code, deprecate --claude

* show --claude as deprecated in help instead of hiding it

* remove test

* [Buckets] Raise when a batch reports failed operations (#4954)

* [Buckets] Raise when a batch reports failed operations

* fix pickling of BucketBatchError

* keep only the main test

* Update src/huggingface_hub/hf_api.py

Co-authored-by: Lucain <lucain@huggingface.co>

* fix missing parenthesis

* use a real test against staging

* keep sending chunks after a failure

* fold batch tests into one

---------

Co-authored-by: Lucain <lucain@huggingface.co>

* [Download] Extend tmp .incomplete path on Windows when too long (#4978)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Fix HfFileSystem.get_file with a bare local filename (#4981)

`os.path.dirname("file.txt")` is "", and `os.makedirs("")` raises
FileNotFoundError. Fall back to the current directory, matching fsspec's
base `get_file` and gcsfs (fsspec/gcsfs#618).

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Scope GITHUB_TOKEN permissions per job (#4982)

A job with no `permissions:` block inherits whatever the repository
hands out. Each block added here grants what that job's own steps
need and nothing more.

Co-authored-by: hf-security-analysis[bot] <265538906+hf-security-analysis[bot]@users.noreply.github.com>

* Send PrivateLink config under privateService in create_inference_endpoint (#4966)

* Send PrivateLink config under privateService in create_inference_endpoint

* [Inference] Keep account_id compatible for endpoint creation

* [Inference] Remove account_id compatibility test

---------

Co-authored-by: Lucain Pouget <lucainp@gmail.com>

---------

Signed-off-by: Sharvil Saxena <sharvil.saxena@gmail.com>
Co-authored-by: Assaf Vayner <assaf@huggingface.co>
Co-authored-by: Celina Hanouti <hanouticelina@gmail.com>
Co-authored-by: Sreekant Baheti <60787859+Sreekant13@users.noreply.github.com>
Co-authored-by: DltsumCtnori <lllalllbpear@gmail.com>
Co-authored-by: dltsum <dltsum@users.noreply.github.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Daniel van Strien <davanstrien@users.noreply.github.com>
Co-authored-by: Kayvan Zahiri <123409429+Kayvan-Zahiri@users.noreply.github.com>
Co-authored-by: Sharvil Saxena <97365286+sharziki@users.noreply.github.com>
Co-authored-by: shaun smith <1936278+evalstate@users.noreply.github.com>
Co-authored-by: hf-security-analysis[bot] <265538906+hf-security-analysis[bot]@users.noreply.github.com>
Co-authored-by: Corentin REGAL <corentin@huggingface.co>

* [hfh 2.x] Migrate to httpx2 (#4921)

* [httpx migration] Migrate to httpx2

* [Docs] Add HTTPX2 migration resources

* [hfh 2.x] Fix HTTPX migration CI

* [CLI] Regenerate CLI reference for v2 branch

* [Core] Drop stale deprecated API exports

* [Docs] Install httpx2 for documentation builds

* Revert "[Docs] Install httpx2 for documentation builds"

This reverts commit 4293e28.

* fix(ci): harden workflow files flagged on #4994 (#4995)

Co-authored-by: hf-security-analysis[bot] <265538906+hf-security-analysis[bot]@users.noreply.github.com>

---------

Signed-off-by: Sharvil Saxena <sharvil.saxena@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Assaf Vayner <assaf@huggingface.co>
Co-authored-by: Celina Hanouti <hanouticelina@gmail.com>
Co-authored-by: Sreekant Baheti <60787859+Sreekant13@users.noreply.github.com>
Co-authored-by: DltsumCtnori <lllalllbpear@gmail.com>
Co-authored-by: dltsum <dltsum@users.noreply.github.com>
Co-authored-by: Daniel van Strien <davanstrien@users.noreply.github.com>
Co-authored-by: Kayvan Zahiri <123409429+Kayvan-Zahiri@users.noreply.github.com>
Co-authored-by: Sharvil Saxena <97365286+sharziki@users.noreply.github.com>
Co-authored-by: shaun smith <1936278+evalstate@users.noreply.github.com>
Co-authored-by: hf-security-analysis[bot] <265538906+hf-security-analysis[bot]@users.noreply.github.com>
Co-authored-by: Corentin REGAL <corentin@huggingface.co>
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] MCPClient only discovers the first tools/list page

2 participants