Spaces:
Running
Running
Commit
·
9ea4c2e
1
Parent(s):
bd9da91
uhuhuhu
Browse files- api_monitor.py +24 -6
api_monitor.py
CHANGED
@@ -121,7 +121,7 @@ def validate_api_configuration(
|
|
121 |
5. If sample_response looks valid: Use config_id in activate_monitoring() to activate monitoring
|
122 |
|
123 |
ARGUMENTS:
|
124 |
-
- mcp_api_key: MCP API key serves as user identifier
|
125 |
- name: User-friendly name for the monitoring task
|
126 |
- description: Description of what is being monitored
|
127 |
- method: HTTP method (GET, POST, PUT, DELETE)
|
@@ -153,7 +153,7 @@ def validate_api_configuration(
|
|
153 |
start_at: ""
|
154 |
|
155 |
2. Weather monitoring with free API:
|
156 |
-
mcp_api_key: "
|
157 |
name: "Weather Monitor"
|
158 |
description: "Monitor current weather conditions every 2 hours for one week using Open-Meteo free API"
|
159 |
method: "GET"
|
@@ -182,14 +182,16 @@ def validate_api_configuration(
|
|
182 |
"""
|
183 |
try:
|
184 |
# Validate input parameters
|
185 |
-
if not mcp_api_key or not mcp_api_key.strip():
|
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 |
key_verification = verify_mcp_api_key(mcp_api_key)
|
194 |
if not key_verification["success"]:
|
195 |
return {
|
@@ -379,7 +381,7 @@ async def activate_monitoring(config_id, mcp_api_key):
|
|
379 |
|
380 |
ARGUMENTS:
|
381 |
- config_id: The ID from successful validate_api_configuration() execution (required)
|
382 |
-
- mcp_api_key: User's MCP API key for verification (must match validation step)
|
383 |
|
384 |
Input Examples:
|
385 |
|
@@ -432,6 +434,14 @@ async def activate_monitoring(config_id, mcp_api_key):
|
|
432 |
|
433 |
# attempt to create the scheduler
|
434 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
435 |
# Verify the MCP API key with the key generation server first
|
436 |
key_verification = verify_mcp_api_key(mcp_api_key)
|
437 |
if not key_verification["success"]:
|
@@ -678,7 +688,7 @@ def retrieve_monitored_data(config_id, mcp_api_key, mode="summary"):
|
|
678 |
|
679 |
ARGUMENTS:
|
680 |
- config_id: The ID of the API configuration to retrieve data for (required)
|
681 |
-
- mcp_api_key: User's MCP API key for verification (must match validation step)
|
682 |
- mode: Data return mode - "summary" (LLM-optimized), "details" (full responses, minimal metadata), "full" (everything)
|
683 |
|
684 |
Input Examples:
|
@@ -759,6 +769,14 @@ def retrieve_monitored_data(config_id, mcp_api_key, mode="summary"):
|
|
759 |
ERROR HANDLING: If config_id not found or invalid, returns success=False with error message
|
760 |
"""
|
761 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
762 |
# Verify the MCP API key with the key generation server first
|
763 |
key_verification = verify_mcp_api_key(mcp_api_key)
|
764 |
if not key_verification["success"]:
|
|
|
121 |
5. If sample_response looks valid: Use config_id in activate_monitoring() to activate monitoring
|
122 |
|
123 |
ARGUMENTS:
|
124 |
+
- mcp_api_key: MCP API key serves as user identifier. Leave as empty string "" to use the environment variable MCP_API_KEY.
|
125 |
- name: User-friendly name for the monitoring task
|
126 |
- description: Description of what is being monitored
|
127 |
- method: HTTP method (GET, POST, PUT, DELETE)
|
|
|
153 |
start_at: ""
|
154 |
|
155 |
2. Weather monitoring with free API:
|
156 |
+
mcp_api_key: ""
|
157 |
name: "Weather Monitor"
|
158 |
description: "Monitor current weather conditions every 2 hours for one week using Open-Meteo free API"
|
159 |
method: "GET"
|
|
|
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"]:
|
197 |
return {
|
|
|
381 |
|
382 |
ARGUMENTS:
|
383 |
- config_id: The ID from successful validate_api_configuration() execution (required)
|
384 |
+
- mcp_api_key: User's MCP API key for verification (must match validation step). Leave as empty string "" to use the environment variable MCP_API_KEY.
|
385 |
|
386 |
Input Examples:
|
387 |
|
|
|
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"]:
|
|
|
688 |
|
689 |
ARGUMENTS:
|
690 |
- config_id: The ID of the API configuration to retrieve data for (required)
|
691 |
+
- mcp_api_key: User's MCP API key for verification (must match validation step). Leave as empty string "" to use the environment variable MCP_API_KEY.
|
692 |
- mode: Data return mode - "summary" (LLM-optimized), "details" (full responses, minimal metadata), "full" (everything)
|
693 |
|
694 |
Input Examples:
|
|
|
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"]:
|