Skip to content

Commit 977d051

Browse files
committed
rename "proxy" to "server"
* Renames `mcp_proxy()` to `mcp_server()` * `the$proxy_socket` becomes `the$server_socket` * Renames file `proxy.R` to `server.R` and analogous test file * Audits mentions of "proxy"
1 parent 2846d31 commit 977d051

File tree

9 files changed

+51
-49
lines changed

9 files changed

+51
-49
lines changed

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Generated by roxygen2: do not edit by hand
22

33
export(mcp_host)
4-
export(mcp_proxy)
4+
export(mcp_server)
55
import(rlang)

R/host.R

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#'
77
#' @section Configuration:
88
#'
9-
#' [mcp_proxy()] should be configured with the MCP clients via the `Rscript`
9+
#' [mcp_server()] should be configured with the MCP clients via the `Rscript`
1010
#' command. For example, to use with Claude Desktop, paste the following in your
1111
#' Claude Desktop configuration (on macOS, at
1212
#' `file.edit("~/Library/Application Support/Claude/claude_desktop_config.json")`):
@@ -16,7 +16,7 @@
1616
#' "mcpServers": {
1717
#' "r-acquaint": {
1818
#' "command": "Rscript",
19-
#' "args": ["-e", "acquaint::mcp_proxy()"]
19+
#' "args": ["-e", "acquaint::mcp_server()"]
2020
#' }
2121
#' }
2222
#' }
@@ -25,12 +25,12 @@
2525
#' Or, to use with Claude Code, you might type in a terminal:
2626
#'
2727
#' ```bash
28-
#' claude mcp add -s "user" r-acquaint Rscript -e "acquaint::mcp_proxy()"
28+
#' claude mcp add -s "user" r-acquaint Rscript -e "acquaint::mcp_server()"
2929
#' ```
3030
#'
31-
#' **mcp_proxy() is not intended for interactive use.**
31+
#' **mcp_server() is not intended for interactive use.**
3232
#'
33-
#' The proxy interfaces with the MCP client on behalf of the host in
33+
#' The server interfaces with the MCP client on behalf of the host in
3434
#' your R session. **Use [mcp_host()] to start the host in your R session.**
3535
#' Place a call to `acquaint::mcp_host()` in your `.Rprofile`, perhaps with
3636
#' `usethis::edit_r_profile()`, to start a host for every interactive R session
@@ -46,9 +46,9 @@
4646
mcp_host <- function() {
4747
# HACK: If a host is already running in one session via `.Rprofile`,
4848
# `mcp_host()` will be called again when the client runs the command
49-
# Rscript -e "acquaint::mcp_proxy()" and the existing host will be wiped.
49+
# Rscript -e "acquaint::mcp_server()" and the existing host will be wiped.
5050
# Returning early in this case allows for the desired R session host to be
51-
# running already before the client initiates the proxy.
51+
# running already before the client initiates the server.
5252
if (!interactive()) {
5353
return(invisible())
5454
}
@@ -67,12 +67,12 @@ mcp_host <- function() {
6767
}
6868
)
6969

70-
schedule_handle_message_from_proxy()
70+
schedule_handle_message_from_server()
7171
}
7272

73-
handle_message_from_proxy <- function(msg) {
73+
handle_message_from_server <- function(msg) {
7474
pipe <- nanonext::pipe_id(the$raio)
75-
schedule_handle_message_from_proxy()
75+
schedule_handle_message_from_server()
7676

7777
# cat("RECV :", msg, "\n", sep = "", file = stderr())
7878
if (!nzchar(msg)) {
@@ -124,13 +124,15 @@ handle_message_from_proxy <- function(msg) {
124124
)
125125
}
126126

127-
schedule_handle_message_from_proxy <- function() {
127+
schedule_handle_message_from_server <- function() {
128128
the$raio <- nanonext::recv_aio(the$host_socket, mode = "string")
129-
promises::as.promise(the$raio)$then(handle_message_from_proxy)$catch(function(
130-
e
131-
) {
132-
print(e)
133-
})
129+
promises::as.promise(the$raio)$then(handle_message_from_server)$catch(
130+
function(
131+
e
132+
) {
133+
print(e)
134+
}
135+
)
134136
}
135137

136138
# Create a jsonrpc-structured response object.

R/proxy.R renamed to R/server.R

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# This R script is a proxy. It takes input on stdin, and when the input forms
1+
# The MCP server is a proxy. It takes input on stdin, and when the input forms
22
# valid JSON, it will send the JSON to the host. Then, when it receives the
33
# response, it will print the response to stdout.
44
#' @rdname mcp
55
#' @export
6-
mcp_proxy <- function() {
6+
mcp_server <- function() {
77
# TODO: should this actually be a check for being called within Rscript or not?
88
check_not_interactive()
99

10-
the$proxy_socket <- nanonext::socket("poly")
11-
nanonext::dial(the$proxy_socket, url = sprintf("%s%d", acquaint_socket, 1L))
10+
the$server_socket <- nanonext::socket("poly")
11+
nanonext::dial(the$server_socket, url = sprintf("%s%d", acquaint_socket, 1L))
1212

1313
# Note that we're using file("stdin") instead of stdin(), which are not the
1414
# same.
@@ -117,14 +117,14 @@ handle_message_from_host <- function(data) {
117117
}
118118

119119
schedule_handle_message_from_host <- function() {
120-
r <- nanonext::recv_aio(the$proxy_socket, mode = "string")
120+
r <- nanonext::recv_aio(the$server_socket, mode = "string")
121121
promises::as.promise(r)$then(handle_message_from_host)
122122
}
123123

124124
forward_request <- function(data) {
125125
logcat("TO HOST: ", data)
126126

127-
nanonext::send_aio(the$proxy_socket, data, mode = "raw")
127+
nanonext::send_aio(the$server_socket, data, mode = "raw")
128128
}
129129

130130
# This process will be launched by the MCP client, so stdout/stderr aren't
@@ -199,7 +199,7 @@ check_not_interactive <- function(call = caller_env()) {
199199
cli::cli_abort(
200200
c(
201201
"This function is not intended for interactive use.",
202-
"i" = "See {.help {.fn mcp_proxy}} for instructions on configuring this
202+
"i" = "See {.help {.fn mcp_server}} for instructions on configuring this
203203
function with applications"
204204
),
205205
call = call
@@ -232,10 +232,10 @@ mcp_discover <- function() {
232232
}
233233

234234
select_host <- function(i) {
235-
lapply(the$proxy_socket[["dialer"]], nanonext::reap)
236-
attr(the$proxy_socket, "dialer") <- NULL
235+
lapply(the$server_socket[["dialer"]], nanonext::reap)
236+
attr(the$server_socket, "dialer") <- NULL
237237
nanonext::dial(
238-
the$proxy_socket,
238+
the$server_socket,
239239
url = sprintf("%s%d", acquaint_socket, as.integer(i))
240240
)
241241
}

README.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ acquaint can be hooked up to any application that supports MCP. For example, to
4545
"mcpServers": {
4646
"r-acquaint": {
4747
"command": "Rscript",
48-
"args": ["-e", "acquaint::mcp_proxy()"]
48+
"args": ["-e", "acquaint::mcp_server()"]
4949
}
5050
}
5151
}
@@ -54,7 +54,7 @@ acquaint can be hooked up to any application that supports MCP. For example, to
5454
Or, to use with Claude Code, you might type in a terminal:
5555

5656
```bash
57-
claude mcp add -s "user" r-acquaint Rscript -e "acquaint::mcp_proxy()"
57+
claude mcp add -s "user" r-acquaint Rscript -e "acquaint::mcp_server()"
5858
```
5959

6060
Then, in your R session, call `acquaint::mcp_hostr()`.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ your Claude Desktop configuration (on macOS, at
4141
"mcpServers": {
4242
"r-acquaint": {
4343
"command": "Rscript",
44-
"args": ["-e", "acquaint::mcp_proxy()"]
44+
"args": ["-e", "acquaint::mcp_server()"]
4545
}
4646
}
4747
}
@@ -50,7 +50,7 @@ your Claude Desktop configuration (on macOS, at
5050
Or, to use with Claude Code, you might type in a terminal:
5151

5252
``` bash
53-
claude mcp add -s "user" r-acquaint Rscript -e "acquaint::mcp_proxy()"
53+
claude mcp add -s "user" r-acquaint Rscript -e "acquaint::mcp_server()"
5454
```
5555

5656
Then, in your R session, call `acquaint::mcp_hostr()`.

man/mcp.Rd

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/_snaps/proxy.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/testthat/_snaps/server.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# check_not_interactive errors informatively
2+
3+
Code
4+
mcp_server()
5+
Condition
6+
Error in `mcp_server()`:
7+
! This function is not intended for interactive use.
8+
i See `mcp_server()` for instructions on configuring this function with applications
9+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
test_that("check_not_interactive errors informatively", {
22
testthat::local_mocked_bindings(interactive = function(...) TRUE)
33

4-
expect_snapshot(error = TRUE, mcp_proxy())
4+
expect_snapshot(error = TRUE, mcp_server())
55
})

0 commit comments

Comments
 (0)