diff --git a/NEWS.md b/NEWS.md index d1288da..0d117da 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # mcptools (development version) +* `mcp_tools()` now sends and receives a `"notifications/initialized"` (#77 by @galachad). * `mcp_session()` now returns invisibly the nanonext socket used for communicating with the server. * `mcp_server()` gains logical argument `session_tools`, allowing users to opt-out of presenting R sessions tools to clients. diff --git a/R/client.R b/R/client.R index 74004e5..a5ffa24 100644 --- a/R/client.R +++ b/R/client.R @@ -195,6 +195,7 @@ error_no_mcp_config <- function(call) { add_mcp_server <- function(process, name) { response_initialize <- send_and_receive(process, mcp_request_initialize()) + send_and_receive(process, mcp_request_initialized()) response_tools_list <- send_and_receive(process, mcp_request_tools_list()) the$mcp_servers[[name]] <- list( @@ -419,7 +420,13 @@ mcp_request_initialize <- function() { } # step 2: send initialized notification -# This is a MAY in the protocol, so omitting. +mcp_request_initialized <- function() { + list( + jsonrpc = "2.0", + method = "notifications/initialized" + ) +} + # step 3: request the list of tools mcp_request_tools_list <- function() {