-
Notifications
You must be signed in to change notification settings - Fork 86
Open
Labels
Description
Problem
Several functions in the security tools modules have inconsistent return types where:
- Functions are declared with
-> strreturn type annotation - But they return dict/object responses instead of strings
- Some functions use
str()for serialization which produces invalid JSON
Affected Files
server/secops/secops_mcp/tools/security_alerts.pyserver/secops/secops_mcp/tools/threat_intel.py
Issues Found
-
security_alerts.py:
get_security_alerts()was returning a raw string but needed JSON serializationget_security_alert_by_id()was returning raw dict response instead of stringdo_update_security_alert()was returning raw dict response instead of string
-
threat_intel.py:
- Used
str(response)which produces Python string representation instead of valid JSON
- Used
Solution
- Add missing
jsonimports - Use
json.dumps()consistently for serializing dict/object responses - Ensure all functions with
-> strreturn type actually return strings
Why json.dumps() over str()
json.dumps()produces valid JSON that can be parsed by clientsstr()produces Python-specific representations with single quotes (not valid JSON)- Ensures consistency across the codebase
- Preserves proper data structure for client parsing
Related PR
PR #160 addresses this issue