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

## [Unreleased]

## [1.6.2] - 2026-06-23

### Fixed
- MCP stdio responses are now emitted as newline-delimited JSON-RPC instead of
`Content-Length` framed (LSP-style) messages. The previous output framing was
not understood by MCP stdio clients and caused connection/initialization to
hang. Input still accepts both framings for compatibility.
- Added a `write_message` test asserting newline-delimited output without
`Content-Length` headers.

## [1.6.1] - 2026-06-23

### Fixed
Expand Down
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 = "mem-cli"
version = "1.6.1"
version = "1.6.2"
edition = "2024"

[dependencies]
Expand Down
21 changes: 19 additions & 2 deletions src/mcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,12 @@ fn read_message<R: BufRead>(reader: &mut R) -> Result<Option<Value>> {

fn write_message<W: Write>(writer: &mut W, message: &Value) -> Result<()> {
let body = serde_json::to_vec(message).context("failed to serialize MCP response")?;
write!(writer, "Content-Length: {}\r\n\r\n", body.len())
.context("failed to write MCP response header")?;
writer
.write_all(&body)
.context("failed to write MCP response body")?;
writer
.write_all(b"\n")
.context("failed to write MCP response newline")?;
Ok(())
}

Expand Down Expand Up @@ -783,4 +784,20 @@ mod tests {
.expect("message");
assert_eq!(parsed, request);
}

#[test]
fn write_message_emits_newline_delimited_json() {
let message = json!({"jsonrpc":"2.0","id":1,"result":{}});
let mut buffer = Vec::new();
write_message(&mut buffer, &message).expect("write message");

let output = String::from_utf8(buffer).expect("utf8 output");
assert!(
!output.contains("Content-Length"),
"output must not use LSP framing"
);
assert!(output.ends_with('\n'), "message must be newline-delimited");
let parsed: Value = serde_json::from_str(output.trim_end()).expect("parse written message");
assert_eq!(parsed, message);
}
}