Skip to content

Conversation

@sgaunet
Copy link
Owner

@sgaunet sgaunet commented Dec 7, 2025

Add context.Context parameter to all database operations to enable
proper request cancellation, timeout handling, and request tracing.

Changes:

  • Add context parameter to all PostgreSQLClient interface methods
  • Update client implementation to use provided context instead of Background()
  • Propagate context through App layer methods
  • Update MCP tool handlers to pass request context
  • Implement smart reconnection logic (uses Background() for reconnection)
  • Update all tests to work with context-enabled signatures

This enables MCP clients to cancel in-flight database operations and
set request-level timeouts that properly propagate to PostgreSQL.

Closes #39

Add context.Context parameter to all database operations to enable
proper request cancellation, timeout handling, and request tracing.

Changes:
- Add context parameter to all PostgreSQLClient interface methods
- Update client implementation to use provided context instead of Background()
- Propagate context through App layer methods
- Update MCP tool handlers to pass request context
- Implement smart reconnection logic (uses Background() for reconnection)
- Update all tests to work with context-enabled signatures

This enables MCP clients to cancel in-flight database operations and
set request-level timeouts that properly propagate to PostgreSQL.

Closes #39
@sgaunet sgaunet self-assigned this Dec 7, 2025
@sgaunet sgaunet linked an issue Dec 7, 2025 that may be closed by this pull request
10 tasks
@sgaunet sgaunet added the feature New feature label Dec 7, 2025
@sgaunet sgaunet merged commit 73a95bc into main Dec 7, 2025
5 checks passed
@sgaunet sgaunet deleted the 39-propagate-request-context-from-tool-handlers-to-database-operations branch December 7, 2025 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Propagate request context from tool handlers to database operations

2 participants