Skip to content

Incorrect Method Name in MCPClient Docstring Example (stop() should be disconnect()) #1365

@aspriya

Description

@aspriya

In the MCPClient class docstring (file: smolagents/mcp_client.py), the example for manual connection management currently uses mcp_client.stop() in the finally block:

try:
    mcp_client = MCPClient(...)
    tools = mcp_client.get_tools()
    # use your tools here.
finally:
    mcp_client.stop()

However, the correct method to close the connection is mcp_client.disconnect(), as defined in the class. There is no stop() method, so this could confuse users and lead to errors.

Suggested fix:

Update the docstring example to use mcp_client.disconnect() instead of mcp_client.stop(). This will ensure the documentation matches the actual API and helps users manage connections correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions