Skip to content

Simple chatbot: unused Server.stdio_context attribute obscures transport ownership #3654

Description

@JEFFTIMES

While studying context management in the simple chatbot example, I noticed that Server.stdio_context suggests the transport context is stored on the instance, but it is never used.

In examples/clients/simple-chatbot/mcp_simple_chatbot/main.py, searching for stdio_context finds only:

# Server.__init__
self.stdio_context: Any | None = None

# Server.cleanup
self.stdio_context = None

Server.initialize() instead enters stdio_client(server_params) through self.exit_stack.enter_async_context(...), and cleanup() calls self.exit_stack.aclose(). The stack already owns the transport cleanup; the attribute is never read or assigned a context manager.

This is a minor example-code clarity issue, not an observed runtime failure. The unused attribute made it unclear whether initialization was missing an assignment. Suggested fix: remove the two self.stdio_context assignments, leaving the existing exit-stack lifecycle unchanged.

Reporting this first per the contribution guide. AI assistance: this report was prepared with OpenAI Codex after discussing the example and inspecting the source.

Activity

  1. added
    enhancementRequest for a new feature that's not currently supported
    on Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementRequest for a new feature that's not currently supported

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions