Skip to content

Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.

feat: add Streamable HTTP transport and fix Glama badge

FABIOTESS0a5dd8f44fc2
diff --git a/Cargo.lock b/Cargo.lock
index 29a1bd0f..27c8007f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -350,6 +350,58 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
+[[package]]
+name = "axum"
+version = "0.8.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b52af3cb4058c895d37317bb27508dccc8e5f2d39454016b297bf4a400597b8"
+dependencies = [
+ "axum-core",
+ "bytes",
+ "form_urlencoded",
+ "futures-util",
+ "http",
+ "http-body",
+ "http-body-util",
+ "hyper",
+ "hyper-util",
+ "itoa",
+ "matchit",
+ "memchr",
+ "mime",
+ "percent-encoding",
+ "pin-project-lite",
+ "serde_core",
+ "serde_json",
+ "serde_path_to_error",
+ "serde_urlencoded",
+ "sync_wrapper",
+ "tokio",
+ "tower",
+ "tower-layer",
+ "tower-service",
+ "tracing",
+]
+
+[[package]]
+name = "axum-core"
+version = "0.5.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "08c78f31d7b1291f7ee735c1c6780ccde7785daae9a9206026862dab7d8792d1"
+dependencies = [
+ "bytes",
+ "futures-core",
+ "http",
+ "http-body",
+ "http-body-util",
+ "mime",
+ "pin-project-lite",
+ "sync_wrapper",
+ "tower-layer",
+ "tower-service",
+ "tracing",
+]
+
[[package]]
name = "base64"
version = "0.22.1"
@@ -457,6 +509,17 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
+[[package]]
+name = "chacha20"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601"
+dependencies = [
+ "cfg-if",
+ "cpufeatures 0.3.0",
+ "rand_core 0.10.0",
+]
+
[[package]]
name = "chrono"
version = "0.4.44"
@@ -601,6 +664,15 @@ dependencies = [
"libc",
]
+[[package]]
+name = "cpufeatures"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201"
+dependencies = [
+ "libc",
+]
+
[[package]]
name = "crc"
version = "3.4.0"
@@ -1066,6 +1138,7 @@ dependencies = [
"cfg-if",
"libc",
"r-efi 6.0.0",
+ "rand_core 0.10.0",
"wasip2",
"wasip3",
]
@@ -1229,6 +1302,12 @@ version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"
+[[package]]
+name = "httpdate"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
+
[[package]]
name = "hyper"
version = "1.8.1"
@@ -1243,6 +1322,7 @@ dependencies = [
"http",
"http-body",
"httparse",
+ "httpdate",
"itoa",
"pin-project-lite",
"pin-utils",
@@ -1677,6 +1757,12 @@ dependencies = [
"regex-automata",
]
+[[package]]
+name = "matchit"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3"
+
[[package]]
name = "md-5"
version = "0.10.6"
@@ -1854,6 +1940,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"arrow",
+ "axum",
"calamine",
"chrono",
"clap",
@@ -1872,6 +1959,7 @@ dependencies = [
"sqlx",
"tempfile",
"tokio",
+ "tokio-util",
"toml",
"tracing",
"tracing-subscriber",
@@ -1944,7 +2032,7 @@ dependencies = [
"oxrdfio",
"oxrocksdb-sys",
"oxsdatatypes",
- "rand",
+ "rand 0.8.5",
"rustc-hash",
"siphasher",
"sparesults",
@@ -1989,7 +2077,7 @@ dependencies = [
"oxilangtag",
"oxiri",
"oxsdatatypes",
- "rand",
+ "rand 0.8.5",
"thiserror",
]
@@ -2263,7 +2351,18 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
"rand_chacha",
- "rand_core",
+ "rand_core 0.6.4",
+]
+
+[[package]]
+name = "rand"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc266eb313df6c5c09c1c7b1fbe2510961e5bcd3add930c1e31f7ed9da0feff8"
+dependencies = [
+ "chacha20",
+ "getrandom 0.4.2",
+ "rand_core 0.10.0",
]
[[package]]
@@ -2273,7 +2372,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
- "rand_core",
+ "rand_core 0.6.4",
]
[[package]]
@@ -2285,6 +2384,12 @@ dependencies = [
"getrandom 0.2.17",
]
+[[package]]
+name = "rand_core"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c8d0fd677905edcbeedbf2edb6494d676f0e98d54d5cf9bda0b061cb8fb8aba"
+
[[package]]
name = "rayon"
version = "1.11.0"
@@ -2434,18 +2539,27 @@ checksum = "ee4950422f87cf98fffc36946ad672c3024750b3c301491599715b7d6497dfbc"
dependencies = [
"async-trait",
"base64",
+ "bytes",
"chrono",
"futures",
+ "http",
+ "http-body",
+ "http-body-util",
"pastey",
"pin-project-lite",
+ "rand 0.10.0",
"rmcp-macros",
"schemars",
"serde",
"serde_json",
+ "sse-stream",
"thiserror",
"tokio",
+ "tokio-stream",
"tokio-util",
+ "tower-service",
"tracing",
+ "uuid",
]
[[package]]
@@ -2678,6 +2792,17 @@ dependencies = [
"zmij",
]
+[[package]]
+name = "serde_path_to_error"
+version = "0.1.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457"
+dependencies = [
+ "itoa",
+ "serde",
+ "serde_core",
+]
+
[[package]]
name = "serde_spanned"
version = "0.6.9"
@@ -2719,7 +2844,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
dependencies = [
"cfg-if",
- "cpufeatures",
+ "cpufeatures 0.2.17",
"digest",
]
@@ -2730,7 +2855,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
dependencies = [
"cfg-if",
- "cpufeatures",
+ "cpufeatures 0.2.17",
"digest",
]
@@ -2827,7 +2952,7 @@ dependencies = [
"oxiri",
"oxrdf",
"oxsdatatypes",
- "rand",
+ "rand 0.8.5",
"regex",
"rustc-hash",
"sha1",
@@ -2848,7 +2973,7 @@ dependencies = [
"oxiri",
"oxrdf",
"peg",
- "rand",
+ "rand 0.8.5",
"thiserror",
]
@@ -2859,7 +2984,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1790bbdf13560c2afc245ab0f82a489003b3918e668ebd45c65fe46bfd7a1763"
dependencies = [
"oxrdf",
- "rand",
+ "rand 0.8.5",
"spargebra",
]
@@ -2969,7 +3094,7 @@ dependencies = [
"md-5",
"memchr",
"once_cell",
- "rand",
+ "rand 0.8.5",
"serde",
"serde_json",
"sha2",
@@ -2981,6 +3106,19 @@ dependencies = [
"whoami",
]
+[[package]]
+name = "sse-stream"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eb4dc4d33c68ec1f27d386b5610a351922656e1fdf5c05bbaad930cd1519479a"
+dependencies = [
+ "bytes",
+ "futures-util",
+ "http-body",
+ "http-body-util",
+ "pin-project-lite",
+]
+
[[package]]
name = "stable_deref_trait"
version = "1.2.1"
@@ -3281,6 +3419,7 @@ dependencies = [
"tokio",
"tower-layer",
"tower-service",
+ "tracing",
]
[[package]]
@@ -3466,6 +3605,17 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
+[[package]]
+name = "uuid"
+version = "1.22.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a68d3c8f01c0cfa54a75291d83601161799e4a89a39e0929f4b0354d88757a37"
+dependencies = [
+ "getrandom 0.4.2",
+ "js-sys",
+ "wasm-bindgen",
+]
+
[[package]]
name = "valuable"
version = "0.1.1"
diff --git a/Cargo.toml b/Cargo.toml
index c7fa122f..6841495f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,7 +11,9 @@ name = "open-ontologies"
path = "src/main.rs"
[dependencies]
-rmcp = { version = "1", features = ["server", "transport-io"] }
+rmcp = { version = "1", features = ["server", "transport-io", "transport-streamable-http-server"] }
+axum = "0.8"
+tokio-util = "0.7"
tokio = { version = "1", features = ["full"] }
oxigraph = "0.4"
rusqlite = { version = "0.32", features = ["bundled"] }
diff --git a/README.md b/README.md
index 07c0cbb3..fe69e654 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
[![CI](https://github.com/fabio-rovai/open-ontologies/actions/workflows/ci.yml/badge.svg)](https://github.com/fabio-rovai/open-ontologies/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![MCP Badge](https://lobehub.com/badge/mcp/fabio-rovai-open-ontologies)](https://lobehub.com/mcp/fabio-rovai-open-ontologies)
-[![Glama](https://glama.ai/mcp/servers/badge/open-ontologies)](https://glama.ai/mcp/servers/open-ontologies)
+[![Glama](https://img.shields.io/badge/Glama-open--ontologies-blue)](https://glama.ai/mcp/servers/open-ontologies)
[![PitchHut](https://img.shields.io/badge/PitchHut-open--ontologies-orange)](https://www.pitchhut.com/project/open-ontologies-mcp)
[![ClawHub Skill](https://img.shields.io/badge/ClawHub-open--ontologies-7c3aed)](https://clawhub.ai/fabio-rovai/open-ontologies)
diff --git a/src/main.rs b/src/main.rs
index 5e7ad92c..7fc5517c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -33,11 +33,22 @@ enum Commands {
#[arg(long, default_value = "~/.open-ontologies")]
data_dir: String,
},
- /// Start the MCP server
+ /// Start the MCP server (stdio transport)
Serve {
#[arg(long, default_value = "~/.open-ontologies/config.toml")]
config: String,
},
+ /// Start the MCP server (Streamable HTTP transport)
+ ServeHttp {
+ #[arg(long, default_value = "~/.open-ontologies/config.toml")]
+ config: String,
+ /// Host to bind to
+ #[arg(long, default_value = "127.0.0.1")]
+ host: String,
+ /// Port to bind to
+ #[arg(long, default_value = "8080")]
+ port: u16,
+ },
// ─── Core ontology ────────────────────────────────────────────
/// Validate RDF/OWL syntax (file or stdin with -)
@@ -332,6 +343,57 @@ async fn main() -> anyhow::Result<()> {
let service = server.serve(rmcp::transport::stdio()).await?;
service.waiting().await?;
}
+ Commands::ServeHttp { config: config_path, host, port } => {
+ use rmcp::transport::streamable_http_server::{
+ StreamableHttpServerConfig, StreamableHttpService,
+ session::local::LocalSessionManager,
+ };
+ use tokio_util::sync::CancellationToken;
+
+ let config_path = expand_tilde(&config_path);
+ let cfg = match Config::load(std::path::Path::new(&config_path)) {
+ Ok(c) => c,
+ Err(e) => {
+ let msg = e.to_string();
+ if msg.contains("failed to read") {
+ Config::default()
+ } else {
+ return Err(e);
+ }
+ }
+ };
+ let data_dir = expand_tilde(&cfg.general.data_dir);
+ let db_path_owned = std::path::Path::new(&data_dir).join("open-ontologies.db");
+
+ std::fs::create_dir_all(&data_dir)?;
+
+ let ct = CancellationToken::new();
+ let http_config = StreamableHttpServerConfig {
+ stateful_mode: true,
+ cancellation_token: ct.clone(),
+ ..Default::default()
+ };
+
+ let service: StreamableHttpService<_, LocalSessionManager> =
+ StreamableHttpService::new(
+ move || {
+ let db = StateDb::open(&db_path_owned)
+ .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
+ Ok(OpenOntologiesServer::new(db))
+ },
+ Default::default(),
+ http_config,
+ );
+
+ let router = axum::Router::new().nest_service("/mcp", service);
+ let addr = format!("{host}:{port}");
+ let listener = tokio::net::TcpListener::bind(&addr).await?;
+ eprintln!("Open Ontologies MCP server listening on http://{addr}/mcp");
+
+ axum::serve(listener, router)
+ .with_graceful_shutdown(async move { ct.cancelled_owned().await })
+ .await?;
+ }
// ─── Core ontology ─────────────────────────────────────────
Commands::Validate { input } => {