google / google/mcp-security

[secops-soar] Dynamic marketplace tool import fails with ModuleNotFoundError when running installed package

Open Beginner friendly
#293 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
528
Forks
141
Avg merge
3d 2h
Merged PRs (30d)
6

Description

### Description

When `secops-soar-mcp` is installed as a Python package (or launched via `uvx secops_soar_mcp --integrations `), dynamic marketplace tool registration fails with `ModuleNotFoundError`.

### Root Cause
In [`server/secops-soar/secops_soar_mcp/server.py` (line 102)](https://github.com/google/mcp-security/blob/main/server/secops-soar/secops_soar_mcp/server.py#L102):

```python
module_stem = py_file.stem # The filename without .py (e.g., "csv")
if module_stem not in enabled_integrations_set:
continue
module_import_path = f"marketplace.{module_stem}" # The import path (e.g., "marketplace.csv")

try:
logger.debug(" Attempting to import module: %s", module_import_path)
module = importlib.import_module(module_import_path)
```

Because `marketplace` is a subpackage inside `secops_soar_mcp` (`secops_soar_mcp.marketplace`), `importlib.import_module("marketplace.csv")` looks for a top-level package named `marketplace`. When the package is installed in `site-packages` and executed from any arbitrary working directory, `sys.path` does not contain the inner `secops_soar_mcp/` directory as root, resulting in:

```text
ERROR:secops-soar:* Failed to import module marketplace.csv. Error: No module named 'marketplace'
```

### Steps to Reproduce
1. Install `secops-soar-mcp` in a clean environment:
```bash
pip install .
```
2. Run the server enabling any marketplace integration:
```bash
secops-soar-mcp --integrations CSV,OKTA
```
3. Observe that no marketplace tools are registered and `ModuleNotFoundError` is logged for each enabled integration.

### Proposed Fix

Update `server/secops-soar/secops_soar_mcp/server.py` to import using the qualified package path `secops_soar_mcp.marketplace.{module_stem}`, with a fallback to `marketplace.{module_stem}` for local directory execution:

```python
module_import_path = f"secops_soar_mcp.marketplace.{module_stem}"
fallback_import_path = f"marketplace.{module_stem}"

try:
logger.debug(" Attempting to import module: %s", module_import_path)
try:
module = importlib.import_module(module_import_path)
except ImportError:
module = importlib.import_module(fallback_import_path)
```

Contributor guide

Open the contributing guide

Research direction

Start in server/secops-soar/secops_soar_mcp/server.py around line 102, where marketplace modules are dynamically imported. Install the package in a clean environment and run secops-soar-mcp --integrations CSV,OKTA to confirm the current ModuleNotFoundError. The work is done when enabled marketplace tools register successfully both from the installed package and local directory execution.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, security
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.