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
3 changes: 3 additions & 0 deletions aimdb-client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- **`InboundRouteMetrics` and `InboundRouteStats` are re-exported**
(feature `observability`), the type of `RecordMetadata::inbound_routes`.

- **`AimxConnection::is_closed()` (#450):** whether the connection's engine has
stopped. A caller keeping a connection open uses it to decide when to
reconnect; an `internal` error reply does not mean the connection is gone.
Expand Down
3 changes: 3 additions & 0 deletions aimdb-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,8 @@ pub use engine::{AimxConnection, DrainResponse, RecordUpdate};
pub use aimdb_core::{Stamp, Stamped, WriteMetadata};
pub use error::{ClientError, ClientResult};
pub use protocol::{RecordMetadata, WelcomeMessage, CLIENT_NAME, PROTOCOL_VERSION};
// The type of `RecordMetadata::inbound_routes`.
#[cfg(feature = "observability")]
pub use aimdb_core::{InboundRouteMetrics, InboundRouteStats};
// Arm a watch, then wait for updates written after it.
pub use watch::{arm, await_updates, Armed, WatchOutcome, WatchStatus};
5 changes: 5 additions & 0 deletions tools/aimdb-mcp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- **`list_records` returns `inbound_routes` (#494):** each inbound link's
admission counters (`accepted`, `upgraded`, `too_new`, `shape_mismatch`,
`malformed`, `decode_error`, ...), so an agent can see why values were
rejected. Omitted for records without inbound links.

- **`list_records` returns `schema_type` and `schema_version` (#420)** for
records configured with a data-contract schema; both are omitted otherwise.

Expand Down
5 changes: 3 additions & 2 deletions tools/aimdb-mcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ List all records in an instance:
```
Query: "What records are in the demo instance?"

Result: Record names, types, buffer configs, producer/consumer counts, and the
declared schema (`schema_type`, `schema_version`) where the record has one
Result: Record names, types, buffer configs, producer/consumer counts, the
declared schema (`schema_type`, `schema_version`) where the record has one, and
per-link admission counters (`inbound_routes`) where it has inbound links
```

### 4. get_record
Expand Down
6 changes: 4 additions & 2 deletions tools/aimdb-mcp/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,10 @@ impl McpServer {
name: "list_records".to_string(),
description: "List all records from a specific AimDB instance. Returns metadata including buffer type, capacity, producer/consumer counts, \
and the declared data contract as schema_type and schema_version. Those two fields \
are absent when the record was configured without a schema. Use get_record to \
see an observed value.".to_string(),
are absent when the record was configured without a schema. Records with inbound \
links also carry inbound_routes: per-link counters of accepted, upgraded and \
rejected values (too_new, shape_mismatch, malformed, decode_error, ...). Use \
get_record to see an observed value.".to_string(),
input_schema: json!({
"type": "object",
"properties": {
Expand Down
33 changes: 33 additions & 0 deletions tools/aimdb-mcp/src/tools/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ struct RecordInfo {
/// declares no schema.
#[serde(skip_serializing_if = "Option::is_none")]
schema_version: Option<u32>,
/// Per-link ingress counters (accepted, upgraded and each rejection
/// reason), one entry per inbound link. Absent when the record has none.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
inbound_routes: Vec<aimdb_client::InboundRouteMetrics>,
}

/// List all records from a specific AimDB instance
Expand Down Expand Up @@ -119,6 +123,7 @@ pub async fn list_records(args: Option<Value>) -> McpResult<Value> {
outbound_connector_count: r.outbound_connector_count,
schema_type: r.schema_type,
schema_version: r.schema_version,
inbound_routes: r.inbound_routes,
})
.collect();

Expand Down Expand Up @@ -301,6 +306,7 @@ mod tests {
outbound_connector_count: 0,
schema_type: schema_type.map(str::to_string),
schema_version,
inbound_routes: Vec::new(),
}
}

Expand All @@ -321,6 +327,33 @@ mod tests {
assert!(!obj.contains_key("schema_version"));
}

/// `list_records` passes each inbound link's admission counters through,
/// so an agent can see why values were rejected (#494).
#[test]
fn record_info_includes_inbound_routes() {
let mut info = record_info(None, None);
info.inbound_routes = vec![aimdb_client::InboundRouteMetrics {
link: "mqtt://sensors/temp".into(),
stats: aimdb_client::InboundRouteStats {
accepted: 3,
too_new: 1,
..Default::default()
},
}];
let v = serde_json::to_value(info).unwrap();
let route = &v["inbound_routes"][0];
assert_eq!(route["link"], json!("mqtt://sensors/temp"));
assert_eq!(route["stats"]["accepted"], json!(3));
assert_eq!(route["stats"]["too_new"], json!(1));
}

/// A record without inbound links omits the field, as the metadata does.
#[test]
fn record_info_omits_empty_inbound_routes() {
let v = serde_json::to_value(record_info(None, None)).unwrap();
assert!(!v.as_object().unwrap().contains_key("inbound_routes"));
}

#[tokio::test]
async fn test_list_records_missing_endpoint() {
// Should fail without endpoint parameter
Expand Down