Skip to content

Commit 1ecb694

Browse files
authored
Merge pull request #10 from genomoncology/health_check
Health check
2 parents d843117 + b944357 commit 1ecb694

6 files changed

Lines changed: 484 additions & 5 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,4 @@ llms/
143143
vault/
144144

145145
.DS_Store
146+
/node_modules/

docs/cli/health.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Health Check CLI Documentation
2+
3+
The Health Check CLI module provides commands for checking the health of API endpoints and system resources used by BioMCP.
4+
5+
> **Tip**: Use the `--help` flag with any command (e.g., `biomcp health check --help`) to see the most up-to-date options directly from the tool.
6+
7+
## Check Command (`check`)
8+
9+
Run a comprehensive health check on API endpoints and system resources.
10+
11+
### Usage
12+
13+
```bash
14+
biomcp health check [OPTIONS]
15+
```
16+
17+
#### Options
18+
19+
- `--api-only`: Check only API endpoints. [default: False]
20+
- `--system-only`: Check only system health. [default: False]
21+
- `-v, --verbose`: Show detailed error information and API responses. [default: False]
22+
- `--help`: Show help message and exit.
23+
24+
### API Endpoints Checked
25+
26+
The health check command tests connectivity and responses from all external APIs that BioMCP depends on:
27+
28+
1. **PubTator3 API**:
29+
30+
- Autocomplete endpoint
31+
- Publications export endpoint
32+
- Search endpoint
33+
34+
2. **ClinicalTrials.gov API**:
35+
36+
- Studies search endpoint
37+
- Individual study retrieval endpoint
38+
39+
3. **MyVariant.info API**:
40+
- Query endpoint
41+
- Variant retrieval endpoint
42+
43+
### System Health Checks
44+
45+
When checking system health, the command evaluates:
46+
47+
- **Network connectivity**: Tests basic internet connectivity
48+
- **System resources**: Monitors CPU usage, memory availability, and disk space
49+
- **Python environment**: Reports Python version and critical dependencies
50+
51+
> **Note**: For full system resource checks, the `psutil` package is required. If not installed, the command will still run but will indicate that `psutil` is missing.
52+
53+
### Examples
54+
55+
Run a complete health check (API endpoints and system resources):
56+
57+
```bash
58+
biomcp health check
59+
```
60+
61+
Check only API endpoints:
62+
63+
```bash
64+
biomcp health check --api-only
65+
```
66+
67+
Check only system resources:
68+
69+
```bash
70+
biomcp health check --system-only
71+
```
72+
73+
Show detailed error information for any failing checks:
74+
75+
```bash
76+
biomcp health check --verbose
77+
```
78+
79+
Combine options as needed:
80+
81+
```bash
82+
biomcp health check --api-only --verbose
83+
```
84+
85+
### Output
86+
87+
The command displays results in formatted tables:
88+
89+
1. **API Endpoints Health**: Shows the status of each API endpoint (200 OK or error code)
90+
2. **System Resources**: Displays CPU, memory, and disk usage statistics
91+
3. **Network & Environment**: Shows network connectivity status and Python environment details
92+
93+
In verbose mode, detailed error information is displayed for any failing endpoints, which can help diagnose API-related issues.
94+
95+
### Exit Status
96+
97+
The command provides a summary of overall health status:
98+
99+
- "✓ All systems operational!" when all checks pass
100+
- "⚠ Some health checks failed." when one or more checks fail

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ dependencies = [
2121
"httpx>=0.28.1",
2222
"mcp[cli]>=1.3.0",
2323
"platformdirs>=4.3.6",
24+
"psutil>=7.0.0",
2425
"pydantic>=2.10.6",
26+
"rich>=14.0.0",
2527
"typer>=0.15.2",
2628
]
2729

0 commit comments

Comments
 (0)