fix: handle MCP notifications properly (notifications/initialized)

- Add handle_notification() for notification messages (no id field)
- Use CARGO_PKG_VERSION for dynamic version in initialize response
- Skip serializing None fields in McpResponse and McpError
- Remove verified field from setup info
This commit is contained in:
Devid HW
2026-04-19 09:51:46 +07:00
parent 42318b040a
commit 41c8b36826
2 changed files with 26 additions and 2 deletions
+13 -2
View File
@@ -99,6 +99,18 @@ impl McpServer {
}
}
/// Handle a notification (no id — no response sent)
pub async fn handle_notification(&self, request: McpRequest) {
match request.method.as_str() {
"notifications/initialized" => {
// Client confirms initialization is complete — no action needed
}
_ => {
tracing::debug!("Unhandled notification: {}", request.method);
}
}
}
pub async fn handle_request(&self, request: McpRequest) -> McpResponse {
match request.method.as_str() {
"initialize" => {
@@ -123,9 +135,8 @@ impl McpServer {
// Return immediately with fast status
let server_info = json!({
"name": "MT5-Quant",
"version": "1.27.0",
"version": env!("CARGO_PKG_VERSION"),
"setup": {
"verified": null, // null = checking
"hint": "Auto-verification running... Use verify_setup tool for detailed status",
}
});