Skip to content

Commit cc5cc3e

Browse files
authored
initial mcptools release 0.1.0
2 parents 4108075 + 0ded05e commit cc5cc3e

File tree

13 files changed

+97
-27
lines changed

13 files changed

+97
-27
lines changed

DESCRIPTION

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: mcptools
2-
Title: Model Context Protocol Server For Your R Sessions
2+
Title: Model Context Protocol Servers and Clients
33
Version: 0.0.0.9000
44
Authors@R: c(
55
person("Simon", "Couch", , "simon.couch@posit.co", role = c("aut", "cre"),
@@ -10,12 +10,13 @@ Authors@R: c(
1010
person("Posit Software, PBC", role = c("cph", "fnd"),
1111
comment = c(ROR = "03wc8by49"))
1212
)
13-
Description: Implements a model context protocol (MCP) server for your R
14-
sessions, allowing MCP-compatible apps like Claude Desktop and Claude
15-
Code to run R code in your interactive R sessions in order to better answer
16-
questions. By default, the package supplies a set of tools that allow models
17-
to inspect your R environment and peruse package documentation, but
18-
supports arbitrary R functions as tools.
13+
Description: Implements the Model Context Protocol (MCP). Users can start
14+
'R'-based servers, serving functions as tools for large language models to
15+
call before responding to the user in MCP-compatible apps like
16+
'Claude Desktop' and 'Claude Code', with options to run those tools inside
17+
of interactive 'R' sessions. On the other end, when 'R' is the client via
18+
the 'ellmer' package, users can register tools from third-party MCP
19+
servers to integrate additional context into chats.
1920
License: MIT + file LICENSE
2021
Suggests:
2122
knitr,

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# mcptools (development version)
2+
3+
Initial CRAN submission.
4+
5+
Before the initial release of the package, mcptools was called acquaint and supplied a default set of tools from btw, currently a GitHub-only package, when R was used as an MCP server. The direction of the dependency has been reversed; to use the same functionality from before, transition `acquaint::mcp_server()` to `btw::btw_mcp_server()` and `acquaint::mcp_session()` to `btw::btw_mcp_session()`.

R/client.R

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,19 @@ the$mcp_servers <- list()
7171
#' to the `$set_tools()` method of an [ellmer::Chat] object. If the file at
7272
#' `config` doesn't exist, an error.
7373
#'
74+
#' @examples
75+
#' # setup
76+
#' config_file <- tempfile(fileext = "json")
77+
#' file.create(config_file)
78+
#'
79+
#' # usually, `config` would be a persistent, user-level
80+
#' # configuration file for a set of MCP server
81+
#' mcp_tools(config = config_file)
82+
#'
83+
#' # teardown
84+
#' file.remove(config_file)
85+
#'
86+
#'
7487
#' @name client
7588
#' @aliases mcp_client
7689
#' @export
@@ -374,7 +387,7 @@ jsonrpc_id <- function(server_name) {
374387
# client protocol --------------------------------------------------------------
375388
## stdio
376389
log_cat_client <- function(x, append = TRUE) {
377-
log_file <- "~/mcp_client_test.txt"
390+
log_file <- mcptools_client_log()
378391
cat(x, "\n\n", sep = "", append = append, file = log_file)
379392
}
380393

R/server.R

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@
5757
#' `Chat$set_tools()` can be passed here. By default, the package won't serve
5858
#' any tools other than those needed to communicate with interactive R sessions.
5959
#'
60+
#' @returns
61+
#' `mcp_server()` and `mcp_session()` are both called primarily for side-effects.
62+
#'
63+
#' * `mcp_server()` blocks the R process it's called in indefinitely and isn't
64+
#' intended for interactive use.
65+
#' * `mcp_session()` makes the interactive R session it's called in available to
66+
#' MCP servers. It returns a promise via [promises::promise()].
67+
#'
6068
#' @seealso
6169
#' - The "R as an MCP server" vignette at
6270
#' `vignette("server", package = "mcptools")` delves into further detail
@@ -68,7 +76,7 @@
6876
#' @examples
6977
#' # should only be run non-interactively, and will block the current R process
7078
#' # once called.
71-
#' if (FALSE) {
79+
#' if (identical(Sys.getenv("MCPTOOLS_CAN_BLOCK_PROCESS"), "true")) {
7280
#' # to start a server with a tool to draw numbers from a random normal:
7381
#' library(ellmer)
7482
#'
@@ -220,7 +228,7 @@ forward_request <- function(data) {
220228
# visible. This function will log output to the `logfile` so that you can view
221229
# it.
222230
logcat <- function(x, ..., append = TRUE) {
223-
log_file <- mcptools_log_file()
231+
log_file <- mcptools_server_log()
224232
cat(x, "\n", sep = "", append = append, file = log_file)
225233
}
226234

R/utils.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ to_json <- function(x, ...) {
2727

2828
interactive <- NULL
2929

30-
mcptools_log_file <- function() {
31-
Sys.getenv("MCPTOOLS_LOG_FILE", tempfile(fileext = ".txt"))
30+
mcptools_server_log <- function() {
31+
Sys.getenv("MCPTOOLS_SERVER_LOG", tempfile(fileext = ".txt"))
32+
}
33+
34+
mcptools_client_log <- function() {
35+
Sys.getenv("MCPTOOLS_CLIENT_LOG", tempfile(fileext = ".txt"))
3236
}

README.Rmd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ e.g. [shinychat](https://github.com/posit-dev/shinychat) and
6464
6565
## Installation
6666

67+
Install mcptools from CRAN with:
68+
69+
```r
70+
install.packages("mcptools")
71+
```
72+
6773
You can install the development version of mcptools like so:
6874

6975
```r

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
[![Lifecycle:
99
experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
10-
[![CRAN
11-
status](https://www.r-pkg.org/badges/version/mcptools)](https://CRAN.R-project.org/package=mcptools)
1210
[![R-CMD-check](https://github.com/posit-dev/mcptools/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/posit-dev/mcptools/actions/workflows/R-CMD-check.yaml)
1311
<!-- badges: end -->
1412

@@ -50,6 +48,12 @@ e.g. [shinychat](https://github.com/posit-dev/shinychat) and
5048
5149
## Installation
5250

51+
Install mcptools from CRAN with:
52+
53+
``` r
54+
install.packages("mcptools")
55+
```
56+
5357
You can install the development version of mcptools like so:
5458

5559
``` r

cran-comments.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
## R CMD check results
1+
**Comments for CRAN team**:
22

3-
0 errors | 0 warnings | 1 note
3+
There's a NOTE since this is an initial release.
44

5-
* This is a new release.
5+
There are not references describing the methods in this package to cite in the Description field.
6+
7+
This is a **resubmission**; the first submission of the package was rejected due to the name of the protocol being single-quoted in the Description field an example's execution being wrapped in `if (FALSE)`. Note that there's now a new NOTE "Possibly misspelled words in DESCRIPTION" because of this change. Thank you for the feedback—both of these issues have been addressed.

man/client.Rd

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

man/mcptools-package.Rd

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

0 commit comments

Comments
 (0)