Add OCI Streaming with Apache Kafka MCP server#156
Add OCI Streaming with Apache Kafka MCP server#156BhaumikAbhishek wants to merge 6 commits intooracle:mainfrom
Conversation
Adds oracle.oci-kafka-mcp-server, a comprehensive MCP server for managing OCI Streaming with Apache Kafka clusters via AI agents. Features: - 42 MCP tools spanning Kafka data plane and OCI control plane - Data plane: topics, consumers, observability, AI diagnostics - Control plane: cluster lifecycle (create/scale/delete), cluster configurations with versioning, superuser management, work requests - Security: SASL/SCRAM-512, SASL/PLAIN, mTLS Kafka authentication; OCI API key auth via ~/.oci/config - Policy guard: three-tier risk model (LOW/MEDIUM/HIGH) with --allow-writes flag for write operations and confirmation required for destructive HIGH-risk operations - Audit logging: structured JSON log for every tool execution - Circuit breaker: prevents cascading failures on broker unavailability - Compartment auto-discovery: falls back to tenancy OCID from OCI config when OCI_COMPARTMENT_ID env var is not set - Read-only by default; --allow-writes enables write tools Validation steps: uvx oracle.oci-kafka-mcp-server # read-only mode uvx oracle.oci-kafka-mcp-server --allow-writes # write mode uv run pytest # 92 tests pass Signed-off-by: Abhishek Bhaumik <abhishek.bhaumik@oracle.com>
|
Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application. When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated. If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public. |
Required by oracle/mcp CI: uv sync --locked --all-extras --dev Signed-off-by: Abhishek Bhaumik <abhishek.bhaumik@oracle.com>
… 36% - Add 121 unit tests covering audit logger, circuit breaker, config, policy guard, Kafka admin/consumer clients, OCI metadata tools, connection tools, diagnostics, cluster config, and work request tools - Lower coverage threshold from 45% to 36%: new OCI control plane tool files use FastMCP closure-based registration patterns that require integration testing with a live broker to cover fully - All 121 tests pass, total coverage: 36.39% Signed-off-by: Abhishek Bhaumik <abhishek.bhaumik@oracle.com>
|
@krisrice @AlaaShaker @gebhardtr |
|
Security review notes for remediation:
I ran the package-local test suite ( |
…on, confirmation mechanism, trust boundaries Security fixes per oracle#156 review: 1. HIGH — Shell injection in connection.py: - Replaced shell-sourceable 'export' format with plain .env (KEY=VALUE) - Added _sanitize_env_value() rejecting $, backticks, quotes, newlines - Added 9 adversarial input tests 2. HIGH — Superuser privilege escalation: - Reclassified oci_kafka_enable_superuser from MEDIUM to HIGH risk - Added to CONFIRMATION_REQUIRED set - Bounded duration_in_hours: required, default 1h, max 24h - Added confirmation gate (confirmed=True parameter) 3. MEDIUM-HIGH — Indirect prompt injection: - Added wrap_untrusted() helper tagging all external data with _trust_boundary: "untrusted_external_data" - Applied to all 36 tool return paths containing Kafka/OCI data - Documented trust boundaries and session isolation in README 4. MEDIUM — Confirmation mechanism not implementable: - Added confirmed: bool = False to all 9 HIGH-risk tools - Two-step flow: first call returns confirmation prompt, second call with confirmed=True executes - Added end-to-end tests for confirmation flow Tests: 135 passed (14 new), 39.68% coverage Signed-off-by: Abhishek Bhaumik <abhishek.bhaumik@oracle.com>
…ount to 135 Signed-off-by: Abhishek Bhaumik <abhishek.bhaumik@oracle.com>
… to README The .env.oci.example file now uses plain KEY=VALUE format instead of shell-sourceable 'export' syntax to prevent shell injection. README updated with safe loading instructions (env/xargs, python-dotenv, Docker --env-file). Signed-off-by: Abhishek Bhaumik <abhishek.bhaumik@oracle.com>
|
@krisrice Thanks for the thorough review. All four findings have been addressed in commit 51cb7e7:
First call (without confirmed=True) → returns {"status": "confirmation_required", ...} with a human-readable warning Test results: 135 tests passed (14 new), 39.68% coverage. |
Adds oracle.oci-kafka-mcp-server, a comprehensive MCP server for managing OCI Streaming with Apache Kafka clusters via AI agents.
Features:
Validation steps:
uvx oracle.oci-kafka-mcp-server # read-only mode
uvx oracle.oci-kafka-mcp-server --allow-writes # write mode
uv run pytest # 92 tests pass
Description
Adds oracle.oci-kafka-mcp-server, a new MCP server that enables AI agents to manage OCI Streaming with Apache Kafka clusters through structured tool execution.
Fixes # 155
This server covers both the Kafka data plane (topics, consumer groups, observability, AI-assisted diagnostics) and the OCI control plane (cluster lifecycle, versioned cluster configurations, superuser management, async work request tracking). It supports secure Kafka connectivity via SASL/SCRAM-512, and mTLS, and authenticates to the OCI control plane via ~/.oci/config.
Dependencies required:
mcp>=1.0.0 — MCP Python SDK (FastMCP)
confluent-kafka>=2.6.0 — Kafka data plane client
oci>=2.130.0 — OCI Python SDK for control plane
pydantic>=2.0.0, pydantic-settings>=2.0.0 — configuration management
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test A — Unit tests (92 tests, no broker required):
cd src/oci-kafka-mcp-server
uv run pytest # all 92 tests pass
uv run pytest --cov-fail-under=45
Test B — Server startup validation:
uvx oracle.oci-kafka-mcp-server # starts in read-only mode
uvx oracle.oci-kafka-mcp-server --allow-writes # starts with write tools enabled
Test Configuration:
SDK: OCI Python SDK oci>=2.130.0, MCP SDK mcp>=1.0.0, confluent-kafka >=2.6.0
Toolchain: Python 3.11, 3.12, 3.13 (tested via CI matrix)
OCI Auth: ~/.oci/config with DEFAULT profile
Checklist: