Fix MCP close tool method signature error (GH #107)

Renamed BdDaemonClient.close() cleanup method to cleanup() to eliminate
method name collision with async close(params) method for closing issues.

Root cause: Python method resolution meant the non-async close(self)
cleanup method was shadowing the async close(self, params) method that
closes issues, causing 'takes 1 positional argument but 2 were given'.

Changes:
- bd_daemon_client.py: Renamed close() -> cleanup()
- server.py: Updated cleanup code to call cleanup() instead of close()
- test_lifecycle.py: Updated tests to use cleanup()

All close-related tests pass. Fixes GitHub issue #107.
Tracked in bd-67 (closed).
This commit is contained in:
Steve Yegge
2025-10-22 17:43:11 -07:00
parent a777e97287
commit 42762188ed
4 changed files with 9 additions and 8 deletions

View File

@@ -431,7 +431,7 @@ class BdDaemonClient(BdClientBase):
except (DaemonNotRunningError, DaemonConnectionError, DaemonError):
return False
def close(self) -> None:
def cleanup(self) -> None:
"""Close daemon client connections and cleanup resources.
This is called during MCP server shutdown to ensure clean termination.

View File

@@ -70,8 +70,8 @@ def cleanup() -> None:
# Close all daemon client connections
for client in _daemon_clients:
try:
if hasattr(client, 'close'):
client.close()
if hasattr(client, 'cleanup'):
client.cleanup()
logger.debug(f"Closed daemon client: {client}")
except Exception as e:
logger.warning(f"Error closing daemon client: {e}")