Skip to content

Commit cf161cb

Browse files
committed
confirm that mcp_server and mcp_tools can roundtrip with mcp-remote
1 parent 5d8c323 commit cf161cb

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

inst/example-config-remote.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"mcpServers": {
3+
"mcptools": {
4+
"command": "npx",
5+
"args": [
6+
"mcp-remote",
7+
"http://localhost:8080"
8+
]
9+
}
10+
}
11+
}

tests/testthat/test-server.R

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
skip_if(is_fedora())
22

3-
test_that("roundtrip mcp_server and mcp_tools", {
3+
test_that("roundtrip mcp_server and mcp_tools (stdio)", {
44
previous_server_processes <- names(the$server_processes)
55

66
# example-config configures `Rscript -e "mcptools::mcp_server()"`
@@ -29,6 +29,44 @@ test_that("roundtrip mcp_server and mcp_tools", {
2929
expect_equal(list_r_sessions_tool@description, list_r_sessions_@description)
3030
})
3131

32+
test_that("roundtrip mcp_server and mcp_tools (http)", {
33+
skip_on_cran()
34+
skip_on_ci()
35+
skip_if_not(nzchar(Sys.which("npx")), "npx not available")
36+
37+
http_server <- processx::process$new(
38+
command = rscript_binary(),
39+
args = c(
40+
"-e",
41+
"mcptools::mcp_server(type = 'http', port = 8080)"
42+
),
43+
stdout = "|",
44+
stderr = "|"
45+
)
46+
withr::defer(http_server$kill())
47+
48+
Sys.sleep(2)
49+
50+
if (!http_server$is_alive()) {
51+
stop("HTTP server failed to start")
52+
}
53+
54+
tools <- mcp_tools(system.file(
55+
"example-config-remote.json",
56+
package = "mcptools"
57+
))
58+
59+
tool_names <- c()
60+
for (tool in tools) {
61+
tool_names <- c(tool_names, tool@name)
62+
}
63+
expect_true(
64+
all(c("list_r_sessions", "select_r_session") %in% tool_names)
65+
)
66+
list_r_sessions_ <- tools[[which(tool_names == "list_r_sessions")]]
67+
expect_equal(list_r_sessions_tool@description, list_r_sessions_@description)
68+
})
69+
3270
test_that("check_not_interactive errors informatively", {
3371
testthat::local_mocked_bindings(interactive = function(...) TRUE)
3472

0 commit comments

Comments
 (0)