this repo has no description
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix JSON-RPC protocol handling in example servers

- Replace stdout prints with stderr to avoid corrupting JSON-RPC protocol
- Fix issue with log messages being sent over stdout instead of stderr
- Ensure all debug/info messages don't interfere with protocol communication
- Apply fix to all example servers for consistent behavior

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

+35 -28
+9 -7
bin/audio_example.ml
··· 126 126 127 127 (* Define startup and shutdown hooks *) 128 128 let startup () = 129 - Printf.printf "AudioExampleServer is starting up!\n"; 130 - flush stdout; 129 + (* Use stderr for direct printing to avoid interfering with JSON-RPC protocol *) 130 + Printf.fprintf stderr "AudioExampleServer is starting up!\n"; 131 + flush stderr; 131 132 Log.info "AudioExampleServer is starting up!" 132 133 133 134 let shutdown () = 134 - Printf.printf "AudioExampleServer is shutting down. Goodbye!\n"; 135 - flush stdout; 135 + Printf.fprintf stderr "AudioExampleServer is shutting down. Goodbye!\n"; 136 + flush stderr; 136 137 Log.info "AudioExampleServer is shutting down. Goodbye!" 137 138 138 139 (* Register the hooks *) ··· 306 307 307 308 (* Main function *) 308 309 let () = 309 - (* Print directly to ensure we see output *) 310 - Printf.printf "Starting AudioExampleServer...\n"; 311 - flush stdout; 310 + (* Use stderr for direct printing to avoid interfering with JSON-RPC protocol *) 311 + Printf.fprintf stderr "Starting AudioExampleServer...\n"; 312 + flush stderr; 313 + Log.info "Starting AudioExampleServer..."; 312 314 313 315 (* Configure the server with appropriate capabilities *) 314 316 ignore (configure_server server ());
+9 -7
bin/capitalize_sdk.ml
··· 19 19 20 20 (* Define startup and shutdown hooks *) 21 21 let startup () = 22 - Printf.printf "CapitalizeServer is starting up!\n"; 23 - flush stdout; 22 + (* Use stderr for direct printing to avoid interfering with JSON-RPC protocol *) 23 + Printf.fprintf stderr "CapitalizeServer is starting up!\n"; 24 + flush stderr; 24 25 Log.info "CapitalizeServer is starting up!" 25 26 26 27 let shutdown () = 27 - Printf.printf "CapitalizeServer is shutting down. Goodbye!\n"; 28 - flush stdout; 28 + Printf.fprintf stderr "CapitalizeServer is shutting down. Goodbye!\n"; 29 + flush stderr; 29 30 Log.info "CapitalizeServer is shutting down. Goodbye!" 30 31 31 32 (* Register the hooks *) ··· 105 106 106 107 (* Main function *) 107 108 let () = 108 - (* Print directly to ensure we see output *) 109 - Printf.printf "Starting CapitalizeServer...\n"; 110 - flush stdout; 109 + (* Use stderr for direct printing to avoid interfering with JSON-RPC protocol *) 110 + Printf.fprintf stderr "Starting CapitalizeServer...\n"; 111 + flush stderr; 112 + Log.info "Starting CapitalizeServer..."; 111 113 112 114 (* Configure the server with appropriate capabilities *) 113 115 ignore (configure_server server ());
+9 -7
bin/completion_example.ml
··· 19 19 20 20 (* Define startup and shutdown hooks *) 21 21 let startup () = 22 - Printf.printf "CompletionServer is starting up!\n"; 23 - flush stdout; 22 + (* Use stderr for direct printing to avoid interfering with JSON-RPC protocol *) 23 + Printf.fprintf stderr "CompletionServer is starting up!\n"; 24 + flush stderr; 24 25 Log.info "CompletionServer is starting up!" 25 26 26 27 let shutdown () = 27 - Printf.printf "CompletionServer is shutting down. Goodbye!\n"; 28 - flush stdout; 28 + Printf.fprintf stderr "CompletionServer is shutting down. Goodbye!\n"; 29 + flush stderr; 29 30 Log.info "CompletionServer is shutting down. Goodbye!" 30 31 31 32 (* Register the hooks *) ··· 156 157 157 158 (* Main function *) 158 159 let () = 159 - (* Print directly to ensure we see output *) 160 - Printf.printf "Starting CompletionServer...\n"; 161 - flush stdout; 160 + (* Use stderr for direct printing to avoid interfering with JSON-RPC protocol *) 161 + Printf.fprintf stderr "Starting CompletionServer...\n"; 162 + flush stderr; 163 + Log.info "Starting CompletionServer..."; 162 164 163 165 (* Set custom capabilities to indicate support for completions *) 164 166 let capabilities = `Assoc [
+8 -7
bin/resource_template_example.ml
··· 19 19 20 20 (* Define startup and shutdown hooks *) 21 21 let startup () = 22 - Printf.printf "ResourceTemplateServer is starting up!\n"; 23 - flush stdout; 22 + (* Use stderr for direct printing to avoid interfering with JSON-RPC protocol *) 23 + Printf.fprintf stderr "ResourceTemplateServer is starting up!\n"; 24 + flush stderr; 24 25 Log.info "ResourceTemplateServer is starting up!" 25 26 26 27 let shutdown () = 27 - Printf.printf "ResourceTemplateServer is shutting down. Goodbye!\n"; 28 - flush stdout; 28 + Printf.fprintf stderr "ResourceTemplateServer is shutting down. Goodbye!\n"; 29 + flush stderr; 29 30 Log.info "ResourceTemplateServer is shutting down. Goodbye!" 30 31 31 32 (* Register the hooks *) ··· 163 164 164 165 (* Main function *) 165 166 let () = 166 - (* Print directly to ensure we see output *) 167 - Printf.printf "Starting ResourceTemplateServer...\n"; 168 - flush stdout; 167 + (* Instead of printing directly to stdout which messes up the JSON-RPC protocol, 168 + use the logging system which sends output to stderr *) 169 + Log.info "Starting ResourceTemplateServer..."; 169 170 170 171 (* Configure the server with appropriate capabilities *) 171 172 ignore (configure_server server ());