Skip to content

Commit e294d1e

Browse files
committed
fix(mcp): Allow several tool groups in btw_mcp_server()
The R file detection chained `is.character(tools) && file.exists(tools)`, which errors under R >= 4.3 when `tools` names more than one tool group. Use `is_string()` so the file branch only considers a single path. Fixes #206
1 parent 076fbe0 commit e294d1e

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎NEWS.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# btw (development version)
22

3+
* `btw_mcp_server()` no longer errors when `tools` is a character vector naming more than one tool group, e.g. `btw_mcp_server(c("docs", "env", "sessioninfo"))` (@taekop, #206).
4+
35
# btw 1.5.0
46

57
## New features

‎R/mcp.R‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
btw_mcp_server <- function(tools = NULL) {
166166
# If given a path to an R script, we'll pass it on to mcp_server()
167167
is_likely_r_file <-
168-
is.character(tools) &&
168+
is_string(tools) &&
169169
file.exists(tools) &&
170170
grepl("[.]r$", tools, ignore.case = TRUE)
171171

‎tests/testthat/test-mcp.R‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ test_that("btw_mcp_server errors informatively with bad `tools`", {
1212
)
1313
})
1414

15+
test_that("btw_mcp_server works with a character vector of multiple tool groups", {
16+
local_enable_tools()
17+
local_mocked_bindings(
18+
mcp_server = function(...) "mocked",
19+
.package = "mcptools"
20+
)
21+
22+
expect_equal(btw_mcp_server(tools = c("docs", "env")), "mocked")
23+
})
24+
1525
test_that("btw_mcp_tools() excludes skills group by default", {
1626
local_enable_tools()
1727
tools <- btw_mcp_tools()

0 commit comments

Comments
 (0)