Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "biomcp-cli"
version = "0.8.6"
version = "0.8.7"
edition = "2024"
description = "Biomedical CLI and MCP server — genes, variants, trials, articles, drugs, diseases, pathways, proteins, adverse events, PGx"
homepage = "https://biomcp.org"
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ biomcp drug trials pembrolizumab
biomcp disease trials melanoma
biomcp disease drugs melanoma
biomcp disease articles "Lynch syndrome"
biomcp gene trials BRAF
biomcp gene drugs BRAF
biomcp gene articles BRCA1
biomcp gene pathways BRAF
biomcp pathway drugs R-HSA-5673001
Expand All @@ -111,7 +113,7 @@ biomcp get gene BRAF civic interactions # multiple sections
biomcp get gene BRAF all # everything

biomcp get variant "BRAF V600E" clinvar population conservation
biomcp get drug pembrolizumab label shortage targets indications approvals
biomcp get drug pembrolizumab label targets civic approvals
biomcp get disease "Lynch syndrome" genes phenotypes variants
biomcp get trial NCT02576665 eligibility locations outcomes
```
Expand Down
4 changes: 3 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ biomcp drug trials pembrolizumab
biomcp disease trials melanoma
biomcp disease drugs melanoma
biomcp disease articles "Lynch syndrome"
biomcp gene trials BRAF
biomcp gene drugs BRAF
biomcp gene articles BRCA1
biomcp gene pathways BRAF
biomcp pathway drugs R-HSA-5673001
Expand All @@ -111,7 +113,7 @@ biomcp get gene BRAF civic interactions # multiple sections
biomcp get gene BRAF all # everything

biomcp get variant "BRAF V600E" clinvar population conservation
biomcp get drug pembrolizumab label shortage targets approvals
biomcp get drug pembrolizumab label targets civic approvals
biomcp get disease "Lynch syndrome" genes phenotypes variants
biomcp get trial NCT02576665 eligibility locations outcomes
```
Expand Down
5 changes: 3 additions & 2 deletions docs/user-guide/variant.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ biomcp get variant rs113488022 all
## Helper commands

```bash
biomcp variant articles "BRAF V600E"
biomcp variant oncokb "BRAF V600E" # requires ONCOKB_TOKEN
biomcp variant trials "BRAF V600E" # search trials mentioning this mutation
biomcp variant articles "BRAF V600E" # search PubMed for this variant
biomcp variant oncokb "BRAF V600E" # OncoKB lookup (requires ONCOKB_TOKEN)
```

## Search variants
Expand Down
11 changes: 10 additions & 1 deletion skills/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,19 @@ Helpers let you pivot quickly between related entities without manually rebuildi
biomcp variant trials "BRAF V600E"
biomcp variant articles "BRAF V600E"
biomcp drug adverse-events pembrolizumab
biomcp drug trials pembrolizumab
biomcp disease trials melanoma
biomcp disease drugs melanoma
biomcp disease articles "Lynch syndrome"
biomcp gene trials BRAF
biomcp gene drugs BRAF
biomcp gene articles BRCA1
biomcp gene pathways BRAF
biomcp pathway drugs R-HSA-5673001
biomcp protein structures P15056 --limit 25
biomcp pathway articles R-HSA-5673001
biomcp pathway trials R-HSA-5673001
biomcp protein structures P15056
biomcp article entities 22663011
```

## Per-Entity Guides
Expand Down
105 changes: 98 additions & 7 deletions src/cli/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ pub struct HealthRow {
pub api: String,
pub status: String,
pub latency: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub affects: Option<String>,
}

#[derive(Debug, Clone, serde::Serialize)]
Expand All @@ -24,14 +26,27 @@ impl HealthReport {

pub fn to_markdown(&self) -> String {
let mut out = String::new();
let show_affects = self.rows.iter().any(|row| row.affects.is_some());
out.push_str("# BioMCP Health Check\n\n");
out.push_str("| API | Status | Latency |\n");
out.push_str("|-----|--------|---------|\n");
for row in &self.rows {
out.push_str(&format!(
"| {} | {} | {} |\n",
row.api, row.status, row.latency
));
if show_affects {
out.push_str("| API | Status | Latency | Affects |\n");
out.push_str("|-----|--------|---------|---------|\n");
for row in &self.rows {
let affects = row.affects.as_deref().unwrap_or("-");
out.push_str(&format!(
"| {} | {} | {} | {} |\n",
row.api, row.status, row.latency, affects
));
}
} else {
out.push_str("| API | Status | Latency |\n");
out.push_str("|-----|--------|---------|\n");
for row in &self.rows {
out.push_str(&format!(
"| {} | {} | {} |\n",
row.api, row.status, row.latency
));
}
}
out.push_str(&format!(
"\nStatus: {}/{} APIs healthy\n",
Expand All @@ -41,6 +56,22 @@ impl HealthReport {
}
}

fn affects_for_api(api: &str) -> Option<&'static str> {
match api {
"MyGene" => Some("get/search gene and gene helper commands"),
"MyVariant" => Some("get/search variant and variant helper commands"),
"ClinicalTrials" => Some("search/get trial and trial helper commands"),
"Enrichr" => Some("gene/pathway enrichment sections"),
"Europe PMC" => Some("article search coverage"),
"PubTator3" => Some("article annotations and entity extraction"),
"OpenFDA" => Some("adverse-event search"),
"CPIC" | "PharmGKB" => Some("pgx recommendations and annotations"),
"Monarch" => Some("disease genes, phenotypes, and models"),
"GWAS Catalog" => Some("gwas search and variant gwas context"),
_ => None,
}
}

async fn check_one(client: reqwest::Client, api: &str, url: &str) -> HealthRow {
let start = Instant::now();
let resp = client
Expand All @@ -58,12 +89,14 @@ async fn check_one(client: reqwest::Client, api: &str, url: &str) -> HealthRow {
api: api.to_string(),
status: "ok".into(),
latency: format!("{elapsed}ms"),
affects: None,
}
} else {
HealthRow {
api: api.to_string(),
status: "error".into(),
latency: format!("{elapsed}ms (HTTP {})", status.as_u16()),
affects: affects_for_api(api).map(str::to_string),
}
}
}
Expand All @@ -79,6 +112,7 @@ async fn check_one(client: reqwest::Client, api: &str, url: &str) -> HealthRow {
api: api.to_string(),
status: "error".into(),
latency: reason.into(),
affects: affects_for_api(api).map(str::to_string),
}
}
}
Expand Down Expand Up @@ -136,11 +170,13 @@ async fn check_cache_dir() -> HealthRow {
api: format!("Cache dir ({})", dir.display()),
status: "ok".into(),
latency: format!("{}ms", start.elapsed().as_millis()),
affects: None,
},
Err(err) => HealthRow {
api: format!("Cache dir ({})", dir.display()),
status: "error".into(),
latency: format!("{:?}", err.kind()),
affects: Some("local cache-backed lookups and downloads".into()),
},
}
}
Expand Down Expand Up @@ -243,3 +279,58 @@ pub async fn check(apis_only: bool) -> Result<HealthReport, BioMcpError> {
rows,
})
}

#[cfg(test)]
mod tests {
use super::{HealthReport, HealthRow};

#[test]
fn markdown_shows_affects_column_when_present() {
let report = HealthReport {
healthy: 1,
total: 2,
rows: vec![
HealthRow {
api: "MyGene".into(),
status: "ok".into(),
latency: "10ms".into(),
affects: None,
},
HealthRow {
api: "OpenFDA".into(),
status: "error".into(),
latency: "timeout".into(),
affects: Some("adverse-event search".into()),
},
],
};
let md = report.to_markdown();
assert!(md.contains("| API | Status | Latency | Affects |"));
assert!(md.contains("adverse-event search"));
}

#[test]
fn markdown_omits_affects_column_when_all_healthy() {
let report = HealthReport {
healthy: 2,
total: 2,
rows: vec![
HealthRow {
api: "MyGene".into(),
status: "ok".into(),
latency: "10ms".into(),
affects: None,
},
HealthRow {
api: "MyVariant".into(),
status: "ok".into(),
latency: "11ms".into(),
affects: None,
},
],
};
let md = report.to_markdown();
assert!(md.contains("| API | Status | Latency |"));
assert!(!md.contains("| API | Status | Latency | Affects |"));
}
}
Loading