fix: in oci_database_mcp_server handle API key auth when security_tok…#149
Open
germanviscuso wants to merge 1 commit intooracle:mainfrom
Open
fix: in oci_database_mcp_server handle API key auth when security_tok…#149germanviscuso wants to merge 1 commit intooracle:mainfrom
germanviscuso wants to merge 1 commit intooracle:mainfrom
Conversation
…en_file is absent The original code unconditionally accessed config['security_token_file'], causing a KeyError for users authenticating with API keys. Added a check so token-based auth is only used when the key is present in the config.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…en_file is absent
The original code unconditionally accessed config['security_token_file'], causing a KeyError for users authenticating with API keys. Added a check so token-based auth is only used when the key is present in the config.
Description
The
get_database_client()function insrc/oci-database-mcp-server/oracle/oci_database_mcp_server/server.pyunconditionally accessedconfig["security_token_file"], causing aKeyErrorfor any user authenticating with standard API keys. This is because API key-based OCI configs do not include asecurity_token_fileentry — only token-based (session) auth configs do.The fix adds a conditional check (
if "security_token_file" in config) so that token-based signing is only used when the key is actually present, and API key auth falls through to the standardDatabaseClientinstantiation.Fixes # (issue)
Type of change
How Has This Been Tested?
The fix was verified by running the MCP server locally against a real OCI tenancy using standard API key authentication (no
security_token_filein~/.oci/config). Prior to the fix, any call tolist_autonomous_databases(and all other database operations) would fail immediately withKeyError: 'security_token_file'. After the fix, all operations complete successfully.Test Configuration:
~/.oci/config, DEFAULT profile, no security token)oci==2.160.0oracle.oci-database-mcp-server 1.0.4Checklist: