fix mcp server error responses
This commit is contained in:
parent
d2f5881838
commit
4fe92b48fd
2 changed files with 13 additions and 58 deletions
|
|
@ -100,18 +100,28 @@ fn dispatch_tool(name: &str, args: &Value) -> Result<String, String> {
|
|||
// ── Main loop ───────────────────────────────────────────────────
|
||||
|
||||
fn main() {
|
||||
eprintln!("consciousness-mcp: starting");
|
||||
let stdin = io::stdin();
|
||||
let reader = stdin.lock();
|
||||
|
||||
for line in reader.lines() {
|
||||
let line = match line {
|
||||
Ok(l) if !l.is_empty() => l,
|
||||
_ => continue,
|
||||
Ok(_) => continue, // blank line
|
||||
Err(e) => {
|
||||
eprintln!("consciousness-mcp: stdin read error: {e}");
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
let req: Request = match serde_json::from_str(&line) {
|
||||
Ok(r) => r,
|
||||
Err(_) => continue,
|
||||
Err(e) => {
|
||||
eprintln!("consciousness-mcp: bad json-rpc: {e}");
|
||||
eprintln!("consciousness-mcp: input was: {line}");
|
||||
respond_error(Value::Null, -32700, &format!("parse error: {e}"));
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
match req.method.as_str() {
|
||||
|
|
@ -165,4 +175,5 @@ fn main() {
|
|||
}
|
||||
}
|
||||
}
|
||||
eprintln!("consciousness-mcp: stdin closed, exiting");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue