Repository navigation
Conversation
|
This PR has been closed automatically. It's still a draft, but we close those early so you don't put in more time only to have it closed the moment you mark it ready. This repo only keeps pull requests open when they come from a maintainer, or from a contributor a maintainer has assigned to the linked issue, and you aren't currently assigned to #3649. If a maintainer assigns you to #3649, this PR reopens on its own and there's nothing more you need to do here. Assignment is a maintainer call based on capacity; comments that only ask to be assigned don't factor in. What does help is engaging on the issue itself by confirming the repro, explaining why it matters for your use case, or describing the approach you'd take. You're welcome to keep pushing commits here (just avoid force-pushing, since GitHub can't reopen a rewritten branch), but that on its own won't get the PR reviewed or the issue assigned, and realistically most auto-closed PRs stay closed. There's no need to open a new PR either way. CONTRIBUTING.md has the full reasoning, but in short:
Maintainers: reopen, remove |
Motivation
Fixes #3649
An
@mcp.completion()handler returning more than 100 values currently behaves inconsistently across protocol versions:values: Annotated[list[str], Field(max_length=100)]. Returning >100 values raises a PydanticValidationErrorinrunner.py, turning the response into an unhandled-32603 "Handler returned an invalid result"internal error.totalandhas_moreunset.This behavior mirrors the TypeScript SDK's
McpServer.createCompletionResultreference implementation:values: suggestions.slice(0, 100), total: suggestions.length, hasMore: suggestions.length > 100.Changes
src/mcp/server/mcpserver/server.py:MCPServer.completionwrapper handler, whenlen(result.values) > 100:valuesto the first 100 items (result.values[:100]).total = len(result.values)ifresult.totalwas not explicitly provided by the handler.has_more = Trueifresult.has_morewas not explicitly provided.total/has_morevalues are preserved unchanged.Serverhandlers remain untouched.tests/server/mcpserver/test_server.py:test_completion_handler_more_than_100_values_paginatesverifying pagination across bothmode="auto"(2026-07-28) andmode="legacy"(2025-11-25) clients.test_completion_handler_more_than_100_values_preserves_explicit_total_and_has_moreverifying that explicitly provided metadata takes precedence.Verification
uv run pytest tests/server/mcpserver/test_server.py(all completion tests passing).tests/server/mcpserver/suite (643 passed, 1 skipped, 0 failures).ruff checkandruff format.