File tree Expand file tree Collapse file tree 4 files changed +4
-11
lines changed
Expand file tree Collapse file tree 4 files changed +4
-11
lines changed Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ export(mcp_server)
44export(mcp_session)
55export(mcp_tools)
66import(rlang)
7+ importFrom(stats,setNames)
Original file line number Diff line number Diff line change 44
55# # usethis namespace: start
66# ' @import rlang
7+ # ' @importFrom stats setNames
78# # usethis namespace: end
89NULL
910
10- utils :: globalVariables(c(" packageVersion" , " setNames" ))
11-
1211.onLoad <- function (libname , pkgname ) {
1312 the $ socket_url <- switch (
1413 Sys.info()[[" sysname" ]],
Original file line number Diff line number Diff line change 109109# ' @name server
110110# ' @export
111111mcp_server <- function (tools = NULL , ... , session_tools = TRUE ) {
112- # TODO: should this actually be a check for being called within Rscript or not?
112+
113113 check_not_interactive()
114+ nanonext :: reap(the $ session_socket ) # in case session was started in .Rprofile
114115 the $ sessions_enabled <- isTRUE(session_tools )
115116 set_server_tools(tools , session_tools = the $ sessions_enabled )
116117
Original file line number Diff line number Diff line change 11# ' @rdname server
22# ' @export
33mcp_session <- function () {
4- # HACK: If a session is already available from another session via `.Rprofile`,
5- # `mcp_session()` will be called again when the client runs the command
6- # Rscript -e "mcptools::mcp_server()" and the existing session connection
7- # will be wiped. Returning early in this case allows for the desired R
8- # session to be running already before the client initiates the server.
9- if (! interactive()) {
10- return (invisible ())
11- }
124
135 the $ session_socket <- nanonext :: socket(" poly" )
146 i <- 1L
You can’t perform that action at this time.
0 commit comments