Skip to content

Commit 1df6f98

Browse files
committed
feat: update mcptoolbox and add main.py
1 parent 0e577fc commit 1df6f98

File tree

3 files changed

+379
-0
lines changed

3 files changed

+379
-0
lines changed

main.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os
2+
3+
import uvicorn
4+
from google.adk.cli.fast_api import get_fast_api_app
5+
6+
# Get the directory where main.py is located
7+
AGENT_DIR = os.path.dirname(os.path.abspath(__file__))
8+
# Example session DB URL (e.g., SQLite)
9+
# SESSION_DB_URL = "sqlite:///./sessions.db"
10+
# Example allowed origins for CORS
11+
ALLOWED_ORIGINS = ["http://localhost", "http://localhost:8080","http://localhost:4200", "*"]
12+
# Set web=True if you intend to serve a web interface, False otherwise
13+
SERVE_WEB_INTERFACE = True
14+
15+
16+
# Call the function to get the FastAPI app instance
17+
# Ensure the agent directory name ('capital_agent') matches your agent folder
18+
app = get_fast_api_app(
19+
agents_dir=AGENT_DIR,
20+
# session_service_uri=SESSION_DB_URL,
21+
allow_origins=ALLOWED_ORIGINS,
22+
web=SERVE_WEB_INTERFACE,
23+
)
24+
25+
26+
if __name__ == "__main__":
27+
# Use the PORT environment variable provided by Cloud Run, defaulting to 8080
28+
uvicorn.run(app, host="0.0.0.0", port=int(os.environ.get("PORT", 8080)))

mcp-toolbox/toolbox.exe

88.6 MB
Binary file not shown.

mcp-toolbox/tools.yaml

Lines changed: 351 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,351 @@
1+
sources:
2+
bq-export:
3+
kind: "bigquery"
4+
project: "aceti-462716"
5+
6+
tools:
7+
system_chaos_summary:
8+
kind: bigquery-sql
9+
source: bq-export
10+
description: Aggregated view of all chaos logs in the system.
11+
parameters: []
12+
statement: |
13+
SELECT
14+
severity,
15+
COUNT(*) AS count,
16+
COUNT(DISTINCT jsonPayload.agent_id) AS affected_agents,
17+
COUNT(DISTINCT jsonPayload.experiment_id) AS affected_experiments,
18+
STRING_AGG(DISTINCT jsonPayload.region) AS involved_regions
19+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
20+
GROUP BY severity
21+
ORDER BY count DESC;
22+
23+
frequent_failure_patterns:
24+
kind: bigquery-sql
25+
source: bq-export
26+
description: Top recurring failure messages in chaos logs.
27+
statement: |
28+
SELECT
29+
jsonPayload.message AS failure_message,
30+
COUNT(*) AS occurrences,
31+
STRING_AGG(DISTINCT jsonPayload.agent_id) AS involved_agents
32+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
33+
WHERE severity IN ('CRITICAL', 'ERROR')
34+
GROUP BY jsonPayload.message
35+
ORDER BY occurrences DESC
36+
LIMIT 10;
37+
38+
list_experiments:
39+
kind: bigquery-sql
40+
source: bq-export
41+
description: List all chaos experiments.
42+
statement: |
43+
SELECT
44+
jsonPayload.experiment_id AS id,
45+
MAX(jsonPayload.timestamp) AS last_seen,
46+
COUNT(*) AS total_logs,
47+
SUM(CASE WHEN severity IN ('CRITICAL', 'ERROR') THEN 1 ELSE 0 END) AS error_logs
48+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
49+
GROUP BY jsonPayload.experiment_id
50+
ORDER BY last_seen DESC;
51+
52+
get_experiment_by_id:
53+
kind: bigquery-sql
54+
source: bq-export
55+
description: Get all logs for a specific experiment.
56+
parameters:
57+
- name: experiment_id
58+
type: string
59+
description: The experiment ID (e.g., "exp0001").
60+
statement: |
61+
SELECT *
62+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
63+
WHERE jsonPayload.experiment_id = ?
64+
ORDER BY TIMESTAMP(jsonPayload.timestamp) DESC;
65+
66+
list_anomalies:
67+
kind: bigquery-sql
68+
source: bq-export
69+
description: List critical or unusual chaos log entries (anomalies).
70+
statement: |
71+
SELECT
72+
jsonPayload.experiment_id,
73+
jsonPayload.message AS anomaly_type,
74+
severity,
75+
jsonPayload.timestamp AS detected_at
76+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
77+
WHERE severity IN ('CRITICAL', 'EMERGENCY', 'ALERT')
78+
ORDER BY TIMESTAMP(jsonPayload.timestamp) DESC;
79+
80+
recent_failed_experiments:
81+
kind: bigquery-sql
82+
source: bq-export
83+
description: List experiments with at least one CRITICAL error in the past 7 days.
84+
statement: |
85+
SELECT
86+
jsonPayload.experiment_id AS id,
87+
MAX(jsonPayload.timestamp) AS last_failure_time,
88+
COUNT(*) AS failure_count
89+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
90+
WHERE severity = 'CRITICAL'
91+
AND TIMESTAMP(jsonPayload.timestamp) >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 7 DAY)
92+
GROUP BY jsonPayload.experiment_id
93+
ORDER BY last_failure_time DESC;
94+
95+
recent_errors:
96+
kind: bigquery-sql
97+
source: bq-export
98+
description: Last 5 ERROR and CRITICAL logs.
99+
parameters: []
100+
statement: |
101+
SELECT
102+
jsonPayload.experiment_id,
103+
jsonPayload.message AS failure_type,
104+
severity,
105+
jsonPayload.region,
106+
jsonPayload.timestamp
107+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
108+
WHERE severity IN ('ERROR', 'CRITICAL')
109+
ORDER BY TIMESTAMP(jsonPayload.timestamp) DESC
110+
LIMIT 5;
111+
112+
most_frequent_error_types:
113+
kind: bigquery-sql
114+
source: bq-export
115+
description: Most frequent error messages by count.
116+
parameters: []
117+
statement: |
118+
SELECT
119+
jsonPayload.message AS failure_type,
120+
COUNT(*) AS count,
121+
STRING_AGG(DISTINCT jsonPayload.region) AS regions
122+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
123+
WHERE severity IN ('ERROR', 'CRITICAL')
124+
GROUP BY jsonPayload.message
125+
ORDER BY count DESC
126+
LIMIT 5;
127+
128+
errors_logs_grouped_by_severity:
129+
kind: bigquery-sql
130+
source: bq-export
131+
description: Errors grouped by severity.
132+
parameters: []
133+
statement: |
134+
SELECT severity, COUNT(*) AS count
135+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
136+
WHERE severity IN ('ERROR', 'CRITICAL')
137+
GROUP BY severity;
138+
139+
critical_error_logs_grouped_by_region:
140+
kind: bigquery-sql
141+
source: bq-export
142+
description: Count of errors by region and severity.
143+
parameters: []
144+
statement: |
145+
SELECT jsonPayload.region, severity, COUNT(*) AS count
146+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
147+
WHERE severity IN ('ERROR', 'CRITICAL')
148+
GROUP BY jsonPayload.region, severity;
149+
150+
total_error_logs:
151+
kind: bigquery-sql
152+
source: bq-export
153+
description: Total ERROR and CRITICAL logs.
154+
parameters: []
155+
statement: |
156+
SELECT COUNT(*) AS total_error_logs
157+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
158+
WHERE severity IN ('ERROR', 'CRITICAL');
159+
160+
agent_failure_rate:
161+
kind: bigquery-sql
162+
source: bq-export
163+
description: Failure rate per agent.
164+
statement: |
165+
SELECT
166+
jsonPayload.agent_id,
167+
COUNT(*) AS total_logs,
168+
SUM(CASE WHEN severity IN ('CRITICAL', 'ERROR') THEN 1 ELSE 0 END) AS error_count,
169+
ROUND(SAFE_DIVIDE(SUM(CASE WHEN severity IN ('CRITICAL', 'ERROR') THEN 1 ELSE 0 END), COUNT(*)), 2) AS failure_rate
170+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
171+
GROUP BY jsonPayload.agent_id
172+
ORDER BY failure_rate DESC;
173+
174+
user_impact_summary:
175+
kind: bigquery-sql
176+
source: bq-export
177+
description: Impact on users from error logs.
178+
statement: |
179+
SELECT
180+
jsonPayload.details.user_id,
181+
COUNT(*) AS total_events,
182+
COUNTIF(severity = 'CRITICAL') AS critical_events,
183+
COUNTIF(severity = 'ERROR') AS error_events
184+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
185+
WHERE severity IN ('CRITICAL', 'ERROR')
186+
GROUP BY jsonPayload.details.user_id
187+
ORDER BY critical_events DESC;
188+
189+
http_error_summary:
190+
kind: bigquery-sql
191+
source: bq-export
192+
description: Common HTTP failure patterns.
193+
statement: |
194+
SELECT
195+
jsonPayload.httprequest.requestmethod AS method,
196+
jsonPayload.httprequest.requesturl AS url,
197+
jsonPayload.status_code,
198+
COUNT(*) AS failures
199+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
200+
WHERE severity = 'ERROR'
201+
GROUP BY method, url, jsonPayload.status_code
202+
ORDER BY failures DESC
203+
LIMIT 10;
204+
205+
incidents_by_agent_and_experiment:
206+
kind: bigquery-sql
207+
source: bq-export
208+
description: Count of logs by agent and experiment, grouped by severity and region.
209+
statement: |
210+
SELECT
211+
jsonPayload.agent_id,
212+
jsonPayload.experiment_id,
213+
severity,
214+
jsonPayload.region,
215+
COUNT(*) AS log_count
216+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
217+
GROUP BY agent_id, experiment_id, severity, region
218+
ORDER BY log_count DESC
219+
220+
error_trends_by_agent:
221+
kind: bigquery-sql
222+
source: bq-export
223+
description: Error and critical log trends by agent over time.
224+
statement: |
225+
SELECT
226+
jsonPayload.agent_id,
227+
severity,
228+
FORMAT_TIMESTAMP('%Y-%m-%d %H:00:00', TIMESTAMP(jsonPayload.timestamp)) AS hour,
229+
COUNT(*) AS count
230+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
231+
WHERE severity IN ('ERROR', 'CRITICAL')
232+
GROUP BY agent_id, severity, hour
233+
ORDER BY hour DESC, count DESC
234+
235+
top_regions_by_error:
236+
kind: bigquery-sql
237+
source: bq-export
238+
description: Top regions by error and critical log count.
239+
statement: |
240+
SELECT
241+
jsonPayload.region,
242+
severity,
243+
COUNT(*) AS error_count
244+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
245+
WHERE severity IN ('ERROR', 'CRITICAL')
246+
GROUP BY region, severity
247+
ORDER BY error_count DESC
248+
249+
user_impact_by_experiment:
250+
kind: bigquery-sql
251+
source: bq-export
252+
description: User impact by experiment.
253+
statement: |
254+
SELECT
255+
jsonPayload.experiment_id,
256+
COUNT(DISTINCT jsonPayload.details.user_id) AS affected_users,
257+
COUNT(*) AS total_events
258+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
259+
WHERE jsonPayload.details.user_id IS NOT NULL
260+
GROUP BY experiment_id
261+
ORDER BY affected_users DESC
262+
263+
most_frequent_action_messages:
264+
kind: bigquery-sql
265+
source: bq-export
266+
description: Most frequent log messages (potential actions) by agent and experiment.
267+
statement: |
268+
SELECT
269+
jsonPayload.agent_id AS agent_id,
270+
jsonPayload.experiment_id AS experiment_id,
271+
jsonPayload.message AS action_message,
272+
COUNT(*) AS count
273+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
274+
WHERE jsonPayload.message IS NOT NULL
275+
GROUP BY agent_id, experiment_id, action_message
276+
ORDER BY count DESC
277+
LIMIT 20;
278+
279+
error_actions_by_agent:
280+
kind: bigquery-sql
281+
source: bq-export
282+
description: Count of ERROR and CRITICAL log messages by agent.
283+
statement: |
284+
SELECT
285+
jsonPayload.agent_id AS agent_id,
286+
COUNT(*) AS error_count
287+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
288+
WHERE severity IN ('ERROR', 'CRITICAL')
289+
GROUP BY agent_id
290+
ORDER BY error_count DESC;
291+
292+
recent_actions_by_experiment:
293+
kind: bigquery-sql
294+
source: bq-export
295+
description: Recent log messages for a specific experiment.
296+
parameters:
297+
- name: experiment_id
298+
type: string
299+
description: The experiment ID (e.g., "exp0001").
300+
statement: |
301+
SELECT
302+
jsonPayload.agent_id,
303+
jsonPayload.message,
304+
severity,
305+
jsonPayload.timestamp
306+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
307+
WHERE jsonPayload.experiment_id = @experiment_id
308+
ORDER BY jsonPayload.timestamp DESC
309+
LIMIT 20;
310+
311+
user_impact_by_action:
312+
kind: bigquery-sql
313+
source: bq-export
314+
description: User impact summary by log message.
315+
statement: |
316+
SELECT
317+
jsonPayload.message AS action_message,
318+
COUNT(DISTINCT jsonPayload.details.user_id) AS affected_users,
319+
COUNT(*) AS total_events
320+
FROM `aceti-462716.bqexport.chaospilot_fake_logs_20250620`
321+
WHERE jsonPayload.details.user_id IS NOT NULL
322+
GROUP BY action_message
323+
ORDER BY affected_users DESC
324+
LIMIT 10;
325+
326+
toolsets:
327+
detector_toolset:
328+
- recent_errors
329+
- most_frequent_error_types
330+
- errors_logs_grouped_by_severity
331+
- critical_error_logs_grouped_by_region
332+
- total_error_logs
333+
- list_experiments
334+
- get_experiment_by_id
335+
- list_anomalies
336+
- recent_failed_experiments
337+
- system_chaos_summary
338+
- frequent_failure_patterns
339+
- agent_failure_rate
340+
- user_impact_summary
341+
- http_error_summary
342+
planner_toolset:
343+
- incidents_by_agent_and_experiment
344+
- error_trends_by_agent
345+
- top_regions_by_error
346+
- user_impact_by_experiment
347+
action_recommender_toolset:
348+
- most_frequent_action_messages
349+
- error_actions_by_agent
350+
- recent_actions_by_experiment
351+
- user_impact_by_action

0 commit comments

Comments
 (0)