|
1 | 1 | skip_if(is_fedora()) |
2 | 2 |
|
3 | | -test_that("roundtrip mcp_server and mcp_tools", { |
| 3 | +test_that("roundtrip mcp_server and mcp_tools (stdio)", { |
4 | 4 | previous_server_processes <- names(the$server_processes) |
5 | 5 |
|
6 | 6 | # example-config configures `Rscript -e "mcptools::mcp_server()"` |
@@ -29,6 +29,44 @@ test_that("roundtrip mcp_server and mcp_tools", { |
29 | 29 | expect_equal(list_r_sessions_tool@description, list_r_sessions_@description) |
30 | 30 | }) |
31 | 31 |
|
| 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 | + |
32 | 70 | test_that("check_not_interactive errors informatively", { |
33 | 71 | testthat::local_mocked_bindings(interactive = function(...) TRUE) |
34 | 72 |
|
|
0 commit comments