Spaces:
Running
Running
Commit
·
35da243
1
Parent(s):
9ea4c2e
Refactor MCP API key validation to streamline checks and improve readability
Browse files- api_monitor.py +7 -7
api_monitor.py
CHANGED
@@ -182,15 +182,15 @@ def validate_api_configuration(
|
|
182 |
"""
|
183 |
try:
|
184 |
# Validate input parameters
|
185 |
-
if not mcp_api_key or not mcp_api_key.strip() or mcp_api_key == ""
|
186 |
mcp_api_key = os.environ["MCP_API_KEY"]
|
187 |
if not mcp_api_key or not mcp_api_key.strip():
|
188 |
return {
|
189 |
"success": False,
|
190 |
"message": "MCP API key is required",
|
191 |
"config_id": None,
|
192 |
-
}
|
193 |
-
|
194 |
# Verify the MCP API key with the key generation server
|
195 |
key_verification = verify_mcp_api_key(mcp_api_key)
|
196 |
if not key_verification["success"]:
|
@@ -434,14 +434,14 @@ async def activate_monitoring(config_id, mcp_api_key):
|
|
434 |
|
435 |
# attempt to create the scheduler
|
436 |
try:
|
437 |
-
if not mcp_api_key or not mcp_api_key.strip() or mcp_api_key == ""
|
438 |
mcp_api_key = os.environ["MCP_API_KEY"]
|
439 |
if not mcp_api_key or not mcp_api_key.strip():
|
440 |
return {
|
441 |
"success": False,
|
442 |
"message": "MCP API key is required",
|
443 |
"config_id": None,
|
444 |
-
}
|
445 |
# Verify the MCP API key with the key generation server first
|
446 |
key_verification = verify_mcp_api_key(mcp_api_key)
|
447 |
if not key_verification["success"]:
|
@@ -769,14 +769,14 @@ def retrieve_monitored_data(config_id, mcp_api_key, mode="summary"):
|
|
769 |
ERROR HANDLING: If config_id not found or invalid, returns success=False with error message
|
770 |
"""
|
771 |
try:
|
772 |
-
if not mcp_api_key or not mcp_api_key.strip() or mcp_api_key == ""
|
773 |
mcp_api_key = os.environ["MCP_API_KEY"]
|
774 |
if not mcp_api_key or not mcp_api_key.strip():
|
775 |
return {
|
776 |
"success": False,
|
777 |
"message": "MCP API key is required",
|
778 |
"config_id": None,
|
779 |
-
}
|
780 |
# Verify the MCP API key with the key generation server first
|
781 |
key_verification = verify_mcp_api_key(mcp_api_key)
|
782 |
if not key_verification["success"]:
|
|
|
182 |
"""
|
183 |
try:
|
184 |
# Validate input parameters
|
185 |
+
if not mcp_api_key or not mcp_api_key.strip() or mcp_api_key == "":
|
186 |
mcp_api_key = os.environ["MCP_API_KEY"]
|
187 |
if not mcp_api_key or not mcp_api_key.strip():
|
188 |
return {
|
189 |
"success": False,
|
190 |
"message": "MCP API key is required",
|
191 |
"config_id": None,
|
192 |
+
}
|
193 |
+
|
194 |
# Verify the MCP API key with the key generation server
|
195 |
key_verification = verify_mcp_api_key(mcp_api_key)
|
196 |
if not key_verification["success"]:
|
|
|
434 |
|
435 |
# attempt to create the scheduler
|
436 |
try:
|
437 |
+
if not mcp_api_key or not mcp_api_key.strip() or mcp_api_key == "":
|
438 |
mcp_api_key = os.environ["MCP_API_KEY"]
|
439 |
if not mcp_api_key or not mcp_api_key.strip():
|
440 |
return {
|
441 |
"success": False,
|
442 |
"message": "MCP API key is required",
|
443 |
"config_id": None,
|
444 |
+
}
|
445 |
# Verify the MCP API key with the key generation server first
|
446 |
key_verification = verify_mcp_api_key(mcp_api_key)
|
447 |
if not key_verification["success"]:
|
|
|
769 |
ERROR HANDLING: If config_id not found or invalid, returns success=False with error message
|
770 |
"""
|
771 |
try:
|
772 |
+
if not mcp_api_key or not mcp_api_key.strip() or mcp_api_key == "":
|
773 |
mcp_api_key = os.environ["MCP_API_KEY"]
|
774 |
if not mcp_api_key or not mcp_api_key.strip():
|
775 |
return {
|
776 |
"success": False,
|
777 |
"message": "MCP API key is required",
|
778 |
"config_id": None,
|
779 |
+
}
|
780 |
# Verify the MCP API key with the key generation server first
|
781 |
key_verification = verify_mcp_api_key(mcp_api_key)
|
782 |
if not key_verification["success"]:
|