Skip to content

Add thick mode compatibility#8

Merged
danielmeppiel merged 1 commit intomainfrom
add-thick-mode
Mar 27, 2025
Merged

Add thick mode compatibility#8
danielmeppiel merged 1 commit intomainfrom
add-thick-mode

Conversation

@danielmeppiel
Copy link
Owner

User can set environment variable THICK_MODE=True and allow for the MCP Server to connect to Oracle in thick mode.

Enhancements to Dockerfile:

  • Added installation steps for Oracle Instant Client dependencies and setup for architecture-specific downloads.

Database context and connector updates:

  • Modified the DatabaseContext class to include a use_thick_mode parameter and pass it to the DatabaseConnector.
  • Updated the DatabaseConnector class to initialize Oracle Client in thick mode if specified and handle fallback to thin mode if initialization fails.

Refactoring of database operations:

  • Refactored the get_connection method to use synchronous connection for thick mode and asynchronous connection for thin mode.
  • Introduced helper methods _execute_cursor, _execute_cursor_no_fetch, and _commit to handle synchronous and asynchronous cursor operations and commits based on the mode.
  • Updated various methods (get_database_info, get_all_table_names, load_table_details, get_pl_sql_objects, get_object_source, get_table_constraints, get_table_indexes) to use the new helper methods for executing database operations. [1] [2] [3] [4] [5] [6] [7] [8] [9]

@danielmeppiel danielmeppiel requested a review from Copilot March 27, 2025 16:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for Oracle thick mode by allowing a new environment variable (THICK_MODE) to dictate whether to use a synchronous connection (thick mode) or an asynchronous connection (thin mode) to the Oracle database. Key changes include:

  • Introducing a new environment variable (THICK_MODE) in main.py and passing the flag to the DatabaseContext.
  • Modifying DatabaseConnector to initialize the Oracle Client in thick mode and to choose between synchronous and asynchronous connection and cursor execution.
  • Refactoring various database operations to use helper methods that dispatch calls based on the mode.

Reviewed Changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated no comments.

File Description
main.py Added a THICK_MODE environment variable and updated context creation
db_context/schema/manager.py Refactored schema retrieval to directly call get_effective_schema
db_context/database.py Updated connection initialization, query execution, and connection closing
db_context/init.py Propagated the new use_thick_mode parameter to the DatabaseConnector
Files not reviewed (2)
  • Dockerfile: Language not supported
  • test/db/.env.example: Language not supported
Comments suppressed due to low confidence (1)

db_context/database.py:329

  • In thick mode, the CLOB object is likely synchronous and may not support being awaited. Consider differentiating the CLOB read operation based on the connection mode (e.g. using 'clob.read()' for thick mode and 'await clob.read()' for thin mode).
clob = result[0][0]

Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more

@danielmeppiel danielmeppiel merged commit 2bdb511 into main Mar 27, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants