Use tuples for tools/resources in plain.mcp docs - #100
Draft
davegaeddert wants to merge 1 commit into
Draft
Conversation
MCPView.tools and MCPView.resources are annotated tuple[type[...], ...], and the framework convention is that declarative class attributes are tuples. The README examples and the MCPView/OAuthResourceServer docstrings still assigned lists, which works at runtime but is a type error for anyone type checking their app with a checker that validates inherited-attribute overrides. Also replaces the `tools = [...]` ellipsis placeholders with a real one-element tuple, and makes the get_tools() override example return list(self.tools) so it matches the documented list return type. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MwkxmxUXppGucqgS7HGZnM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MCPView.toolsandMCPView.resourcesare annotatedtuple[type[MCPTool], ...]/tuple[type[MCPResource], ...], and the framework convention is that declarative class attributes are tuples. The plain-mcp README examples and theMCPView/OAuthResourceServerdocstrings still assigned lists.Docs only — no runtime behavior changes.
Changes
plain-mcp/plain/mcp/README.md— everytools = [...]/resources = [...]example (and the two prose mentions) now uses tuple syntax, e.g.tools = (Greet,),resources = (AppVersion, AppReadme).tools = [...]ellipsis placeholders in the OAuth section become a real one-element tupletools = (MyTool,), so the snippet is valid as written.get_tools()override example returnslist(self.tools)instead ofself.tools, matching the documentedlist[type[MCPTool]]return type ofget_tools().plain-mcp/plain/mcp/views.py,plain-mcp/plain/mcp/oauth.py— same fix in the class docstrings.Notes on the type-checking claim
The list form is a real type error under pyright (
reportAssignmentType), which is what surfaced this. Worth noting for accuracy:ty— the checker./scripts/type-checkandplain checkuse — does not currently flag it. I verified this: eventools = 5on anMCPViewsubclass passestytoday, so it doesn't validate assignments that override an inherited annotated attribute. So the shipped examples were not failingplain check; they were inconsistent with the documented convention and would fail for users on pyright/mypy.Testing
./scripts/fix— ruff check and ruff format pass. Its oxlint step could not run in this environment (TLS failure downloading the binary); no JS/CSS was touched../scripts/test plain-mcpcould not run here — no Postgres available in the sandbox. The change is markdown and docstrings only.🤖 Generated with Claude Code
https://claude.ai/code/session_01MwkxmxUXppGucqgS7HGZnM
Generated by Claude Code