Repository navigation
Migrate OCI Monitoring MCP server authentication to oracle-mcp-common #419
Description
Migrate OCI Monitoring MCP server authentication to oracle-mcp-common
Summary
Migrate oci-monitoring-mcp-server from its locally implemented OCI authentication logic to the shared oracle-mcp-common authentication APIs.
Use oci-cloud-mcp-server as the reference implementation:
Related work:
- Issue #366: shared OCI MCP authentication library
- PR #367:
oracle-mcp-commonimplementation and initial adoption - PR #417: Logging and Monitoring region selection
Problem
oci-monitoring-mcp-server currently implements authentication directly by:
- reading OCI config profiles;
- loading security-token files and private keys;
- constructing
SecurityTokenSigner; - constructing HTTP
TokenExchangeSigner; - configuring FastMCP's
OCIProvider.
This duplicates behavior now owned by oracle-mcp-common and supports fewer credential modes. It can also mishandle valid API-key profiles when the selected profile has no security_token_file, or when that value is inherited from [DEFAULT].
Every Monitoring SDK client path must use consistent authentication and the exact derived additional_user_agent, including:
oci.monitoring.MonitoringClient;oci.identity.IdentityClientused for subscribed-region discovery after PR Support for subscribed region selection in monitoring and logging mcp servers #417.
Proposed changes
-
Declare the same bounded dependency used by
oci-cloud-mcp-server:"oracle-mcp-common>=0.1.2,<0.2.0" -
Add the workspace dependency mapping used by the reference server:
[tool.uv.sources] oracle-mcp-common = { workspace = true }
-
Derive one canonical
_ADDITIONAL_UAfrom__project__and__version__. -
Use
build_auth_context()for stdio and configured credential modes. -
When a Monitoring tool supplies an explicit region, use
AuthOptions(region=region)or otherwise preserve the common library's documented region precedence. -
Merge
AuthContext.configwith_ADDITIONAL_UAand passAuthContext.signerto every OCI client. -
Use
AuthContext.tenancy_idwhen resolving the tenancy for subscribed-region discovery. -
At HTTP startup, call
build_idcs_http_auth(required_scopes)once and assign its provider tomcp.auth. -
For every authenticated HTTP request:
- obtain the FastMCP access token in the server;
- call
IDCSHttpAuth.context_for(access_token.token, region=region)when an explicit region is supplied; - merge the returned config with
_ADDITIONAL_UA; - construct caller-specific Monitoring or Identity clients.
-
Do not cache an HTTP-derived signer or OCI client across callers.
-
Preserve the server's existing retry, circuit-breaker, client lifecycle, MCP tool contracts, and region-selection behavior.
-
Remove duplicated profile parsing and direct signer/provider construction from the server.
-
Update
README.md,CHANGELOG.md,pyproject.toml, anduv.lock.
Shared-library ownership
oracle-mcp-common remains the source of truth for reusable OCI authentication behavior.
If this migration identifies a missing authentication mode, configuration input, signer behavior, validation rule, error contract, or other reusable requirement:
- implement and test the capability in
src/commonrather than adding a server-local workaround; - document the behavior in
src/common/README.md; - maintain secret-safe errors and backward compatibility;
- publish an appropriate
oracle-mcp-commonversion before depending on it from this server; - update the server's bounded dependency and lockfile afterward.
The Monitoring server should retain only service-specific client construction, region handling, retry and circuit-breaker policy, user-agent assignment, and client lifecycle.
Supported authentication modes
The migrated server should support the modes provided by oracle-mcp-common:
autoapi_keysecurity_tokenidentity_domain_upstinstance_principalresource_principalinstance_principal_delegationresource_principal_delegationoke_workload_identity
Acceptance criteria
-
oci-monitoring-mcp-serverdeclaresoracle-mcp-common>=0.1.2,<0.2.0.
Activity