matrix-mcp: surface serialise errors + clarify ping doc (argus #603 nits)
This commit is contained in:
parent
e6c53045ad
commit
61133e71e7
1 changed files with 12 additions and 5 deletions
|
|
@ -68,8 +68,11 @@ pub enum DaemonRequest {
|
||||||
#[serde(rename = "read_room")]
|
#[serde(rename = "read_room")]
|
||||||
ReadRoom { room: String, limit: Option<usize> },
|
ReadRoom { room: String, limit: Option<usize> },
|
||||||
|
|
||||||
/// Liveness probe used by the stdio MCP bridge on connect — fast
|
/// Liveness probe — fast "are you up?" round-trip that doesn't
|
||||||
/// "are you up?" round-trip that doesn't touch matrix-sdk.
|
/// touch matrix-sdk. Not used by the in-tree stdio MCP bridge
|
||||||
|
/// (which surfaces a daemon-down condition as a normal tool-call
|
||||||
|
/// connect error); reserved for external clients that want an
|
||||||
|
/// explicit health check without doing real work.
|
||||||
#[serde(rename = "ping")]
|
#[serde(rename = "ping")]
|
||||||
Ping,
|
Ping,
|
||||||
}
|
}
|
||||||
|
|
@ -86,10 +89,14 @@ pub enum DaemonResponse {
|
||||||
|
|
||||||
impl DaemonResponse {
|
impl DaemonResponse {
|
||||||
/// Convenience: build an Ok response from any serializable value.
|
/// Convenience: build an Ok response from any serializable value.
|
||||||
|
/// Serialisation failure (impossible for the small handler structs
|
||||||
|
/// we use, but the API is generic) surfaces as a structured
|
||||||
|
/// `{"serialise_error": "..."}` payload so callers see WHY the
|
||||||
|
/// data is missing instead of a silent `null`.
|
||||||
pub fn ok<T: Serialize>(payload: &T) -> Self {
|
pub fn ok<T: Serialize>(payload: &T) -> Self {
|
||||||
Self::Ok {
|
let payload = serde_json::to_value(payload)
|
||||||
payload: serde_json::to_value(payload).unwrap_or(serde_json::Value::Null),
|
.unwrap_or_else(|e| serde_json::json!({ "serialise_error": e.to_string() }));
|
||||||
}
|
Self::Ok { payload }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convenience: build an Error response from any `Display` value.
|
/// Convenience: build an Error response from any `Display` value.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue