Skip to content

[mcp] fix: advertise gpu id item limit - #272

Merged
Wangmerlyn merged 1 commit into
mainfrom
codex/mcp-gpu-ids-max-items
Jul 2, 2026
Merged

[mcp] fix: advertise gpu id item limit#272
Wangmerlyn merged 1 commit into
mainfrom
codex/mcp-gpu-ids-max-items

Conversation

@Wangmerlyn

@Wangmerlyn Wangmerlyn commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • add shared MAX_GPU_IDS for the public gpu_ids list-size contract
  • advertise that limit as MCP start_keep.inputSchema.properties.gpu_ids.maxItems
  • cover the runtime cap and MCP schema in tests, and align docs/AGENTS wording

Verification

  • PYTHONPATH=src pytest tests/mcp/test_server.py -k mcp_tools_list_exposes_keepgpu_actions -q
  • PYTHONPATH=src pytest tests/utilities/test_session_config.py -q
  • PYTHONPATH=src pytest tests/mcp/test_server.py tests/utilities/test_session_config.py -q
  • mkdocs build --strict
  • PYTHONPATH=src pytest tests -q
  • pre-commit run --all-files --show-diff-on-failure

Local subagent review: no must-fix issues found.

README note: Zenodo DOI badge remains present at README.md:5.

Summary by CodeRabbit

  • New Features

    • GPU selection limits are now consistently enforced and exposed across the API, CLI, and MCP tool schema.
    • gpu_ids lists are capped at 64 entries, and this limit is now clearly advertised to clients.
  • Documentation

    • Clarified GPU selection rules, including invalid list cases and startup behavior when no devices are found.
    • Updated API, CLI, and MCP guidance to reflect the 64-item limit.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 01e13d92-fa50-4533-9af1-50b1ab476dfd

📥 Commits

Reviewing files that changed from the base of the PR and between 1adedf8 and e7b3c2b.

📒 Files selected for processing (9)
  • AGENTS.md
  • docs/guides/mcp.md
  • docs/guides/python.md
  • docs/reference/api.md
  • docs/reference/cli.md
  • src/keep_gpu/mcp/server.py
  • src/keep_gpu/utilities/session_config.py
  • tests/mcp/test_server.py
  • tests/utilities/test_session_config.py

📝 Walkthrough

Walkthrough

A MAX_GPU_IDS constant (64) is introduced in session_config.py and used by validate_gpu_ids for length validation. The MCP server's start_keep tool schema now advertises this limit via maxItems. Documentation and tests are updated accordingly.

Changes

MAX_GPU_IDS Enforcement

Layer / File(s) Summary
Shared constant and validation logic
src/keep_gpu/utilities/session_config.py, tests/utilities/test_session_config.py
Introduces MAX_GPU_IDS = 64 constant, updates validate_gpu_ids to compare against it instead of a literal, and adds a test verifying accept/reject behavior at the boundary.
MCP server schema wiring
src/keep_gpu/mcp/server.py, tests/mcp/test_server.py
Imports MAX_GPU_IDS and applies it as maxItems on the start_keep tool's gpu_ids input schema; tests assert the schema exposes the correct maxItems value.
Documentation updates
AGENTS.md, docs/guides/mcp.md, docs/guides/python.md, docs/reference/api.md, docs/reference/cli.md
Documents the 64-item gpu_ids limit, the maxItems schema contract, and related validation/telemetry behavior across guides and reference docs.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • Wangmerlyn/KeepGPU#59: Both PRs touch the MCP server's start_keep handling in src/keep_gpu/mcp/server.py, with this PR adding MAX_GPU_IDS-driven gpu_ids schema limiting on top of the server implementation from #59.
  • Wangmerlyn/KeepGPU#146: Both PRs change start_keep's gpu_ids validation in the same server module, this PR adding a schema-level maxItems cap alongside prior validation logic.

Poem

A rabbit hopped through code so neat,
Counting GPUs, sixty-four a treat,
No more, no less, the schema's clear,
maxItems now sits right here,
Docs and tests all in a row—
Sixty-four's the limit, don't you know!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: advertising the GPU ID item limit in the MCP schema.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/mcp-gpu-ids-max-items

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Wangmerlyn
Wangmerlyn merged commit 85fbce5 into main Jul 2, 2026
6 checks passed
@Wangmerlyn
Wangmerlyn deleted the codex/mcp-gpu-ids-max-items branch July 2, 2026 00:08
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.

1 participant