fix mcp server error responses
This commit is contained in:
parent
d2f5881838
commit
4fe92b48fd
2 changed files with 13 additions and 58 deletions
56
Cargo.lock
generated
56
Cargo.lock
generated
|
|
@ -538,7 +538,6 @@ dependencies = [
|
||||||
"http-body-util",
|
"http-body-util",
|
||||||
"hyper",
|
"hyper",
|
||||||
"hyper-util",
|
"hyper-util",
|
||||||
"jobkit",
|
|
||||||
"json5",
|
"json5",
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
|
|
@ -560,7 +559,6 @@ dependencies = [
|
||||||
"tokenizers",
|
"tokenizers",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-rustls",
|
"tokio-rustls",
|
||||||
"tokio-scoped",
|
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
"tui-markdown",
|
"tui-markdown",
|
||||||
"tui-textarea-2",
|
"tui-textarea-2",
|
||||||
|
|
@ -1520,20 +1518,6 @@ dependencies = [
|
||||||
"syn 2.0.117",
|
"syn 2.0.117",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "jobkit"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "git+https://evilpiepirate.org/git/jobkit.git#4aacaac22c5f59a7fbc6ce3a65708fc370e55754"
|
|
||||||
dependencies = [
|
|
||||||
"chrono",
|
|
||||||
"libc",
|
|
||||||
"log",
|
|
||||||
"profiling",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"tokio",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jobserver"
|
name = "jobserver"
|
||||||
version = "0.1.34"
|
version = "0.1.34"
|
||||||
|
|
@ -2160,25 +2144,6 @@ dependencies = [
|
||||||
"yansi",
|
"yansi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "profiling"
|
|
||||||
version = "1.0.17"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3eb8486b569e12e2c32ad3e204dbaba5e4b5b216e9367044f25f1dba42341773"
|
|
||||||
dependencies = [
|
|
||||||
"profiling-procmacros",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "profiling-procmacros"
|
|
||||||
version = "1.0.17"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "52717f9a02b6965224f95ca2a81e2e0c5c43baacd28ca057577988930b6c3d5b"
|
|
||||||
dependencies = [
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.117",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ptr_meta"
|
name = "ptr_meta"
|
||||||
version = "0.1.4"
|
version = "0.1.4"
|
||||||
|
|
@ -3144,27 +3109,6 @@ dependencies = [
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tokio-scoped"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e4beb8ba13bc53ac53ce1d52b42f02e5d8060f0f42138862869beb769722b256"
|
|
||||||
dependencies = [
|
|
||||||
"tokio",
|
|
||||||
"tokio-stream",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tokio-stream"
|
|
||||||
version = "0.1.18"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "32da49809aab5c3bc678af03902d4ccddea2a87d028d86392a4b1560c6906c70"
|
|
||||||
dependencies = [
|
|
||||||
"futures-core",
|
|
||||||
"pin-project-lite",
|
|
||||||
"tokio",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-util"
|
name = "tokio-util"
|
||||||
version = "0.7.18"
|
version = "0.7.18"
|
||||||
|
|
|
||||||
|
|
@ -100,18 +100,28 @@ fn dispatch_tool(name: &str, args: &Value) -> Result<String, String> {
|
||||||
// ── Main loop ───────────────────────────────────────────────────
|
// ── Main loop ───────────────────────────────────────────────────
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
eprintln!("consciousness-mcp: starting");
|
||||||
let stdin = io::stdin();
|
let stdin = io::stdin();
|
||||||
let reader = stdin.lock();
|
let reader = stdin.lock();
|
||||||
|
|
||||||
for line in reader.lines() {
|
for line in reader.lines() {
|
||||||
let line = match line {
|
let line = match line {
|
||||||
Ok(l) if !l.is_empty() => l,
|
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) {
|
let req: Request = match serde_json::from_str(&line) {
|
||||||
Ok(r) => r,
|
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() {
|
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