diff --git a/DESCRIPTION b/DESCRIPTION index a92d407..7b21976 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,7 +19,7 @@ Description: Create, run, and connect to Model Context Protocol (MCP) servers, a License: GPL (>= 2) Depends: R (>= 4.1.0) Encoding: UTF-8 -Roxygen: list(markdown = TRUE) +Roxygen: list(markdown = TRUE, roclets = c("collate", "rd", "namespace", "mcpr::mcp_roclet")) RoxygenNote: 7.3.2 Imports: yyjsonr @@ -29,6 +29,7 @@ Suggests: knitr, rmarkdown, httr2, - ellmer + ellmer, + roxygen2 URL: https://mcpr.opifex.org/, https://github.com/devOpifex/mcpr VignetteBuilder: knitr diff --git a/NAMESPACE b/NAMESPACE index ba3ebf7..e1e030a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -17,6 +17,12 @@ S3method(resources_list,client) S3method(resources_list,server) S3method(resources_read,client) S3method(resources_read,server) +S3method(roclet_output,roclet_mcp) +S3method(roclet_process,roclet_mcp) +S3method(roxy_tag_parse,roxy_tag_mcp) +S3method(roxy_tag_parse,roxy_tag_type) +S3method(roxy_tag_rd,roxy_tag_mcp) +S3method(roxy_tag_rd,roxy_tag_type) S3method(send,jsonrpc_error) S3method(send,jsonrpc_response) S3method(tools_call,client) @@ -29,6 +35,7 @@ export(add_capability) export(ellmer_to_mcpr_tool) export(get_name) export(initialize) +export(mcp_roclet) export(new_client_io) export(new_mcp) export(new_prompt) @@ -63,3 +70,11 @@ export(serve_io) export(tools_call) export(tools_list) export(write) +importFrom(roxygen2,block_get_tag_value) +importFrom(roxygen2,block_get_tags) +importFrom(roxygen2,roclet) +importFrom(roxygen2,roclet_output) +importFrom(roxygen2,roclet_process) +importFrom(roxygen2,roxy_tag_parse) +importFrom(roxygen2,roxy_tag_rd) +importFrom(roxygen2,roxy_tag_warning) diff --git a/NEWS.md b/NEWS.md index c107000..af1bfb7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,12 @@ # mcpr 0.0.2 - Added support for `ellmer::tool` +- Added MCP roclet for automatic server generation: + - New `@mcp` tag for marking functions as MCP tools + - New `@type` tag for specifying parameter types (string, number, boolean, array, object, enum) + - `mcp_roclet()` function integrates with roxygen2 to generate complete MCP servers + - Automatically creates `inst/mcp_server.R` with tool definitions and handlers + - Supports all standard JSON Schema types and enum values # mcpr 0.0.1 diff --git a/R/input-schema.R b/R/input-schema.R index 9754161..a308811 100644 --- a/R/input-schema.R +++ b/R/input-schema.R @@ -1,10 +1,14 @@ #' Create a new input schema #' -#' @param properties List of property definitions -#' @param type Type of the schema -#' @param additional_properties Logical indicating if additional properties are allowed +#' @param properties List of property definitions created with properties() +#' @type properties object +#' @param type Type of the schema (default: "object") +#' @type type string +#' @param additional_properties Whether additional properties are allowed +#' @type additional_properties boolean #' #' @return A list representing a JSON Schema object +#' @mcp create_json_schema Create a JSON Schema object for MCP tool inputs with property validation #' @export #' #' @examples @@ -93,15 +97,24 @@ new_property <- function(type, title, description, required = FALSE, ...) { #' Create a string property definition #' #' @param title Short title for the property +#' @type title string #' @param description Longer description of the property +#' @type description string #' @param required Whether the property is required +#' @type required boolean #' @param enum Optional character vector of allowed values +#' @type enum array #' @param pattern Optional regex pattern the string must match +#' @type pattern string #' @param min_length Optional minimum length +#' @type min_length number #' @param max_length Optional maximum length -#' @param format Optional format (e.g., "date-time", "email", "uri") +#' @type max_length number +#' @param format Optional format constraint +#' @type format enum:date-time,email,uri,hostname,ipv4,ipv6 #' #' @return A string property object +#' @mcp create_string_property Create a string property with validation constraints for MCP schemas #' @export #' #' @examples @@ -147,16 +160,26 @@ property_string <- function( #' Create a number property definition #' #' @param title Short title for the property +#' @type title string #' @param description Longer description of the property +#' @type description string #' @param required Whether the property is required +#' @type required boolean #' @param minimum Optional minimum value +#' @type minimum number #' @param maximum Optional maximum value -#' @param exclusive_minimum Optional logical for exclusive minimum -#' @param exclusive_maximum Optional logical for exclusive maximum +#' @type maximum number +#' @param exclusive_minimum Whether minimum is exclusive +#' @type exclusive_minimum boolean +#' @param exclusive_maximum Whether maximum is exclusive +#' @type exclusive_maximum boolean #' @param multiple_of Optional value the number must be a multiple of -#' @param integer Logical indicating if the number should be an integer +#' @type multiple_of number +#' @param integer Whether the number should be an integer +#' @type integer boolean #' #' @return A number property object +#' @mcp create_number_property Create a number property with range and type constraints for MCP schemas #' @export #' #' @examples @@ -205,10 +228,14 @@ property_number <- function( #' Create a boolean property definition #' #' @param title Short title for the property +#' @type title string #' @param description Longer description of the property +#' @type description string #' @param required Whether the property is required +#' @type required boolean #' #' @return A boolean property object +#' @mcp create_boolean_property Create a boolean property for MCP schemas #' @export #' #' @examples @@ -316,11 +343,16 @@ property_object <- function( #' Create an enum property with predefined values #' #' @param title Short title for the property +#' @type title string #' @param description Longer description of the property +#' @type description string #' @param values Character vector of allowed values +#' @type values array #' @param required Whether the property is required +#' @type required boolean #' #' @return An enum property object +#' @mcp create_enum_property Create an enum property with predefined values for MCP schemas #' @export #' #' @examples diff --git a/R/io.R b/R/io.R index e34d329..ef30461 100644 --- a/R/io.R +++ b/R/io.R @@ -1,8 +1,10 @@ #' Serve an MCP server using stdin/stdout #' -#' @param mcp An MCP server object +#' @param mcp An MCP server object created with new_server() +#' @type mcp object #' #' @return Nothing, runs indefinitely in normal mode, or the response in test mode +#' @mcp start_mcp_server_io Start an MCP server using stdin/stdout transport #' @export serve_io <- function( mcp diff --git a/R/mcp.R b/R/mcp.R index 2352847..0ee5ea4 100644 --- a/R/mcp.R +++ b/R/mcp.R @@ -1,14 +1,21 @@ #' Create a new MCP object #' -#' @param name Name of the MCP -#' @param description Description of the MCP -#' @param version Version of the MCP -#' @param tools List of tools -#' @param resources List of resources -#' @param prompts List of prompts +#' @param name Name of the MCP server +#' @type name string +#' @param description Description of the MCP server +#' @type description string +#' @param version Version of the MCP server +#' @type version string +#' @param tools List of tools (optional) +#' @type tools array +#' @param resources List of resources (optional) +#' @type resources array +#' @param prompts List of prompts (optional) +#' @type prompts array #' @param ... Forwarded to [new_server()] #' #' @return A new MCP object +#' @mcp create_mcp_server Create a new MCP server with specified name, description, and version #' @export #' #' @examples @@ -94,11 +101,16 @@ new_mcp <- function(...) { #' Create a new tool #' #' @param name Name of the tool -#' @param description Description of the tool -#' @param input_schema Input schema for the tool -#' @param handler Function to handle the tool +#' @type name string +#' @param description Description of the tool +#' @type description string +#' @param input_schema Input schema for the tool (must be a schema object) +#' @type input_schema object +#' @param handler Function to handle the tool execution +#' @type handler object #' #' @return A new tool capability +#' @mcp create_mcp_tool Create a new MCP tool with input schema and handler function #' @export #' #' @examples @@ -152,12 +164,18 @@ new_tool <- function( #' Create a new resource #' #' @param name Name of the resource +#' @type name string #' @param description Description of the resource +#' @type description string #' @param uri URI of the resource -#' @param mime_type Mime type of the resource -#' @param handler Function to handle the resource +#' @type uri string +#' @param mime_type MIME type of the resource (optional) +#' @type mime_type string +#' @param handler Function to handle the resource request +#' @type handler object #' #' @return A new resource capability +#' @mcp create_mcp_resource Create a new MCP resource with URI and MIME type #' @export #' #' @examples @@ -199,11 +217,16 @@ new_resource <- function(name, description, uri, mime_type = NULL, handler) { #' Create a new prompt #' #' @param name Name of the prompt +#' @type name string #' @param description Description of the prompt +#' @type description string #' @param arguments List of arguments for the prompt -#' @param handler Function to handle the prompt +#' @type arguments array +#' @param handler Function to handle the prompt execution +#' @type handler object #' #' @return A new prompt capability +#' @mcp create_mcp_prompt Create a new MCP prompt with arguments and handler function #' @export #' #' @examples @@ -269,10 +292,13 @@ new_capability <- function( #' Add a capability to an MCP object #' -#' @param capability A capability object -#' @param mcp An MCP object +#' @param mcp An MCP server object +#' @type mcp object +#' @param capability A tool, resource, or prompt capability object +#' @type capability object #' #' @return The MCP object with the capability added +#' @mcp add_mcp_capability Add a tool, resource, or prompt capability to an existing MCP server #' @export add_capability <- function(mcp, capability) { UseMethod("add_capability", capability) diff --git a/R/response.R b/R/response.R index 7e729ae..6ed9b9b 100644 --- a/R/response.R +++ b/R/response.R @@ -1,6 +1,7 @@ #' Create a response object #' -#' @param text Text content +#' @param text Text content for the response +#' @type text string #' @param image Image content #' @param audio Audio content #' @param video Video content @@ -25,6 +26,7 @@ #' #' @name response #' @return A response object +#' @mcp create_text_response Create a text response for MCP tool handlers #' @export response_text <- function(text) { if (missing(text)) { diff --git a/R/roclet.R b/R/roclet.R new file mode 100644 index 0000000..52a881e --- /dev/null +++ b/R/roclet.R @@ -0,0 +1,509 @@ +#' MCP Roclet for Generating MCP Servers +#' +#' This roclet automatically generates MCP (Model Context Protocol) servers +#' from R functions annotated with @mcp tags. +#' +#' @importFrom roxygen2 roclet roclet_process roclet_output roxy_tag_parse roxy_tag_rd block_get_tags roxy_tag_warning block_get_tag_value +#' @export +#' @examples +#' \dontrun{ +#' # Use the roclet in roxygenise +#' roxygen2::roxygenise(roclets = c("rd", "mcpr::mcp_roclet")) +#' } +mcp_roclet <- function() { + roxygen2::roclet("mcp") +} + +# Custom tags are automatically recognized by having roxy_tag_parse methods + +#' Parse @mcp tag +#' +#' Parses @mcp tags to extract tool name and description. +#' +#' @param x A roxy_tag object +#' @method roxy_tag_parse roxy_tag_mcp +#' @export +roxy_tag_parse.roxy_tag_mcp <- function(x) { + # Parse the raw content + raw <- trimws(x$raw) + + if (raw == "") { + # If no content, use defaults from function + x$val <- list( + name = NULL, # Will be filled from function name + description = NULL # Will be filled from title + ) + } else { + # Split by first whitespace to separate name and description + # Use regexpr to find first space + first_space <- regexpr("\\s", raw) + + if (first_space == -1) { + # Only name provided (no spaces) + x$val <- list( + name = raw, + description = NULL + ) + } else { + # Both name and description provided + name_part <- substr(raw, 1, first_space - 1) + desc_part <- trimws(substr(raw, first_space + 1, nchar(raw))) + + x$val <- list( + name = name_part, + description = desc_part + ) + } + } + + x +} + +#' Parse @type tag +#' +#' Parses @type tags to extract parameter type information. +#' Format: @type param_name type enum_values +#' +#' @param x A roxy_tag object +#' @method roxy_tag_parse roxy_tag_type +#' @export +roxy_tag_parse.roxy_tag_type <- function(x) { + # Parse the raw content + raw <- trimws(x$raw) + + if (raw == "") { + roxygen2::roxy_tag_warning(x, "Empty @type tag") + return(x) + } + + # Split by whitespace + parts <- strsplit(raw, "\\s+")[[1]] + + if (length(parts) < 2) { + roxygen2::roxy_tag_warning( + x, + "Invalid @type format. Expected: param_name type [enum_values]" + ) + return(x) + } + + param_name <- parts[1] + param_type <- parts[2] + + # Validate type + valid_types <- c( + "string", + "number", + "integer", + "boolean", + "array", + "object", + "enum" + ) + + # Handle enum type specially + if (grepl("^enum:", param_type)) { + param_type_base <- "enum" + enum_string <- gsub("^enum:", "", param_type) + enum_values <- trimws(strsplit(enum_string, ",")[[1]]) + } else { + param_type_base <- param_type + enum_values <- NULL + } + + if (!param_type_base %in% valid_types) { + roxygen2::roxy_tag_warning( + x, + paste( + "Invalid parameter type:", + param_type_base, + ". Valid types:", + paste(valid_types, collapse = ", ") + ) + ) + return(x) + } + + x$val <- list( + param_name = param_name, + type = param_type_base, + enum_values = enum_values + ) + + x +} + +#' Roxygen2 tag for @mcp +#' This function is called by Roxygen2 to generate documentation for the @mcp tag +#' @param x Roxygen2 tag object +#' @param base_path Base path for the package +#' @param env Environment +#' @return NULL (invisible) +#' @method roxy_tag_rd roxy_tag_mcp +#' @export +roxy_tag_rd.roxy_tag_mcp <- function(x, base_path, env) { + # @mcp tags are not for .Rd generation, only for MCP roclet + NULL +} + +#' Roxygen2 tag handler for @type +#' This function is called by Roxygen2 to generate documentation for the @type +#' @param x Roxygen2 tag object +#' @param base_path Base path for the package +#' @param env Environment +#' @return NULL (invisible) +#' @method roxy_tag_rd roxy_tag_type +#' @export +roxy_tag_rd.roxy_tag_type <- function(x, base_path, env) { + # @type tags are not for .Rd generation, only for MCP roclet + NULL +} + +#' Process blocks for MCP roclet +#' +#' @param x MCP roclet object +#' @param blocks List of roxy_block objects +#' @param env Environment +#' @param base_path Base path +#' @return List of processed MCP tools +#' @method roclet_process roclet_mcp +#' @export +roclet_process.roclet_mcp <- function(x, blocks, env, base_path) { + tools <- list() + + for (block in blocks) { + # Check if block has @mcp tag + mcp_tags <- roxygen2::block_get_tags(block, "mcp") + + if (length(mcp_tags) > 0) { + # Process this block as an MCP tool + tool_info <- process_mcp_block(block) + if (!is.null(tool_info)) { + tools[[length(tools) + 1]] <- tool_info + } + } + } + + tools +} + +#' Generate MCP server output +#' +#' @param x MCP roclet object +#' @param results List of processed tools +#' @param base_path Base path +#' @param ... Additional arguments +#' @return NULL (invisible) +#' @method roclet_output roclet_mcp +#' @export +roclet_output.roclet_mcp <- function(x, results, base_path, ...) { + if (length(results) == 0) { + message("No @mcp tags found. No MCP server generated.") + return(invisible(NULL)) + } + + # Generate MCP server file + server_content <- generate_mcp_server(results, base_path) + + # Write to file + output_file <- file.path(base_path, "inst", "mcp_server.R") + writeLines(server_content, output_file) + + message("Generated MCP server: ", output_file) + message("Found ", length(results), " MCP tools:") + for (tool in results) { + message(" - ", tool$name, ": ", tool$description) + } + + invisible(NULL) +} + +#' Process a single block with @mcp tag +#' +#' @param block A roxy_block object +#' @return A list with tool information or NULL +#' @keywords internal +process_mcp_block <- function(block) { + # Get @mcp tag + mcp_tags <- roxygen2::block_get_tags(block, "mcp") + if (length(mcp_tags) == 0) { + return(NULL) + } + + mcp_tag <- mcp_tags[[1]] # Use first @mcp tag + + # Get function name from block object + func_name <- if (!is.null(block$object) && !is.null(block$object$alias)) { + block$object$alias + } else { + "unknown_function" + } + + # Get tool name and description + tool_name <- mcp_tag$val$name %||% paste0(func_name, "_tool") + tool_description <- mcp_tag$val$description %||% + roxygen2::block_get_tag_value(block, "title") %||% + paste("Tool for", func_name) + + # Get parameters and types + param_tags <- roxygen2::block_get_tags(block, "param") + type_tags <- roxygen2::block_get_tags(block, "type") + + # Build parameter information + params <- build_param_info(param_tags, type_tags) + + list( + name = tool_name, + description = tool_description, + function_name = func_name, + params = params, + file = block$file, + line = block$line + ) +} + +#' Build parameter information from @param and @type tags +#' +#' @param param_tags List of @param tags +#' @param type_tags List of @type tags +#' @return List of parameter information +#' @keywords internal +build_param_info <- function(param_tags, type_tags = list()) { + params <- list() + + # Create lookup table for parameter types + type_lookup <- list() + for (type_tag in type_tags) { + if (!is.null(type_tag$val$param_name)) { + type_lookup[[type_tag$val$param_name]] <- type_tag$val + } + } + + # Process each @param tag + for (param_tag in param_tags) { + # Parse parameter name(s) and description + raw <- trimws(param_tag$raw) + if (raw == "") { + next + } + + # Split by first whitespace to separate names and description + first_space <- regexpr("\\s", raw) + if (first_space == -1) { + next + } # No space found + + param_names <- substr(raw, 1, first_space - 1) + param_desc <- trimws(substr(raw, first_space + 1, nchar(raw))) + + # Handle multiple parameter names separated by comma + names <- trimws(strsplit(param_names, ",")[[1]]) + + for (name in names) { + # Get type information from @type tags + type_info <- type_lookup[[name]] + param_type <- if (!is.null(type_info)) type_info$type else "string" + enum_values <- if (!is.null(type_info)) type_info$enum_values else NULL + + params[[name]] <- list( + name = name, + description = param_desc, + type = param_type, + enum_values = enum_values, + required = TRUE # Default to required, could be enhanced later + ) + } + } + + params +} + + +#' Generate MCP server R code +#' +#' @param tools List of tool information +#' @param base_path Base path for the package +#' @return Character vector of R code lines +#' @keywords internal +generate_mcp_server <- function(tools, base_path) { + lines <- c( + "# Auto-generated MCP Server", + "# Generated by mcpr::mcp_roclet", + "", + "library(mcpr)", + "" + ) + + # Generate tool definitions + for (i in seq_along(tools)) { + tool <- tools[[i]] + lines <- c(lines, generate_tool_code(tool, i)) + } + + # Generate server creation + lines <- c( + lines, + "", + "# Create MCP server", + "mcp_server <- new_server(", + " name = \"Auto-generated MCP Server\",", + " description = \"MCP server generated from R functions with @mcp tags\",", + " version = \"1.0.0\"", + ")", + "" + ) + + # Add tools to server + for (i in seq_along(tools)) { + tool <- tools[[i]] + lines <- c( + lines, + paste0("mcp_server <- add_capability(mcp_server, ", tool$name, "_tool)") + ) + } + + # Add server deployment + lines <- c( + lines, + "", + "# Start the server", + "serve_io(mcp_server)" + ) + + lines +} + +#' Generate R code for a single tool +#' +#' @param tool Tool information list +#' @param index Tool index for naming +#' @return Character vector of R code lines +#' @keywords internal +generate_tool_code <- function(tool, index) { + lines <- c( + paste0("# Tool: ", tool$name), + paste0(tool$name, "_tool <- new_tool("), + paste0(" name = \"", tool$name, "\","), + paste0(" description = \"", tool$description, "\","), + " input_schema = schema(" + ) + + # Generate properties + if (length(tool$params) > 0) { + lines <- c(lines, " properties = properties(") + + prop_lines <- c() + for (param_name in names(tool$params)) { + param <- tool$params[[param_name]] + prop_line <- generate_property_code(param) + prop_lines <- c(prop_lines, paste0(" ", prop_line)) + } + + # Join properties with commas + if (length(prop_lines) > 0) { + prop_lines[length(prop_lines)] <- prop_lines[length(prop_lines)] # No comma on last + for (i in seq_len(length(prop_lines) - 1)) { + prop_lines[i] <- paste0(prop_lines[i], ",") + } + } + + lines <- c(lines, prop_lines, " )") + } else { + lines <- c(lines, " properties = properties()") + } + + lines <- c( + lines, + " ),", + " handler = function(params) {", + paste0(" # Call the original function: ", tool$function_name), + generate_handler_code(tool), + " }", + ")", + "" + ) + + lines +} + +#' Generate property code for a parameter +#' +#' @param param Parameter information +#' @return Character string with property code +#' @keywords internal +generate_property_code <- function(param) { + type <- param$type + name <- param$name + desc <- param$description + required <- param$required + + if (type == "enum" && !is.null(param$enum_values)) { + values_str <- paste0( + "c(", + paste0("\"", param$enum_values, "\"", collapse = ", "), + ")" + ) + return(paste0( + name, + " = property_enum(\"", + name, + "\", \"", + desc, + "\", values = ", + values_str, + ", required = ", + required, + ")" + )) + } + + func_name <- switch( + type, + "string" = "property_string", + "number" = "property_number", + "integer" = "property_number", # Use property_number for integers + "boolean" = "property_boolean", + "array" = "property_array", + "object" = "property_object", + "property_string" # default + ) + + paste0( + name, + " = ", + func_name, + "(\"", + name, + "\", \"", + gsub("\"", "'", desc), + "\", required = ", + required, + ")" + ) +} + +#' Generate handler code that calls the original function +#' +#' @param tool Tool information +#' @return Character vector of handler code lines +#' @keywords internal +generate_handler_code <- function(tool) { + if (length(tool$params) == 0) { + return(c( + paste0(" result <- ", tool$function_name, "()"), + " response_text(result)" + )) + } + + # Generate parameter extraction and function call + param_names <- names(tool$params) + args_str <- paste0("params$", param_names, collapse = ", ") + + c( + paste0(" result <- ", tool$function_name, "(", args_str, ")"), + " response_text(result)" + ) +} + +# Helper function for null coalescing +`%||%` <- function(x, y) if (is.null(x)) y else x diff --git a/README.md b/README.md index 1a4971b..37bcbd2 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,79 @@ serve_http(mcp, port = 3000) See the [Get Started](https://mcpr.opifex.org/articles/get-started) guide for more information. +## MCP Roclet for Automatic Server Generation + +mcpr includes a roxygen2 roclet that can automatically generate MCP servers from your R functions using special documentation tags. This provides a convenient way to expose existing R functions as MCP tools. + +### Usage + +1. Add `@mcp` and `@type` tags to your function documentation: + +```r +#' Add two numbers +#' @param x First number +#' @param y Second number +#' @type x number +#' @type y number +#' @mcp add_numbers Add two numbers together +add_numbers <- function(x, y) { + x + y +} +``` + +2. Generate the MCP server using roxygen2: + +```r +# Generate documentation and MCP server +roxygen2::roxygenise(roclets = c("rd", "mcpr::mcp_roclet")) +``` + +This will create an MCP server file at `inst/mcp_server.R` that includes: +- Tool definitions for all functions with `@mcp` tags +- Proper input schemas based on `@type` tags +- Handler functions that call your original R functions +- A complete, runnable MCP server + +### Supported Types + +The `@type` tag supports these parameter types: +- `string` - Text values +- `number` - Numeric values (integers and decimals) +- `integer` - Integer values +- `boolean` - True/false values +- `array` - Lists/vectors +- `object` - Complex R objects +- `enum:value1,value2,value3` - Enumerated values + +### Example Generated Server + +```r +# Generated MCP server code +add_numbers_tool <- new_tool( + name = "add_numbers", + description = "Add two numbers together", + input_schema = schema( + properties = properties( + x = property_number("x", "First number", required = TRUE), + y = property_number("y", "Second number", required = TRUE) + ) + ), + handler = function(params) { + result <- add_numbers(params$x, params$y) + response_text(result) + } +) + +mcp_server <- new_server( + name = "Auto-generated MCP Server", + description = "MCP server generated from R functions with @mcp tags", + version = "1.0.0" +) + +mcp_server <- add_capability(mcp_server, add_numbers_tool) +serve_io(mcp_server) +``` + ### Client Here's a simple example of using the client to interact with an MCP server: diff --git a/_pkgdown.yml b/_pkgdown.yml index c503d9d..d8aba47 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -39,6 +39,7 @@ reference: contents: - serve_io - serve_http + - get_name - title: "Client Functions" desc: > @@ -63,6 +64,18 @@ reference: - response - matches("^response_") +- title: "Roxygen2 Extension" + desc: > + Functions for extending roxygen2 with MCP server generation + contents: + - mcp_roclet + - roxy_tag_parse.roxy_tag_mcp + - roxy_tag_parse.roxy_tag_type + - roclet_process.roclet_mcp + - roxy_tag_rd.roxy_tag_mcp + - roxy_tag_rd.roxy_tag_type + - roclet_output.roclet_mcp + - title: "Ellmer Integration" desc: > Functions for integrating with the Ellmer package diff --git a/docs/404.html b/docs/404.html index c75d43b..45e2767 100644 --- a/docs/404.html +++ b/docs/404.html @@ -27,7 +27,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/LICENSE.html b/docs/LICENSE.html index f4f58a8..3d29c44 100644 --- a/docs/LICENSE.html +++ b/docs/LICENSE.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/articles/client-integration.html b/docs/articles/client-integration.html index 81fc8bf..897aae1 100644 --- a/docs/articles/client-integration.html +++ b/docs/articles/client-integration.html @@ -26,7 +26,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/articles/client-usage.html b/docs/articles/client-usage.html index 689777f..92f63fd 100644 --- a/docs/articles/client-usage.html +++ b/docs/articles/client-usage.html @@ -26,7 +26,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/articles/get-started.html b/docs/articles/get-started.html index 7d1f9cb..904ac30 100644 --- a/docs/articles/get-started.html +++ b/docs/articles/get-started.html @@ -26,7 +26,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/articles/index.html b/docs/articles/index.html index b1e3bc7..f9b9037 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/articles/practical-examples.html b/docs/articles/practical-examples.html index de2d389..814c7ed 100644 --- a/docs/articles/practical-examples.html +++ b/docs/articles/practical-examples.html @@ -26,7 +26,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/authors.html b/docs/authors.html index 94742ec..71f4a67 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -56,13 +56,13 @@ Citation Coene J (2025). mcpr: Model Context Protocol for R. -R package version 0.0.1.9000, https://mcpr.opifex.org/. +R package version 0.0.2.9000, https://mcpr.opifex.org/. @Manual{, title = {mcpr: Model Context Protocol for R}, author = {John Coene}, year = {2025}, - note = {R package version 0.0.1.9000}, + note = {R package version 0.0.2.9000}, url = {https://mcpr.opifex.org/}, } diff --git a/docs/index.html b/docs/index.html index 7e1c1bd..6ac7448 100644 --- a/docs/index.html +++ b/docs/index.html @@ -17,8 +17,8 @@ - - + + @@ -29,7 +29,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -202,8 +202,10 @@ Client ellmer integration Now supports ellmer tools, you can use ellmer’s or mcpr’s tools, interchangeably. +See the example below, taken from the ellmer documentation -current_time <- ellmer::tool( +# create an ellmer tool +current_time <- ellmer::tool( \(tz = "UTC") { format(Sys.time(), tz = tz, usetz = TRUE) }, @@ -220,9 +222,9 @@ ellmer integration= "1.0.0" ) +# register ellmer tool with mcpr server mcp <- add_capability(mcp, current_time) -# Start the server (listening on stdin/stdout) serve_io(mcp) diff --git a/docs/news/index.html b/docs/news/index.html index 83f6a08..3c3e098 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -38,6 +38,11 @@ Source: NEWS.md + +mcpr 0.0.2 +Added support for ellmer::tool + + mcpr 0.0.1 diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 41e41fd..c3302da 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -6,7 +6,7 @@ articles: client-usage: client-usage.html get-started: get-started.html practical-examples: practical-examples.html -last_built: 2025-06-19T16:39Z +last_built: 2025-06-20T08:07Z urls: reference: https://mcpr.opifex.org/reference article: https://mcpr.opifex.org/articles diff --git a/docs/reference/JSONRPC_PARSE_ERROR.html b/docs/reference/JSONRPC_PARSE_ERROR.html index 5ffb900..8421bec 100644 --- a/docs/reference/JSONRPC_PARSE_ERROR.html +++ b/docs/reference/JSONRPC_PARSE_ERROR.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/add_capability.html b/docs/reference/add_capability.html index 58b04e1..d323bfc 100644 --- a/docs/reference/add_capability.html +++ b/docs/reference/add_capability.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -53,11 +53,11 @@ Argumentsmcp -An MCP object +An MCP server object capability -A capability object +A tool, resource, or prompt capability object diff --git a/docs/reference/build_param_info.html b/docs/reference/build_param_info.html new file mode 100644 index 0000000..d428920 --- /dev/null +++ b/docs/reference/build_param_info.html @@ -0,0 +1,87 @@ + +Build parameter information from @param and @type tags — build_param_info • mcpr + Skip to contents + + + + + mcpr + + 0.0.2.9000 + + + + + + + + Reference + + Articles + Integrating mcpr with MCP Clients + Using the MCP Client + Getting Started with mcpr + Practical MCP Examples with R + +Changelog + + + + + + + + + + + Build parameter information from @param and @type tags + Source: R/roclet.R + build_param_info.Rd + + + + Build parameter information from @param and @type tags + + + + Usage + build_param_info(param_tags, type_tags = list()) + + + + Arguments + + +param_tags +List of @param tags + + +type_tags +List of @type tags + + + + Value + List of parameter information + + + + + + + + + + + + + diff --git a/docs/reference/client.html b/docs/reference/client.html index f75d8d3..d034afc 100644 --- a/docs/reference/client.html +++ b/docs/reference/client.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/convert_ellmer_type_to_mcpr_property.html b/docs/reference/convert_ellmer_type_to_mcpr_property.html new file mode 100644 index 0000000..816c31a --- /dev/null +++ b/docs/reference/convert_ellmer_type_to_mcpr_property.html @@ -0,0 +1,87 @@ + +Convert a single ellmer type to an mcpr property — convert_ellmer_type_to_mcpr_property • mcpr + Skip to contents + + + + + mcpr + + 0.0.2.9000 + + + + + + + + Reference + + Articles + Integrating mcpr with MCP Clients + Using the MCP Client + Getting Started with mcpr + Practical MCP Examples with R + +Changelog + + + + + + + + + + + Convert a single ellmer type to an mcpr property + Source: R/ellmer-to-mcpr.R + convert_ellmer_type_to_mcpr_property.Rd + + + + Convert a single ellmer type to an mcpr property + + + + Usage + convert_ellmer_type_to_mcpr_property(ellmer_type, prop_name) + + + + Arguments + + +ellmer_type +An ellmer Type object (TypeBasic, TypeArray, etc.) + + +prop_name +The name of the property (for better error messages) + + + + Value + An mcpr property object + + + + + + + + + + + + + diff --git a/docs/reference/convert_ellmer_types_to_mcpr.html b/docs/reference/convert_ellmer_types_to_mcpr.html new file mode 100644 index 0000000..3f4063d --- /dev/null +++ b/docs/reference/convert_ellmer_types_to_mcpr.html @@ -0,0 +1,83 @@ + +Convert ellmer TypeObject to mcpr schema — convert_ellmer_types_to_mcpr • mcpr + Skip to contents + + + + + mcpr + + 0.0.2.9000 + + + + + + + + Reference + + Articles + Integrating mcpr with MCP Clients + Using the MCP Client + Getting Started with mcpr + Practical MCP Examples with R + +Changelog + + + + + + + + + + + Convert ellmer TypeObject to mcpr schema + Source: R/ellmer-to-mcpr.R + convert_ellmer_types_to_mcpr.Rd + + + + Convert ellmer TypeObject to mcpr schema + + + + Usage + convert_ellmer_types_to_mcpr(type_object) + + + + Arguments + + +type_object +An ellmer TypeObject containing the function arguments + + + + Value + An mcpr schema object + + + + + + + + + + + + + diff --git a/docs/reference/create_ellmer_handler.html b/docs/reference/create_ellmer_handler.html index 6a85ae4..58a98f6 100644 --- a/docs/reference/create_ellmer_handler.html +++ b/docs/reference/create_ellmer_handler.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -35,7 +35,7 @@ Create an ellmer handler function for an MCP tool - Source: R/ellmer.R + Source: R/mcpr-to-ellmer.R create_ellmer_handler.Rd diff --git a/docs/reference/create_ellmer_type.html b/docs/reference/create_ellmer_type.html index cab08b6..fc5880d 100644 --- a/docs/reference/create_ellmer_type.html +++ b/docs/reference/create_ellmer_type.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -35,7 +35,7 @@ Create an ellmer type function for a specific MCP property - Source: R/ellmer.R + Source: R/mcpr-to-ellmer.R create_ellmer_type.Rd diff --git a/docs/reference/create_ellmer_types.html b/docs/reference/create_ellmer_types.html index f736b2c..ff75404 100644 --- a/docs/reference/create_ellmer_types.html +++ b/docs/reference/create_ellmer_types.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -35,7 +35,7 @@ Create ellmer type functions from MCP schema properties - Source: R/ellmer.R + Source: R/mcpr-to-ellmer.R create_ellmer_types.Rd diff --git a/docs/reference/create_error.html b/docs/reference/create_error.html index 35b195e..b41e24c 100644 --- a/docs/reference/create_error.html +++ b/docs/reference/create_error.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/create_response.html b/docs/reference/create_response.html index c0ae9f8..7d172a6 100644 --- a/docs/reference/create_response.html +++ b/docs/reference/create_response.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/ellmer_to_mcpr_tool.html b/docs/reference/ellmer_to_mcpr_tool.html new file mode 100644 index 0000000..67f6516 --- /dev/null +++ b/docs/reference/ellmer_to_mcpr_tool.html @@ -0,0 +1,115 @@ + +Convert ellmer tools to mcpr tools — ellmer_to_mcpr_tool • mcpr + Skip to contents + + + + + mcpr + + 0.0.2.9000 + + + + + + + + Reference + + Articles + Integrating mcpr with MCP Clients + Using the MCP Client + Getting Started with mcpr + Practical MCP Examples with R + +Changelog + + + + + + + + + + + Convert ellmer tools to mcpr tools + Source: R/ellmer-to-mcpr.R + ellmer_to_mcpr_tool.Rd + + + + This function converts tools from the ellmer package to a format compatible +with the mcpr package. It takes an ellmer ToolDef object and creates an +mcpr tool object with the appropriate input schema and handler function. + + + + Usage + ellmer_to_mcpr_tool(ellmer_tool) + + + + Arguments + + +ellmer_tool +An ellmer ToolDef object created with ellmer::tool() + + + + Value + An mcpr tool object compatible with new_tool() + + + See also + new_tool(), ellmer::tool(), add_capability() + + + + Examples + if (FALSE) { # \dontrun{ +# Create an ellmer tool +ellmer_rnorm <- ellmer::tool( + rnorm, + "Generate random normal numbers", + n = ellmer::type_integer("Number of observations"), + mean = ellmer::type_number("Mean value", required = FALSE), + sd = ellmer::type_number("Standard deviation", required = FALSE) +) + +# Convert to mcpr format +mcpr_tool <- ellmer_to_mcpr_tool(ellmer_rnorm) + +# Add to an mcpr server +server <- new_server("MyServer", "Test server", "1.0.0") +add_capability(server, mcpr_tool) +} # } + + + + + + + + + + + + + + diff --git a/docs/reference/extract_mcp_result.html b/docs/reference/extract_mcp_result.html index ccd5f43..cb93ba4 100644 --- a/docs/reference/extract_mcp_result.html +++ b/docs/reference/extract_mcp_result.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -35,7 +35,7 @@ Extract and convert an MCP result to ellmer-compatible format - Source: R/ellmer.R + Source: R/mcpr-to-ellmer.R extract_mcp_result.Rd diff --git a/docs/reference/from_json.html b/docs/reference/from_json.html index 66f849f..57436a0 100644 --- a/docs/reference/from_json.html +++ b/docs/reference/from_json.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/generate_handler_code.html b/docs/reference/generate_handler_code.html new file mode 100644 index 0000000..35c450e --- /dev/null +++ b/docs/reference/generate_handler_code.html @@ -0,0 +1,83 @@ + +Generate handler code that calls the original function — generate_handler_code • mcpr + Skip to contents + + + + + mcpr + + 0.0.2.9000 + + + + + + + + Reference + + Articles + Integrating mcpr with MCP Clients + Using the MCP Client + Getting Started with mcpr + Practical MCP Examples with R + +Changelog + + + + + + + + + + + Generate handler code that calls the original function + Source: R/roclet.R + generate_handler_code.Rd + + + + Generate handler code that calls the original function + + + + Usage + generate_handler_code(tool) + + + + Arguments + + +tool +Tool information + + + + Value + Character vector of handler code lines + + + + + + + + + + + + + diff --git a/docs/reference/generate_mcp_server.html b/docs/reference/generate_mcp_server.html new file mode 100644 index 0000000..031c279 --- /dev/null +++ b/docs/reference/generate_mcp_server.html @@ -0,0 +1,87 @@ + +Generate MCP server R code — generate_mcp_server • mcpr + Skip to contents + + + + + mcpr + + 0.0.2.9000 + + + + + + + + Reference + + Articles + Integrating mcpr with MCP Clients + Using the MCP Client + Getting Started with mcpr + Practical MCP Examples with R + +Changelog + + + + + + + + + + + Generate MCP server R code + Source: R/roclet.R + generate_mcp_server.Rd + + + + Generate MCP server R code + + + + Usage + generate_mcp_server(tools, base_path) + + + + Arguments + + +tools +List of tool information + + +base_path +Base path for the package + + + + Value + Character vector of R code lines + + + + + + + + + + + + + diff --git a/docs/reference/generate_property_code.html b/docs/reference/generate_property_code.html new file mode 100644 index 0000000..d45aed2 --- /dev/null +++ b/docs/reference/generate_property_code.html @@ -0,0 +1,83 @@ + +Generate property code for a parameter — generate_property_code • mcpr + Skip to contents + + + + + mcpr + + 0.0.2.9000 + + + + + + + + Reference + + Articles + Integrating mcpr with MCP Clients + Using the MCP Client + Getting Started with mcpr + Practical MCP Examples with R + +Changelog + + + + + + + + + + + Generate property code for a parameter + Source: R/roclet.R + generate_property_code.Rd + + + + Generate property code for a parameter + + + + Usage + generate_property_code(param) + + + + Arguments + + +param +Parameter information + + + + Value + Character string with property code + + + + + + + + + + + + + diff --git a/docs/reference/generate_tool_code.html b/docs/reference/generate_tool_code.html new file mode 100644 index 0000000..842f733 --- /dev/null +++ b/docs/reference/generate_tool_code.html @@ -0,0 +1,87 @@ + +Generate R code for a single tool — generate_tool_code • mcpr + Skip to contents + + + + + mcpr + + 0.0.2.9000 + + + + + + + + Reference + + Articles + Integrating mcpr with MCP Clients + Using the MCP Client + Getting Started with mcpr + Practical MCP Examples with R + +Changelog + + + + + + + + + + + Generate R code for a single tool + Source: R/roclet.R + generate_tool_code.Rd + + + + Generate R code for a single tool + + + + Usage + generate_tool_code(tool, index) + + + + Arguments + + +tool +Tool information list + + +index +Tool index for naming + + + + Value + Character vector of R code lines + + + + + + + + + + + + + diff --git a/docs/reference/get_name.html b/docs/reference/get_name.html new file mode 100644 index 0000000..a3b3d7c --- /dev/null +++ b/docs/reference/get_name.html @@ -0,0 +1,83 @@ + +Get the name of a client — get_name • mcpr + Skip to contents + + + + + mcpr + + 0.0.2.9000 + + + + + + + + Reference + + Articles + Integrating mcpr with MCP Clients + Using the MCP Client + Getting Started with mcpr + Practical MCP Examples with R + +Changelog + + + + + + + + + + + Get the name of a client + Source: R/client.R + get_name.Rd + + + + Get the name of a client + + + + Usage + get_name(x) + + + + Arguments + + +x +A client object + + + + Value + The name of the client + + + + + + + + + + + + + diff --git a/docs/reference/index.html b/docs/reference/index.html index 5f767d2..798fcf4 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -183,6 +183,12 @@ Server Functions Serve an MCP server over HTTP using ambiorix + + + get_name() + + + Get the name of a client Client Functions @@ -272,6 +278,59 @@ Response Functions + Roxygen2 Extension + + Functions for extending roxygen2 with MCP server generation + + + + + + + + + + mcp_roclet() + + + MCP Roclet for Generating MCP Servers + + + roxy_tag_parse(<roxy_tag_mcp>) + + + Parse @mcp tag + + + roxy_tag_parse(<roxy_tag_type>) + + + Parse @type tag + + + roclet_process(<roclet_mcp>) + + + Process blocks for MCP roclet + + + roxy_tag_rd(<roxy_tag_mcp>) + + + Roxygen2 tag for @mcp This function is called by Roxygen2 to generate documentation for the @mcp tag + + + roxy_tag_rd(<roxy_tag_type>) + + + Roxygen2 tag handler for @type This function is called by Roxygen2 to generate documentation for the @type + + + roclet_output(<roclet_mcp>) + + + Generate MCP server output + Ellmer Integration Functions for integrating with the Ellmer package @@ -288,6 +347,12 @@ Ellmer Integrationellmer_to_mcpr_tool() + + + Convert ellmer tools to mcpr tools diff --git a/docs/reference/initialize.html b/docs/reference/initialize.html index d15bcb1..86b16a6 100644 --- a/docs/reference/initialize.html +++ b/docs/reference/initialize.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/mcp_roclet.html b/docs/reference/mcp_roclet.html new file mode 100644 index 0000000..7366107 --- /dev/null +++ b/docs/reference/mcp_roclet.html @@ -0,0 +1,82 @@ + +MCP Roclet for Generating MCP Servers — mcp_roclet • mcpr + Skip to contents + + + + + mcpr + + 0.0.2.9000 + + + + + + + + Reference + + Articles + Integrating mcpr with MCP Clients + Using the MCP Client + Getting Started with mcpr + Practical MCP Examples with R + +Changelog + + + + + + + + + + + MCP Roclet for Generating MCP Servers + Source: R/roclet.R + mcp_roclet.Rd + + + + This roclet automatically generates MCP (Model Context Protocol) servers +from R functions annotated with @mcp tags. + + + + Usage + mcp_roclet() + + + + + Examples + if (FALSE) { # \dontrun{ +# Use the roclet in roxygenise +roxygen2::roxygenise(roclets = c("rd", "mcpr::mcp_roclet")) +} # } + + + + + + + + + + + + + diff --git a/docs/reference/mcpr_clients_to_ellmer_tools.html b/docs/reference/mcpr_clients_to_ellmer_tools.html index 45c643c..d247d05 100644 --- a/docs/reference/mcpr_clients_to_ellmer_tools.html +++ b/docs/reference/mcpr_clients_to_ellmer_tools.html @@ -11,7 +11,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -39,7 +39,7 @@ Convert multiple MCPR clients to ellmer tools - Source: R/ellmer.R + Source: R/mcpr-to-ellmer.R mcpr_clients_to_ellmer_tools.Rd diff --git a/docs/reference/mcpr_to_ellmer_tools.html b/docs/reference/mcpr_to_ellmer_tools.html index fa9839d..f447353 100644 --- a/docs/reference/mcpr_to_ellmer_tools.html +++ b/docs/reference/mcpr_to_ellmer_tools.html @@ -11,7 +11,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -39,7 +39,7 @@ Convert MCPR tools to ellmer tools - Source: R/ellmer.R + Source: R/mcpr-to-ellmer.R mcpr_to_ellmer_tools.Rd diff --git a/docs/reference/new_prompt.html b/docs/reference/new_prompt.html index edb5af6..44b4fbb 100644 --- a/docs/reference/new_prompt.html +++ b/docs/reference/new_prompt.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -65,7 +65,7 @@ Argumentshandler -Function to handle the prompt +Function to handle the prompt execution diff --git a/docs/reference/new_property.html b/docs/reference/new_property.html index ba8dfcd..87a9824 100644 --- a/docs/reference/new_property.html +++ b/docs/reference/new_property.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/new_resource.html b/docs/reference/new_resource.html index 4d9c2e1..00a2302 100644 --- a/docs/reference/new_resource.html +++ b/docs/reference/new_resource.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -65,11 +65,11 @@ Argumentsmime_type -Mime type of the resource +MIME type of the resource (optional) handler -Function to handle the resource +Function to handle the resource request diff --git a/docs/reference/new_server.html b/docs/reference/new_server.html index feb6fab..37365fb 100644 --- a/docs/reference/new_server.html +++ b/docs/reference/new_server.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -62,27 +62,27 @@ Argumentsname -Name of the MCP +Name of the MCP server description -Description of the MCP +Description of the MCP server version -Version of the MCP +Version of the MCP server tools -List of tools +List of tools (optional) resources -List of resources +List of resources (optional) prompts -List of prompts +List of prompts (optional) ... diff --git a/docs/reference/new_tool.html b/docs/reference/new_tool.html index a783e83..9e6155a 100644 --- a/docs/reference/new_tool.html +++ b/docs/reference/new_tool.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -61,11 +61,11 @@ Argumentsinput_schema -Input schema for the tool +Input schema for the tool (must be a schema object) handler -Function to handle the tool +Function to handle the tool execution diff --git a/docs/reference/parse_request.html b/docs/reference/parse_request.html index 888de74..04e75ec 100644 --- a/docs/reference/parse_request.html +++ b/docs/reference/parse_request.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/process_batch.html b/docs/reference/process_batch.html index 650f96e..7fd25d0 100644 --- a/docs/reference/process_batch.html +++ b/docs/reference/process_batch.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/process_mcp_block.html b/docs/reference/process_mcp_block.html new file mode 100644 index 0000000..164abbf --- /dev/null +++ b/docs/reference/process_mcp_block.html @@ -0,0 +1,83 @@ + +Process a single block with @mcp tag — process_mcp_block • mcpr + Skip to contents + + + + + mcpr + + 0.0.2.9000 + + + + + + + + Reference + + Articles + Integrating mcpr with MCP Clients + Using the MCP Client + Getting Started with mcpr + Practical MCP Examples with R + +Changelog + + + + + + + + + + + Process a single block with @mcp tag + Source: R/roclet.R + process_mcp_block.Rd + + + + Process a single block with @mcp tag + + + + Usage + process_mcp_block(block) + + + + Arguments + + +block +A roxy_block object + + + + Value + A list with tool information or NULL + + + + + + + + + + + + + diff --git a/docs/reference/process_request.html b/docs/reference/process_request.html index 12120a8..7093646 100644 --- a/docs/reference/process_request.html +++ b/docs/reference/process_request.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/prompts_get.html b/docs/reference/prompts_get.html index 7adf89c..3e9bd3f 100644 --- a/docs/reference/prompts_get.html +++ b/docs/reference/prompts_get.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/prompts_list.html b/docs/reference/prompts_list.html index c749d27..80d081a 100644 --- a/docs/reference/prompts_list.html +++ b/docs/reference/prompts_list.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/properties.html b/docs/reference/properties.html index 17b7b1d..0b5162e 100644 --- a/docs/reference/properties.html +++ b/docs/reference/properties.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/property_array.html b/docs/reference/property_array.html index d87f8f5..21d9fd8 100644 --- a/docs/reference/property_array.html +++ b/docs/reference/property_array.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/property_boolean.html b/docs/reference/property_boolean.html index 0689a3e..f05d011 100644 --- a/docs/reference/property_boolean.html +++ b/docs/reference/property_boolean.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/property_enum.html b/docs/reference/property_enum.html index 68e3450..9e2a27b 100644 --- a/docs/reference/property_enum.html +++ b/docs/reference/property_enum.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/property_number.html b/docs/reference/property_number.html index df7f775..589b647 100644 --- a/docs/reference/property_number.html +++ b/docs/reference/property_number.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -83,11 +83,11 @@ Argumentsexclusive_minimum -Optional logical for exclusive minimum +Whether minimum is exclusive exclusive_maximum -Optional logical for exclusive maximum +Whether maximum is exclusive multiple_of @@ -95,7 +95,7 @@ Argumentsinteger -Logical indicating if the number should be an integer +Whether the number should be an integer diff --git a/docs/reference/property_object.html b/docs/reference/property_object.html index 20e8f1e..b6c311c 100644 --- a/docs/reference/property_object.html +++ b/docs/reference/property_object.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/property_string.html b/docs/reference/property_string.html index 7fc9214..04b37d0 100644 --- a/docs/reference/property_string.html +++ b/docs/reference/property_string.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -90,7 +90,7 @@ Argumentsformat -Optional format (e.g., "date-time", "email", "uri") +Optional format constraint diff --git a/docs/reference/read.html b/docs/reference/read.html index 07ce43c..ecaba2a 100644 --- a/docs/reference/read.html +++ b/docs/reference/read.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/register_mcpr_tools.html b/docs/reference/register_mcpr_tools.html index c08b97c..561d9ce 100644 --- a/docs/reference/register_mcpr_tools.html +++ b/docs/reference/register_mcpr_tools.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -35,7 +35,7 @@ Register MCPR tools with an ellmer chat - Source: R/ellmer.R + Source: R/mcpr-to-ellmer.R register_mcpr_tools.Rd diff --git a/docs/reference/resources_list.html b/docs/reference/resources_list.html index eb06e9e..c238abf 100644 --- a/docs/reference/resources_list.html +++ b/docs/reference/resources_list.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/resources_read.html b/docs/reference/resources_read.html index 9f04eba..9f1c023 100644 --- a/docs/reference/resources_read.html +++ b/docs/reference/resources_read.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/response.html b/docs/reference/response.html index 8c44106..26ebd89 100644 --- a/docs/reference/response.html +++ b/docs/reference/response.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -72,7 +72,7 @@ Argumentstext -Text content +Text content for the response image diff --git a/docs/reference/roclet_output.roclet_mcp.html b/docs/reference/roclet_output.roclet_mcp.html new file mode 100644 index 0000000..2377985 --- /dev/null +++ b/docs/reference/roclet_output.roclet_mcp.html @@ -0,0 +1,96 @@ + +Generate MCP server output — roclet_output.roclet_mcp • mcpr + Skip to contents + + + + + mcpr + + 0.0.2.9000 + + + + + + + + Reference + + Articles + Integrating mcpr with MCP Clients + Using the MCP Client + Getting Started with mcpr + Practical MCP Examples with R + +Changelog + + + + + + + + + + + Generate MCP server output + Source: R/roclet.R + roclet_output.roclet_mcp.Rd + + + + Generate MCP server output + + + + Usage + # S3 method for class 'roclet_mcp' +roclet_output(x, results, base_path, ...) + + + + Arguments + + +x +MCP roclet object + + +results +List of processed tools + + +base_path +Base path + + +... +Additional arguments + + + + Value + NULL (invisible) + + + + + + + + + + + + + diff --git a/docs/reference/roclet_process.roclet_mcp.html b/docs/reference/roclet_process.roclet_mcp.html new file mode 100644 index 0000000..07d5a0b --- /dev/null +++ b/docs/reference/roclet_process.roclet_mcp.html @@ -0,0 +1,96 @@ + +Process blocks for MCP roclet — roclet_process.roclet_mcp • mcpr + Skip to contents + + + + + mcpr + + 0.0.2.9000 + + + + + + + + Reference + + Articles + Integrating mcpr with MCP Clients + Using the MCP Client + Getting Started with mcpr + Practical MCP Examples with R + +Changelog + + + + + + + + + + + Process blocks for MCP roclet + Source: R/roclet.R + roclet_process.roclet_mcp.Rd + + + + Process blocks for MCP roclet + + + + Usage + # S3 method for class 'roclet_mcp' +roclet_process(x, blocks, env, base_path) + + + + Arguments + + +x +MCP roclet object + + +blocks +List of roxy_block objects + + +env +Environment + + +base_path +Base path + + + + Value + List of processed MCP tools + + + + + + + + + + + + + diff --git a/docs/reference/roxy_tag_parse.roxy_tag_mcp.html b/docs/reference/roxy_tag_parse.roxy_tag_mcp.html new file mode 100644 index 0000000..a434a30 --- /dev/null +++ b/docs/reference/roxy_tag_parse.roxy_tag_mcp.html @@ -0,0 +1,80 @@ + +Parse @mcp tag — roxy_tag_parse.roxy_tag_mcp • mcpr + Skip to contents + + + + + mcpr + + 0.0.2.9000 + + + + + + + + Reference + + Articles + Integrating mcpr with MCP Clients + Using the MCP Client + Getting Started with mcpr + Practical MCP Examples with R + +Changelog + + + + + + + + + + + Parse @mcp tag + Source: R/roclet.R + roxy_tag_parse.roxy_tag_mcp.Rd + + + + Parses @mcp tags to extract tool name and description. + + + + Usage + # S3 method for class 'roxy_tag_mcp' +roxy_tag_parse(x) + + + + Arguments + + +x +A roxy_tag object + + + + + + + + + + + + + + diff --git a/docs/reference/roxy_tag_parse.roxy_tag_type.html b/docs/reference/roxy_tag_parse.roxy_tag_type.html new file mode 100644 index 0000000..98402c7 --- /dev/null +++ b/docs/reference/roxy_tag_parse.roxy_tag_type.html @@ -0,0 +1,83 @@ + +Parse @type tag — roxy_tag_parse.roxy_tag_type • mcpr + Skip to contents + + + + + mcpr + + 0.0.2.9000 + + + + + + + + Reference + + Articles + Integrating mcpr with MCP Clients + Using the MCP Client + Getting Started with mcpr + Practical MCP Examples with R + +Changelog + + + + + + + + + + + Parse @type tag + Source: R/roclet.R + roxy_tag_parse.roxy_tag_type.Rd + + + + Parses @type tags to extract parameter type information. +Format: @type param_name type enum_values + + + + Usage + # S3 method for class 'roxy_tag_type' +roxy_tag_parse(x) + + + + Arguments + + +x +A roxy_tag object + + + + + + + + + + + + + + diff --git a/docs/reference/roxy_tag_rd.roxy_tag_mcp.html b/docs/reference/roxy_tag_rd.roxy_tag_mcp.html new file mode 100644 index 0000000..ced7ce0 --- /dev/null +++ b/docs/reference/roxy_tag_rd.roxy_tag_mcp.html @@ -0,0 +1,95 @@ + +Roxygen2 tag for @mcp This function is called by Roxygen2 to generate documentation for the @mcp tag — roxy_tag_rd.roxy_tag_mcp • mcpr + Skip to contents + + + + + mcpr + + 0.0.2.9000 + + + + + + + + Reference + + Articles + Integrating mcpr with MCP Clients + Using the MCP Client + Getting Started with mcpr + Practical MCP Examples with R + +Changelog + + + + + + + + + + + Roxygen2 tag for @mcp This function is called by Roxygen2 to generate documentation for the @mcp tag + Source: R/roclet.R + roxy_tag_rd.roxy_tag_mcp.Rd + + + + Roxygen2 tag for @mcp +This function is called by Roxygen2 to generate documentation for the @mcp tag + + + + Usage + # S3 method for class 'roxy_tag_mcp' +roxy_tag_rd(x, base_path, env) + + + + Arguments + + +x +Roxygen2 tag object + + +base_path +Base path for the package + + +env +Environment + + + + Value + NULL (invisible) + + + + + + + + + + + + + diff --git a/docs/reference/roxy_tag_rd.roxy_tag_type.html b/docs/reference/roxy_tag_rd.roxy_tag_type.html new file mode 100644 index 0000000..b70ccc1 --- /dev/null +++ b/docs/reference/roxy_tag_rd.roxy_tag_type.html @@ -0,0 +1,95 @@ + +Roxygen2 tag handler for @type This function is called by Roxygen2 to generate documentation for the @type — roxy_tag_rd.roxy_tag_type • mcpr + Skip to contents + + + + + mcpr + + 0.0.2.9000 + + + + + + + + Reference + + Articles + Integrating mcpr with MCP Clients + Using the MCP Client + Getting Started with mcpr + Practical MCP Examples with R + +Changelog + + + + + + + + + + + Roxygen2 tag handler for @type This function is called by Roxygen2 to generate documentation for the @type + Source: R/roclet.R + roxy_tag_rd.roxy_tag_type.Rd + + + + Roxygen2 tag handler for @type +This function is called by Roxygen2 to generate documentation for the @type + + + + Usage + # S3 method for class 'roxy_tag_type' +roxy_tag_rd(x, base_path, env) + + + + Arguments + + +x +Roxygen2 tag object + + +base_path +Base path for the package + + +env +Environment + + + + Value + NULL (invisible) + + + + + + + + + + + + + diff --git a/docs/reference/schema.html b/docs/reference/schema.html index 1a0c172..783db40 100644 --- a/docs/reference/schema.html +++ b/docs/reference/schema.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -53,15 +53,15 @@ Argumentsproperties -List of property definitions +List of property definitions created with properties() type -Type of the schema +Type of the schema (default: "object") additional_properties -Logical indicating if additional properties are allowed +Whether additional properties are allowed diff --git a/docs/reference/serve_http.html b/docs/reference/serve_http.html index ca3d356..f01d49b 100644 --- a/docs/reference/serve_http.html +++ b/docs/reference/serve_http.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/serve_io.html b/docs/reference/serve_io.html index d4ec168..a583e98 100644 --- a/docs/reference/serve_io.html +++ b/docs/reference/serve_io.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 @@ -53,7 +53,7 @@ Argumentsmcp -An MCP server object +An MCP server object created with new_server() diff --git a/docs/reference/to_json.html b/docs/reference/to_json.html index 2222056..b025c5c 100644 --- a/docs/reference/to_json.html +++ b/docs/reference/to_json.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/tools_call.html b/docs/reference/tools_call.html index 32ad3b7..2b395a2 100644 --- a/docs/reference/tools_call.html +++ b/docs/reference/tools_call.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/tools_list.html b/docs/reference/tools_list.html index 6b1a8b7..b835cf8 100644 --- a/docs/reference/tools_list.html +++ b/docs/reference/tools_list.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/validate_request.html b/docs/reference/validate_request.html index efd71c0..6fa9e4f 100644 --- a/docs/reference/validate_request.html +++ b/docs/reference/validate_request.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/reference/write.html b/docs/reference/write.html index 2431af7..400bf8c 100644 --- a/docs/reference/write.html +++ b/docs/reference/write.html @@ -7,7 +7,7 @@ mcpr - 0.0.1.9000 + 0.0.2.9000 diff --git a/docs/search.json b/docs/search.json index 3f2ead6..3ba651e 100644 --- a/docs/search.json +++ b/docs/search.json @@ -1 +1 @@ -[{"path":"https://mcpr.opifex.org/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"GNU General Public License","title":"GNU General Public License","text":"Version 2, June 1991Copyright © 1989, 1991 Free Software Foundation, Inc.,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone permitted copy distribute verbatim copies license document, changing allowed.","code":""},{"path":"https://mcpr.opifex.org/LICENSE.html","id":"preamble","dir":"","previous_headings":"","what":"Preamble","title":"GNU General Public License","text":"licenses software designed take away freedom share change . contrast, GNU General Public License intended guarantee freedom share change free software–make sure software free users. General Public License applies Free Software Foundation’s software program whose authors commit using . (Free Software Foundation software covered GNU Lesser General Public License instead.) can apply programs, . speak free software, referring freedom, price. General Public Licenses designed make sure freedom distribute copies free software (charge service wish), receive source code can get want , can change software use pieces new free programs; know can things. protect rights, need make restrictions forbid anyone deny rights ask surrender rights. restrictions translate certain responsibilities distribute copies software, modify . example, distribute copies program, whether gratis fee, must give recipients rights . must make sure , , receive can get source code. must show terms know rights. protect rights two steps: (1) copyright software, (2) offer license gives legal permission copy, distribute /modify software. Also, author’s protection , want make certain everyone understands warranty free software. software modified someone else passed , want recipients know original, problems introduced others reflect original authors’ reputations. Finally, free program threatened constantly software patents. wish avoid danger redistributors free program individually obtain patent licenses, effect making program proprietary. prevent , made clear patent must licensed everyone’s free use licensed . precise terms conditions copying, distribution modification follow.","code":""},{"path":"https://mcpr.opifex.org/LICENSE.html","id":"terms-and-conditions-for-copying-distribution-and-modification","dir":"","previous_headings":"","what":"TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION","title":"GNU General Public License","text":"0. License applies program work contains notice placed copyright holder saying may distributed terms General Public License. “Program”, , refers program work, “work based Program” means either Program derivative work copyright law: say, work containing Program portion , either verbatim modifications /translated another language. (Hereinafter, translation included without limitation term “modification”.) licensee addressed “”. Activities copying, distribution modification covered License; outside scope. act running Program restricted, output Program covered contents constitute work based Program (independent made running Program). Whether true depends Program . 1. may copy distribute verbatim copies Program’s source code receive , medium, provided conspicuously appropriately publish copy appropriate copyright notice disclaimer warranty; keep intact notices refer License absence warranty; give recipients Program copy License along Program. may charge fee physical act transferring copy, may option offer warranty protection exchange fee. 2. may modify copy copies Program portion , thus forming work based Program, copy distribute modifications work terms Section 1 , provided also meet conditions: ) must cause modified files carry prominent notices stating changed files date change. b) must cause work distribute publish, whole part contains derived Program part thereof, licensed whole charge third parties terms License. c) modified program normally reads commands interactively run, must cause , started running interactive use ordinary way, print display announcement including appropriate copyright notice notice warranty (else, saying provide warranty) users may redistribute program conditions, telling user view copy License. (Exception: Program interactive normally print announcement, work based Program required print announcement.) requirements apply modified work whole. identifiable sections work derived Program, can reasonably considered independent separate works , License, terms, apply sections distribute separate works. distribute sections part whole work based Program, distribution whole must terms License, whose permissions licensees extend entire whole, thus every part regardless wrote . Thus, intent section claim rights contest rights work written entirely ; rather, intent exercise right control distribution derivative collective works based Program. addition, mere aggregation another work based Program Program (work based Program) volume storage distribution medium bring work scope License. 3. may copy distribute Program (work based , Section 2) object code executable form terms Sections 1 2 provided also one following: ) Accompany complete corresponding machine-readable source code, must distributed terms Sections 1 2 medium customarily used software interchange; , b) Accompany written offer, valid least three years, give third party, charge cost physically performing source distribution, complete machine-readable copy corresponding source code, distributed terms Sections 1 2 medium customarily used software interchange; , c) Accompany information received offer distribute corresponding source code. (alternative allowed noncommercial distribution received program object code executable form offer, accord Subsection b .) source code work means preferred form work making modifications . executable work, complete source code means source code modules contains, plus associated interface definition files, plus scripts used control compilation installation executable. However, special exception, source code distributed need include anything normally distributed (either source binary form) major components (compiler, kernel, ) operating system executable runs, unless component accompanies executable. distribution executable object code made offering access copy designated place, offering equivalent access copy source code place counts distribution source code, even though third parties compelled copy source along object code. 4. may copy, modify, sublicense, distribute Program except expressly provided License. attempt otherwise copy, modify, sublicense distribute Program void, automatically terminate rights License. However, parties received copies, rights, License licenses terminated long parties remain full compliance. 5. required accept License, since signed . However, nothing else grants permission modify distribute Program derivative works. actions prohibited law accept License. Therefore, modifying distributing Program (work based Program), indicate acceptance License , terms conditions copying, distributing modifying Program works based . 6. time redistribute Program (work based Program), recipient automatically receives license original licensor copy, distribute modify Program subject terms conditions. may impose restrictions recipients’ exercise rights granted herein. responsible enforcing compliance third parties License. 7. , consequence court judgment allegation patent infringement reason (limited patent issues), conditions imposed (whether court order, agreement otherwise) contradict conditions License, excuse conditions License. distribute satisfy simultaneously obligations License pertinent obligations, consequence may distribute Program . example, patent license permit royalty-free redistribution Program receive copies directly indirectly , way satisfy License refrain entirely distribution Program. portion section held invalid unenforceable particular circumstance, balance section intended apply section whole intended apply circumstances. purpose section induce infringe patents property right claims contest validity claims; section sole purpose protecting integrity free software distribution system, implemented public license practices. Many people made generous contributions wide range software distributed system reliance consistent application system; author/donor decide willing distribute software system licensee impose choice. section intended make thoroughly clear believed consequence rest License. 8. distribution /use Program restricted certain countries either patents copyrighted interfaces, original copyright holder places Program License may add explicit geographical distribution limitation excluding countries, distribution permitted among countries thus excluded. case, License incorporates limitation written body License. 9. Free Software Foundation may publish revised /new versions General Public License time time. new versions similar spirit present version, may differ detail address new problems concerns. version given distinguishing version number. Program specifies version number License applies “later version”, option following terms conditions either version later version published Free Software Foundation. Program specify version number License, may choose version ever published Free Software Foundation. 10. wish incorporate parts Program free programs whose distribution conditions different, write author ask permission. software copyrighted Free Software Foundation, write Free Software Foundation; sometimes make exceptions . decision guided two goals preserving free status derivatives free software promoting sharing reuse software generally.","code":""},{"path":"https://mcpr.opifex.org/LICENSE.html","id":"no-warranty","dir":"","previous_headings":"","what":"NO WARRANTY","title":"GNU General Public License","text":"11. PROGRAM LICENSED FREE CHARGE, WARRANTY PROGRAM, EXTENT PERMITTED APPLICABLE LAW. EXCEPT OTHERWISE STATED WRITING COPYRIGHT HOLDERS /PARTIES PROVIDE PROGRAM “” WITHOUT WARRANTY KIND, EITHER EXPRESSED IMPLIED, INCLUDING, LIMITED , IMPLIED WARRANTIES MERCHANTABILITY FITNESS PARTICULAR PURPOSE. ENTIRE RISK QUALITY PERFORMANCE PROGRAM . PROGRAM PROVE DEFECTIVE, ASSUME COST NECESSARY SERVICING, REPAIR CORRECTION. 12. EVENT UNLESS REQUIRED APPLICABLE LAW AGREED WRITING COPYRIGHT HOLDER, PARTY MAY MODIFY /REDISTRIBUTE PROGRAM PERMITTED , LIABLE DAMAGES, INCLUDING GENERAL, SPECIAL, INCIDENTAL CONSEQUENTIAL DAMAGES ARISING USE INABILITY USE PROGRAM (INCLUDING LIMITED LOSS DATA DATA RENDERED INACCURATE LOSSES SUSTAINED THIRD PARTIES FAILURE PROGRAM OPERATE PROGRAMS), EVEN HOLDER PARTY ADVISED POSSIBILITY DAMAGES. END TERMS CONDITIONS","code":""},{"path":"https://mcpr.opifex.org/LICENSE.html","id":"how-to-apply-these-terms-to-your-new-programs","dir":"","previous_headings":"","what":"How to Apply These Terms to Your New Programs","title":"GNU General Public License","text":"develop new program, want greatest possible use public, best way achieve make free software everyone can redistribute change terms. , attach following notices program. safest attach start source file effectively convey exclusion warranty; file least “copyright” line pointer full notice found. Also add information contact electronic paper mail. program interactive, make output short notice like starts interactive mode: hypothetical commands show w show c show appropriate parts General Public License. course, commands use may called something show w show c; even mouse-clicks menu items–whatever suits program. also get employer (work programmer) school, , sign “copyright disclaimer” program, necessary. sample; alter names: General Public License permit incorporating program proprietary programs. program subroutine library, may consider useful permit linking proprietary applications library. want , use GNU Lesser General Public License instead License.","code":" Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice"},{"path":"https://mcpr.opifex.org/articles/client-integration.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Integrating mcpr with MCP Clients","text":"Model Context Protocol (MCP) allows register custom tools various AI clients. vignette demonstrates create simple MCP server mcpr register popular clients including Claude Code, Cursor, OpenAI GPTs, LangChain.","code":""},{"path":"https://mcpr.opifex.org/articles/client-integration.html","id":"creating-a-simple-math-calculator-server","dir":"Articles","previous_headings":"","what":"Creating a Simple Math Calculator Server","title":"Integrating mcpr with MCP Clients","text":"Let’s create simple MCP server basic calculator tool: Save code file, example calculator_server.R, add code serve end:","code":"# Create a new MCP server math_server <- new_server( name = \"r-calculator\", description = \"A simple calculator that performs basic arithmetic operations\", version = \"1.0.0\" ) # Create a calculator tool calculator <- new_tool( name = \"math_calculator\", description = \"Performs basic arithmetic operations\", input_schema = schema( properties = properties( operation = property_enum( \"Operation\", \"Math operation to perform\", enum = c(\"add\", \"subtract\", \"multiply\", \"divide\"), required = TRUE ), a = property_number(\"First number\", \"First operand\", required = TRUE), b = property_number(\"Second number\", \"Second operand\", required = TRUE) ) ), handler = function(input) { result <- switch(input$operation, \"add\" = input$a + input$b, \"subtract\" = input$a - input$b, \"multiply\" = input$a * input$b, \"divide\" = input$a / input$b ) response_text(paste(\"Result:\", result)) } ) # Add the tool to the server math_server <- add_capability(math_server, calculator) # At the end of calculator_server.R, add: serve_io(math_server)"},{"path":[]},{"path":"https://mcpr.opifex.org/articles/client-integration.html","id":"claude-code","dir":"Articles","previous_headings":"Registering with MCP Clients","what":"Claude Code","title":"Integrating mcpr with MCP Clients","text":"Claude Code supports registering MCP tools using claude mcp command: Claude automatically discover use registered MCP server’s capabilities.","code":"# Register the MCP server claude mcp add r-calculator -- Rscript /path/to/calculator_server.R # List registered MCP servers claude mcp list # Use the registered tool claude \"Add 2 to 40\""},{"path":"https://mcpr.opifex.org/articles/client-integration.html","id":"cursor","dir":"Articles","previous_headings":"Registering with MCP Clients","what":"Cursor","title":"Integrating mcpr with MCP Clients","text":"Cursor supports registering MCP tools via configuration: Open Cursor settings Navigate “Tools” section Name: r-calculator Command: Rscript /path//calculator_server.R Save settings Now ask Cursor perform calculations, access MCP tool.","code":""},{"path":"https://mcpr.opifex.org/articles/client-integration.html","id":"openai-gpt","dir":"Articles","previous_headings":"Registering with MCP Clients","what":"OpenAI GPT","title":"Integrating mcpr with MCP Clients","text":"OpenAI GPTs, ’ll need run MCP server HTTP: register custom GPT: Create custom GPT GPT Builder “Configure” tab, add “Action” Set Authentication “None” Set API URL server (e.g., http://localhost:8080) Import schema URL: http://localhost:8080/openapi.json Save GPT custom GPT now able use MCP calculator.","code":"# Modify your calculator_server.R to use HTTP instead of IO serve_http(math_server, port = 8080)"},{"path":"https://mcpr.opifex.org/articles/client-integration.html","id":"langchain","dir":"Articles","previous_headings":"Registering with MCP Clients","what":"LangChain","title":"Integrating mcpr with MCP Clients","text":"LangChain provides adapters specifically MCP integration: Alternatively, can use process-based approach:","code":"from langchain_mcp_adapters.client import MultiServerMCPClient from langchain.agents import create_tool_calling_agent from langchain_openai import ChatOpenAI # Connect to your R-based MCP server # You need to run your server with serve_http for this approach mcp_client = MultiServerMCPClient( servers=[{\"url\": \"http://localhost:8080\"}] ) # Get tools from the MCP server tools = mcp_client.get_tools() # Create a LangChain agent with the MCP tools llm = ChatOpenAI(model=\"gpt-4o\") agent = create_tool_calling_agent(llm, tools) # Use the agent response = agent.invoke({\"input\": \"What is 10 multiplied by 5?\"}) print(response[\"output\"]) from langchain_mcp_adapters.client import MultiServerMCPClient from langchain.agents import create_tool_calling_agent from langchain_openai import ChatOpenAI # Connect to your R-based MCP server using process mcp_client = MultiServerMCPClient( servers=[{\"command\": [\"Rscript\", \"/path/to/calculator_server.R\"]}] ) # The rest is the same as above tools = mcp_client.get_tools() llm = ChatOpenAI(model=\"gpt-4o\") agent = create_tool_calling_agent(llm, tools)"},{"path":"https://mcpr.opifex.org/articles/client-integration.html","id":"conclusion","dir":"Articles","previous_headings":"","what":"Conclusion","title":"Integrating mcpr with MCP Clients","text":"mcpr, can create MCP servers register seamlessly various AI clients. enables AI tools leverage R’s statistical data processing capabilities. advanced usage, consider: Adding multiple tools server Creating resources serve data Implementing prompts text generation Handling complex data types tools See vignettes function documentation details advanced features.","code":""},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Using the MCP Client","text":"mcpr package allows create Model Context Protocol (MCP) servers R also connect existing MCP servers client. vignette guide using MCP client interact servers.","code":""},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"creating-an-mcp-client","dir":"Articles","previous_headings":"","what":"Creating an MCP Client","title":"Using the MCP Client","text":"client functionality allows connect MCP server, whether ’s running locally separate process, remotely via HTTP. ’s create client:","code":""},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"connecting-to-a-local-server-process","dir":"Articles","previous_headings":"Creating an MCP Client","what":"Connecting to a Local Server Process","title":"Using the MCP Client","text":"can connect server running separate process. useful testing need communicate local MCP implementation:","code":"# Create a client that connects to a local process client <- new_client( \"Rscript\", # Command to run \"path/to/your/server.R\", # Path to the server script name = \"calculator\", # Optional name for the server version = \"1.0.0\" # Optional version )"},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"connecting-to-an-http-server","dir":"Articles","previous_headings":"Creating an MCP Client","what":"Connecting to an HTTP Server","title":"Using the MCP Client","text":"can also connect MCP server running HTTP:","code":"# Create a client that connects to an HTTP server http_client <- new_client(\"Rscript\", \"path/to/your/server.R\")"},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"basic-client-operations","dir":"Articles","previous_headings":"","what":"Basic Client Operations","title":"Using the MCP Client","text":"created client, can interact server using various client methods:","code":""},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"initializing-the-connection","dir":"Articles","previous_headings":"Basic Client Operations","what":"Initializing the Connection","title":"Using the MCP Client","text":"’s good practice initialize connection first:","code":"# Initialize the connection res <- initialize(client) print(res)"},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"listing-available-tools","dir":"Articles","previous_headings":"Basic Client Operations","what":"Listing Available Tools","title":"Using the MCP Client","text":"can list tools server provides:","code":"# Get a list of available tools tools <- tools_list(client) print(tools)"},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"calling-a-tool","dir":"Articles","previous_headings":"Basic Client Operations","what":"Calling a Tool","title":"Using the MCP Client","text":"know tools available, can call specific parameters:","code":"# Call the math_calculator tool result <- tools_call( client, list( name = \"math_calculator\", params = list( name = \"add\", arguments = list( a = 10, b = 5 ) ) ) ) print(result)"},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"working-with-prompts","dir":"Articles","previous_headings":"Basic Client Operations","what":"Working with Prompts","title":"Using the MCP Client","text":"server prompts available, can list use :","code":"# List available prompts prompts <- prompts_list(client) print(prompts) # Get a specific prompt prompt <- prompts_get(client, \"example-prompt\") print(prompt)"},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"working-with-resources","dir":"Articles","previous_headings":"Basic Client Operations","what":"Working with Resources","title":"Using the MCP Client","text":"can also access resources provided server:","code":"# List available resources resources <- resources_list(client) print(resources) # Read a specific resource resource_content <- resources_read(client, \"example-resource\") print(resource_content)"},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"complete-example","dir":"Articles","previous_headings":"","what":"Complete Example","title":"Using the MCP Client","text":"’s complete example demonstrates connecting calculator server performing operations:","code":"# Create a client client <- new_client( \"Rscript\", system.file(\"examples/calculator/server.R\", package = \"mcpr\"), name = \"calculator\", version = \"1.0.0\" ) # Initialize the connection initialize(client) # List available tools tools <- tools_list(client) print(tools) # Call the math_calculator tool with different operations add_result <- tools_call( client, name = \"math_calculator\", params = list( operation = \"add\", a = 10, b = 5 ) ) print(add_result) multiply_result <- tools_call( client, name = \"math_calculator\", params = list( operation = \"multiply\", a = 10, b = 5 ) ) print(multiply_result)"},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"practical-use-cases","dir":"Articles","previous_headings":"","what":"Practical Use Cases","title":"Using the MCP Client","text":"MCP clients can used various scenarios: Integration External AI Services: Connect AI models services expose MCP interface Microservices Architecture: Communicate different R services using MCP protocol Testing MCP Servers: Verify MCP server implementations work correctly Building UI Applications: Create user interfaces interact MCP servers provide functionality","code":""},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"conclusion","dir":"Articles","previous_headings":"","what":"Conclusion","title":"Using the MCP Client","text":"MCP client functionality mcpr package provides flexible way interact MCP servers R. Whether ’re building applications consume AI capabilities creating distributed systems communicate via MCP, client interface makes easy work protocol. advanced usage, check function documentation vignettes.","code":""},{"path":"https://mcpr.opifex.org/articles/get-started.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Getting Started with mcpr","text":"mcpr package allows create Model Context Protocol (MCP) servers R. vignette guide building simple MCP server basic addition tool.","code":""},{"path":"https://mcpr.opifex.org/articles/get-started.html","id":"creating-a-simple-mcp-server","dir":"Articles","previous_headings":"","what":"Creating a Simple MCP Server","title":"Getting Started with mcpr","text":"Let’s create simple MCP server can add two numbers:","code":"# Create a new MCP server mcp_server <- new_server( name = \"Simple Adder\", description = \"A basic MCP server that adds two numbers\", version = \"1.0.0\" ) # Create a simple addition tool add_tool <- new_tool( name = \"add\", description = \"Adds two numbers together\", input_schema = schema( properties = list( a = property_number(\"First number\", \"First number to add\", required = TRUE), b = property_number(\"Second number\", \"Second number to add\", required = TRUE) ) ), handler = function(input) { result <- input$a + input$b response_text(paste(\"The sum is:\", result)) } ) # Add the tool to the server mcp_server <- add_capability(mcp_server, add_tool)"},{"path":"https://mcpr.opifex.org/articles/get-started.html","id":"using-standard-inputoutput","dir":"Articles","previous_headings":"","what":"Using Standard Input/Output","title":"Getting Started with mcpr","text":"simplest way interact MCP server standard input/output using serve_io function: run serve_io(mcp_server), R session wait input JSON-RPC 2.0 format. can communicate server sending JSON-RPC requests.","code":"# Start the server using standard input/output serve_io(mcp_server)"},{"path":"https://mcpr.opifex.org/articles/get-started.html","id":"testing-the-server","dir":"Articles","previous_headings":"","what":"Testing the Server","title":"Getting Started with mcpr","text":"test server, can run code R script interact using command line. example: Save code file named mcp_adder.R Run command line: Rscript mcp_adder.R Send JSON-RPC request standard input: server respond :","code":"{\"jsonrpc\": \"2.0\", \"id\": 123, \"method\": \"tools/call\", \"params\": {\"name\": \"add\", \"arguments\": {\"a\": 15, \"b\": 27}}} {\"jsonrpc\": \"2.0\", \"id\": 123, \"result\": {\"content\": [{\"type\": \"text\", \"text\": \"The sum is: 42\"}]}}"},{"path":"https://mcpr.opifex.org/articles/get-started.html","id":"next-steps","dir":"Articles","previous_headings":"","what":"Next Steps","title":"Getting Started with mcpr","text":"’re comfortable basics, can: Add complex tools different operations Create resources serve data Implement prompts text generation See vignettes function documentation details advanced features.","code":""},{"path":"https://mcpr.opifex.org/articles/practical-examples.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Practical MCP Examples with R","text":"Model Context Protocol (MCP) enables AI models interact R code. vignette showcases several practical examples MCP tools leverage R’s statistical data manipulation capabilities.","code":""},{"path":"https://mcpr.opifex.org/articles/practical-examples.html","id":"example-1-statistical-analysis-tool","dir":"Articles","previous_headings":"","what":"Example 1: Statistical Analysis Tool","title":"Practical MCP Examples with R","text":"example creates MCP tool performs basic statistical analysis numeric data:","code":"# Create a statistical analysis MCP server stats_server <- new_server( name = \"r-statistics\", description = \"Statistical analysis tools using R\", version = \"1.0.0\" ) # Create a summary statistics tool summary_stats <- new_tool( name = \"summary_statistics\", description = \"Calculate summary statistics for a numeric vector\", input_schema = schema( properties = properties( data = property_array( \"Data\", \"Numeric vector to analyze\", items = property_number(\"Value\", \"A numeric value\"), required = TRUE ), include_quantiles = property_boolean( \"Include Quantiles\", \"Whether to include quantiles in the results\", default = FALSE ) ) ), handler = function(input) { # Convert input to numeric vector data <- unlist(input$data) # Calculate basic statistics stats <- list( n = length(data), mean = mean(data, na.rm = TRUE), median = median(data, na.rm = TRUE), sd = sd(data, na.rm = TRUE), min = min(data, na.rm = TRUE), max = max(data, na.rm = TRUE) ) # Add quantiles if requested if (input$include_quantiles) { stats$quantiles <- as.list(quantile(data, probs = c(0.25, 0.5, 0.75), na.rm = TRUE)) } # Format the results as text result_text <- paste0( \"Summary Statistics:\\n\", \"- n: \", stats$n, \"\\n\", \"- Mean: \", round(stats$mean, 4), \"\\n\", \"- Median: \", round(stats$median, 4), \"\\n\", \"- Standard Deviation: \", round(stats$sd, 4), \"\\n\", \"- Min: \", round(stats$min, 4), \"\\n\", \"- Max: \", round(stats$max, 4) ) if (input$include_quantiles) { result_text <- paste0( result_text, \"\\n\", \"- 25th Percentile: \", round(stats$quantiles[[1]], 4), \"\\n\", \"- 50th Percentile: \", round(stats$quantiles[[2]], 4), \"\\n\", \"- 75th Percentile: \", round(stats$quantiles[[3]], 4) ) } response_text(result_text) } ) # Add the tool to the server stats_server <- add_capability(stats_server, summary_stats)"},{"path":"https://mcpr.opifex.org/articles/practical-examples.html","id":"example-2-data-visualization-resource","dir":"Articles","previous_headings":"","what":"Example 2: Data Visualization Resource","title":"Practical MCP Examples with R","text":"example creates MCP resource generates visualizations data:","code":"# Load required packages library(ggplot2) # Create visualization server viz_server <- new_server( name = \"r-visualizations\", description = \"Data visualization tools using R\", version = \"1.0.0\" ) # Create a scatter plot tool scatter_plot <- new_tool( name = \"scatter_plot\", description = \"Create a scatter plot from x and y coordinates\", input_schema = schema( properties = properties( x = property_array( \"X values\", \"X-axis coordinates\", items = property_number(\"X value\", \"A numeric value\"), required = TRUE ), y = property_array( \"Y values\", \"Y-axis coordinates\", items = property_number(\"Y value\", \"A numeric value\"), required = TRUE ), title = property_string( \"Plot title\", \"Title for the plot\", default = \"Scatter Plot\" ), x_label = property_string( \"X-axis label\", \"Label for the x-axis\", default = \"X\" ), y_label = property_string( \"Y-axis label\", \"Label for the y-axis\", default = \"Y\" ) ) ), handler = function(input) { # Check that x and y have the same length x <- unlist(input$x) y <- unlist(input$y) if (length(x) != length(y)) { return(response_error(\"X and Y arrays must have the same length\")) } # Create a data frame for ggplot plot_data <- data.frame(x = x, y = y) # Create a temporary file for the plot # Note: In a production environment, consider file cleanup strategies # that don't risk deleting files before clients can access them temp_file <- tempfile(fileext = \".png\") # Create the plot using ggplot2 p <- ggplot(plot_data, aes(x = x, y = y)) + geom_point(color = \"steelblue\", size = 3) + labs( title = input$title, x = input$x_label, y = input$y_label ) + theme_minimal() # Save the plot to the temporary file ggsave(temp_file, p, width = 8, height = 6, dpi = 100) # Return the image # The application should handle cleanup of temporary files # based on its specific file management strategy response_image(temp_file) } ) # Add the tool to the server viz_server <- add_capability(viz_server, scatter_plot)"},{"path":"https://mcpr.opifex.org/articles/practical-examples.html","id":"example-3-natural-language-processing","dir":"Articles","previous_headings":"","what":"Example 3: Natural Language Processing","title":"Practical MCP Examples with R","text":"example demonstrates create MCP tool text analysis:","code":"# Create an NLP server nlp_server <- new_server( name = \"r-text-analysis\", description = \"Text analysis tools using R\", version = \"1.0.0\" ) # Create a text summary tool text_analyzer <- new_tool( name = \"text_analyzer\", description = \"Analyze text to extract basic metrics\", input_schema = schema( properties = properties( text = property_string( \"Text\", \"Text content to analyze\", required = TRUE ) ) ), handler = function(input) { # Extract text from input text <- input$text # Calculate basic text metrics char_count <- nchar(text) word_count <- length(unlist(strsplit(text, \"\\\\s+\"))) sentence_count <- length(unlist(strsplit(text, \"[.!?]\\\\s*\"))) # Calculate word frequencies words <- tolower(unlist(strsplit(text, \"\\\\W+\"))) words <- words[words != \"\"] word_freq <- sort(table(words), decreasing = TRUE) # Get top 5 words top_words <- head(word_freq, 5) top_words_text <- paste(names(top_words), \"(\", top_words, \")\", collapse = \", \") # Format the results result <- paste0( \"Text Analysis:\\n\", \"- Character count: \", char_count, \"\\n\", \"- Word count: \", word_count, \"\\n\", \"- Sentence count: \", sentence_count, \"\\n\", \"- Unique words: \", length(word_freq), \"\\n\", \"- Top 5 words: \", top_words_text ) response_text(result) } ) # Add the tool to the server nlp_server <- add_capability(nlp_server, text_analyzer)"},{"path":"https://mcpr.opifex.org/articles/practical-examples.html","id":"example-4-time-series-forecasting","dir":"Articles","previous_headings":"","what":"Example 4: Time Series Forecasting","title":"Practical MCP Examples with R","text":"example creates MCP tool simple time series forecasting:","code":"# Create a forecasting server forecast_server <- new_server( name = \"r-forecasting\", description = \"Time series forecasting tools using R\", version = \"1.0.0\" ) # Create a simple forecasting tool simple_forecast <- new_tool( name = \"simple_forecast\", description = \"Forecast future values based on historical time series data\", input_schema = schema( properties = properties( values = property_array( \"Historical values\", \"Historical time series values\", items = property_number(\"Value\", \"A numeric value\"), required = TRUE ), periods = property_number( \"Forecast periods\", \"Number of periods to forecast\", default = 5, minimum = 1, maximum = 50 ), method = property_enum( \"Forecast method\", \"Method to use for forecasting\", enum = c(\"mean\", \"naive\", \"drift\", \"exponential\"), default = \"exponential\" ) ) ), handler = function(input) { # Extract inputs values <- unlist(input$values) periods <- input$periods method <- input$method # Apply the selected forecasting method forecast_values <- switch( method, \"mean\" = { rep(mean(values), periods) }, \"naive\" = { rep(tail(values, 1), periods) }, \"drift\" = { last_value <- tail(values, 1) avg_change <- (last_value - values[1]) / (length(values) - 1) last_value + (1:periods) * avg_change }, \"exponential\" = { # Simple exponential smoothing alpha <- 0.3 # smoothing parameter level <- values[1] for (i in 2:length(values)) { level <- alpha * values[i] + (1 - alpha) * level } rep(level, periods) } ) # Format the results forecast_text <- paste( \"Forecast for next\", periods, \"periods using\", method, \"method:\", paste(round(forecast_values, 2), collapse = \", \") ) # Create a plot of historical + forecast values using ggplot2 # Note: In a production environment, consider file cleanup strategies # that don't risk deleting files before clients can access them temp_file <- tempfile(fileext = \".png\") # Prepare data for ggplot # Create a data frame with historical and forecast data n_hist <- length(values) n_forecast <- length(forecast_values) plot_data <- data.frame( time = 1:(n_hist + n_forecast), value = c(values, forecast_values), type = c(rep(\"Historical\", n_hist), rep(\"Forecast\", n_forecast)) ) # Create the plot using ggplot2 p <- ggplot(plot_data, aes(x = time, y = value, color = type, linetype = type)) + geom_line(size = 1) + scale_color_manual(values = c(\"Historical\" = \"black\", \"Forecast\" = \"blue\")) + scale_linetype_manual(values = c(\"Historical\" = \"solid\", \"Forecast\" = \"dashed\")) + labs( title = paste(\"Time Series Forecast (\", method, \")\"), x = \"Time Period\", y = \"Value\", color = \"Data Type\", linetype = \"Data Type\" ) + theme_minimal() + theme(legend.position = \"top\") # Save the plot to the temporary file ggsave(temp_file, p, width = 8, height = 6, dpi = 100) # Return both text and image # The application should handle cleanup of temporary files # based on its specific file management strategy response(list( response_text(forecast_text), response_image(temp_file) )) } ) # Add the tool to the server forecast_server <- add_capability(forecast_server, simple_forecast)"},{"path":"https://mcpr.opifex.org/articles/practical-examples.html","id":"example-5-machine-learning-classification","dir":"Articles","previous_headings":"","what":"Example 5: Machine Learning Classification","title":"Practical MCP Examples with R","text":"example demonstrates simple machine learning classification tool:","code":"# Create an ML server ml_server <- new_server( name = \"r-machine-learning\", description = \"Machine learning tools using R\", version = \"1.0.0\" ) # Create a simple classifier tool simple_classifier <- new_tool( name = \"simple_classifier\", description = \"Train a simple classifier and make predictions\", input_schema = schema( properties = properties( features = property_array( \"Training features\", \"Features for training (list of feature vectors)\", items = property_array( \"Feature vector\", \"Vector of features for a single instance\", items = property_number(\"Feature\", \"Feature value\") ), required = TRUE ), labels = property_array( \"Training labels\", \"Labels for training data (0 or 1)\", items = property_number( \"Label\", \"Class label (0 or 1)\" ), required = TRUE ), test_features = property_array( \"Test features\", \"Features for prediction\", items = property_array( \"Feature vector\", \"Vector of features for a single instance\", items = property_number(\"Feature\", \"Feature value\") ), required = TRUE ), method = property_enum( \"Classification method\", \"Method to use for classification\", enum = c(\"logistic\", \"lda\"), default = \"logistic\" ) ) ), handler = function(input) { # Process input data features <- lapply(input$features, unlist) labels <- unlist(input$labels) test_features <- lapply(input$test_features, unlist) method <- input$method # Check that all feature vectors have the same length feature_lengths <- sapply(features, length) if (length(unique(feature_lengths)) != 1) { return(response_error(\"All feature vectors must have the same length\")) } test_feature_lengths <- sapply(test_features, length) if (any(test_feature_lengths != feature_lengths[1])) { return(response_error(\"Test features must have the same dimensions as training features\")) } # Create a training data frame train_df <- as.data.frame(do.call(rbind, features)) colnames(train_df) <- paste0(\"X\", 1:ncol(train_df)) train_df$y <- as.factor(labels) # Create a test data frame test_df <- as.data.frame(do.call(rbind, test_features)) colnames(test_df) <- paste0(\"X\", 1:ncol(test_df)) # Train a model based on the selected method if (method == \"logistic\") { formula <- as.formula(paste(\"y ~\", paste(colnames(train_df)[colnames(train_df) != \"y\"], collapse = \" + \"))) model <- glm(formula, data = train_df, family = \"binomial\") # Make predictions pred_probs <- predict(model, test_df, type = \"response\") predictions <- ifelse(pred_probs > 0.5, 1, 0) } else if (method == \"lda\") { # Use simple implementation to avoid additional dependencies # Calculate means for each class means_class0 <- colMeans(train_df[train_df$y == 0, colnames(train_df) != \"y\", drop = FALSE]) means_class1 <- colMeans(train_df[train_df$y == 1, colnames(train_df) != \"y\", drop = FALSE]) # Calculate pooled covariance matrix n0 <- sum(train_df$y == 0) n1 <- sum(train_df$y == 1) # Make predictions using distance to means predictions <- numeric(nrow(test_df)) for (i in 1:nrow(test_df)) { dist0 <- sum((as.numeric(test_df[i,]) - means_class0)^2) dist1 <- sum((as.numeric(test_df[i,]) - means_class1)^2) predictions[i] <- ifelse(dist0 < dist1, 0, 1) } } # Format results result_text <- paste( \"Classification results using\", method, \"method:\\n\", \"Predictions:\", paste(predictions, collapse = \", \") ) response_text(result_text) } ) # Add the tool to the server ml_server <- add_capability(ml_server, simple_classifier)"},{"path":"https://mcpr.opifex.org/articles/practical-examples.html","id":"running-these-examples","dir":"Articles","previous_headings":"","what":"Running These Examples","title":"Practical MCP Examples with R","text":"run examples, save code R script add appropriate serve_io() serve_http() call end: follow client integration instructions “Integrating mcpr MCP Clients” vignette.","code":"# For CLI-based tools (Claude Code, Cursor, etc.) serve_io(your_server) # For HTTP-based tools (OpenAI, LangChain, etc.) serve_http(your_server, port = 8080)"},{"path":"https://mcpr.opifex.org/articles/practical-examples.html","id":"conclusion","dir":"Articles","previous_headings":"","what":"Conclusion","title":"Practical MCP Examples with R","text":"examples demonstrate R’s powerful statistical, visualization, machine learning capabilities can exposed AI systems Model Context Protocol. creating specialized MCP tools, can enhance AI applications R’s unique strengths. advanced usage, consider: Combining multiple tools single server Adding error handling input validation Creating complex responses multiple content types Leveraging R packages specialized domains See package documentation details advanced features.","code":""},{"path":"https://mcpr.opifex.org/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"John Coene. Author, maintainer. Opifex. Copyright holder, funder.","code":""},{"path":"https://mcpr.opifex.org/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Coene J (2025). mcpr: Model Context Protocol R. R package version 0.0.1.9000, https://mcpr.opifex.org/.","code":"@Manual{, title = {mcpr: Model Context Protocol for R}, author = {John Coene}, year = {2025}, note = {R package version 0.0.1.9000}, url = {https://mcpr.opifex.org/}, }"},{"path":"https://mcpr.opifex.org/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Model Context Protocol for R","text":"can install mcpr GitHub using pak package:","code":"pak::pkg_install(\"devOpifex/mcpr\")"},{"path":[]},{"path":"https://mcpr.opifex.org/index.html","id":"server","dir":"","previous_headings":"Basic Usage","what":"Server","title":"Model Context Protocol for R","text":"’s simple example creates MCP server calculator tool: can return multiple responses returning list response objects: can also serve via HTTP transport serve_http: See Get Started guide information.","code":"library(mcpr) calculator <- new_tool( name = \"calculator\", description = \"Performs basic arithmetic operations\", input_schema = schema( properties = properties( operation = property_enum( \"Operation\", \"Math operation to perform\", values = c(\"add\", \"subtract\", \"multiply\", \"divide\"), required = TRUE ), a = property_number(\"First number\", \"First operand\", required = TRUE), b = property_number(\"Second number\", \"Second operand\", required = TRUE) ) ), handler = function(params) { result <- switch(params$operation, \"add\" = params$a + params$b, \"subtract\" = params$a - params$b, \"multiply\" = params$a * params$b, \"divide\" = params$a / params$b ) response_text(result) } ) mcp <- new_mcp( name = \"R Calculator Server\", description = \"A simple calculator server implemented in R\", version = \"1.0.0\" ) mcp <- add_capability(mcp, calculator) serve_io(mcp) response( response_text(\"Hello, world!\"), response_image(system.file(\"extdata/logo.png\", package = \"mcpr\")), response_audio(system.file(\"extdata/sound.mp3\", package = \"mcpr\")), response_video(system.file(\"extdata/video.mp4\", package = \"mcpr\")), response_file(system.file(\"extdata/file.txt\", package = \"mcpr\")), response_resource(system.file(\"extdata/resource.json\", package = \"mcpr\")) ) # Serve via HTTP on port 3000 serve_http(mcp, port = 3000)"},{"path":"https://mcpr.opifex.org/index.html","id":"client","dir":"","previous_headings":"Basic Usage","what":"Client","title":"Model Context Protocol for R","text":"’s simple example using client interact MCP server:","code":"library(mcpr) # Create a client that connects to an MCP server # For HTTP transport client <- new_client_http( \"http://localhost:8080\", name = \"calculator\", version = \"1.0.0\" ) # Or for standard IO transport # client <- new_client_io( # \"Rscript\", # \"/path/to/server.R\", # name = \"calculator\", # version = \"1.0.0\" # ) # List available tools tools <- tools_list(client) print(tools) # Call a tool result <- tools_call( client, params = list( name = \"calculator\", arguments = list( operation = \"add\", a = 5, b = 3 ) ), id = 1L ) print(result) # List available prompts prompts <- prompts_list(client) print(prompts) # List available resources resources <- resources_list(client) print(resources) # Read a resource resource_content <- resources_read( client, params = list( name = \"example-resource\" ) ) print(resource_content)"},{"path":"https://mcpr.opifex.org/index.html","id":"ellmer-integration","dir":"","previous_headings":"","what":"ellmer integration","title":"Model Context Protocol for R","text":"Use register_mcpr_tools function convert MCPR tools ellmer tools register ellmer chat session. Note integration standard since ellmer currently support MCPs. re-recreate tools obtained via tools_list ellmer tools call tools_call execute tool. tools currently namespaced.","code":"# Create an MCPR client connected to the calculator server client <- new_client_io( \"Rscript\", \"path/to/server.R\", name = \"calculator\", version = \"1.0.0\" ) # Create a Claude chat session with ellmer chat <- ellmer::chat_anthropic() ## Convert MCPR tools to ellmer tools and register them with the chat chat <- register_mcpr_tools(chat, client) ## Try using the tools in a chat chat$chat( \"Subtract 2 from 44\" )"},{"path":[]},{"path":"https://mcpr.opifex.org/index.html","id":"claude-code-integration","dir":"","previous_headings":"Using mcpr","what":"Claude Code Integration","title":"Model Context Protocol for R","text":"use MCP server Claude Code, see documentation","code":"claude mcp add r-calculator -- Rscript /path/to/calculator_server.R"},{"path":"https://mcpr.opifex.org/index.html","id":"cursor-integration","dir":"","previous_headings":"Using mcpr","what":"Cursor Integration","title":"Model Context Protocol for R","text":"integrate Cursor see documentation","code":"{ \"customCommands\": { \"r-calculator\": { \"command\": \"Rscript 'path/to/calculator_server.R'\" } } }"},{"path":"https://mcpr.opifex.org/index.html","id":"vs-code-agent-mode-integration","dir":"","previous_headings":"Using mcpr","what":"VS Code Agent Mode Integration","title":"Model Context Protocol for R","text":"integrate VS Code Agent mode see documentation integrations docs","code":"\"mcp\": { \"servers\": { \"my-mcp-server-calculator\": { \"type\": \"stdio\", \"command\": \"Rscript\", \"args\": [ \"path/to/calculator_server.R\" ] } } }"},{"path":"https://mcpr.opifex.org/reference/JSONRPC_PARSE_ERROR.html","id":null,"dir":"Reference","previous_headings":"","what":"JSON-RPC 2.0 Standard Error Codes — JSONRPC_PARSE_ERROR","title":"JSON-RPC 2.0 Standard Error Codes — JSONRPC_PARSE_ERROR","text":"JSON-RPC 2.0 Standard Error Codes","code":""},{"path":"https://mcpr.opifex.org/reference/JSONRPC_PARSE_ERROR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"JSON-RPC 2.0 Standard Error Codes — JSONRPC_PARSE_ERROR","text":"","code":"JSONRPC_PARSE_ERROR"},{"path":"https://mcpr.opifex.org/reference/JSONRPC_PARSE_ERROR.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"JSON-RPC 2.0 Standard Error Codes — JSONRPC_PARSE_ERROR","text":"object class numeric length 1.","code":""},{"path":"https://mcpr.opifex.org/reference/add_capability.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a capability to an MCP object — add_capability","title":"Add a capability to an MCP object — add_capability","text":"Add capability MCP object","code":""},{"path":"https://mcpr.opifex.org/reference/add_capability.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a capability to an MCP object — add_capability","text":"","code":"add_capability(mcp, capability)"},{"path":"https://mcpr.opifex.org/reference/add_capability.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a capability to an MCP object — add_capability","text":"mcp MCP object capability capability object","code":""},{"path":"https://mcpr.opifex.org/reference/add_capability.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a capability to an MCP object — add_capability","text":"MCP object capability added","code":""},{"path":"https://mcpr.opifex.org/reference/client.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new mcp IO — client","title":"Create a new mcp IO — client","text":"Create new mcp IO","code":""},{"path":"https://mcpr.opifex.org/reference/client.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new mcp IO — client","text":"","code":"new_client_io(command, args = character(), name, version = \"1.0.0\") new_client_http(endpoint, name, version = \"1.0.0\")"},{"path":"https://mcpr.opifex.org/reference/client.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new mcp IO — client","text":"command command run args Arguments pass command name name client version version client endpoint endpoint connect ","code":""},{"path":"https://mcpr.opifex.org/reference/client.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new mcp IO — client","text":"new mcp client","code":""},{"path":"https://mcpr.opifex.org/reference/create_ellmer_handler.html","id":null,"dir":"Reference","previous_headings":"","what":"Create an ellmer handler function for an MCP tool — create_ellmer_handler","title":"Create an ellmer handler function for an MCP tool — create_ellmer_handler","text":"Create ellmer handler function MCP tool","code":""},{"path":"https://mcpr.opifex.org/reference/create_ellmer_handler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create an ellmer handler function for an MCP tool — create_ellmer_handler","text":"","code":"create_ellmer_handler(client, tool_name, input_schema)"},{"path":"https://mcpr.opifex.org/reference/create_ellmer_handler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create an ellmer handler function for an MCP tool — create_ellmer_handler","text":"client mcpr client tool_name name MCP tool input_schema tool's input schema","code":""},{"path":"https://mcpr.opifex.org/reference/create_ellmer_handler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create an ellmer handler function for an MCP tool — create_ellmer_handler","text":"function can used ellmer tool handler","code":""},{"path":"https://mcpr.opifex.org/reference/create_ellmer_type.html","id":null,"dir":"Reference","previous_headings":"","what":"Create an ellmer type function for a specific MCP property — create_ellmer_type","title":"Create an ellmer type function for a specific MCP property — create_ellmer_type","text":"Create ellmer type function specific MCP property","code":""},{"path":"https://mcpr.opifex.org/reference/create_ellmer_type.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create an ellmer type function for a specific MCP property — create_ellmer_type","text":"","code":"create_ellmer_type(prop)"},{"path":"https://mcpr.opifex.org/reference/create_ellmer_type.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create an ellmer type function for a specific MCP property — create_ellmer_type","text":"prop MCP property","code":""},{"path":"https://mcpr.opifex.org/reference/create_ellmer_type.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create an ellmer type function for a specific MCP property — create_ellmer_type","text":"ellmer type function call","code":""},{"path":"https://mcpr.opifex.org/reference/create_ellmer_types.html","id":null,"dir":"Reference","previous_headings":"","what":"Create ellmer type functions from MCP schema properties — create_ellmer_types","title":"Create ellmer type functions from MCP schema properties — create_ellmer_types","text":"Create ellmer type functions MCP schema properties","code":""},{"path":"https://mcpr.opifex.org/reference/create_ellmer_types.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create ellmer type functions from MCP schema properties — create_ellmer_types","text":"","code":"create_ellmer_types(schema)"},{"path":"https://mcpr.opifex.org/reference/create_ellmer_types.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create ellmer type functions from MCP schema properties — create_ellmer_types","text":"schema MCP schema object","code":""},{"path":"https://mcpr.opifex.org/reference/create_ellmer_types.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create ellmer type functions from MCP schema properties — create_ellmer_types","text":"list ellmer type function calls property","code":""},{"path":"https://mcpr.opifex.org/reference/create_error.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a JSON-RPC 2.0 error response — create_error","title":"Create a JSON-RPC 2.0 error response — create_error","text":"Create JSON-RPC 2.0 error response","code":""},{"path":"https://mcpr.opifex.org/reference/create_error.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a JSON-RPC 2.0 error response — create_error","text":"","code":"create_error(code, message, data = NULL, id = NULL)"},{"path":"https://mcpr.opifex.org/reference/create_error.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a JSON-RPC 2.0 error response — create_error","text":"code Error code message Error message data Optional error data id Request identifier","code":""},{"path":"https://mcpr.opifex.org/reference/create_error.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a JSON-RPC 2.0 error response — create_error","text":"structured JSON-RPC 2.0 error response","code":""},{"path":"https://mcpr.opifex.org/reference/create_response.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a JSON-RPC 2.0 success response — create_response","title":"Create a JSON-RPC 2.0 success response — create_response","text":"Create JSON-RPC 2.0 success response","code":""},{"path":"https://mcpr.opifex.org/reference/create_response.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a JSON-RPC 2.0 success response — create_response","text":"","code":"create_response(result, id = NULL)"},{"path":"https://mcpr.opifex.org/reference/create_response.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a JSON-RPC 2.0 success response — create_response","text":"result Result data id Request identifier","code":""},{"path":"https://mcpr.opifex.org/reference/create_response.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a JSON-RPC 2.0 success response — create_response","text":"structured JSON-RPC 2.0 success response","code":""},{"path":"https://mcpr.opifex.org/reference/extract_mcp_result.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract and convert an MCP result to ellmer-compatible format — extract_mcp_result","title":"Extract and convert an MCP result to ellmer-compatible format — extract_mcp_result","text":"Extract convert MCP result ellmer-compatible format","code":""},{"path":"https://mcpr.opifex.org/reference/extract_mcp_result.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract and convert an MCP result to ellmer-compatible format — extract_mcp_result","text":"","code":"extract_mcp_result(result)"},{"path":"https://mcpr.opifex.org/reference/extract_mcp_result.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract and convert an MCP result to ellmer-compatible format — extract_mcp_result","text":"result MCP result object","code":""},{"path":"https://mcpr.opifex.org/reference/extract_mcp_result.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract and convert an MCP result to ellmer-compatible format — extract_mcp_result","text":"value ellmer-compatible format","code":""},{"path":"https://mcpr.opifex.org/reference/from_json.html","id":null,"dir":"Reference","previous_headings":"","what":"Parse JSON to an R object — from_json","title":"Parse JSON to an R object — from_json","text":"Parse JSON R object","code":""},{"path":"https://mcpr.opifex.org/reference/from_json.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Parse JSON to an R object — from_json","text":"","code":"from_json(json, ...)"},{"path":"https://mcpr.opifex.org/reference/from_json.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Parse JSON to an R object — from_json","text":"json JSON string parse ... Additional arguments passed yyjsonr::read_json_str","code":""},{"path":"https://mcpr.opifex.org/reference/from_json.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Parse JSON to an R object — from_json","text":"R object","code":""},{"path":"https://mcpr.opifex.org/reference/initialize.html","id":null,"dir":"Reference","previous_headings":"","what":"Initialize the server with protocol information — initialize","title":"Initialize the server with protocol information — initialize","text":"Initialize server protocol information","code":""},{"path":"https://mcpr.opifex.org/reference/initialize.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Initialize the server with protocol information — initialize","text":"","code":"initialize(mcp)"},{"path":"https://mcpr.opifex.org/reference/initialize.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Initialize the server with protocol information — initialize","text":"mcp server object","code":""},{"path":"https://mcpr.opifex.org/reference/initialize.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Initialize the server with protocol information — initialize","text":"list containing protocol version, server info, capabilities","code":""},{"path":"https://mcpr.opifex.org/reference/mcpr_clients_to_ellmer_tools.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert multiple MCPR clients to ellmer tools — mcpr_clients_to_ellmer_tools","title":"Convert multiple MCPR clients to ellmer tools — mcpr_clients_to_ellmer_tools","text":"function converts tools multiple MCPR clients format compatible ellmer package. useful want combine tools multiple MCP servers single ellmer session.","code":""},{"path":"https://mcpr.opifex.org/reference/mcpr_clients_to_ellmer_tools.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert multiple MCPR clients to ellmer tools — mcpr_clients_to_ellmer_tools","text":"","code":"mcpr_clients_to_ellmer_tools(...)"},{"path":"https://mcpr.opifex.org/reference/mcpr_clients_to_ellmer_tools.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert multiple MCPR clients to ellmer tools — mcpr_clients_to_ellmer_tools","text":"... One mcpr client objects","code":""},{"path":"https://mcpr.opifex.org/reference/mcpr_clients_to_ellmer_tools.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert multiple MCPR clients to ellmer tools — mcpr_clients_to_ellmer_tools","text":"list ellmer-compatible tool functions clients","code":""},{"path":"https://mcpr.opifex.org/reference/mcpr_clients_to_ellmer_tools.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert multiple MCPR clients to ellmer tools — mcpr_clients_to_ellmer_tools","text":"","code":"if (FALSE) { # \\dontrun{ # Create multiple MCPR clients client1 <- new_client_io(\"path/to/server1\") client2 <- new_client_io(\"path/to/server2\") # Convert all tools ellmer_tools <- mcpr_clients_to_ellmer_tools(client1, client2) # Use with ellmer chat <- ellmer::chat_claude() chat$set_tools(ellmer_tools) } # }"},{"path":"https://mcpr.opifex.org/reference/mcpr_to_ellmer_tools.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert MCPR tools to ellmer tools — mcpr_to_ellmer_tools","title":"Convert MCPR tools to ellmer tools — mcpr_to_ellmer_tools","text":"function converts tools MCPR client format compatible ellmer package. retrieves available tools client creates wrapper functions call tools MCPR protocol.","code":""},{"path":"https://mcpr.opifex.org/reference/mcpr_to_ellmer_tools.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert MCPR tools to ellmer tools — mcpr_to_ellmer_tools","text":"","code":"mcpr_to_ellmer_tools(client)"},{"path":"https://mcpr.opifex.org/reference/mcpr_to_ellmer_tools.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert MCPR tools to ellmer tools — mcpr_to_ellmer_tools","text":"client mcpr client object","code":""},{"path":"https://mcpr.opifex.org/reference/mcpr_to_ellmer_tools.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert MCPR tools to ellmer tools — mcpr_to_ellmer_tools","text":"list ellmer-compatible tool functions","code":""},{"path":"https://mcpr.opifex.org/reference/mcpr_to_ellmer_tools.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert MCPR tools to ellmer tools — mcpr_to_ellmer_tools","text":"","code":"if (FALSE) { # \\dontrun{ # Create an MCPR client client <- new_client_io(\"path/to/server\") # Convert its tools to ellmer format ellmer_tools <- mcpr_to_ellmer_tools(client) # Use with ellmer chat <- ellmer::chat_claude() chat$set_tools(ellmer_tools) } # }"},{"path":"https://mcpr.opifex.org/reference/new_client.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new mcp client — new_client","title":"Create a new mcp client — new_client","text":"Create new mcp client","code":""},{"path":"https://mcpr.opifex.org/reference/new_client.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new mcp client — new_client","text":"","code":"new_client(command, args = character(), name = command, version = \"1.0.0\")"},{"path":"https://mcpr.opifex.org/reference/new_client.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new mcp client — new_client","text":"command command run args Arguments pass command name name client version version client","code":""},{"path":"https://mcpr.opifex.org/reference/new_client.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new mcp client — new_client","text":"new mcp client","code":""},{"path":"https://mcpr.opifex.org/reference/new_prompt.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new prompt — new_prompt","title":"Create a new prompt — new_prompt","text":"Create new prompt","code":""},{"path":"https://mcpr.opifex.org/reference/new_prompt.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new prompt — new_prompt","text":"","code":"new_prompt(name, description, arguments = list(), handler)"},{"path":"https://mcpr.opifex.org/reference/new_prompt.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new prompt — new_prompt","text":"name Name prompt description Description prompt arguments List arguments prompt handler Function handle prompt","code":""},{"path":"https://mcpr.opifex.org/reference/new_prompt.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new prompt — new_prompt","text":"new prompt capability","code":""},{"path":"https://mcpr.opifex.org/reference/new_prompt.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a new prompt — new_prompt","text":"","code":"prompt <- new_prompt( name = \"My Prompt\", description = \"This is a description\", arguments = list( input1 = list( type = \"string\", description = \"Input 1\" ), input2 = list( type = \"number\", description = \"Input 2\" ) ), handler = function(params) { # Process the prompt request return(list(text = \"Generated text from prompt\")) } )"},{"path":"https://mcpr.opifex.org/reference/new_property.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new property — new_property","title":"Create a new property — new_property","text":"Create new property","code":""},{"path":"https://mcpr.opifex.org/reference/new_property.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new property — new_property","text":"","code":"new_property(type, title, description, required = FALSE, ...)"},{"path":"https://mcpr.opifex.org/reference/new_property.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new property — new_property","text":"type Type property title Short title property description Longer description property required Whether property required ... Additional attributes property","code":""},{"path":"https://mcpr.opifex.org/reference/new_property.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new property — new_property","text":"property object specified attributes","code":""},{"path":"https://mcpr.opifex.org/reference/new_resource.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new resource — new_resource","title":"Create a new resource — new_resource","text":"Create new resource","code":""},{"path":"https://mcpr.opifex.org/reference/new_resource.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new resource — new_resource","text":"","code":"new_resource(name, description, uri, mime_type = NULL, handler)"},{"path":"https://mcpr.opifex.org/reference/new_resource.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new resource — new_resource","text":"name Name resource description Description resource uri URI resource mime_type Mime type resource handler Function handle resource","code":""},{"path":"https://mcpr.opifex.org/reference/new_resource.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new resource — new_resource","text":"new resource capability","code":""},{"path":"https://mcpr.opifex.org/reference/new_resource.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a new resource — new_resource","text":"","code":"resource <- new_resource( name = \"My Resource\", description = \"This is a description\", uri = \"https://example.com/resource\", mime_type = \"text/plain\", handler = function(params) { # Process the resource request return(list(content = \"Resource content\")) } )"},{"path":"https://mcpr.opifex.org/reference/new_server.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new MCP object — new_server","title":"Create a new MCP object — new_server","text":"Create new MCP object","code":""},{"path":"https://mcpr.opifex.org/reference/new_server.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new MCP object — new_server","text":"","code":"new_server( name, description, version, tools = list(), resources = list(), prompts = list() ) new_mcp(...)"},{"path":"https://mcpr.opifex.org/reference/new_server.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new MCP object — new_server","text":"name Name MCP description Description MCP version Version MCP tools List tools resources List resources prompts List prompts ... Forwarded new_server()","code":""},{"path":"https://mcpr.opifex.org/reference/new_server.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new MCP object — new_server","text":"new MCP object","code":""},{"path":"https://mcpr.opifex.org/reference/new_server.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a new MCP object — new_server","text":"","code":"mcp <- new_server( name = \"My MCP\", description = \"This is a description\", version = \"1.0.0\" )"},{"path":"https://mcpr.opifex.org/reference/new_tool.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new tool — new_tool","title":"Create a new tool — new_tool","text":"Create new tool","code":""},{"path":"https://mcpr.opifex.org/reference/new_tool.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new tool — new_tool","text":"","code":"new_tool(name, description, input_schema, handler)"},{"path":"https://mcpr.opifex.org/reference/new_tool.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new tool — new_tool","text":"name Name tool description Description tool input_schema Input schema tool handler Function handle tool","code":""},{"path":"https://mcpr.opifex.org/reference/new_tool.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new tool — new_tool","text":"new tool capability","code":""},{"path":"https://mcpr.opifex.org/reference/new_tool.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a new tool — new_tool","text":"","code":"tool <- new_tool( name = \"My Tool\", description = \"This is a description\", input_schema = schema( properties = list( input1 = property_string(\"Input 1\", \"Description of input 1\"), input2 = property_number(\"Input 2\", \"Description of input 2\") ) ), handler = function(input) { # Process the input here return(input) } )"},{"path":"https://mcpr.opifex.org/reference/parse_request.html","id":null,"dir":"Reference","previous_headings":"","what":"Parse and process a JSON-RPC 2.0 request — parse_request","title":"Parse and process a JSON-RPC 2.0 request — parse_request","text":"Parse process JSON-RPC 2.0 request","code":""},{"path":"https://mcpr.opifex.org/reference/parse_request.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Parse and process a JSON-RPC 2.0 request — parse_request","text":"","code":"parse_request(json_text, mcp)"},{"path":"https://mcpr.opifex.org/reference/parse_request.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Parse and process a JSON-RPC 2.0 request — parse_request","text":"json_text JSON request text mcp MCP server object","code":""},{"path":"https://mcpr.opifex.org/reference/parse_request.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Parse and process a JSON-RPC 2.0 request — parse_request","text":"JSON response text NULL notifications","code":""},{"path":"https://mcpr.opifex.org/reference/process_batch.html","id":null,"dir":"Reference","previous_headings":"","what":"Process batch JSON-RPC 2.0 requests — process_batch","title":"Process batch JSON-RPC 2.0 requests — process_batch","text":"Process batch JSON-RPC 2.0 requests","code":""},{"path":"https://mcpr.opifex.org/reference/process_batch.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Process batch JSON-RPC 2.0 requests — process_batch","text":"","code":"process_batch(batch_requests, mcp)"},{"path":"https://mcpr.opifex.org/reference/process_batch.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Process batch JSON-RPC 2.0 requests — process_batch","text":"batch_requests List request objects mcp MCP server object","code":""},{"path":"https://mcpr.opifex.org/reference/process_batch.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Process batch JSON-RPC 2.0 requests — process_batch","text":"List response objects","code":""},{"path":"https://mcpr.opifex.org/reference/process_request.html","id":null,"dir":"Reference","previous_headings":"","what":"Process a JSON-RPC 2.0 request — process_request","title":"Process a JSON-RPC 2.0 request — process_request","text":"Process JSON-RPC 2.0 request","code":""},{"path":"https://mcpr.opifex.org/reference/process_request.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Process a JSON-RPC 2.0 request — process_request","text":"","code":"process_request(request, mcp)"},{"path":"https://mcpr.opifex.org/reference/process_request.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Process a JSON-RPC 2.0 request — process_request","text":"request Parsed request object mcp MCP server object","code":""},{"path":"https://mcpr.opifex.org/reference/process_request.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Process a JSON-RPC 2.0 request — process_request","text":"Response object NULL notifications","code":""},{"path":"https://mcpr.opifex.org/reference/prompts_get.html","id":null,"dir":"Reference","previous_headings":"","what":"Get a prompt with the given parameters — prompts_get","title":"Get a prompt with the given parameters — prompts_get","text":"Get prompt given parameters","code":""},{"path":"https://mcpr.opifex.org/reference/prompts_get.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get a prompt with the given parameters — prompts_get","text":"","code":"prompts_get(mcp, params, id = NULL)"},{"path":"https://mcpr.opifex.org/reference/prompts_get.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get a prompt with the given parameters — prompts_get","text":"mcp server object params Parameters prompt request id Optional request ID response tracking","code":""},{"path":"https://mcpr.opifex.org/reference/prompts_get.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get a prompt with the given parameters — prompts_get","text":"response object prompt results error","code":""},{"path":"https://mcpr.opifex.org/reference/prompts_list.html","id":null,"dir":"Reference","previous_headings":"","what":"List all available prompts — prompts_list","title":"List all available prompts — prompts_list","text":"List available prompts","code":""},{"path":"https://mcpr.opifex.org/reference/prompts_list.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"List all available prompts — prompts_list","text":"","code":"prompts_list(mcp)"},{"path":"https://mcpr.opifex.org/reference/prompts_list.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"List all available prompts — prompts_list","text":"mcp server object","code":""},{"path":"https://mcpr.opifex.org/reference/prompts_list.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"List all available prompts — prompts_list","text":"list containing available prompts","code":""},{"path":"https://mcpr.opifex.org/reference/properties.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new properties list — properties","title":"Create a new properties list — properties","text":"Create new properties list","code":""},{"path":"https://mcpr.opifex.org/reference/properties.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new properties list — properties","text":"","code":"properties(...)"},{"path":"https://mcpr.opifex.org/reference/properties.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new properties list — properties","text":"... Property objects","code":""},{"path":"https://mcpr.opifex.org/reference/properties.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new properties list — properties","text":"list property objects","code":""},{"path":"https://mcpr.opifex.org/reference/properties.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a new properties list — properties","text":"","code":"properties <- properties( property_string(\"Name\", \"The name of the user\", required = TRUE), property_number(\"Age\", \"The age of the user in years\", minimum = 0) )"},{"path":"https://mcpr.opifex.org/reference/property_array.html","id":null,"dir":"Reference","previous_headings":"","what":"Create an array property definition — property_array","title":"Create an array property definition — property_array","text":"Create array property definition","code":""},{"path":"https://mcpr.opifex.org/reference/property_array.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create an array property definition — property_array","text":"","code":"property_array( title, description, items, required = FALSE, min_items = NULL, max_items = NULL, unique_items = FALSE )"},{"path":"https://mcpr.opifex.org/reference/property_array.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create an array property definition — property_array","text":"title Short title property description Longer description property items Schema items array required Whether property required min_items Optional minimum number items max_items Optional maximum number items unique_items Logical indicating items must unique","code":""},{"path":"https://mcpr.opifex.org/reference/property_array.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create an array property definition — property_array","text":"array property object","code":""},{"path":"https://mcpr.opifex.org/reference/property_array.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create an array property definition — property_array","text":"","code":"tags_prop <- property_array( \"Tags\", \"List of tags for the user\", items = property_string(\"Tag\", \"A user tag\"), unique_items = TRUE )"},{"path":"https://mcpr.opifex.org/reference/property_boolean.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a boolean property definition — property_boolean","title":"Create a boolean property definition — property_boolean","text":"Create boolean property definition","code":""},{"path":"https://mcpr.opifex.org/reference/property_boolean.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a boolean property definition — property_boolean","text":"","code":"property_boolean(title, description, required = FALSE)"},{"path":"https://mcpr.opifex.org/reference/property_boolean.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a boolean property definition — property_boolean","text":"title Short title property description Longer description property required Whether property required","code":""},{"path":"https://mcpr.opifex.org/reference/property_boolean.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a boolean property definition — property_boolean","text":"boolean property object","code":""},{"path":"https://mcpr.opifex.org/reference/property_boolean.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a boolean property definition — property_boolean","text":"","code":"active_prop <- property_boolean( \"Active status\", \"Whether the user account is active\", required = TRUE )"},{"path":"https://mcpr.opifex.org/reference/property_enum.html","id":null,"dir":"Reference","previous_headings":"","what":"Create an enum property with predefined values — property_enum","title":"Create an enum property with predefined values — property_enum","text":"Create enum property predefined values","code":""},{"path":"https://mcpr.opifex.org/reference/property_enum.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create an enum property with predefined values — property_enum","text":"","code":"property_enum(title, description, values, required = FALSE)"},{"path":"https://mcpr.opifex.org/reference/property_enum.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create an enum property with predefined values — property_enum","text":"title Short title property description Longer description property values Character vector allowed values required Whether property required","code":""},{"path":"https://mcpr.opifex.org/reference/property_enum.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create an enum property with predefined values — property_enum","text":"enum property object","code":""},{"path":"https://mcpr.opifex.org/reference/property_enum.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create an enum property with predefined values — property_enum","text":"","code":"status_prop <- property_enum( \"Status\", \"User account status\", values = c(\"active\", \"pending\", \"suspended\"), required = TRUE )"},{"path":"https://mcpr.opifex.org/reference/property_number.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a number property definition — property_number","title":"Create a number property definition — property_number","text":"Create number property definition","code":""},{"path":"https://mcpr.opifex.org/reference/property_number.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a number property definition — property_number","text":"","code":"property_number( title, description, required = FALSE, minimum = NULL, maximum = NULL, exclusive_minimum = NULL, exclusive_maximum = NULL, multiple_of = NULL, integer = FALSE )"},{"path":"https://mcpr.opifex.org/reference/property_number.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a number property definition — property_number","text":"title Short title property description Longer description property required Whether property required minimum Optional minimum value maximum Optional maximum value exclusive_minimum Optional logical exclusive minimum exclusive_maximum Optional logical exclusive maximum multiple_of Optional value number must multiple integer Logical indicating number integer","code":""},{"path":"https://mcpr.opifex.org/reference/property_number.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a number property definition — property_number","text":"number property object","code":""},{"path":"https://mcpr.opifex.org/reference/property_number.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a number property definition — property_number","text":"","code":"age_prop <- property_number( \"User age\", \"The age of the user in years\", required = TRUE, minimum = 0, integer = TRUE )"},{"path":"https://mcpr.opifex.org/reference/property_object.html","id":null,"dir":"Reference","previous_headings":"","what":"Create an object property definition — property_object","title":"Create an object property definition — property_object","text":"Create object property definition","code":""},{"path":"https://mcpr.opifex.org/reference/property_object.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create an object property definition — property_object","text":"","code":"property_object( title, description, properties, required = FALSE, additional_properties = FALSE )"},{"path":"https://mcpr.opifex.org/reference/property_object.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create an object property definition — property_object","text":"title Short title property description Longer description property properties List property definitions object required Whether property required additional_properties Logical indicating additional properties allowed","code":""},{"path":"https://mcpr.opifex.org/reference/property_object.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create an object property definition — property_object","text":"object property object","code":""},{"path":"https://mcpr.opifex.org/reference/property_object.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create an object property definition — property_object","text":"","code":"address_prop <- property_object( \"Address\", \"User's address information\", properties = list( street = property_string(\"Street\", \"Street address\", required = TRUE), city = property_string(\"City\", \"City name\", required = TRUE), country = property_string(\"Country\", \"Country name\") ) )"},{"path":"https://mcpr.opifex.org/reference/property_string.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a string property definition — property_string","title":"Create a string property definition — property_string","text":"Create string property definition","code":""},{"path":"https://mcpr.opifex.org/reference/property_string.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a string property definition — property_string","text":"","code":"property_string( title, description, required = FALSE, enum = NULL, pattern = NULL, min_length = NULL, max_length = NULL, format = NULL )"},{"path":"https://mcpr.opifex.org/reference/property_string.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a string property definition — property_string","text":"title Short title property description Longer description property required Whether property required enum Optional character vector allowed values pattern Optional regex pattern string must match min_length Optional minimum length max_length Optional maximum length format Optional format (e.g., \"date-time\", \"email\", \"uri\")","code":""},{"path":"https://mcpr.opifex.org/reference/property_string.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a string property definition — property_string","text":"string property object","code":""},{"path":"https://mcpr.opifex.org/reference/property_string.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a string property definition — property_string","text":"","code":"name_prop <- property_string( \"User name\", \"The name of the user\", required = TRUE, min_length = 2, max_length = 50 )"},{"path":"https://mcpr.opifex.org/reference/read.html","id":null,"dir":"Reference","previous_headings":"","what":"Read a JSON-RPC response from a client provider — read","title":"Read a JSON-RPC response from a client provider — read","text":"Read JSON-RPC response client provider","code":""},{"path":"https://mcpr.opifex.org/reference/read.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read a JSON-RPC response from a client provider — read","text":"","code":"read(x, timeout = 60 * 1000)"},{"path":"https://mcpr.opifex.org/reference/read.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read a JSON-RPC response from a client provider — read","text":"x client provider timeout Timeout milliseconds reading response","code":""},{"path":"https://mcpr.opifex.org/reference/read.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Read a JSON-RPC response from a client provider — read","text":"response","code":""},{"path":"https://mcpr.opifex.org/reference/register_mcpr_tools.html","id":null,"dir":"Reference","previous_headings":"","what":"Register MCPR tools with an ellmer chat — register_mcpr_tools","title":"Register MCPR tools with an ellmer chat — register_mcpr_tools","text":"function registers tools MCPR client ellmer chat instance.","code":""},{"path":"https://mcpr.opifex.org/reference/register_mcpr_tools.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Register MCPR tools with an ellmer chat — register_mcpr_tools","text":"","code":"register_mcpr_tools(chat, client)"},{"path":"https://mcpr.opifex.org/reference/register_mcpr_tools.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Register MCPR tools with an ellmer chat — register_mcpr_tools","text":"chat ellmer chat object client mcpr client object","code":""},{"path":"https://mcpr.opifex.org/reference/register_mcpr_tools.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Register MCPR tools with an ellmer chat — register_mcpr_tools","text":"chat object (invisibly)","code":""},{"path":"https://mcpr.opifex.org/reference/resources_list.html","id":null,"dir":"Reference","previous_headings":"","what":"List all available resources — resources_list","title":"List all available resources — resources_list","text":"List available resources","code":""},{"path":"https://mcpr.opifex.org/reference/resources_list.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"List all available resources — resources_list","text":"","code":"resources_list(mcp)"},{"path":"https://mcpr.opifex.org/reference/resources_list.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"List all available resources — resources_list","text":"mcp server object","code":""},{"path":"https://mcpr.opifex.org/reference/resources_list.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"List all available resources — resources_list","text":"list containing available resources","code":""},{"path":"https://mcpr.opifex.org/reference/resources_read.html","id":null,"dir":"Reference","previous_headings":"","what":"Read a resource with the given parameters — resources_read","title":"Read a resource with the given parameters — resources_read","text":"Read resource given parameters","code":""},{"path":"https://mcpr.opifex.org/reference/resources_read.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read a resource with the given parameters — resources_read","text":"","code":"resources_read(mcp, params, id = NULL)"},{"path":"https://mcpr.opifex.org/reference/resources_read.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read a resource with the given parameters — resources_read","text":"mcp server object params Parameters resource read id Optional request ID response tracking","code":""},{"path":"https://mcpr.opifex.org/reference/resources_read.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Read a resource with the given parameters — resources_read","text":"response object resource read results error","code":""},{"path":"https://mcpr.opifex.org/reference/response.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a response object — response","title":"Create a response object — response","text":"Create response object","code":""},{"path":"https://mcpr.opifex.org/reference/response.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a response object — response","text":"","code":"response_text(text) response_image(image, mime_type = \"image/png\") response_audio(audio, mime_type = \"audio/mpeg\") response_video(video, mime_type = \"video/mp4\") response_file(file, mime_type = \"application/octet-stream\") response_resource(resource) response_error(text) response_item( ..., type = c(\"text\", \"image\", \"audio\", \"video\", \"file\", \"resource\") ) response(..., is_error = FALSE)"},{"path":"https://mcpr.opifex.org/reference/response.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a response object — response","text":"text Text content image Image content mime_type Mime type content audio Audio content video Video content file File content resource Resource content ... Mutliple response objects type Type content is_error Whether response error","code":""},{"path":"https://mcpr.opifex.org/reference/response.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a response object — response","text":"response object","code":""},{"path":"https://mcpr.opifex.org/reference/response.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create a response object — response","text":"Use response_item create custom response item.","code":""},{"path":"https://mcpr.opifex.org/reference/response.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a response object — response","text":"","code":"response( response_text(\"Hello, world!\"), response_image(system.file(\"extdata/logo.png\", package = \"mcpr\")), response_audio(system.file(\"extdata/sound.mp3\", package = \"mcpr\")), response_video(system.file(\"extdata/video.mp4\", package = \"mcpr\")), response_file(system.file(\"extdata/file.txt\", package = \"mcpr\")), response_resource(system.file(\"extdata/resource.json\", package = \"mcpr\")) ) #> $content #> $content[[1]] #> $type #> [1] \"text\" #> #> $text #> [1] \"Hello, world!\" #> #> attr(,\"class\") #> [1] \"response_item\" \"response_item_text\" \"list\" #> #> $content[[2]] #> $type #> [1] \"image\" #> #> $data #> [1] \"\" #> #> $mimeType #> [1] \"image/png\" #> #> attr(,\"class\") #> [1] \"response_item\" \"response_item_image\" \"list\" #> #> $content[[3]] #> $type #> [1] \"audio\" #> #> $data #> [1] \"\" #> #> $mimeType #> [1] \"audio/mpeg\" #> #> attr(,\"class\") #> [1] \"response_item\" \"response_item_audio\" \"list\" #> #> $content[[4]] #> $type #> [1] \"video\" #> #> $data #> [1] \"\" #> #> $mimeType #> [1] \"video/mp4\" #> #> attr(,\"class\") #> [1] \"response_item\" \"response_item_video\" \"list\" #> #> $content[[5]] #> $type #> [1] \"file\" #> #> $data #> [1] \"\" #> #> $mimeType #> [1] \"application/octet-stream\" #> #> attr(,\"class\") #> [1] \"response_item\" \"response_item_file\" \"list\" #> #> $content[[6]] #> $type #> [1] \"resource\" #> #> $resource #> [1] \"\" #> #> attr(,\"class\") #> [1] \"response_item\" \"response_item_resource\" \"list\" #> #> #> $isError #> [1] FALSE #> #> attr(,\"class\") #> [1] \"response\" \"list\""},{"path":"https://mcpr.opifex.org/reference/schema.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new input schema — schema","title":"Create a new input schema — schema","text":"Create new input schema","code":""},{"path":"https://mcpr.opifex.org/reference/schema.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new input schema — schema","text":"","code":"schema(properties, type = \"object\", additional_properties = FALSE)"},{"path":"https://mcpr.opifex.org/reference/schema.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new input schema — schema","text":"properties List property definitions type Type schema additional_properties Logical indicating additional properties allowed","code":""},{"path":"https://mcpr.opifex.org/reference/schema.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new input schema — schema","text":"list representing JSON Schema object","code":""},{"path":"https://mcpr.opifex.org/reference/schema.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a new input schema — schema","text":"","code":"schema <- schema( properties = properties( name = property_string(\"User name\", \"The name of the user\", required = TRUE), age = property_number(\"User age\", \"The age of the user in years\", minimum = 0) ) )"},{"path":"https://mcpr.opifex.org/reference/serve_http.html","id":null,"dir":"Reference","previous_headings":"","what":"Serve an MCP server over HTTP using ambiorix — serve_http","title":"Serve an MCP server over HTTP using ambiorix — serve_http","text":"Serve MCP server HTTP using ambiorix","code":""},{"path":"https://mcpr.opifex.org/reference/serve_http.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Serve an MCP server over HTTP using ambiorix — serve_http","text":"","code":"serve_http(mcp, port = Sys.getenv(\"SHINY_PORT\", 3000), path = \"/mcp\")"},{"path":"https://mcpr.opifex.org/reference/serve_http.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Serve an MCP server over HTTP using ambiorix — serve_http","text":"mcp MCP server object port Port listen , defaults 3000 path Path serve MCP endpoint, defaults \"/mcp\"","code":""},{"path":"https://mcpr.opifex.org/reference/serve_http.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Serve an MCP server over HTTP using ambiorix — serve_http","text":"Invisible, runs indefinitely","code":""},{"path":"https://mcpr.opifex.org/reference/serve_io.html","id":null,"dir":"Reference","previous_headings":"","what":"Serve an MCP server using stdin/stdout — serve_io","title":"Serve an MCP server using stdin/stdout — serve_io","text":"Serve MCP server using stdin/stdout","code":""},{"path":"https://mcpr.opifex.org/reference/serve_io.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Serve an MCP server using stdin/stdout — serve_io","text":"","code":"serve_io(mcp)"},{"path":"https://mcpr.opifex.org/reference/serve_io.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Serve an MCP server using stdin/stdout — serve_io","text":"mcp MCP server object","code":""},{"path":"https://mcpr.opifex.org/reference/serve_io.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Serve an MCP server using stdin/stdout — serve_io","text":"Nothing, runs indefinitely normal mode, response test mode","code":""},{"path":"https://mcpr.opifex.org/reference/to_json.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert an R object to JSON — to_json","title":"Convert an R object to JSON — to_json","text":"Convert R object JSON","code":""},{"path":"https://mcpr.opifex.org/reference/to_json.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert an R object to JSON — to_json","text":"","code":"to_json(x, ...)"},{"path":"https://mcpr.opifex.org/reference/to_json.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert an R object to JSON — to_json","text":"x R object convert JSON ... Additional arguments passed yyjsonr::write_json_str","code":""},{"path":"https://mcpr.opifex.org/reference/to_json.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert an R object to JSON — to_json","text":"JSON string","code":""},{"path":"https://mcpr.opifex.org/reference/tools_call.html","id":null,"dir":"Reference","previous_headings":"","what":"Call a tool with the given parameters — tools_call","title":"Call a tool with the given parameters — tools_call","text":"Call tool given parameters","code":""},{"path":"https://mcpr.opifex.org/reference/tools_call.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Call a tool with the given parameters — tools_call","text":"","code":"tools_call(mcp, params, id = NULL)"},{"path":"https://mcpr.opifex.org/reference/tools_call.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Call a tool with the given parameters — tools_call","text":"mcp server object params Parameters tool call id Optional request ID response tracking","code":""},{"path":"https://mcpr.opifex.org/reference/tools_call.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Call a tool with the given parameters — tools_call","text":"response object tool call results error","code":""},{"path":"https://mcpr.opifex.org/reference/tools_list.html","id":null,"dir":"Reference","previous_headings":"","what":"List all available tools — tools_list","title":"List all available tools — tools_list","text":"List available tools","code":""},{"path":"https://mcpr.opifex.org/reference/tools_list.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"List all available tools — tools_list","text":"","code":"tools_list(mcp)"},{"path":"https://mcpr.opifex.org/reference/tools_list.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"List all available tools — tools_list","text":"mcp server object","code":""},{"path":"https://mcpr.opifex.org/reference/tools_list.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"List all available tools — tools_list","text":"list containing available tools","code":""},{"path":"https://mcpr.opifex.org/reference/validate_request.html","id":null,"dir":"Reference","previous_headings":"","what":"Validate a JSON-RPC 2.0 request — validate_request","title":"Validate a JSON-RPC 2.0 request — validate_request","text":"Validate JSON-RPC 2.0 request","code":""},{"path":"https://mcpr.opifex.org/reference/validate_request.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Validate a JSON-RPC 2.0 request — validate_request","text":"","code":"validate_request(request)"},{"path":"https://mcpr.opifex.org/reference/validate_request.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Validate a JSON-RPC 2.0 request — validate_request","text":"request Parsed request object","code":""},{"path":"https://mcpr.opifex.org/reference/validate_request.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Validate a JSON-RPC 2.0 request — validate_request","text":"NULL valid, error response invalid","code":""},{"path":"https://mcpr.opifex.org/reference/write.html","id":null,"dir":"Reference","previous_headings":"","what":"Write a JSON-RPC request to a client provider — write","title":"Write a JSON-RPC request to a client provider — write","text":"Write JSON-RPC request client provider","code":""},{"path":"https://mcpr.opifex.org/reference/write.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Write a JSON-RPC request to a client provider — write","text":"","code":"write(x, method, params = NULL, id = generate_id(), timeout = 5000)"},{"path":"https://mcpr.opifex.org/reference/write.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Write a JSON-RPC request to a client provider — write","text":"x client provider method method call params parameters pass method id id request timeout Timeout milliseconds reading response","code":""},{"path":"https://mcpr.opifex.org/reference/write.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Write a JSON-RPC request to a client provider — write","text":"client provider","code":""},{"path":[]},{"path":"https://mcpr.opifex.org/news/index.html","id":"major-changes-0-0-1","dir":"Changelog","previous_headings":"","what":"Major Changes","title":"mcpr 0.0.1","text":"new_client() creating client connections local process HTTP servers initialize() initializing client connections tools_list() tools_call() discovering using server tools prompts_list() prompts_get() working server prompts resources_list() resources_read() accessing server resources Renamed new_mcp() (deprecated) new_server() clarity Added example implementations server client Added client usage vignette Fix major issue serve_http()","code":""},{"path":"https://mcpr.opifex.org/news/index.html","id":"mcpr-000","dir":"Changelog","previous_headings":"","what":"mcpr 0.0.0","title":"mcpr 0.0.0","text":"Initial CRAN submission.","code":""}] +[{"path":"https://mcpr.opifex.org/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"GNU General Public License","title":"GNU General Public License","text":"Version 2, June 1991Copyright © 1989, 1991 Free Software Foundation, Inc.,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone permitted copy distribute verbatim copies license document, changing allowed.","code":""},{"path":"https://mcpr.opifex.org/LICENSE.html","id":"preamble","dir":"","previous_headings":"","what":"Preamble","title":"GNU General Public License","text":"licenses software designed take away freedom share change . contrast, GNU General Public License intended guarantee freedom share change free software–make sure software free users. General Public License applies Free Software Foundation’s software program whose authors commit using . (Free Software Foundation software covered GNU Lesser General Public License instead.) can apply programs, . speak free software, referring freedom, price. General Public Licenses designed make sure freedom distribute copies free software (charge service wish), receive source code can get want , can change software use pieces new free programs; know can things. protect rights, need make restrictions forbid anyone deny rights ask surrender rights. restrictions translate certain responsibilities distribute copies software, modify . example, distribute copies program, whether gratis fee, must give recipients rights . must make sure , , receive can get source code. must show terms know rights. protect rights two steps: (1) copyright software, (2) offer license gives legal permission copy, distribute /modify software. Also, author’s protection , want make certain everyone understands warranty free software. software modified someone else passed , want recipients know original, problems introduced others reflect original authors’ reputations. Finally, free program threatened constantly software patents. wish avoid danger redistributors free program individually obtain patent licenses, effect making program proprietary. prevent , made clear patent must licensed everyone’s free use licensed . precise terms conditions copying, distribution modification follow.","code":""},{"path":"https://mcpr.opifex.org/LICENSE.html","id":"terms-and-conditions-for-copying-distribution-and-modification","dir":"","previous_headings":"","what":"TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION","title":"GNU General Public License","text":"0. License applies program work contains notice placed copyright holder saying may distributed terms General Public License. “Program”, , refers program work, “work based Program” means either Program derivative work copyright law: say, work containing Program portion , either verbatim modifications /translated another language. (Hereinafter, translation included without limitation term “modification”.) licensee addressed “”. Activities copying, distribution modification covered License; outside scope. act running Program restricted, output Program covered contents constitute work based Program (independent made running Program). Whether true depends Program . 1. may copy distribute verbatim copies Program’s source code receive , medium, provided conspicuously appropriately publish copy appropriate copyright notice disclaimer warranty; keep intact notices refer License absence warranty; give recipients Program copy License along Program. may charge fee physical act transferring copy, may option offer warranty protection exchange fee. 2. may modify copy copies Program portion , thus forming work based Program, copy distribute modifications work terms Section 1 , provided also meet conditions: ) must cause modified files carry prominent notices stating changed files date change. b) must cause work distribute publish, whole part contains derived Program part thereof, licensed whole charge third parties terms License. c) modified program normally reads commands interactively run, must cause , started running interactive use ordinary way, print display announcement including appropriate copyright notice notice warranty (else, saying provide warranty) users may redistribute program conditions, telling user view copy License. (Exception: Program interactive normally print announcement, work based Program required print announcement.) requirements apply modified work whole. identifiable sections work derived Program, can reasonably considered independent separate works , License, terms, apply sections distribute separate works. distribute sections part whole work based Program, distribution whole must terms License, whose permissions licensees extend entire whole, thus every part regardless wrote . Thus, intent section claim rights contest rights work written entirely ; rather, intent exercise right control distribution derivative collective works based Program. addition, mere aggregation another work based Program Program (work based Program) volume storage distribution medium bring work scope License. 3. may copy distribute Program (work based , Section 2) object code executable form terms Sections 1 2 provided also one following: ) Accompany complete corresponding machine-readable source code, must distributed terms Sections 1 2 medium customarily used software interchange; , b) Accompany written offer, valid least three years, give third party, charge cost physically performing source distribution, complete machine-readable copy corresponding source code, distributed terms Sections 1 2 medium customarily used software interchange; , c) Accompany information received offer distribute corresponding source code. (alternative allowed noncommercial distribution received program object code executable form offer, accord Subsection b .) source code work means preferred form work making modifications . executable work, complete source code means source code modules contains, plus associated interface definition files, plus scripts used control compilation installation executable. However, special exception, source code distributed need include anything normally distributed (either source binary form) major components (compiler, kernel, ) operating system executable runs, unless component accompanies executable. distribution executable object code made offering access copy designated place, offering equivalent access copy source code place counts distribution source code, even though third parties compelled copy source along object code. 4. may copy, modify, sublicense, distribute Program except expressly provided License. attempt otherwise copy, modify, sublicense distribute Program void, automatically terminate rights License. However, parties received copies, rights, License licenses terminated long parties remain full compliance. 5. required accept License, since signed . However, nothing else grants permission modify distribute Program derivative works. actions prohibited law accept License. Therefore, modifying distributing Program (work based Program), indicate acceptance License , terms conditions copying, distributing modifying Program works based . 6. time redistribute Program (work based Program), recipient automatically receives license original licensor copy, distribute modify Program subject terms conditions. may impose restrictions recipients’ exercise rights granted herein. responsible enforcing compliance third parties License. 7. , consequence court judgment allegation patent infringement reason (limited patent issues), conditions imposed (whether court order, agreement otherwise) contradict conditions License, excuse conditions License. distribute satisfy simultaneously obligations License pertinent obligations, consequence may distribute Program . example, patent license permit royalty-free redistribution Program receive copies directly indirectly , way satisfy License refrain entirely distribution Program. portion section held invalid unenforceable particular circumstance, balance section intended apply section whole intended apply circumstances. purpose section induce infringe patents property right claims contest validity claims; section sole purpose protecting integrity free software distribution system, implemented public license practices. Many people made generous contributions wide range software distributed system reliance consistent application system; author/donor decide willing distribute software system licensee impose choice. section intended make thoroughly clear believed consequence rest License. 8. distribution /use Program restricted certain countries either patents copyrighted interfaces, original copyright holder places Program License may add explicit geographical distribution limitation excluding countries, distribution permitted among countries thus excluded. case, License incorporates limitation written body License. 9. Free Software Foundation may publish revised /new versions General Public License time time. new versions similar spirit present version, may differ detail address new problems concerns. version given distinguishing version number. Program specifies version number License applies “later version”, option following terms conditions either version later version published Free Software Foundation. Program specify version number License, may choose version ever published Free Software Foundation. 10. wish incorporate parts Program free programs whose distribution conditions different, write author ask permission. software copyrighted Free Software Foundation, write Free Software Foundation; sometimes make exceptions . decision guided two goals preserving free status derivatives free software promoting sharing reuse software generally.","code":""},{"path":"https://mcpr.opifex.org/LICENSE.html","id":"no-warranty","dir":"","previous_headings":"","what":"NO WARRANTY","title":"GNU General Public License","text":"11. PROGRAM LICENSED FREE CHARGE, WARRANTY PROGRAM, EXTENT PERMITTED APPLICABLE LAW. EXCEPT OTHERWISE STATED WRITING COPYRIGHT HOLDERS /PARTIES PROVIDE PROGRAM “” WITHOUT WARRANTY KIND, EITHER EXPRESSED IMPLIED, INCLUDING, LIMITED , IMPLIED WARRANTIES MERCHANTABILITY FITNESS PARTICULAR PURPOSE. ENTIRE RISK QUALITY PERFORMANCE PROGRAM . PROGRAM PROVE DEFECTIVE, ASSUME COST NECESSARY SERVICING, REPAIR CORRECTION. 12. EVENT UNLESS REQUIRED APPLICABLE LAW AGREED WRITING COPYRIGHT HOLDER, PARTY MAY MODIFY /REDISTRIBUTE PROGRAM PERMITTED , LIABLE DAMAGES, INCLUDING GENERAL, SPECIAL, INCIDENTAL CONSEQUENTIAL DAMAGES ARISING USE INABILITY USE PROGRAM (INCLUDING LIMITED LOSS DATA DATA RENDERED INACCURATE LOSSES SUSTAINED THIRD PARTIES FAILURE PROGRAM OPERATE PROGRAMS), EVEN HOLDER PARTY ADVISED POSSIBILITY DAMAGES. END TERMS CONDITIONS","code":""},{"path":"https://mcpr.opifex.org/LICENSE.html","id":"how-to-apply-these-terms-to-your-new-programs","dir":"","previous_headings":"","what":"How to Apply These Terms to Your New Programs","title":"GNU General Public License","text":"develop new program, want greatest possible use public, best way achieve make free software everyone can redistribute change terms. , attach following notices program. safest attach start source file effectively convey exclusion warranty; file least “copyright” line pointer full notice found. Also add information contact electronic paper mail. program interactive, make output short notice like starts interactive mode: hypothetical commands show w show c show appropriate parts General Public License. course, commands use may called something show w show c; even mouse-clicks menu items–whatever suits program. also get employer (work programmer) school, , sign “copyright disclaimer” program, necessary. sample; alter names: General Public License permit incorporating program proprietary programs. program subroutine library, may consider useful permit linking proprietary applications library. want , use GNU Lesser General Public License instead License.","code":" Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice"},{"path":"https://mcpr.opifex.org/articles/client-integration.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Integrating mcpr with MCP Clients","text":"Model Context Protocol (MCP) allows register custom tools various AI clients. vignette demonstrates create simple MCP server mcpr register popular clients including Claude Code, Cursor, OpenAI GPTs, LangChain.","code":""},{"path":"https://mcpr.opifex.org/articles/client-integration.html","id":"creating-a-simple-math-calculator-server","dir":"Articles","previous_headings":"","what":"Creating a Simple Math Calculator Server","title":"Integrating mcpr with MCP Clients","text":"Let’s create simple MCP server basic calculator tool: Save code file, example calculator_server.R, add code serve end:","code":"# Create a new MCP server math_server <- new_server( name = \"r-calculator\", description = \"A simple calculator that performs basic arithmetic operations\", version = \"1.0.0\" ) # Create a calculator tool calculator <- new_tool( name = \"math_calculator\", description = \"Performs basic arithmetic operations\", input_schema = schema( properties = properties( operation = property_enum( \"Operation\", \"Math operation to perform\", enum = c(\"add\", \"subtract\", \"multiply\", \"divide\"), required = TRUE ), a = property_number(\"First number\", \"First operand\", required = TRUE), b = property_number(\"Second number\", \"Second operand\", required = TRUE) ) ), handler = function(input) { result <- switch(input$operation, \"add\" = input$a + input$b, \"subtract\" = input$a - input$b, \"multiply\" = input$a * input$b, \"divide\" = input$a / input$b ) response_text(paste(\"Result:\", result)) } ) # Add the tool to the server math_server <- add_capability(math_server, calculator) # At the end of calculator_server.R, add: serve_io(math_server)"},{"path":[]},{"path":"https://mcpr.opifex.org/articles/client-integration.html","id":"claude-code","dir":"Articles","previous_headings":"Registering with MCP Clients","what":"Claude Code","title":"Integrating mcpr with MCP Clients","text":"Claude Code supports registering MCP tools using claude mcp command: Claude automatically discover use registered MCP server’s capabilities.","code":"# Register the MCP server claude mcp add r-calculator -- Rscript /path/to/calculator_server.R # List registered MCP servers claude mcp list # Use the registered tool claude \"Add 2 to 40\""},{"path":"https://mcpr.opifex.org/articles/client-integration.html","id":"cursor","dir":"Articles","previous_headings":"Registering with MCP Clients","what":"Cursor","title":"Integrating mcpr with MCP Clients","text":"Cursor supports registering MCP tools via configuration: Open Cursor settings Navigate “Tools” section Name: r-calculator Command: Rscript /path//calculator_server.R Save settings Now ask Cursor perform calculations, access MCP tool.","code":""},{"path":"https://mcpr.opifex.org/articles/client-integration.html","id":"openai-gpt","dir":"Articles","previous_headings":"Registering with MCP Clients","what":"OpenAI GPT","title":"Integrating mcpr with MCP Clients","text":"OpenAI GPTs, ’ll need run MCP server HTTP: register custom GPT: Create custom GPT GPT Builder “Configure” tab, add “Action” Set Authentication “None” Set API URL server (e.g., http://localhost:8080) Import schema URL: http://localhost:8080/openapi.json Save GPT custom GPT now able use MCP calculator.","code":"# Modify your calculator_server.R to use HTTP instead of IO serve_http(math_server, port = 8080)"},{"path":"https://mcpr.opifex.org/articles/client-integration.html","id":"langchain","dir":"Articles","previous_headings":"Registering with MCP Clients","what":"LangChain","title":"Integrating mcpr with MCP Clients","text":"LangChain provides adapters specifically MCP integration: Alternatively, can use process-based approach:","code":"from langchain_mcp_adapters.client import MultiServerMCPClient from langchain.agents import create_tool_calling_agent from langchain_openai import ChatOpenAI # Connect to your R-based MCP server # You need to run your server with serve_http for this approach mcp_client = MultiServerMCPClient( servers=[{\"url\": \"http://localhost:8080\"}] ) # Get tools from the MCP server tools = mcp_client.get_tools() # Create a LangChain agent with the MCP tools llm = ChatOpenAI(model=\"gpt-4o\") agent = create_tool_calling_agent(llm, tools) # Use the agent response = agent.invoke({\"input\": \"What is 10 multiplied by 5?\"}) print(response[\"output\"]) from langchain_mcp_adapters.client import MultiServerMCPClient from langchain.agents import create_tool_calling_agent from langchain_openai import ChatOpenAI # Connect to your R-based MCP server using process mcp_client = MultiServerMCPClient( servers=[{\"command\": [\"Rscript\", \"/path/to/calculator_server.R\"]}] ) # The rest is the same as above tools = mcp_client.get_tools() llm = ChatOpenAI(model=\"gpt-4o\") agent = create_tool_calling_agent(llm, tools)"},{"path":"https://mcpr.opifex.org/articles/client-integration.html","id":"conclusion","dir":"Articles","previous_headings":"","what":"Conclusion","title":"Integrating mcpr with MCP Clients","text":"mcpr, can create MCP servers register seamlessly various AI clients. enables AI tools leverage R’s statistical data processing capabilities. advanced usage, consider: Adding multiple tools server Creating resources serve data Implementing prompts text generation Handling complex data types tools See vignettes function documentation details advanced features.","code":""},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Using the MCP Client","text":"mcpr package allows create Model Context Protocol (MCP) servers R also connect existing MCP servers client. vignette guide using MCP client interact servers.","code":""},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"creating-an-mcp-client","dir":"Articles","previous_headings":"","what":"Creating an MCP Client","title":"Using the MCP Client","text":"client functionality allows connect MCP server, whether ’s running locally separate process, remotely via HTTP. ’s create client:","code":""},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"connecting-to-a-local-server-process","dir":"Articles","previous_headings":"Creating an MCP Client","what":"Connecting to a Local Server Process","title":"Using the MCP Client","text":"can connect server running separate process. useful testing need communicate local MCP implementation:","code":"# Create a client that connects to a local process client <- new_client( \"Rscript\", # Command to run \"path/to/your/server.R\", # Path to the server script name = \"calculator\", # Optional name for the server version = \"1.0.0\" # Optional version )"},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"connecting-to-an-http-server","dir":"Articles","previous_headings":"Creating an MCP Client","what":"Connecting to an HTTP Server","title":"Using the MCP Client","text":"can also connect MCP server running HTTP:","code":"# Create a client that connects to an HTTP server http_client <- new_client(\"Rscript\", \"path/to/your/server.R\")"},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"basic-client-operations","dir":"Articles","previous_headings":"","what":"Basic Client Operations","title":"Using the MCP Client","text":"created client, can interact server using various client methods:","code":""},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"initializing-the-connection","dir":"Articles","previous_headings":"Basic Client Operations","what":"Initializing the Connection","title":"Using the MCP Client","text":"’s good practice initialize connection first:","code":"# Initialize the connection res <- initialize(client) print(res)"},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"listing-available-tools","dir":"Articles","previous_headings":"Basic Client Operations","what":"Listing Available Tools","title":"Using the MCP Client","text":"can list tools server provides:","code":"# Get a list of available tools tools <- tools_list(client) print(tools)"},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"calling-a-tool","dir":"Articles","previous_headings":"Basic Client Operations","what":"Calling a Tool","title":"Using the MCP Client","text":"know tools available, can call specific parameters:","code":"# Call the math_calculator tool result <- tools_call( client, list( name = \"math_calculator\", params = list( name = \"add\", arguments = list( a = 10, b = 5 ) ) ) ) print(result)"},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"working-with-prompts","dir":"Articles","previous_headings":"Basic Client Operations","what":"Working with Prompts","title":"Using the MCP Client","text":"server prompts available, can list use :","code":"# List available prompts prompts <- prompts_list(client) print(prompts) # Get a specific prompt prompt <- prompts_get(client, \"example-prompt\") print(prompt)"},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"working-with-resources","dir":"Articles","previous_headings":"Basic Client Operations","what":"Working with Resources","title":"Using the MCP Client","text":"can also access resources provided server:","code":"# List available resources resources <- resources_list(client) print(resources) # Read a specific resource resource_content <- resources_read(client, \"example-resource\") print(resource_content)"},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"complete-example","dir":"Articles","previous_headings":"","what":"Complete Example","title":"Using the MCP Client","text":"’s complete example demonstrates connecting calculator server performing operations:","code":"# Create a client client <- new_client( \"Rscript\", system.file(\"examples/calculator/server.R\", package = \"mcpr\"), name = \"calculator\", version = \"1.0.0\" ) # Initialize the connection initialize(client) # List available tools tools <- tools_list(client) print(tools) # Call the math_calculator tool with different operations add_result <- tools_call( client, name = \"math_calculator\", params = list( operation = \"add\", a = 10, b = 5 ) ) print(add_result) multiply_result <- tools_call( client, name = \"math_calculator\", params = list( operation = \"multiply\", a = 10, b = 5 ) ) print(multiply_result)"},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"practical-use-cases","dir":"Articles","previous_headings":"","what":"Practical Use Cases","title":"Using the MCP Client","text":"MCP clients can used various scenarios: Integration External AI Services: Connect AI models services expose MCP interface Microservices Architecture: Communicate different R services using MCP protocol Testing MCP Servers: Verify MCP server implementations work correctly Building UI Applications: Create user interfaces interact MCP servers provide functionality","code":""},{"path":"https://mcpr.opifex.org/articles/client-usage.html","id":"conclusion","dir":"Articles","previous_headings":"","what":"Conclusion","title":"Using the MCP Client","text":"MCP client functionality mcpr package provides flexible way interact MCP servers R. Whether ’re building applications consume AI capabilities creating distributed systems communicate via MCP, client interface makes easy work protocol. advanced usage, check function documentation vignettes.","code":""},{"path":"https://mcpr.opifex.org/articles/get-started.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Getting Started with mcpr","text":"mcpr package allows create Model Context Protocol (MCP) servers R. vignette guide building simple MCP server basic addition tool.","code":""},{"path":"https://mcpr.opifex.org/articles/get-started.html","id":"creating-a-simple-mcp-server","dir":"Articles","previous_headings":"","what":"Creating a Simple MCP Server","title":"Getting Started with mcpr","text":"Let’s create simple MCP server can add two numbers:","code":"# Create a new MCP server mcp_server <- new_server( name = \"Simple Adder\", description = \"A basic MCP server that adds two numbers\", version = \"1.0.0\" ) # Create a simple addition tool add_tool <- new_tool( name = \"add\", description = \"Adds two numbers together\", input_schema = schema( properties = list( a = property_number(\"First number\", \"First number to add\", required = TRUE), b = property_number(\"Second number\", \"Second number to add\", required = TRUE) ) ), handler = function(input) { result <- input$a + input$b response_text(paste(\"The sum is:\", result)) } ) # Add the tool to the server mcp_server <- add_capability(mcp_server, add_tool)"},{"path":"https://mcpr.opifex.org/articles/get-started.html","id":"using-standard-inputoutput","dir":"Articles","previous_headings":"","what":"Using Standard Input/Output","title":"Getting Started with mcpr","text":"simplest way interact MCP server standard input/output using serve_io function: run serve_io(mcp_server), R session wait input JSON-RPC 2.0 format. can communicate server sending JSON-RPC requests.","code":"# Start the server using standard input/output serve_io(mcp_server)"},{"path":"https://mcpr.opifex.org/articles/get-started.html","id":"testing-the-server","dir":"Articles","previous_headings":"","what":"Testing the Server","title":"Getting Started with mcpr","text":"test server, can run code R script interact using command line. example: Save code file named mcp_adder.R Run command line: Rscript mcp_adder.R Send JSON-RPC request standard input: server respond :","code":"{\"jsonrpc\": \"2.0\", \"id\": 123, \"method\": \"tools/call\", \"params\": {\"name\": \"add\", \"arguments\": {\"a\": 15, \"b\": 27}}} {\"jsonrpc\": \"2.0\", \"id\": 123, \"result\": {\"content\": [{\"type\": \"text\", \"text\": \"The sum is: 42\"}]}}"},{"path":"https://mcpr.opifex.org/articles/get-started.html","id":"next-steps","dir":"Articles","previous_headings":"","what":"Next Steps","title":"Getting Started with mcpr","text":"’re comfortable basics, can: Add complex tools different operations Create resources serve data Implement prompts text generation See vignettes function documentation details advanced features.","code":""},{"path":"https://mcpr.opifex.org/articles/practical-examples.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Practical MCP Examples with R","text":"Model Context Protocol (MCP) enables AI models interact R code. vignette showcases several practical examples MCP tools leverage R’s statistical data manipulation capabilities.","code":""},{"path":"https://mcpr.opifex.org/articles/practical-examples.html","id":"example-1-statistical-analysis-tool","dir":"Articles","previous_headings":"","what":"Example 1: Statistical Analysis Tool","title":"Practical MCP Examples with R","text":"example creates MCP tool performs basic statistical analysis numeric data:","code":"# Create a statistical analysis MCP server stats_server <- new_server( name = \"r-statistics\", description = \"Statistical analysis tools using R\", version = \"1.0.0\" ) # Create a summary statistics tool summary_stats <- new_tool( name = \"summary_statistics\", description = \"Calculate summary statistics for a numeric vector\", input_schema = schema( properties = properties( data = property_array( \"Data\", \"Numeric vector to analyze\", items = property_number(\"Value\", \"A numeric value\"), required = TRUE ), include_quantiles = property_boolean( \"Include Quantiles\", \"Whether to include quantiles in the results\", default = FALSE ) ) ), handler = function(input) { # Convert input to numeric vector data <- unlist(input$data) # Calculate basic statistics stats <- list( n = length(data), mean = mean(data, na.rm = TRUE), median = median(data, na.rm = TRUE), sd = sd(data, na.rm = TRUE), min = min(data, na.rm = TRUE), max = max(data, na.rm = TRUE) ) # Add quantiles if requested if (input$include_quantiles) { stats$quantiles <- as.list(quantile(data, probs = c(0.25, 0.5, 0.75), na.rm = TRUE)) } # Format the results as text result_text <- paste0( \"Summary Statistics:\\n\", \"- n: \", stats$n, \"\\n\", \"- Mean: \", round(stats$mean, 4), \"\\n\", \"- Median: \", round(stats$median, 4), \"\\n\", \"- Standard Deviation: \", round(stats$sd, 4), \"\\n\", \"- Min: \", round(stats$min, 4), \"\\n\", \"- Max: \", round(stats$max, 4) ) if (input$include_quantiles) { result_text <- paste0( result_text, \"\\n\", \"- 25th Percentile: \", round(stats$quantiles[[1]], 4), \"\\n\", \"- 50th Percentile: \", round(stats$quantiles[[2]], 4), \"\\n\", \"- 75th Percentile: \", round(stats$quantiles[[3]], 4) ) } response_text(result_text) } ) # Add the tool to the server stats_server <- add_capability(stats_server, summary_stats)"},{"path":"https://mcpr.opifex.org/articles/practical-examples.html","id":"example-2-data-visualization-resource","dir":"Articles","previous_headings":"","what":"Example 2: Data Visualization Resource","title":"Practical MCP Examples with R","text":"example creates MCP resource generates visualizations data:","code":"# Load required packages library(ggplot2) # Create visualization server viz_server <- new_server( name = \"r-visualizations\", description = \"Data visualization tools using R\", version = \"1.0.0\" ) # Create a scatter plot tool scatter_plot <- new_tool( name = \"scatter_plot\", description = \"Create a scatter plot from x and y coordinates\", input_schema = schema( properties = properties( x = property_array( \"X values\", \"X-axis coordinates\", items = property_number(\"X value\", \"A numeric value\"), required = TRUE ), y = property_array( \"Y values\", \"Y-axis coordinates\", items = property_number(\"Y value\", \"A numeric value\"), required = TRUE ), title = property_string( \"Plot title\", \"Title for the plot\", default = \"Scatter Plot\" ), x_label = property_string( \"X-axis label\", \"Label for the x-axis\", default = \"X\" ), y_label = property_string( \"Y-axis label\", \"Label for the y-axis\", default = \"Y\" ) ) ), handler = function(input) { # Check that x and y have the same length x <- unlist(input$x) y <- unlist(input$y) if (length(x) != length(y)) { return(response_error(\"X and Y arrays must have the same length\")) } # Create a data frame for ggplot plot_data <- data.frame(x = x, y = y) # Create a temporary file for the plot # Note: In a production environment, consider file cleanup strategies # that don't risk deleting files before clients can access them temp_file <- tempfile(fileext = \".png\") # Create the plot using ggplot2 p <- ggplot(plot_data, aes(x = x, y = y)) + geom_point(color = \"steelblue\", size = 3) + labs( title = input$title, x = input$x_label, y = input$y_label ) + theme_minimal() # Save the plot to the temporary file ggsave(temp_file, p, width = 8, height = 6, dpi = 100) # Return the image # The application should handle cleanup of temporary files # based on its specific file management strategy response_image(temp_file) } ) # Add the tool to the server viz_server <- add_capability(viz_server, scatter_plot)"},{"path":"https://mcpr.opifex.org/articles/practical-examples.html","id":"example-3-natural-language-processing","dir":"Articles","previous_headings":"","what":"Example 3: Natural Language Processing","title":"Practical MCP Examples with R","text":"example demonstrates create MCP tool text analysis:","code":"# Create an NLP server nlp_server <- new_server( name = \"r-text-analysis\", description = \"Text analysis tools using R\", version = \"1.0.0\" ) # Create a text summary tool text_analyzer <- new_tool( name = \"text_analyzer\", description = \"Analyze text to extract basic metrics\", input_schema = schema( properties = properties( text = property_string( \"Text\", \"Text content to analyze\", required = TRUE ) ) ), handler = function(input) { # Extract text from input text <- input$text # Calculate basic text metrics char_count <- nchar(text) word_count <- length(unlist(strsplit(text, \"\\\\s+\"))) sentence_count <- length(unlist(strsplit(text, \"[.!?]\\\\s*\"))) # Calculate word frequencies words <- tolower(unlist(strsplit(text, \"\\\\W+\"))) words <- words[words != \"\"] word_freq <- sort(table(words), decreasing = TRUE) # Get top 5 words top_words <- head(word_freq, 5) top_words_text <- paste(names(top_words), \"(\", top_words, \")\", collapse = \", \") # Format the results result <- paste0( \"Text Analysis:\\n\", \"- Character count: \", char_count, \"\\n\", \"- Word count: \", word_count, \"\\n\", \"- Sentence count: \", sentence_count, \"\\n\", \"- Unique words: \", length(word_freq), \"\\n\", \"- Top 5 words: \", top_words_text ) response_text(result) } ) # Add the tool to the server nlp_server <- add_capability(nlp_server, text_analyzer)"},{"path":"https://mcpr.opifex.org/articles/practical-examples.html","id":"example-4-time-series-forecasting","dir":"Articles","previous_headings":"","what":"Example 4: Time Series Forecasting","title":"Practical MCP Examples with R","text":"example creates MCP tool simple time series forecasting:","code":"# Create a forecasting server forecast_server <- new_server( name = \"r-forecasting\", description = \"Time series forecasting tools using R\", version = \"1.0.0\" ) # Create a simple forecasting tool simple_forecast <- new_tool( name = \"simple_forecast\", description = \"Forecast future values based on historical time series data\", input_schema = schema( properties = properties( values = property_array( \"Historical values\", \"Historical time series values\", items = property_number(\"Value\", \"A numeric value\"), required = TRUE ), periods = property_number( \"Forecast periods\", \"Number of periods to forecast\", default = 5, minimum = 1, maximum = 50 ), method = property_enum( \"Forecast method\", \"Method to use for forecasting\", enum = c(\"mean\", \"naive\", \"drift\", \"exponential\"), default = \"exponential\" ) ) ), handler = function(input) { # Extract inputs values <- unlist(input$values) periods <- input$periods method <- input$method # Apply the selected forecasting method forecast_values <- switch( method, \"mean\" = { rep(mean(values), periods) }, \"naive\" = { rep(tail(values, 1), periods) }, \"drift\" = { last_value <- tail(values, 1) avg_change <- (last_value - values[1]) / (length(values) - 1) last_value + (1:periods) * avg_change }, \"exponential\" = { # Simple exponential smoothing alpha <- 0.3 # smoothing parameter level <- values[1] for (i in 2:length(values)) { level <- alpha * values[i] + (1 - alpha) * level } rep(level, periods) } ) # Format the results forecast_text <- paste( \"Forecast for next\", periods, \"periods using\", method, \"method:\", paste(round(forecast_values, 2), collapse = \", \") ) # Create a plot of historical + forecast values using ggplot2 # Note: In a production environment, consider file cleanup strategies # that don't risk deleting files before clients can access them temp_file <- tempfile(fileext = \".png\") # Prepare data for ggplot # Create a data frame with historical and forecast data n_hist <- length(values) n_forecast <- length(forecast_values) plot_data <- data.frame( time = 1:(n_hist + n_forecast), value = c(values, forecast_values), type = c(rep(\"Historical\", n_hist), rep(\"Forecast\", n_forecast)) ) # Create the plot using ggplot2 p <- ggplot(plot_data, aes(x = time, y = value, color = type, linetype = type)) + geom_line(size = 1) + scale_color_manual(values = c(\"Historical\" = \"black\", \"Forecast\" = \"blue\")) + scale_linetype_manual(values = c(\"Historical\" = \"solid\", \"Forecast\" = \"dashed\")) + labs( title = paste(\"Time Series Forecast (\", method, \")\"), x = \"Time Period\", y = \"Value\", color = \"Data Type\", linetype = \"Data Type\" ) + theme_minimal() + theme(legend.position = \"top\") # Save the plot to the temporary file ggsave(temp_file, p, width = 8, height = 6, dpi = 100) # Return both text and image # The application should handle cleanup of temporary files # based on its specific file management strategy response(list( response_text(forecast_text), response_image(temp_file) )) } ) # Add the tool to the server forecast_server <- add_capability(forecast_server, simple_forecast)"},{"path":"https://mcpr.opifex.org/articles/practical-examples.html","id":"example-5-machine-learning-classification","dir":"Articles","previous_headings":"","what":"Example 5: Machine Learning Classification","title":"Practical MCP Examples with R","text":"example demonstrates simple machine learning classification tool:","code":"# Create an ML server ml_server <- new_server( name = \"r-machine-learning\", description = \"Machine learning tools using R\", version = \"1.0.0\" ) # Create a simple classifier tool simple_classifier <- new_tool( name = \"simple_classifier\", description = \"Train a simple classifier and make predictions\", input_schema = schema( properties = properties( features = property_array( \"Training features\", \"Features for training (list of feature vectors)\", items = property_array( \"Feature vector\", \"Vector of features for a single instance\", items = property_number(\"Feature\", \"Feature value\") ), required = TRUE ), labels = property_array( \"Training labels\", \"Labels for training data (0 or 1)\", items = property_number( \"Label\", \"Class label (0 or 1)\" ), required = TRUE ), test_features = property_array( \"Test features\", \"Features for prediction\", items = property_array( \"Feature vector\", \"Vector of features for a single instance\", items = property_number(\"Feature\", \"Feature value\") ), required = TRUE ), method = property_enum( \"Classification method\", \"Method to use for classification\", enum = c(\"logistic\", \"lda\"), default = \"logistic\" ) ) ), handler = function(input) { # Process input data features <- lapply(input$features, unlist) labels <- unlist(input$labels) test_features <- lapply(input$test_features, unlist) method <- input$method # Check that all feature vectors have the same length feature_lengths <- sapply(features, length) if (length(unique(feature_lengths)) != 1) { return(response_error(\"All feature vectors must have the same length\")) } test_feature_lengths <- sapply(test_features, length) if (any(test_feature_lengths != feature_lengths[1])) { return(response_error(\"Test features must have the same dimensions as training features\")) } # Create a training data frame train_df <- as.data.frame(do.call(rbind, features)) colnames(train_df) <- paste0(\"X\", 1:ncol(train_df)) train_df$y <- as.factor(labels) # Create a test data frame test_df <- as.data.frame(do.call(rbind, test_features)) colnames(test_df) <- paste0(\"X\", 1:ncol(test_df)) # Train a model based on the selected method if (method == \"logistic\") { formula <- as.formula(paste(\"y ~\", paste(colnames(train_df)[colnames(train_df) != \"y\"], collapse = \" + \"))) model <- glm(formula, data = train_df, family = \"binomial\") # Make predictions pred_probs <- predict(model, test_df, type = \"response\") predictions <- ifelse(pred_probs > 0.5, 1, 0) } else if (method == \"lda\") { # Use simple implementation to avoid additional dependencies # Calculate means for each class means_class0 <- colMeans(train_df[train_df$y == 0, colnames(train_df) != \"y\", drop = FALSE]) means_class1 <- colMeans(train_df[train_df$y == 1, colnames(train_df) != \"y\", drop = FALSE]) # Calculate pooled covariance matrix n0 <- sum(train_df$y == 0) n1 <- sum(train_df$y == 1) # Make predictions using distance to means predictions <- numeric(nrow(test_df)) for (i in 1:nrow(test_df)) { dist0 <- sum((as.numeric(test_df[i,]) - means_class0)^2) dist1 <- sum((as.numeric(test_df[i,]) - means_class1)^2) predictions[i] <- ifelse(dist0 < dist1, 0, 1) } } # Format results result_text <- paste( \"Classification results using\", method, \"method:\\n\", \"Predictions:\", paste(predictions, collapse = \", \") ) response_text(result_text) } ) # Add the tool to the server ml_server <- add_capability(ml_server, simple_classifier)"},{"path":"https://mcpr.opifex.org/articles/practical-examples.html","id":"running-these-examples","dir":"Articles","previous_headings":"","what":"Running These Examples","title":"Practical MCP Examples with R","text":"run examples, save code R script add appropriate serve_io() serve_http() call end: follow client integration instructions “Integrating mcpr MCP Clients” vignette.","code":"# For CLI-based tools (Claude Code, Cursor, etc.) serve_io(your_server) # For HTTP-based tools (OpenAI, LangChain, etc.) serve_http(your_server, port = 8080)"},{"path":"https://mcpr.opifex.org/articles/practical-examples.html","id":"conclusion","dir":"Articles","previous_headings":"","what":"Conclusion","title":"Practical MCP Examples with R","text":"examples demonstrate R’s powerful statistical, visualization, machine learning capabilities can exposed AI systems Model Context Protocol. creating specialized MCP tools, can enhance AI applications R’s unique strengths. advanced usage, consider: Combining multiple tools single server Adding error handling input validation Creating complex responses multiple content types Leveraging R packages specialized domains See package documentation details advanced features.","code":""},{"path":"https://mcpr.opifex.org/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"John Coene. Author, maintainer. Opifex. Copyright holder, funder.","code":""},{"path":"https://mcpr.opifex.org/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Coene J (2025). mcpr: Model Context Protocol R. R package version 0.0.2.9000, https://mcpr.opifex.org/.","code":"@Manual{, title = {mcpr: Model Context Protocol for R}, author = {John Coene}, year = {2025}, note = {R package version 0.0.2.9000}, url = {https://mcpr.opifex.org/}, }"},{"path":"https://mcpr.opifex.org/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Model Context Protocol for R","text":"can install mcpr GitHub using pak package:","code":"pak::pkg_install(\"devOpifex/mcpr\")"},{"path":[]},{"path":"https://mcpr.opifex.org/index.html","id":"server","dir":"","previous_headings":"Basic Usage","what":"Server","title":"Model Context Protocol for R","text":"’s simple example creates MCP server calculator tool: can return multiple responses returning list response objects: can also serve via HTTP transport serve_http: See Get Started guide information.","code":"library(mcpr) calculator <- new_tool( name = \"calculator\", description = \"Performs basic arithmetic operations\", input_schema = schema( properties = properties( operation = property_enum( \"Operation\", \"Math operation to perform\", values = c(\"add\", \"subtract\", \"multiply\", \"divide\"), required = TRUE ), a = property_number(\"First number\", \"First operand\", required = TRUE), b = property_number(\"Second number\", \"Second operand\", required = TRUE) ) ), handler = function(params) { result <- switch(params$operation, \"add\" = params$a + params$b, \"subtract\" = params$a - params$b, \"multiply\" = params$a * params$b, \"divide\" = params$a / params$b ) response_text(result) } ) mcp <- new_mcp( name = \"R Calculator Server\", description = \"A simple calculator server implemented in R\", version = \"1.0.0\" ) mcp <- add_capability(mcp, calculator) serve_io(mcp) response( response_text(\"Hello, world!\"), response_image(system.file(\"extdata/logo.png\", package = \"mcpr\")), response_audio(system.file(\"extdata/sound.mp3\", package = \"mcpr\")), response_video(system.file(\"extdata/video.mp4\", package = \"mcpr\")), response_file(system.file(\"extdata/file.txt\", package = \"mcpr\")), response_resource(system.file(\"extdata/resource.json\", package = \"mcpr\")) ) # Serve via HTTP on port 3000 serve_http(mcp, port = 3000)"},{"path":"https://mcpr.opifex.org/index.html","id":"client","dir":"","previous_headings":"Basic Usage","what":"Client","title":"Model Context Protocol for R","text":"’s simple example using client interact MCP server:","code":"library(mcpr) # Create a client that connects to an MCP server # For HTTP transport client <- new_client_http( \"http://localhost:8080\", name = \"calculator\", version = \"1.0.0\" ) # Or for standard IO transport # client <- new_client_io( # \"Rscript\", # \"/path/to/server.R\", # name = \"calculator\", # version = \"1.0.0\" # ) # List available tools tools <- tools_list(client) print(tools) # Call a tool result <- tools_call( client, params = list( name = \"calculator\", arguments = list( operation = \"add\", a = 5, b = 3 ) ), id = 1L ) print(result) # List available prompts prompts <- prompts_list(client) print(prompts) # List available resources resources <- resources_list(client) print(resources) # Read a resource resource_content <- resources_read( client, params = list( name = \"example-resource\" ) ) print(resource_content)"},{"path":"https://mcpr.opifex.org/index.html","id":"ellmer-integration","dir":"","previous_headings":"","what":"ellmer integration","title":"Model Context Protocol for R","text":"Now supports ellmer tools, can use ellmer’s mcpr’s tools, interchangeably. See example , taken ellmer documentation","code":"# create an ellmer tool current_time <- ellmer::tool( \\(tz = \"UTC\") { format(Sys.time(), tz = tz, usetz = TRUE) }, \"Gets the current time in the given time zone.\", tz = ellmer::type_string( \"The time zone to get the current time in. Defaults to `\\\"UTC\\\"`.\", required = FALSE ) ) mcp <- new_server( name = \"R Calculator Server\", description = \"A simple calculator server implemented in R\", version = \"1.0.0\" ) # register ellmer tool with mcpr server mcp <- add_capability(mcp, current_time) serve_io(mcp)"},{"path":[]},{"path":"https://mcpr.opifex.org/index.html","id":"claude-code-integration","dir":"","previous_headings":"Using mcpr","what":"Claude Code Integration","title":"Model Context Protocol for R","text":"use MCP server Claude Code, see documentation","code":"claude mcp add r-calculator -- Rscript /path/to/calculator_server.R"},{"path":"https://mcpr.opifex.org/index.html","id":"cursor-integration","dir":"","previous_headings":"Using mcpr","what":"Cursor Integration","title":"Model Context Protocol for R","text":"integrate Cursor see documentation","code":"{ \"customCommands\": { \"r-calculator\": { \"command\": \"Rscript 'path/to/calculator_server.R'\" } } }"},{"path":"https://mcpr.opifex.org/index.html","id":"vs-code-agent-mode-integration","dir":"","previous_headings":"Using mcpr","what":"VS Code Agent Mode Integration","title":"Model Context Protocol for R","text":"integrate VS Code Agent mode see documentation integrations docs","code":"\"mcp\": { \"servers\": { \"my-mcp-server-calculator\": { \"type\": \"stdio\", \"command\": \"Rscript\", \"args\": [ \"path/to/calculator_server.R\" ] } } }"},{"path":"https://mcpr.opifex.org/reference/JSONRPC_PARSE_ERROR.html","id":null,"dir":"Reference","previous_headings":"","what":"JSON-RPC 2.0 Standard Error Codes — JSONRPC_PARSE_ERROR","title":"JSON-RPC 2.0 Standard Error Codes — JSONRPC_PARSE_ERROR","text":"JSON-RPC 2.0 Standard Error Codes","code":""},{"path":"https://mcpr.opifex.org/reference/JSONRPC_PARSE_ERROR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"JSON-RPC 2.0 Standard Error Codes — JSONRPC_PARSE_ERROR","text":"","code":"JSONRPC_PARSE_ERROR"},{"path":"https://mcpr.opifex.org/reference/JSONRPC_PARSE_ERROR.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"JSON-RPC 2.0 Standard Error Codes — JSONRPC_PARSE_ERROR","text":"object class numeric length 1.","code":""},{"path":"https://mcpr.opifex.org/reference/add_capability.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a capability to an MCP object — add_capability","title":"Add a capability to an MCP object — add_capability","text":"Add capability MCP object","code":""},{"path":"https://mcpr.opifex.org/reference/add_capability.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a capability to an MCP object — add_capability","text":"","code":"add_capability(mcp, capability)"},{"path":"https://mcpr.opifex.org/reference/add_capability.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a capability to an MCP object — add_capability","text":"mcp MCP server object capability tool, resource, prompt capability object","code":""},{"path":"https://mcpr.opifex.org/reference/add_capability.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a capability to an MCP object — add_capability","text":"MCP object capability added","code":""},{"path":"https://mcpr.opifex.org/reference/build_param_info.html","id":null,"dir":"Reference","previous_headings":"","what":"Build parameter information from @param and @type tags — build_param_info","title":"Build parameter information from @param and @type tags — build_param_info","text":"Build parameter information @param @type tags","code":""},{"path":"https://mcpr.opifex.org/reference/build_param_info.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Build parameter information from @param and @type tags — build_param_info","text":"","code":"build_param_info(param_tags, type_tags = list())"},{"path":"https://mcpr.opifex.org/reference/build_param_info.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Build parameter information from @param and @type tags — build_param_info","text":"param_tags List @param tags type_tags List @type tags","code":""},{"path":"https://mcpr.opifex.org/reference/build_param_info.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Build parameter information from @param and @type tags — build_param_info","text":"List parameter information","code":""},{"path":"https://mcpr.opifex.org/reference/client.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new mcp IO — client","title":"Create a new mcp IO — client","text":"Create new mcp IO","code":""},{"path":"https://mcpr.opifex.org/reference/client.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new mcp IO — client","text":"","code":"new_client_io(command, args = character(), name, version = \"1.0.0\") new_client_http(endpoint, name, version = \"1.0.0\")"},{"path":"https://mcpr.opifex.org/reference/client.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new mcp IO — client","text":"command command run args Arguments pass command name name client version version client endpoint endpoint connect ","code":""},{"path":"https://mcpr.opifex.org/reference/client.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new mcp IO — client","text":"new mcp client","code":""},{"path":"https://mcpr.opifex.org/reference/convert_ellmer_type_to_mcpr_property.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert a single ellmer type to an mcpr property — convert_ellmer_type_to_mcpr_property","title":"Convert a single ellmer type to an mcpr property — convert_ellmer_type_to_mcpr_property","text":"Convert single ellmer type mcpr property","code":""},{"path":"https://mcpr.opifex.org/reference/convert_ellmer_type_to_mcpr_property.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert a single ellmer type to an mcpr property — convert_ellmer_type_to_mcpr_property","text":"","code":"convert_ellmer_type_to_mcpr_property(ellmer_type, prop_name)"},{"path":"https://mcpr.opifex.org/reference/convert_ellmer_type_to_mcpr_property.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert a single ellmer type to an mcpr property — convert_ellmer_type_to_mcpr_property","text":"ellmer_type ellmer Type object (TypeBasic, TypeArray, etc.) prop_name name property (better error messages)","code":""},{"path":"https://mcpr.opifex.org/reference/convert_ellmer_type_to_mcpr_property.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert a single ellmer type to an mcpr property — convert_ellmer_type_to_mcpr_property","text":"mcpr property object","code":""},{"path":"https://mcpr.opifex.org/reference/convert_ellmer_types_to_mcpr.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert ellmer TypeObject to mcpr schema — convert_ellmer_types_to_mcpr","title":"Convert ellmer TypeObject to mcpr schema — convert_ellmer_types_to_mcpr","text":"Convert ellmer TypeObject mcpr schema","code":""},{"path":"https://mcpr.opifex.org/reference/convert_ellmer_types_to_mcpr.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert ellmer TypeObject to mcpr schema — convert_ellmer_types_to_mcpr","text":"","code":"convert_ellmer_types_to_mcpr(type_object)"},{"path":"https://mcpr.opifex.org/reference/convert_ellmer_types_to_mcpr.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert ellmer TypeObject to mcpr schema — convert_ellmer_types_to_mcpr","text":"type_object ellmer TypeObject containing function arguments","code":""},{"path":"https://mcpr.opifex.org/reference/convert_ellmer_types_to_mcpr.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert ellmer TypeObject to mcpr schema — convert_ellmer_types_to_mcpr","text":"mcpr schema object","code":""},{"path":"https://mcpr.opifex.org/reference/create_ellmer_handler.html","id":null,"dir":"Reference","previous_headings":"","what":"Create an ellmer handler function for an MCP tool — create_ellmer_handler","title":"Create an ellmer handler function for an MCP tool — create_ellmer_handler","text":"Create ellmer handler function MCP tool","code":""},{"path":"https://mcpr.opifex.org/reference/create_ellmer_handler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create an ellmer handler function for an MCP tool — create_ellmer_handler","text":"","code":"create_ellmer_handler(client, tool_name, input_schema)"},{"path":"https://mcpr.opifex.org/reference/create_ellmer_handler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create an ellmer handler function for an MCP tool — create_ellmer_handler","text":"client mcpr client tool_name name MCP tool input_schema tool's input schema","code":""},{"path":"https://mcpr.opifex.org/reference/create_ellmer_handler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create an ellmer handler function for an MCP tool — create_ellmer_handler","text":"function can used ellmer tool handler","code":""},{"path":"https://mcpr.opifex.org/reference/create_ellmer_type.html","id":null,"dir":"Reference","previous_headings":"","what":"Create an ellmer type function for a specific MCP property — create_ellmer_type","title":"Create an ellmer type function for a specific MCP property — create_ellmer_type","text":"Create ellmer type function specific MCP property","code":""},{"path":"https://mcpr.opifex.org/reference/create_ellmer_type.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create an ellmer type function for a specific MCP property — create_ellmer_type","text":"","code":"create_ellmer_type(prop)"},{"path":"https://mcpr.opifex.org/reference/create_ellmer_type.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create an ellmer type function for a specific MCP property — create_ellmer_type","text":"prop MCP property","code":""},{"path":"https://mcpr.opifex.org/reference/create_ellmer_type.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create an ellmer type function for a specific MCP property — create_ellmer_type","text":"ellmer type function call","code":""},{"path":"https://mcpr.opifex.org/reference/create_ellmer_types.html","id":null,"dir":"Reference","previous_headings":"","what":"Create ellmer type functions from MCP schema properties — create_ellmer_types","title":"Create ellmer type functions from MCP schema properties — create_ellmer_types","text":"Create ellmer type functions MCP schema properties","code":""},{"path":"https://mcpr.opifex.org/reference/create_ellmer_types.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create ellmer type functions from MCP schema properties — create_ellmer_types","text":"","code":"create_ellmer_types(schema)"},{"path":"https://mcpr.opifex.org/reference/create_ellmer_types.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create ellmer type functions from MCP schema properties — create_ellmer_types","text":"schema MCP schema object","code":""},{"path":"https://mcpr.opifex.org/reference/create_ellmer_types.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create ellmer type functions from MCP schema properties — create_ellmer_types","text":"list ellmer type function calls property","code":""},{"path":"https://mcpr.opifex.org/reference/create_error.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a JSON-RPC 2.0 error response — create_error","title":"Create a JSON-RPC 2.0 error response — create_error","text":"Create JSON-RPC 2.0 error response","code":""},{"path":"https://mcpr.opifex.org/reference/create_error.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a JSON-RPC 2.0 error response — create_error","text":"","code":"create_error(code, message, data = NULL, id = NULL)"},{"path":"https://mcpr.opifex.org/reference/create_error.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a JSON-RPC 2.0 error response — create_error","text":"code Error code message Error message data Optional error data id Request identifier","code":""},{"path":"https://mcpr.opifex.org/reference/create_error.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a JSON-RPC 2.0 error response — create_error","text":"structured JSON-RPC 2.0 error response","code":""},{"path":"https://mcpr.opifex.org/reference/create_response.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a JSON-RPC 2.0 success response — create_response","title":"Create a JSON-RPC 2.0 success response — create_response","text":"Create JSON-RPC 2.0 success response","code":""},{"path":"https://mcpr.opifex.org/reference/create_response.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a JSON-RPC 2.0 success response — create_response","text":"","code":"create_response(result, id = NULL)"},{"path":"https://mcpr.opifex.org/reference/create_response.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a JSON-RPC 2.0 success response — create_response","text":"result Result data id Request identifier","code":""},{"path":"https://mcpr.opifex.org/reference/create_response.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a JSON-RPC 2.0 success response — create_response","text":"structured JSON-RPC 2.0 success response","code":""},{"path":"https://mcpr.opifex.org/reference/ellmer_to_mcpr_tool.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert ellmer tools to mcpr tools — ellmer_to_mcpr_tool","title":"Convert ellmer tools to mcpr tools — ellmer_to_mcpr_tool","text":"function converts tools ellmer package format compatible mcpr package. takes ellmer ToolDef object creates mcpr tool object appropriate input schema handler function.","code":""},{"path":"https://mcpr.opifex.org/reference/ellmer_to_mcpr_tool.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert ellmer tools to mcpr tools — ellmer_to_mcpr_tool","text":"","code":"ellmer_to_mcpr_tool(ellmer_tool)"},{"path":"https://mcpr.opifex.org/reference/ellmer_to_mcpr_tool.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert ellmer tools to mcpr tools — ellmer_to_mcpr_tool","text":"ellmer_tool ellmer ToolDef object created ellmer::tool()","code":""},{"path":"https://mcpr.opifex.org/reference/ellmer_to_mcpr_tool.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert ellmer tools to mcpr tools — ellmer_to_mcpr_tool","text":"mcpr tool object compatible new_tool()","code":""},{"path":[]},{"path":"https://mcpr.opifex.org/reference/ellmer_to_mcpr_tool.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert ellmer tools to mcpr tools — ellmer_to_mcpr_tool","text":"","code":"if (FALSE) { # \\dontrun{ # Create an ellmer tool ellmer_rnorm <- ellmer::tool( rnorm, \"Generate random normal numbers\", n = ellmer::type_integer(\"Number of observations\"), mean = ellmer::type_number(\"Mean value\", required = FALSE), sd = ellmer::type_number(\"Standard deviation\", required = FALSE) ) # Convert to mcpr format mcpr_tool <- ellmer_to_mcpr_tool(ellmer_rnorm) # Add to an mcpr server server <- new_server(\"MyServer\", \"Test server\", \"1.0.0\") add_capability(server, mcpr_tool) } # }"},{"path":"https://mcpr.opifex.org/reference/extract_mcp_result.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract and convert an MCP result to ellmer-compatible format — extract_mcp_result","title":"Extract and convert an MCP result to ellmer-compatible format — extract_mcp_result","text":"Extract convert MCP result ellmer-compatible format","code":""},{"path":"https://mcpr.opifex.org/reference/extract_mcp_result.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract and convert an MCP result to ellmer-compatible format — extract_mcp_result","text":"","code":"extract_mcp_result(result)"},{"path":"https://mcpr.opifex.org/reference/extract_mcp_result.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract and convert an MCP result to ellmer-compatible format — extract_mcp_result","text":"result MCP result object","code":""},{"path":"https://mcpr.opifex.org/reference/extract_mcp_result.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract and convert an MCP result to ellmer-compatible format — extract_mcp_result","text":"value ellmer-compatible format","code":""},{"path":"https://mcpr.opifex.org/reference/from_json.html","id":null,"dir":"Reference","previous_headings":"","what":"Parse JSON to an R object — from_json","title":"Parse JSON to an R object — from_json","text":"Parse JSON R object","code":""},{"path":"https://mcpr.opifex.org/reference/from_json.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Parse JSON to an R object — from_json","text":"","code":"from_json(json, ...)"},{"path":"https://mcpr.opifex.org/reference/from_json.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Parse JSON to an R object — from_json","text":"json JSON string parse ... Additional arguments passed yyjsonr::read_json_str","code":""},{"path":"https://mcpr.opifex.org/reference/from_json.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Parse JSON to an R object — from_json","text":"R object","code":""},{"path":"https://mcpr.opifex.org/reference/generate_handler_code.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate handler code that calls the original function — generate_handler_code","title":"Generate handler code that calls the original function — generate_handler_code","text":"Generate handler code calls original function","code":""},{"path":"https://mcpr.opifex.org/reference/generate_handler_code.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate handler code that calls the original function — generate_handler_code","text":"","code":"generate_handler_code(tool)"},{"path":"https://mcpr.opifex.org/reference/generate_handler_code.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate handler code that calls the original function — generate_handler_code","text":"tool Tool information","code":""},{"path":"https://mcpr.opifex.org/reference/generate_handler_code.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate handler code that calls the original function — generate_handler_code","text":"Character vector handler code lines","code":""},{"path":"https://mcpr.opifex.org/reference/generate_mcp_server.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate MCP server R code — generate_mcp_server","title":"Generate MCP server R code — generate_mcp_server","text":"Generate MCP server R code","code":""},{"path":"https://mcpr.opifex.org/reference/generate_mcp_server.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate MCP server R code — generate_mcp_server","text":"","code":"generate_mcp_server(tools, base_path)"},{"path":"https://mcpr.opifex.org/reference/generate_mcp_server.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate MCP server R code — generate_mcp_server","text":"tools List tool information base_path Base path package","code":""},{"path":"https://mcpr.opifex.org/reference/generate_mcp_server.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate MCP server R code — generate_mcp_server","text":"Character vector R code lines","code":""},{"path":"https://mcpr.opifex.org/reference/generate_property_code.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate property code for a parameter — generate_property_code","title":"Generate property code for a parameter — generate_property_code","text":"Generate property code parameter","code":""},{"path":"https://mcpr.opifex.org/reference/generate_property_code.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate property code for a parameter — generate_property_code","text":"","code":"generate_property_code(param)"},{"path":"https://mcpr.opifex.org/reference/generate_property_code.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate property code for a parameter — generate_property_code","text":"param Parameter information","code":""},{"path":"https://mcpr.opifex.org/reference/generate_property_code.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate property code for a parameter — generate_property_code","text":"Character string property code","code":""},{"path":"https://mcpr.opifex.org/reference/generate_tool_code.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate R code for a single tool — generate_tool_code","title":"Generate R code for a single tool — generate_tool_code","text":"Generate R code single tool","code":""},{"path":"https://mcpr.opifex.org/reference/generate_tool_code.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate R code for a single tool — generate_tool_code","text":"","code":"generate_tool_code(tool, index)"},{"path":"https://mcpr.opifex.org/reference/generate_tool_code.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate R code for a single tool — generate_tool_code","text":"tool Tool information list index Tool index naming","code":""},{"path":"https://mcpr.opifex.org/reference/generate_tool_code.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate R code for a single tool — generate_tool_code","text":"Character vector R code lines","code":""},{"path":"https://mcpr.opifex.org/reference/get_name.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the name of a client — get_name","title":"Get the name of a client — get_name","text":"Get name client","code":""},{"path":"https://mcpr.opifex.org/reference/get_name.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the name of a client — get_name","text":"","code":"get_name(x)"},{"path":"https://mcpr.opifex.org/reference/get_name.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the name of a client — get_name","text":"x client object","code":""},{"path":"https://mcpr.opifex.org/reference/get_name.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the name of a client — get_name","text":"name client","code":""},{"path":"https://mcpr.opifex.org/reference/initialize.html","id":null,"dir":"Reference","previous_headings":"","what":"Initialize the server with protocol information — initialize","title":"Initialize the server with protocol information — initialize","text":"Initialize server protocol information","code":""},{"path":"https://mcpr.opifex.org/reference/initialize.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Initialize the server with protocol information — initialize","text":"","code":"initialize(mcp)"},{"path":"https://mcpr.opifex.org/reference/initialize.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Initialize the server with protocol information — initialize","text":"mcp server object","code":""},{"path":"https://mcpr.opifex.org/reference/initialize.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Initialize the server with protocol information — initialize","text":"list containing protocol version, server info, capabilities","code":""},{"path":"https://mcpr.opifex.org/reference/mcp_roclet.html","id":null,"dir":"Reference","previous_headings":"","what":"MCP Roclet for Generating MCP Servers — mcp_roclet","title":"MCP Roclet for Generating MCP Servers — mcp_roclet","text":"roclet automatically generates MCP (Model Context Protocol) servers R functions annotated @mcp tags.","code":""},{"path":"https://mcpr.opifex.org/reference/mcp_roclet.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"MCP Roclet for Generating MCP Servers — mcp_roclet","text":"","code":"mcp_roclet()"},{"path":"https://mcpr.opifex.org/reference/mcp_roclet.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"MCP Roclet for Generating MCP Servers — mcp_roclet","text":"","code":"if (FALSE) { # \\dontrun{ # Use the roclet in roxygenise roxygen2::roxygenise(roclets = c(\"rd\", \"mcpr::mcp_roclet\")) } # }"},{"path":"https://mcpr.opifex.org/reference/mcpr_clients_to_ellmer_tools.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert multiple MCPR clients to ellmer tools — mcpr_clients_to_ellmer_tools","title":"Convert multiple MCPR clients to ellmer tools — mcpr_clients_to_ellmer_tools","text":"function converts tools multiple MCPR clients format compatible ellmer package. useful want combine tools multiple MCP servers single ellmer session.","code":""},{"path":"https://mcpr.opifex.org/reference/mcpr_clients_to_ellmer_tools.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert multiple MCPR clients to ellmer tools — mcpr_clients_to_ellmer_tools","text":"","code":"mcpr_clients_to_ellmer_tools(...)"},{"path":"https://mcpr.opifex.org/reference/mcpr_clients_to_ellmer_tools.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert multiple MCPR clients to ellmer tools — mcpr_clients_to_ellmer_tools","text":"... One mcpr client objects","code":""},{"path":"https://mcpr.opifex.org/reference/mcpr_clients_to_ellmer_tools.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert multiple MCPR clients to ellmer tools — mcpr_clients_to_ellmer_tools","text":"list ellmer-compatible tool functions clients","code":""},{"path":"https://mcpr.opifex.org/reference/mcpr_clients_to_ellmer_tools.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert multiple MCPR clients to ellmer tools — mcpr_clients_to_ellmer_tools","text":"","code":"if (FALSE) { # \\dontrun{ # Create multiple MCPR clients client1 <- new_client_io(\"path/to/server1\") client2 <- new_client_io(\"path/to/server2\") # Convert all tools ellmer_tools <- mcpr_clients_to_ellmer_tools(client1, client2) # Use with ellmer chat <- ellmer::chat_claude() chat$set_tools(ellmer_tools) } # }"},{"path":"https://mcpr.opifex.org/reference/mcpr_to_ellmer_tools.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert MCPR tools to ellmer tools — mcpr_to_ellmer_tools","title":"Convert MCPR tools to ellmer tools — mcpr_to_ellmer_tools","text":"function converts tools MCPR client format compatible ellmer package. retrieves available tools client creates wrapper functions call tools MCPR protocol.","code":""},{"path":"https://mcpr.opifex.org/reference/mcpr_to_ellmer_tools.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert MCPR tools to ellmer tools — mcpr_to_ellmer_tools","text":"","code":"mcpr_to_ellmer_tools(client)"},{"path":"https://mcpr.opifex.org/reference/mcpr_to_ellmer_tools.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert MCPR tools to ellmer tools — mcpr_to_ellmer_tools","text":"client mcpr client object","code":""},{"path":"https://mcpr.opifex.org/reference/mcpr_to_ellmer_tools.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert MCPR tools to ellmer tools — mcpr_to_ellmer_tools","text":"list ellmer-compatible tool functions","code":""},{"path":"https://mcpr.opifex.org/reference/mcpr_to_ellmer_tools.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert MCPR tools to ellmer tools — mcpr_to_ellmer_tools","text":"","code":"if (FALSE) { # \\dontrun{ # Create an MCPR client client <- new_client_io(\"path/to/server\") # Convert its tools to ellmer format ellmer_tools <- mcpr_to_ellmer_tools(client) # Use with ellmer chat <- ellmer::chat_claude() chat$set_tools(ellmer_tools) } # }"},{"path":"https://mcpr.opifex.org/reference/new_client.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new mcp client — new_client","title":"Create a new mcp client — new_client","text":"Create new mcp client","code":""},{"path":"https://mcpr.opifex.org/reference/new_client.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new mcp client — new_client","text":"","code":"new_client(command, args = character(), name = command, version = \"1.0.0\")"},{"path":"https://mcpr.opifex.org/reference/new_client.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new mcp client — new_client","text":"command command run args Arguments pass command name name client version version client","code":""},{"path":"https://mcpr.opifex.org/reference/new_client.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new mcp client — new_client","text":"new mcp client","code":""},{"path":"https://mcpr.opifex.org/reference/new_prompt.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new prompt — new_prompt","title":"Create a new prompt — new_prompt","text":"Create new prompt","code":""},{"path":"https://mcpr.opifex.org/reference/new_prompt.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new prompt — new_prompt","text":"","code":"new_prompt(name, description, arguments = list(), handler)"},{"path":"https://mcpr.opifex.org/reference/new_prompt.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new prompt — new_prompt","text":"name Name prompt description Description prompt arguments List arguments prompt handler Function handle prompt execution","code":""},{"path":"https://mcpr.opifex.org/reference/new_prompt.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new prompt — new_prompt","text":"new prompt capability","code":""},{"path":"https://mcpr.opifex.org/reference/new_prompt.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a new prompt — new_prompt","text":"","code":"prompt <- new_prompt( name = \"My Prompt\", description = \"This is a description\", arguments = list( input1 = list( type = \"string\", description = \"Input 1\" ), input2 = list( type = \"number\", description = \"Input 2\" ) ), handler = function(params) { # Process the prompt request return(list(text = \"Generated text from prompt\")) } )"},{"path":"https://mcpr.opifex.org/reference/new_property.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new property — new_property","title":"Create a new property — new_property","text":"Create new property","code":""},{"path":"https://mcpr.opifex.org/reference/new_property.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new property — new_property","text":"","code":"new_property(type, title, description, required = FALSE, ...)"},{"path":"https://mcpr.opifex.org/reference/new_property.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new property — new_property","text":"type Type property title Short title property description Longer description property required Whether property required ... Additional attributes property","code":""},{"path":"https://mcpr.opifex.org/reference/new_property.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new property — new_property","text":"property object specified attributes","code":""},{"path":"https://mcpr.opifex.org/reference/new_resource.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new resource — new_resource","title":"Create a new resource — new_resource","text":"Create new resource","code":""},{"path":"https://mcpr.opifex.org/reference/new_resource.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new resource — new_resource","text":"","code":"new_resource(name, description, uri, mime_type = NULL, handler)"},{"path":"https://mcpr.opifex.org/reference/new_resource.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new resource — new_resource","text":"name Name resource description Description resource uri URI resource mime_type MIME type resource (optional) handler Function handle resource request","code":""},{"path":"https://mcpr.opifex.org/reference/new_resource.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new resource — new_resource","text":"new resource capability","code":""},{"path":"https://mcpr.opifex.org/reference/new_resource.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a new resource — new_resource","text":"","code":"resource <- new_resource( name = \"My Resource\", description = \"This is a description\", uri = \"https://example.com/resource\", mime_type = \"text/plain\", handler = function(params) { # Process the resource request return(list(content = \"Resource content\")) } )"},{"path":"https://mcpr.opifex.org/reference/new_server.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new MCP object — new_server","title":"Create a new MCP object — new_server","text":"Create new MCP object","code":""},{"path":"https://mcpr.opifex.org/reference/new_server.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new MCP object — new_server","text":"","code":"new_server( name, description, version, tools = list(), resources = list(), prompts = list() ) new_mcp(...)"},{"path":"https://mcpr.opifex.org/reference/new_server.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new MCP object — new_server","text":"name Name MCP server description Description MCP server version Version MCP server tools List tools (optional) resources List resources (optional) prompts List prompts (optional) ... Forwarded new_server()","code":""},{"path":"https://mcpr.opifex.org/reference/new_server.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new MCP object — new_server","text":"new MCP object","code":""},{"path":"https://mcpr.opifex.org/reference/new_server.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a new MCP object — new_server","text":"","code":"mcp <- new_server( name = \"My MCP\", description = \"This is a description\", version = \"1.0.0\" )"},{"path":"https://mcpr.opifex.org/reference/new_tool.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new tool — new_tool","title":"Create a new tool — new_tool","text":"Create new tool","code":""},{"path":"https://mcpr.opifex.org/reference/new_tool.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new tool — new_tool","text":"","code":"new_tool(name, description, input_schema, handler)"},{"path":"https://mcpr.opifex.org/reference/new_tool.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new tool — new_tool","text":"name Name tool description Description tool input_schema Input schema tool (must schema object) handler Function handle tool execution","code":""},{"path":"https://mcpr.opifex.org/reference/new_tool.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new tool — new_tool","text":"new tool capability","code":""},{"path":"https://mcpr.opifex.org/reference/new_tool.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a new tool — new_tool","text":"","code":"tool <- new_tool( name = \"My Tool\", description = \"This is a description\", input_schema = schema( properties = list( input1 = property_string(\"Input 1\", \"Description of input 1\"), input2 = property_number(\"Input 2\", \"Description of input 2\") ) ), handler = function(input) { # Process the input here return(input) } )"},{"path":"https://mcpr.opifex.org/reference/parse_request.html","id":null,"dir":"Reference","previous_headings":"","what":"Parse and process a JSON-RPC 2.0 request — parse_request","title":"Parse and process a JSON-RPC 2.0 request — parse_request","text":"Parse process JSON-RPC 2.0 request","code":""},{"path":"https://mcpr.opifex.org/reference/parse_request.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Parse and process a JSON-RPC 2.0 request — parse_request","text":"","code":"parse_request(json_text, mcp)"},{"path":"https://mcpr.opifex.org/reference/parse_request.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Parse and process a JSON-RPC 2.0 request — parse_request","text":"json_text JSON request text mcp MCP server object","code":""},{"path":"https://mcpr.opifex.org/reference/parse_request.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Parse and process a JSON-RPC 2.0 request — parse_request","text":"JSON response text NULL notifications","code":""},{"path":"https://mcpr.opifex.org/reference/process_batch.html","id":null,"dir":"Reference","previous_headings":"","what":"Process batch JSON-RPC 2.0 requests — process_batch","title":"Process batch JSON-RPC 2.0 requests — process_batch","text":"Process batch JSON-RPC 2.0 requests","code":""},{"path":"https://mcpr.opifex.org/reference/process_batch.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Process batch JSON-RPC 2.0 requests — process_batch","text":"","code":"process_batch(batch_requests, mcp)"},{"path":"https://mcpr.opifex.org/reference/process_batch.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Process batch JSON-RPC 2.0 requests — process_batch","text":"batch_requests List request objects mcp MCP server object","code":""},{"path":"https://mcpr.opifex.org/reference/process_batch.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Process batch JSON-RPC 2.0 requests — process_batch","text":"List response objects","code":""},{"path":"https://mcpr.opifex.org/reference/process_mcp_block.html","id":null,"dir":"Reference","previous_headings":"","what":"Process a single block with @mcp tag — process_mcp_block","title":"Process a single block with @mcp tag — process_mcp_block","text":"Process single block @mcp tag","code":""},{"path":"https://mcpr.opifex.org/reference/process_mcp_block.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Process a single block with @mcp tag — process_mcp_block","text":"","code":"process_mcp_block(block)"},{"path":"https://mcpr.opifex.org/reference/process_mcp_block.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Process a single block with @mcp tag — process_mcp_block","text":"block roxy_block object","code":""},{"path":"https://mcpr.opifex.org/reference/process_mcp_block.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Process a single block with @mcp tag — process_mcp_block","text":"list tool information NULL","code":""},{"path":"https://mcpr.opifex.org/reference/process_request.html","id":null,"dir":"Reference","previous_headings":"","what":"Process a JSON-RPC 2.0 request — process_request","title":"Process a JSON-RPC 2.0 request — process_request","text":"Process JSON-RPC 2.0 request","code":""},{"path":"https://mcpr.opifex.org/reference/process_request.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Process a JSON-RPC 2.0 request — process_request","text":"","code":"process_request(request, mcp)"},{"path":"https://mcpr.opifex.org/reference/process_request.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Process a JSON-RPC 2.0 request — process_request","text":"request Parsed request object mcp MCP server object","code":""},{"path":"https://mcpr.opifex.org/reference/process_request.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Process a JSON-RPC 2.0 request — process_request","text":"Response object NULL notifications","code":""},{"path":"https://mcpr.opifex.org/reference/prompts_get.html","id":null,"dir":"Reference","previous_headings":"","what":"Get a prompt with the given parameters — prompts_get","title":"Get a prompt with the given parameters — prompts_get","text":"Get prompt given parameters","code":""},{"path":"https://mcpr.opifex.org/reference/prompts_get.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get a prompt with the given parameters — prompts_get","text":"","code":"prompts_get(mcp, params, id = NULL)"},{"path":"https://mcpr.opifex.org/reference/prompts_get.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get a prompt with the given parameters — prompts_get","text":"mcp server object params Parameters prompt request id Optional request ID response tracking","code":""},{"path":"https://mcpr.opifex.org/reference/prompts_get.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get a prompt with the given parameters — prompts_get","text":"response object prompt results error","code":""},{"path":"https://mcpr.opifex.org/reference/prompts_list.html","id":null,"dir":"Reference","previous_headings":"","what":"List all available prompts — prompts_list","title":"List all available prompts — prompts_list","text":"List available prompts","code":""},{"path":"https://mcpr.opifex.org/reference/prompts_list.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"List all available prompts — prompts_list","text":"","code":"prompts_list(mcp)"},{"path":"https://mcpr.opifex.org/reference/prompts_list.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"List all available prompts — prompts_list","text":"mcp server object","code":""},{"path":"https://mcpr.opifex.org/reference/prompts_list.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"List all available prompts — prompts_list","text":"list containing available prompts","code":""},{"path":"https://mcpr.opifex.org/reference/properties.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new properties list — properties","title":"Create a new properties list — properties","text":"Create new properties list","code":""},{"path":"https://mcpr.opifex.org/reference/properties.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new properties list — properties","text":"","code":"properties(...)"},{"path":"https://mcpr.opifex.org/reference/properties.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new properties list — properties","text":"... Property objects","code":""},{"path":"https://mcpr.opifex.org/reference/properties.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new properties list — properties","text":"list property objects","code":""},{"path":"https://mcpr.opifex.org/reference/properties.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a new properties list — properties","text":"","code":"properties <- properties( property_string(\"Name\", \"The name of the user\", required = TRUE), property_number(\"Age\", \"The age of the user in years\", minimum = 0) )"},{"path":"https://mcpr.opifex.org/reference/property_array.html","id":null,"dir":"Reference","previous_headings":"","what":"Create an array property definition — property_array","title":"Create an array property definition — property_array","text":"Create array property definition","code":""},{"path":"https://mcpr.opifex.org/reference/property_array.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create an array property definition — property_array","text":"","code":"property_array( title, description, items, required = FALSE, min_items = NULL, max_items = NULL, unique_items = FALSE )"},{"path":"https://mcpr.opifex.org/reference/property_array.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create an array property definition — property_array","text":"title Short title property description Longer description property items Schema items array required Whether property required min_items Optional minimum number items max_items Optional maximum number items unique_items Logical indicating items must unique","code":""},{"path":"https://mcpr.opifex.org/reference/property_array.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create an array property definition — property_array","text":"array property object","code":""},{"path":"https://mcpr.opifex.org/reference/property_array.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create an array property definition — property_array","text":"","code":"tags_prop <- property_array( \"Tags\", \"List of tags for the user\", items = property_string(\"Tag\", \"A user tag\"), unique_items = TRUE )"},{"path":"https://mcpr.opifex.org/reference/property_boolean.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a boolean property definition — property_boolean","title":"Create a boolean property definition — property_boolean","text":"Create boolean property definition","code":""},{"path":"https://mcpr.opifex.org/reference/property_boolean.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a boolean property definition — property_boolean","text":"","code":"property_boolean(title, description, required = FALSE)"},{"path":"https://mcpr.opifex.org/reference/property_boolean.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a boolean property definition — property_boolean","text":"title Short title property description Longer description property required Whether property required","code":""},{"path":"https://mcpr.opifex.org/reference/property_boolean.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a boolean property definition — property_boolean","text":"boolean property object","code":""},{"path":"https://mcpr.opifex.org/reference/property_boolean.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a boolean property definition — property_boolean","text":"","code":"active_prop <- property_boolean( \"Active status\", \"Whether the user account is active\", required = TRUE )"},{"path":"https://mcpr.opifex.org/reference/property_enum.html","id":null,"dir":"Reference","previous_headings":"","what":"Create an enum property with predefined values — property_enum","title":"Create an enum property with predefined values — property_enum","text":"Create enum property predefined values","code":""},{"path":"https://mcpr.opifex.org/reference/property_enum.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create an enum property with predefined values — property_enum","text":"","code":"property_enum(title, description, values, required = FALSE)"},{"path":"https://mcpr.opifex.org/reference/property_enum.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create an enum property with predefined values — property_enum","text":"title Short title property description Longer description property values Character vector allowed values required Whether property required","code":""},{"path":"https://mcpr.opifex.org/reference/property_enum.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create an enum property with predefined values — property_enum","text":"enum property object","code":""},{"path":"https://mcpr.opifex.org/reference/property_enum.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create an enum property with predefined values — property_enum","text":"","code":"status_prop <- property_enum( \"Status\", \"User account status\", values = c(\"active\", \"pending\", \"suspended\"), required = TRUE )"},{"path":"https://mcpr.opifex.org/reference/property_number.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a number property definition — property_number","title":"Create a number property definition — property_number","text":"Create number property definition","code":""},{"path":"https://mcpr.opifex.org/reference/property_number.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a number property definition — property_number","text":"","code":"property_number( title, description, required = FALSE, minimum = NULL, maximum = NULL, exclusive_minimum = NULL, exclusive_maximum = NULL, multiple_of = NULL, integer = FALSE )"},{"path":"https://mcpr.opifex.org/reference/property_number.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a number property definition — property_number","text":"title Short title property description Longer description property required Whether property required minimum Optional minimum value maximum Optional maximum value exclusive_minimum Whether minimum exclusive exclusive_maximum Whether maximum exclusive multiple_of Optional value number must multiple integer Whether number integer","code":""},{"path":"https://mcpr.opifex.org/reference/property_number.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a number property definition — property_number","text":"number property object","code":""},{"path":"https://mcpr.opifex.org/reference/property_number.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a number property definition — property_number","text":"","code":"age_prop <- property_number( \"User age\", \"The age of the user in years\", required = TRUE, minimum = 0, integer = TRUE )"},{"path":"https://mcpr.opifex.org/reference/property_object.html","id":null,"dir":"Reference","previous_headings":"","what":"Create an object property definition — property_object","title":"Create an object property definition — property_object","text":"Create object property definition","code":""},{"path":"https://mcpr.opifex.org/reference/property_object.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create an object property definition — property_object","text":"","code":"property_object( title, description, properties, required = FALSE, additional_properties = FALSE )"},{"path":"https://mcpr.opifex.org/reference/property_object.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create an object property definition — property_object","text":"title Short title property description Longer description property properties List property definitions object required Whether property required additional_properties Logical indicating additional properties allowed","code":""},{"path":"https://mcpr.opifex.org/reference/property_object.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create an object property definition — property_object","text":"object property object","code":""},{"path":"https://mcpr.opifex.org/reference/property_object.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create an object property definition — property_object","text":"","code":"address_prop <- property_object( \"Address\", \"User's address information\", properties = list( street = property_string(\"Street\", \"Street address\", required = TRUE), city = property_string(\"City\", \"City name\", required = TRUE), country = property_string(\"Country\", \"Country name\") ) )"},{"path":"https://mcpr.opifex.org/reference/property_string.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a string property definition — property_string","title":"Create a string property definition — property_string","text":"Create string property definition","code":""},{"path":"https://mcpr.opifex.org/reference/property_string.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a string property definition — property_string","text":"","code":"property_string( title, description, required = FALSE, enum = NULL, pattern = NULL, min_length = NULL, max_length = NULL, format = NULL )"},{"path":"https://mcpr.opifex.org/reference/property_string.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a string property definition — property_string","text":"title Short title property description Longer description property required Whether property required enum Optional character vector allowed values pattern Optional regex pattern string must match min_length Optional minimum length max_length Optional maximum length format Optional format constraint","code":""},{"path":"https://mcpr.opifex.org/reference/property_string.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a string property definition — property_string","text":"string property object","code":""},{"path":"https://mcpr.opifex.org/reference/property_string.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a string property definition — property_string","text":"","code":"name_prop <- property_string( \"User name\", \"The name of the user\", required = TRUE, min_length = 2, max_length = 50 )"},{"path":"https://mcpr.opifex.org/reference/read.html","id":null,"dir":"Reference","previous_headings":"","what":"Read a JSON-RPC response from a client provider — read","title":"Read a JSON-RPC response from a client provider — read","text":"Read JSON-RPC response client provider","code":""},{"path":"https://mcpr.opifex.org/reference/read.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read a JSON-RPC response from a client provider — read","text":"","code":"read(x, timeout = 60 * 1000)"},{"path":"https://mcpr.opifex.org/reference/read.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read a JSON-RPC response from a client provider — read","text":"x client provider timeout Timeout milliseconds reading response","code":""},{"path":"https://mcpr.opifex.org/reference/read.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Read a JSON-RPC response from a client provider — read","text":"response","code":""},{"path":"https://mcpr.opifex.org/reference/register_mcpr_tools.html","id":null,"dir":"Reference","previous_headings":"","what":"Register MCPR tools with an ellmer chat — register_mcpr_tools","title":"Register MCPR tools with an ellmer chat — register_mcpr_tools","text":"function registers tools MCPR client ellmer chat instance.","code":""},{"path":"https://mcpr.opifex.org/reference/register_mcpr_tools.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Register MCPR tools with an ellmer chat — register_mcpr_tools","text":"","code":"register_mcpr_tools(chat, client)"},{"path":"https://mcpr.opifex.org/reference/register_mcpr_tools.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Register MCPR tools with an ellmer chat — register_mcpr_tools","text":"chat ellmer chat object client mcpr client object","code":""},{"path":"https://mcpr.opifex.org/reference/register_mcpr_tools.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Register MCPR tools with an ellmer chat — register_mcpr_tools","text":"chat object (invisibly)","code":""},{"path":"https://mcpr.opifex.org/reference/resources_list.html","id":null,"dir":"Reference","previous_headings":"","what":"List all available resources — resources_list","title":"List all available resources — resources_list","text":"List available resources","code":""},{"path":"https://mcpr.opifex.org/reference/resources_list.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"List all available resources — resources_list","text":"","code":"resources_list(mcp)"},{"path":"https://mcpr.opifex.org/reference/resources_list.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"List all available resources — resources_list","text":"mcp server object","code":""},{"path":"https://mcpr.opifex.org/reference/resources_list.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"List all available resources — resources_list","text":"list containing available resources","code":""},{"path":"https://mcpr.opifex.org/reference/resources_read.html","id":null,"dir":"Reference","previous_headings":"","what":"Read a resource with the given parameters — resources_read","title":"Read a resource with the given parameters — resources_read","text":"Read resource given parameters","code":""},{"path":"https://mcpr.opifex.org/reference/resources_read.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read a resource with the given parameters — resources_read","text":"","code":"resources_read(mcp, params, id = NULL)"},{"path":"https://mcpr.opifex.org/reference/resources_read.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read a resource with the given parameters — resources_read","text":"mcp server object params Parameters resource read id Optional request ID response tracking","code":""},{"path":"https://mcpr.opifex.org/reference/resources_read.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Read a resource with the given parameters — resources_read","text":"response object resource read results error","code":""},{"path":"https://mcpr.opifex.org/reference/response.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a response object — response","title":"Create a response object — response","text":"Create response object","code":""},{"path":"https://mcpr.opifex.org/reference/response.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a response object — response","text":"","code":"response_text(text) response_image(image, mime_type = \"image/png\") response_audio(audio, mime_type = \"audio/mpeg\") response_video(video, mime_type = \"video/mp4\") response_file(file, mime_type = \"application/octet-stream\") response_resource(resource) response_error(text) response_item( ..., type = c(\"text\", \"image\", \"audio\", \"video\", \"file\", \"resource\") ) response(..., is_error = FALSE)"},{"path":"https://mcpr.opifex.org/reference/response.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a response object — response","text":"text Text content response image Image content mime_type Mime type content audio Audio content video Video content file File content resource Resource content ... Mutliple response objects type Type content is_error Whether response error","code":""},{"path":"https://mcpr.opifex.org/reference/response.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a response object — response","text":"response object","code":""},{"path":"https://mcpr.opifex.org/reference/response.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create a response object — response","text":"Use response_item create custom response item.","code":""},{"path":"https://mcpr.opifex.org/reference/response.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a response object — response","text":"","code":"response( response_text(\"Hello, world!\"), response_image(system.file(\"extdata/logo.png\", package = \"mcpr\")), response_audio(system.file(\"extdata/sound.mp3\", package = \"mcpr\")), response_video(system.file(\"extdata/video.mp4\", package = \"mcpr\")), response_file(system.file(\"extdata/file.txt\", package = \"mcpr\")), response_resource(system.file(\"extdata/resource.json\", package = \"mcpr\")) ) #> $content #> $content[[1]] #> $type #> [1] \"text\" #> #> $text #> [1] \"Hello, world!\" #> #> attr(,\"class\") #> [1] \"response_item\" \"response_item_text\" \"list\" #> #> $content[[2]] #> $type #> [1] \"image\" #> #> $data #> [1] \"\" #> #> $mimeType #> [1] \"image/png\" #> #> attr(,\"class\") #> [1] \"response_item\" \"response_item_image\" \"list\" #> #> $content[[3]] #> $type #> [1] \"audio\" #> #> $data #> [1] \"\" #> #> $mimeType #> [1] \"audio/mpeg\" #> #> attr(,\"class\") #> [1] \"response_item\" \"response_item_audio\" \"list\" #> #> $content[[4]] #> $type #> [1] \"video\" #> #> $data #> [1] \"\" #> #> $mimeType #> [1] \"video/mp4\" #> #> attr(,\"class\") #> [1] \"response_item\" \"response_item_video\" \"list\" #> #> $content[[5]] #> $type #> [1] \"file\" #> #> $data #> [1] \"\" #> #> $mimeType #> [1] \"application/octet-stream\" #> #> attr(,\"class\") #> [1] \"response_item\" \"response_item_file\" \"list\" #> #> $content[[6]] #> $type #> [1] \"resource\" #> #> $resource #> [1] \"\" #> #> attr(,\"class\") #> [1] \"response_item\" \"response_item_resource\" \"list\" #> #> #> $isError #> [1] FALSE #> #> attr(,\"class\") #> [1] \"response\" \"list\""},{"path":"https://mcpr.opifex.org/reference/roclet_output.roclet_mcp.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate MCP server output — roclet_output.roclet_mcp","title":"Generate MCP server output — roclet_output.roclet_mcp","text":"Generate MCP server output","code":""},{"path":"https://mcpr.opifex.org/reference/roclet_output.roclet_mcp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate MCP server output — roclet_output.roclet_mcp","text":"","code":"# S3 method for class 'roclet_mcp' roclet_output(x, results, base_path, ...)"},{"path":"https://mcpr.opifex.org/reference/roclet_output.roclet_mcp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate MCP server output — roclet_output.roclet_mcp","text":"x MCP roclet object results List processed tools base_path Base path ... Additional arguments","code":""},{"path":"https://mcpr.opifex.org/reference/roclet_output.roclet_mcp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate MCP server output — roclet_output.roclet_mcp","text":"NULL (invisible)","code":""},{"path":"https://mcpr.opifex.org/reference/roclet_process.roclet_mcp.html","id":null,"dir":"Reference","previous_headings":"","what":"Process blocks for MCP roclet — roclet_process.roclet_mcp","title":"Process blocks for MCP roclet — roclet_process.roclet_mcp","text":"Process blocks MCP roclet","code":""},{"path":"https://mcpr.opifex.org/reference/roclet_process.roclet_mcp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Process blocks for MCP roclet — roclet_process.roclet_mcp","text":"","code":"# S3 method for class 'roclet_mcp' roclet_process(x, blocks, env, base_path)"},{"path":"https://mcpr.opifex.org/reference/roclet_process.roclet_mcp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Process blocks for MCP roclet — roclet_process.roclet_mcp","text":"x MCP roclet object blocks List roxy_block objects env Environment base_path Base path","code":""},{"path":"https://mcpr.opifex.org/reference/roclet_process.roclet_mcp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Process blocks for MCP roclet — roclet_process.roclet_mcp","text":"List processed MCP tools","code":""},{"path":"https://mcpr.opifex.org/reference/roxy_tag_parse.roxy_tag_mcp.html","id":null,"dir":"Reference","previous_headings":"","what":"Parse @mcp tag — roxy_tag_parse.roxy_tag_mcp","title":"Parse @mcp tag — roxy_tag_parse.roxy_tag_mcp","text":"Parses @mcp tags extract tool name description.","code":""},{"path":"https://mcpr.opifex.org/reference/roxy_tag_parse.roxy_tag_mcp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Parse @mcp tag — roxy_tag_parse.roxy_tag_mcp","text":"","code":"# S3 method for class 'roxy_tag_mcp' roxy_tag_parse(x)"},{"path":"https://mcpr.opifex.org/reference/roxy_tag_parse.roxy_tag_mcp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Parse @mcp tag — roxy_tag_parse.roxy_tag_mcp","text":"x roxy_tag object","code":""},{"path":"https://mcpr.opifex.org/reference/roxy_tag_parse.roxy_tag_type.html","id":null,"dir":"Reference","previous_headings":"","what":"Parse @type tag — roxy_tag_parse.roxy_tag_type","title":"Parse @type tag — roxy_tag_parse.roxy_tag_type","text":"Parses @type tags extract parameter type information. Format: @type param_name type enum_values","code":""},{"path":"https://mcpr.opifex.org/reference/roxy_tag_parse.roxy_tag_type.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Parse @type tag — roxy_tag_parse.roxy_tag_type","text":"","code":"# S3 method for class 'roxy_tag_type' roxy_tag_parse(x)"},{"path":"https://mcpr.opifex.org/reference/roxy_tag_parse.roxy_tag_type.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Parse @type tag — roxy_tag_parse.roxy_tag_type","text":"x roxy_tag object","code":""},{"path":"https://mcpr.opifex.org/reference/roxy_tag_rd.roxy_tag_mcp.html","id":null,"dir":"Reference","previous_headings":"","what":"Roxygen2 tag for @mcp This function is called by Roxygen2 to generate documentation for the @mcp tag — roxy_tag_rd.roxy_tag_mcp","title":"Roxygen2 tag for @mcp This function is called by Roxygen2 to generate documentation for the @mcp tag — roxy_tag_rd.roxy_tag_mcp","text":"Roxygen2 tag @mcp function called Roxygen2 generate documentation @mcp tag","code":""},{"path":"https://mcpr.opifex.org/reference/roxy_tag_rd.roxy_tag_mcp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Roxygen2 tag for @mcp This function is called by Roxygen2 to generate documentation for the @mcp tag — roxy_tag_rd.roxy_tag_mcp","text":"","code":"# S3 method for class 'roxy_tag_mcp' roxy_tag_rd(x, base_path, env)"},{"path":"https://mcpr.opifex.org/reference/roxy_tag_rd.roxy_tag_mcp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Roxygen2 tag for @mcp This function is called by Roxygen2 to generate documentation for the @mcp tag — roxy_tag_rd.roxy_tag_mcp","text":"x Roxygen2 tag object base_path Base path package env Environment","code":""},{"path":"https://mcpr.opifex.org/reference/roxy_tag_rd.roxy_tag_mcp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Roxygen2 tag for @mcp This function is called by Roxygen2 to generate documentation for the @mcp tag — roxy_tag_rd.roxy_tag_mcp","text":"NULL (invisible)","code":""},{"path":"https://mcpr.opifex.org/reference/roxy_tag_rd.roxy_tag_type.html","id":null,"dir":"Reference","previous_headings":"","what":"Roxygen2 tag handler for @type This function is called by Roxygen2 to generate documentation for the @type — roxy_tag_rd.roxy_tag_type","title":"Roxygen2 tag handler for @type This function is called by Roxygen2 to generate documentation for the @type — roxy_tag_rd.roxy_tag_type","text":"Roxygen2 tag handler @type function called Roxygen2 generate documentation @type","code":""},{"path":"https://mcpr.opifex.org/reference/roxy_tag_rd.roxy_tag_type.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Roxygen2 tag handler for @type This function is called by Roxygen2 to generate documentation for the @type — roxy_tag_rd.roxy_tag_type","text":"","code":"# S3 method for class 'roxy_tag_type' roxy_tag_rd(x, base_path, env)"},{"path":"https://mcpr.opifex.org/reference/roxy_tag_rd.roxy_tag_type.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Roxygen2 tag handler for @type This function is called by Roxygen2 to generate documentation for the @type — roxy_tag_rd.roxy_tag_type","text":"x Roxygen2 tag object base_path Base path package env Environment","code":""},{"path":"https://mcpr.opifex.org/reference/roxy_tag_rd.roxy_tag_type.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Roxygen2 tag handler for @type This function is called by Roxygen2 to generate documentation for the @type — roxy_tag_rd.roxy_tag_type","text":"NULL (invisible)","code":""},{"path":"https://mcpr.opifex.org/reference/schema.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new input schema — schema","title":"Create a new input schema — schema","text":"Create new input schema","code":""},{"path":"https://mcpr.opifex.org/reference/schema.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new input schema — schema","text":"","code":"schema(properties, type = \"object\", additional_properties = FALSE)"},{"path":"https://mcpr.opifex.org/reference/schema.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new input schema — schema","text":"properties List property definitions created properties() type Type schema (default: \"object\") additional_properties Whether additional properties allowed","code":""},{"path":"https://mcpr.opifex.org/reference/schema.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new input schema — schema","text":"list representing JSON Schema object","code":""},{"path":"https://mcpr.opifex.org/reference/schema.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a new input schema — schema","text":"","code":"schema <- schema( properties = properties( name = property_string(\"User name\", \"The name of the user\", required = TRUE), age = property_number(\"User age\", \"The age of the user in years\", minimum = 0) ) )"},{"path":"https://mcpr.opifex.org/reference/serve_http.html","id":null,"dir":"Reference","previous_headings":"","what":"Serve an MCP server over HTTP using ambiorix — serve_http","title":"Serve an MCP server over HTTP using ambiorix — serve_http","text":"Serve MCP server HTTP using ambiorix","code":""},{"path":"https://mcpr.opifex.org/reference/serve_http.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Serve an MCP server over HTTP using ambiorix — serve_http","text":"","code":"serve_http(mcp, port = Sys.getenv(\"SHINY_PORT\", 3000), path = \"/mcp\")"},{"path":"https://mcpr.opifex.org/reference/serve_http.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Serve an MCP server over HTTP using ambiorix — serve_http","text":"mcp MCP server object port Port listen , defaults 3000 path Path serve MCP endpoint, defaults \"/mcp\"","code":""},{"path":"https://mcpr.opifex.org/reference/serve_http.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Serve an MCP server over HTTP using ambiorix — serve_http","text":"Invisible, runs indefinitely","code":""},{"path":"https://mcpr.opifex.org/reference/serve_io.html","id":null,"dir":"Reference","previous_headings":"","what":"Serve an MCP server using stdin/stdout — serve_io","title":"Serve an MCP server using stdin/stdout — serve_io","text":"Serve MCP server using stdin/stdout","code":""},{"path":"https://mcpr.opifex.org/reference/serve_io.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Serve an MCP server using stdin/stdout — serve_io","text":"","code":"serve_io(mcp)"},{"path":"https://mcpr.opifex.org/reference/serve_io.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Serve an MCP server using stdin/stdout — serve_io","text":"mcp MCP server object created new_server()","code":""},{"path":"https://mcpr.opifex.org/reference/serve_io.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Serve an MCP server using stdin/stdout — serve_io","text":"Nothing, runs indefinitely normal mode, response test mode","code":""},{"path":"https://mcpr.opifex.org/reference/to_json.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert an R object to JSON — to_json","title":"Convert an R object to JSON — to_json","text":"Convert R object JSON","code":""},{"path":"https://mcpr.opifex.org/reference/to_json.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert an R object to JSON — to_json","text":"","code":"to_json(x, ...)"},{"path":"https://mcpr.opifex.org/reference/to_json.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert an R object to JSON — to_json","text":"x R object convert JSON ... Additional arguments passed yyjsonr::write_json_str","code":""},{"path":"https://mcpr.opifex.org/reference/to_json.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert an R object to JSON — to_json","text":"JSON string","code":""},{"path":"https://mcpr.opifex.org/reference/tools_call.html","id":null,"dir":"Reference","previous_headings":"","what":"Call a tool with the given parameters — tools_call","title":"Call a tool with the given parameters — tools_call","text":"Call tool given parameters","code":""},{"path":"https://mcpr.opifex.org/reference/tools_call.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Call a tool with the given parameters — tools_call","text":"","code":"tools_call(mcp, params, id = NULL)"},{"path":"https://mcpr.opifex.org/reference/tools_call.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Call a tool with the given parameters — tools_call","text":"mcp server object params Parameters tool call id Optional request ID response tracking","code":""},{"path":"https://mcpr.opifex.org/reference/tools_call.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Call a tool with the given parameters — tools_call","text":"response object tool call results error","code":""},{"path":"https://mcpr.opifex.org/reference/tools_list.html","id":null,"dir":"Reference","previous_headings":"","what":"List all available tools — tools_list","title":"List all available tools — tools_list","text":"List available tools","code":""},{"path":"https://mcpr.opifex.org/reference/tools_list.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"List all available tools — tools_list","text":"","code":"tools_list(mcp)"},{"path":"https://mcpr.opifex.org/reference/tools_list.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"List all available tools — tools_list","text":"mcp server object","code":""},{"path":"https://mcpr.opifex.org/reference/tools_list.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"List all available tools — tools_list","text":"list containing available tools","code":""},{"path":"https://mcpr.opifex.org/reference/validate_request.html","id":null,"dir":"Reference","previous_headings":"","what":"Validate a JSON-RPC 2.0 request — validate_request","title":"Validate a JSON-RPC 2.0 request — validate_request","text":"Validate JSON-RPC 2.0 request","code":""},{"path":"https://mcpr.opifex.org/reference/validate_request.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Validate a JSON-RPC 2.0 request — validate_request","text":"","code":"validate_request(request)"},{"path":"https://mcpr.opifex.org/reference/validate_request.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Validate a JSON-RPC 2.0 request — validate_request","text":"request Parsed request object","code":""},{"path":"https://mcpr.opifex.org/reference/validate_request.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Validate a JSON-RPC 2.0 request — validate_request","text":"NULL valid, error response invalid","code":""},{"path":"https://mcpr.opifex.org/reference/write.html","id":null,"dir":"Reference","previous_headings":"","what":"Write a JSON-RPC request to a client provider — write","title":"Write a JSON-RPC request to a client provider — write","text":"Write JSON-RPC request client provider","code":""},{"path":"https://mcpr.opifex.org/reference/write.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Write a JSON-RPC request to a client provider — write","text":"","code":"write(x, method, params = NULL, id = generate_id(), timeout = 5000)"},{"path":"https://mcpr.opifex.org/reference/write.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Write a JSON-RPC request to a client provider — write","text":"x client provider method method call params parameters pass method id id request timeout Timeout milliseconds reading response","code":""},{"path":"https://mcpr.opifex.org/reference/write.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Write a JSON-RPC request to a client provider — write","text":"client provider","code":""},{"path":"https://mcpr.opifex.org/news/index.html","id":"mcpr-002","dir":"Changelog","previous_headings":"","what":"mcpr 0.0.2","title":"mcpr 0.0.2","text":"Added support ellmer::tool","code":""},{"path":[]},{"path":"https://mcpr.opifex.org/news/index.html","id":"major-changes-0-0-1","dir":"Changelog","previous_headings":"","what":"Major Changes","title":"mcpr 0.0.1","text":"new_client() creating client connections local process HTTP servers initialize() initializing client connections tools_list() tools_call() discovering using server tools prompts_list() prompts_get() working server prompts resources_list() resources_read() accessing server resources Renamed new_mcp() (deprecated) new_server() clarity Added example implementations server client Added client usage vignette Fix major issue serve_http()","code":""},{"path":"https://mcpr.opifex.org/news/index.html","id":"mcpr-000","dir":"Changelog","previous_headings":"","what":"mcpr 0.0.0","title":"mcpr 0.0.0","text":"Initial CRAN submission.","code":""}] diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 875d6e8..201332d 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -11,16 +11,26 @@ https://mcpr.opifex.org/news/index.html https://mcpr.opifex.org/reference/JSONRPC_PARSE_ERROR.html https://mcpr.opifex.org/reference/add_capability.html +https://mcpr.opifex.org/reference/build_param_info.html https://mcpr.opifex.org/reference/client.html +https://mcpr.opifex.org/reference/convert_ellmer_type_to_mcpr_property.html +https://mcpr.opifex.org/reference/convert_ellmer_types_to_mcpr.html https://mcpr.opifex.org/reference/create_ellmer_handler.html https://mcpr.opifex.org/reference/create_ellmer_type.html https://mcpr.opifex.org/reference/create_ellmer_types.html https://mcpr.opifex.org/reference/create_error.html https://mcpr.opifex.org/reference/create_response.html +https://mcpr.opifex.org/reference/ellmer_to_mcpr_tool.html https://mcpr.opifex.org/reference/extract_mcp_result.html https://mcpr.opifex.org/reference/from_json.html +https://mcpr.opifex.org/reference/generate_handler_code.html +https://mcpr.opifex.org/reference/generate_mcp_server.html +https://mcpr.opifex.org/reference/generate_property_code.html +https://mcpr.opifex.org/reference/generate_tool_code.html +https://mcpr.opifex.org/reference/get_name.html https://mcpr.opifex.org/reference/index.html https://mcpr.opifex.org/reference/initialize.html +https://mcpr.opifex.org/reference/mcp_roclet.html https://mcpr.opifex.org/reference/mcpr_clients_to_ellmer_tools.html https://mcpr.opifex.org/reference/mcpr_to_ellmer_tools.html https://mcpr.opifex.org/reference/new_client.html @@ -31,6 +41,7 @@ https://mcpr.opifex.org/reference/new_tool.html https://mcpr.opifex.org/reference/parse_request.html https://mcpr.opifex.org/reference/process_batch.html +https://mcpr.opifex.org/reference/process_mcp_block.html https://mcpr.opifex.org/reference/process_request.html https://mcpr.opifex.org/reference/prompts_get.html https://mcpr.opifex.org/reference/prompts_list.html @@ -46,6 +57,12 @@ https://mcpr.opifex.org/reference/resources_list.html https://mcpr.opifex.org/reference/resources_read.html https://mcpr.opifex.org/reference/response.html +https://mcpr.opifex.org/reference/roclet_output.roclet_mcp.html +https://mcpr.opifex.org/reference/roclet_process.roclet_mcp.html +https://mcpr.opifex.org/reference/roxy_tag_parse.roxy_tag_mcp.html +https://mcpr.opifex.org/reference/roxy_tag_parse.roxy_tag_type.html +https://mcpr.opifex.org/reference/roxy_tag_rd.roxy_tag_mcp.html +https://mcpr.opifex.org/reference/roxy_tag_rd.roxy_tag_type.html https://mcpr.opifex.org/reference/schema.html https://mcpr.opifex.org/reference/serve_http.html https://mcpr.opifex.org/reference/serve_io.html diff --git a/inst/mcp_server.R b/inst/mcp_server.R new file mode 100644 index 0000000..4b35878 --- /dev/null +++ b/inst/mcp_server.R @@ -0,0 +1,268 @@ +# Auto-generated MCP Server +# Generated by mcpr::mcp_roclet + +library(mcpr) + +# Tool: create_json_schema +create_json_schema_tool <- new_tool( + name = "create_json_schema", + description = "Create a JSON Schema object for MCP tool inputs with property validation", + input_schema = schema( + properties = properties( + properties = property_object("properties", "List of property definitions created with properties()", required = TRUE), + type = property_string("type", "Type of the schema (default: 'object')", required = TRUE), + additional_properties = property_boolean("additional_properties", "Whether additional properties are allowed", required = TRUE) + ) + ), + handler = function(params) { + # Call the original function: schema + result <- schema(params$properties, params$type, params$additional_properties) + response_text(result) + } +) + +# Tool: create_string_property +create_string_property_tool <- new_tool( + name = "create_string_property", + description = "Create a string property with validation constraints for MCP schemas", + input_schema = schema( + properties = properties( + title = property_string("title", "Short title for the property", required = TRUE), + description = property_string("description", "Longer description of the property", required = TRUE), + required = property_boolean("required", "Whether the property is required", required = TRUE), + enum = property_array("enum", "Optional character vector of allowed values", required = TRUE), + pattern = property_string("pattern", "Optional regex pattern the string must match", required = TRUE), + min_length = property_number("min_length", "Optional minimum length", required = TRUE), + max_length = property_number("max_length", "Optional maximum length", required = TRUE), + format = property_enum("format", "Optional format constraint", values = c("date-time", "email", "uri", "hostname", "ipv4", "ipv6"), required = TRUE) + ) + ), + handler = function(params) { + # Call the original function: property_string + result <- property_string(params$title, params$description, params$required, params$enum, params$pattern, params$min_length, params$max_length, params$format) + response_text(result) + } +) + +# Tool: create_number_property +create_number_property_tool <- new_tool( + name = "create_number_property", + description = "Create a number property with range and type constraints for MCP schemas", + input_schema = schema( + properties = properties( + title = property_string("title", "Short title for the property", required = TRUE), + description = property_string("description", "Longer description of the property", required = TRUE), + required = property_boolean("required", "Whether the property is required", required = TRUE), + minimum = property_number("minimum", "Optional minimum value", required = TRUE), + maximum = property_number("maximum", "Optional maximum value", required = TRUE), + exclusive_minimum = property_boolean("exclusive_minimum", "Whether minimum is exclusive", required = TRUE), + exclusive_maximum = property_boolean("exclusive_maximum", "Whether maximum is exclusive", required = TRUE), + multiple_of = property_number("multiple_of", "Optional value the number must be a multiple of", required = TRUE), + integer = property_boolean("integer", "Whether the number should be an integer", required = TRUE) + ) + ), + handler = function(params) { + # Call the original function: property_number + result <- property_number(params$title, params$description, params$required, params$minimum, params$maximum, params$exclusive_minimum, params$exclusive_maximum, params$multiple_of, params$integer) + response_text(result) + } +) + +# Tool: create_boolean_property +create_boolean_property_tool <- new_tool( + name = "create_boolean_property", + description = "Create a boolean property for MCP schemas", + input_schema = schema( + properties = properties( + title = property_string("title", "Short title for the property", required = TRUE), + description = property_string("description", "Longer description of the property", required = TRUE), + required = property_boolean("required", "Whether the property is required", required = TRUE) + ) + ), + handler = function(params) { + # Call the original function: property_boolean + result <- property_boolean(params$title, params$description, params$required) + response_text(result) + } +) + +# Tool: create_enum_property +create_enum_property_tool <- new_tool( + name = "create_enum_property", + description = "Create an enum property with predefined values for MCP schemas", + input_schema = schema( + properties = properties( + title = property_string("title", "Short title for the property", required = TRUE), + description = property_string("description", "Longer description of the property", required = TRUE), + values = property_array("values", "Character vector of allowed values", required = TRUE), + required = property_boolean("required", "Whether the property is required", required = TRUE) + ) + ), + handler = function(params) { + # Call the original function: property_enum + result <- property_enum(params$title, params$description, params$values, params$required) + response_text(result) + } +) + +# Tool: start_mcp_server_io +start_mcp_server_io_tool <- new_tool( + name = "start_mcp_server_io", + description = "Start an MCP server using stdin/stdout transport", + input_schema = schema( + properties = properties( + mcp = property_object("mcp", "An MCP server object created with new_server()", required = TRUE) + ) + ), + handler = function(params) { + # Call the original function: serve_io + result <- serve_io(params$mcp) + response_text(result) + } +) + +# Tool: create_mcp_server +create_mcp_server_tool <- new_tool( + name = "create_mcp_server", + description = "Create a new MCP server with specified name, description, and version", + input_schema = schema( + properties = properties( + name = property_string("name", "Name of the MCP server", required = TRUE), + description = property_string("description", "Description of the MCP server", required = TRUE), + version = property_string("version", "Version of the MCP server", required = TRUE), + tools = property_array("tools", "List of tools (optional)", required = TRUE), + resources = property_array("resources", "List of resources (optional)", required = TRUE), + prompts = property_array("prompts", "List of prompts (optional)", required = TRUE), + ... = property_string("...", "Forwarded to [new_server()]", required = TRUE) + ) + ), + handler = function(params) { + # Call the original function: new_server + result <- new_server(params$name, params$description, params$version, params$tools, params$resources, params$prompts, params$...) + response_text(result) + } +) + +# Tool: create_mcp_tool +create_mcp_tool_tool <- new_tool( + name = "create_mcp_tool", + description = "Create a new MCP tool with input schema and handler function", + input_schema = schema( + properties = properties( + name = property_string("name", "Name of the tool", required = TRUE), + description = property_string("description", "Description of the tool", required = TRUE), + input_schema = property_object("input_schema", "Input schema for the tool (must be a schema object)", required = TRUE), + handler = property_object("handler", "Function to handle the tool execution", required = TRUE) + ) + ), + handler = function(params) { + # Call the original function: new_tool + result <- new_tool(params$name, params$description, params$input_schema, params$handler) + response_text(result) + } +) + +# Tool: create_mcp_resource +create_mcp_resource_tool <- new_tool( + name = "create_mcp_resource", + description = "Create a new MCP resource with URI and MIME type", + input_schema = schema( + properties = properties( + name = property_string("name", "Name of the resource", required = TRUE), + description = property_string("description", "Description of the resource", required = TRUE), + uri = property_string("uri", "URI of the resource", required = TRUE), + mime_type = property_string("mime_type", "MIME type of the resource (optional)", required = TRUE), + handler = property_object("handler", "Function to handle the resource request", required = TRUE) + ) + ), + handler = function(params) { + # Call the original function: new_resource + result <- new_resource(params$name, params$description, params$uri, params$mime_type, params$handler) + response_text(result) + } +) + +# Tool: create_mcp_prompt +create_mcp_prompt_tool <- new_tool( + name = "create_mcp_prompt", + description = "Create a new MCP prompt with arguments and handler function", + input_schema = schema( + properties = properties( + name = property_string("name", "Name of the prompt", required = TRUE), + description = property_string("description", "Description of the prompt", required = TRUE), + arguments = property_array("arguments", "List of arguments for the prompt", required = TRUE), + handler = property_object("handler", "Function to handle the prompt execution", required = TRUE) + ) + ), + handler = function(params) { + # Call the original function: new_prompt + result <- new_prompt(params$name, params$description, params$arguments, params$handler) + response_text(result) + } +) + +# Tool: add_mcp_capability +add_mcp_capability_tool <- new_tool( + name = "add_mcp_capability", + description = "Add a tool, resource, or prompt capability to an existing MCP server", + input_schema = schema( + properties = properties( + mcp = property_object("mcp", "An MCP server object", required = TRUE), + capability = property_object("capability", "A tool, resource, or prompt capability object", required = TRUE) + ) + ), + handler = function(params) { + # Call the original function: add_capability + result <- add_capability(params$mcp, params$capability) + response_text(result) + } +) + +# Tool: create_text_response +create_text_response_tool <- new_tool( + name = "create_text_response", + description = "Create a text response for MCP tool handlers", + input_schema = schema( + properties = properties( + text = property_string("text", "Text content for the response", required = TRUE), + image = property_string("image", "Image content", required = TRUE), + audio = property_string("audio", "Audio content", required = TRUE), + video = property_string("video", "Video content", required = TRUE), + file = property_string("file", "File content", required = TRUE), + type = property_string("type", "Type of the content", required = TRUE), + resource = property_string("resource", "Resource content", required = TRUE), + is_error = property_string("is_error", "Whether the response is an error", required = TRUE), + mime_type = property_string("mime_type", "Mime type of the content", required = TRUE), + ... = property_string("...", "Mutliple `response` objects", required = TRUE) + ) + ), + handler = function(params) { + # Call the original function: response_text + result <- response_text(params$text, params$image, params$audio, params$video, params$file, params$type, params$resource, params$is_error, params$mime_type, params$...) + response_text(result) + } +) + + +# Create MCP server +mcp_server <- new_server( + name = "Auto-generated MCP Server", + description = "MCP server generated from R functions with @mcp tags", + version = "1.0.0" +) + +mcp_server <- add_capability(mcp_server, create_json_schema_tool) +mcp_server <- add_capability(mcp_server, create_string_property_tool) +mcp_server <- add_capability(mcp_server, create_number_property_tool) +mcp_server <- add_capability(mcp_server, create_boolean_property_tool) +mcp_server <- add_capability(mcp_server, create_enum_property_tool) +mcp_server <- add_capability(mcp_server, start_mcp_server_io_tool) +mcp_server <- add_capability(mcp_server, create_mcp_server_tool) +mcp_server <- add_capability(mcp_server, create_mcp_tool_tool) +mcp_server <- add_capability(mcp_server, create_mcp_resource_tool) +mcp_server <- add_capability(mcp_server, create_mcp_prompt_tool) +mcp_server <- add_capability(mcp_server, add_mcp_capability_tool) +mcp_server <- add_capability(mcp_server, create_text_response_tool) + +# Start the server +serve_io(mcp_server) diff --git a/makefile b/makefile index 054f63e..8af530d 100644 --- a/makefile +++ b/makefile @@ -3,7 +3,7 @@ default: install document: R -s -e "devtools::document()" -check: site +check: document R -s -e "devtools::check(document = FALSE)" install: check diff --git a/man/add_capability.Rd b/man/add_capability.Rd index 9c1cfbd..80bd34f 100644 --- a/man/add_capability.Rd +++ b/man/add_capability.Rd @@ -7,9 +7,9 @@ add_capability(mcp, capability) } \arguments{ -\item{mcp}{An MCP object} +\item{mcp}{An MCP server object} -\item{capability}{A capability object} +\item{capability}{A tool, resource, or prompt capability object} } \value{ The MCP object with the capability added diff --git a/man/build_param_info.Rd b/man/build_param_info.Rd new file mode 100644 index 0000000..b22ed90 --- /dev/null +++ b/man/build_param_info.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/roclet.R +\name{build_param_info} +\alias{build_param_info} +\title{Build parameter information from @param and @type tags} +\usage{ +build_param_info(param_tags, type_tags = list()) +} +\arguments{ +\item{param_tags}{List of @param tags} + +\item{type_tags}{List of @type tags} +} +\value{ +List of parameter information +} +\description{ +Build parameter information from @param and @type tags +} +\keyword{internal} diff --git a/man/generate_handler_code.Rd b/man/generate_handler_code.Rd new file mode 100644 index 0000000..a1f8974 --- /dev/null +++ b/man/generate_handler_code.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/roclet.R +\name{generate_handler_code} +\alias{generate_handler_code} +\title{Generate handler code that calls the original function} +\usage{ +generate_handler_code(tool) +} +\arguments{ +\item{tool}{Tool information} +} +\value{ +Character vector of handler code lines +} +\description{ +Generate handler code that calls the original function +} +\keyword{internal} diff --git a/man/generate_mcp_server.Rd b/man/generate_mcp_server.Rd new file mode 100644 index 0000000..a940b2e --- /dev/null +++ b/man/generate_mcp_server.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/roclet.R +\name{generate_mcp_server} +\alias{generate_mcp_server} +\title{Generate MCP server R code} +\usage{ +generate_mcp_server(tools, base_path) +} +\arguments{ +\item{tools}{List of tool information} + +\item{base_path}{Base path for the package} +} +\value{ +Character vector of R code lines +} +\description{ +Generate MCP server R code +} +\keyword{internal} diff --git a/man/generate_property_code.Rd b/man/generate_property_code.Rd new file mode 100644 index 0000000..1c36db0 --- /dev/null +++ b/man/generate_property_code.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/roclet.R +\name{generate_property_code} +\alias{generate_property_code} +\title{Generate property code for a parameter} +\usage{ +generate_property_code(param) +} +\arguments{ +\item{param}{Parameter information} +} +\value{ +Character string with property code +} +\description{ +Generate property code for a parameter +} +\keyword{internal} diff --git a/man/generate_tool_code.Rd b/man/generate_tool_code.Rd new file mode 100644 index 0000000..bdf66cc --- /dev/null +++ b/man/generate_tool_code.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/roclet.R +\name{generate_tool_code} +\alias{generate_tool_code} +\title{Generate R code for a single tool} +\usage{ +generate_tool_code(tool, index) +} +\arguments{ +\item{tool}{Tool information list} + +\item{index}{Tool index for naming} +} +\value{ +Character vector of R code lines +} +\description{ +Generate R code for a single tool +} +\keyword{internal} diff --git a/man/mcp_roclet.Rd b/man/mcp_roclet.Rd new file mode 100644 index 0000000..4bbd0f6 --- /dev/null +++ b/man/mcp_roclet.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/roclet.R +\name{mcp_roclet} +\alias{mcp_roclet} +\title{MCP Roclet for Generating MCP Servers} +\usage{ +mcp_roclet() +} +\description{ +This roclet automatically generates MCP (Model Context Protocol) servers +from R functions annotated with @mcp tags. +} +\examples{ +\dontrun{ +# Use the roclet in roxygenise +roxygen2::roxygenise(roclets = c("rd", "mcpr::mcp_roclet")) +} +} diff --git a/man/new_prompt.Rd b/man/new_prompt.Rd index 158d4c1..527320d 100644 --- a/man/new_prompt.Rd +++ b/man/new_prompt.Rd @@ -13,7 +13,7 @@ new_prompt(name, description, arguments = list(), handler) \item{arguments}{List of arguments for the prompt} -\item{handler}{Function to handle the prompt} +\item{handler}{Function to handle the prompt execution} } \value{ A new prompt capability diff --git a/man/new_resource.Rd b/man/new_resource.Rd index dac6aa4..9c60dec 100644 --- a/man/new_resource.Rd +++ b/man/new_resource.Rd @@ -13,9 +13,9 @@ new_resource(name, description, uri, mime_type = NULL, handler) \item{uri}{URI of the resource} -\item{mime_type}{Mime type of the resource} +\item{mime_type}{MIME type of the resource (optional)} -\item{handler}{Function to handle the resource} +\item{handler}{Function to handle the resource request} } \value{ A new resource capability diff --git a/man/new_server.Rd b/man/new_server.Rd index a88cc56..1c92866 100644 --- a/man/new_server.Rd +++ b/man/new_server.Rd @@ -17,17 +17,17 @@ new_server( new_mcp(...) } \arguments{ -\item{name}{Name of the MCP} +\item{name}{Name of the MCP server} -\item{description}{Description of the MCP} +\item{description}{Description of the MCP server} -\item{version}{Version of the MCP} +\item{version}{Version of the MCP server} -\item{tools}{List of tools} +\item{tools}{List of tools (optional)} -\item{resources}{List of resources} +\item{resources}{List of resources (optional)} -\item{prompts}{List of prompts} +\item{prompts}{List of prompts (optional)} \item{...}{Forwarded to \code{\link[=new_server]{new_server()}}} } diff --git a/man/new_tool.Rd b/man/new_tool.Rd index 30a85c4..d15628b 100644 --- a/man/new_tool.Rd +++ b/man/new_tool.Rd @@ -11,9 +11,9 @@ new_tool(name, description, input_schema, handler) \item{description}{Description of the tool} -\item{input_schema}{Input schema for the tool} +\item{input_schema}{Input schema for the tool (must be a schema object)} -\item{handler}{Function to handle the tool} +\item{handler}{Function to handle the tool execution} } \value{ A new tool capability diff --git a/man/process_mcp_block.Rd b/man/process_mcp_block.Rd new file mode 100644 index 0000000..b8f07ef --- /dev/null +++ b/man/process_mcp_block.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/roclet.R +\name{process_mcp_block} +\alias{process_mcp_block} +\title{Process a single block with @mcp tag} +\usage{ +process_mcp_block(block) +} +\arguments{ +\item{block}{A roxy_block object} +} +\value{ +A list with tool information or NULL +} +\description{ +Process a single block with @mcp tag +} +\keyword{internal} diff --git a/man/property_number.Rd b/man/property_number.Rd index 6908ab2..f14dfc0 100644 --- a/man/property_number.Rd +++ b/man/property_number.Rd @@ -27,13 +27,13 @@ property_number( \item{maximum}{Optional maximum value} -\item{exclusive_minimum}{Optional logical for exclusive minimum} +\item{exclusive_minimum}{Whether minimum is exclusive} -\item{exclusive_maximum}{Optional logical for exclusive maximum} +\item{exclusive_maximum}{Whether maximum is exclusive} \item{multiple_of}{Optional value the number must be a multiple of} -\item{integer}{Logical indicating if the number should be an integer} +\item{integer}{Whether the number should be an integer} } \value{ A number property object diff --git a/man/property_string.Rd b/man/property_string.Rd index 2ce838e..24611ef 100644 --- a/man/property_string.Rd +++ b/man/property_string.Rd @@ -30,7 +30,7 @@ property_string( \item{max_length}{Optional maximum length} -\item{format}{Optional format (e.g., "date-time", "email", "uri")} +\item{format}{Optional format constraint} } \value{ A string property object diff --git a/man/response.Rd b/man/response.Rd index 21e72c4..32441db 100644 --- a/man/response.Rd +++ b/man/response.Rd @@ -34,7 +34,7 @@ response_item( response(..., is_error = FALSE) } \arguments{ -\item{text}{Text content} +\item{text}{Text content for the response} \item{image}{Image content} diff --git a/man/roclet_output.roclet_mcp.Rd b/man/roclet_output.roclet_mcp.Rd new file mode 100644 index 0000000..baf4d8d --- /dev/null +++ b/man/roclet_output.roclet_mcp.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/roclet.R +\name{roclet_output.roclet_mcp} +\alias{roclet_output.roclet_mcp} +\title{Generate MCP server output} +\usage{ +\method{roclet_output}{roclet_mcp}(x, results, base_path, ...) +} +\arguments{ +\item{x}{MCP roclet object} + +\item{results}{List of processed tools} + +\item{base_path}{Base path} + +\item{...}{Additional arguments} +} +\value{ +NULL (invisible) +} +\description{ +Generate MCP server output +} diff --git a/man/roclet_process.roclet_mcp.Rd b/man/roclet_process.roclet_mcp.Rd new file mode 100644 index 0000000..d32e0f3 --- /dev/null +++ b/man/roclet_process.roclet_mcp.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/roclet.R +\name{roclet_process.roclet_mcp} +\alias{roclet_process.roclet_mcp} +\title{Process blocks for MCP roclet} +\usage{ +\method{roclet_process}{roclet_mcp}(x, blocks, env, base_path) +} +\arguments{ +\item{x}{MCP roclet object} + +\item{blocks}{List of roxy_block objects} + +\item{env}{Environment} + +\item{base_path}{Base path} +} +\value{ +List of processed MCP tools +} +\description{ +Process blocks for MCP roclet +} diff --git a/man/roxy_tag_parse.roxy_tag_mcp.Rd b/man/roxy_tag_parse.roxy_tag_mcp.Rd new file mode 100644 index 0000000..2c818c1 --- /dev/null +++ b/man/roxy_tag_parse.roxy_tag_mcp.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/roclet.R +\name{roxy_tag_parse.roxy_tag_mcp} +\alias{roxy_tag_parse.roxy_tag_mcp} +\title{Parse @mcp tag} +\usage{ +\method{roxy_tag_parse}{roxy_tag_mcp}(x) +} +\arguments{ +\item{x}{A roxy_tag object} +} +\description{ +Parses @mcp tags to extract tool name and description. +} diff --git a/man/roxy_tag_parse.roxy_tag_type.Rd b/man/roxy_tag_parse.roxy_tag_type.Rd new file mode 100644 index 0000000..6734446 --- /dev/null +++ b/man/roxy_tag_parse.roxy_tag_type.Rd @@ -0,0 +1,15 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/roclet.R +\name{roxy_tag_parse.roxy_tag_type} +\alias{roxy_tag_parse.roxy_tag_type} +\title{Parse @type tag} +\usage{ +\method{roxy_tag_parse}{roxy_tag_type}(x) +} +\arguments{ +\item{x}{A roxy_tag object} +} +\description{ +Parses @type tags to extract parameter type information. +Format: @type param_name type enum_values +} diff --git a/man/roxy_tag_rd.roxy_tag_mcp.Rd b/man/roxy_tag_rd.roxy_tag_mcp.Rd new file mode 100644 index 0000000..1af4f26 --- /dev/null +++ b/man/roxy_tag_rd.roxy_tag_mcp.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/roclet.R +\name{roxy_tag_rd.roxy_tag_mcp} +\alias{roxy_tag_rd.roxy_tag_mcp} +\title{Roxygen2 tag for @mcp +This function is called by Roxygen2 to generate documentation for the @mcp tag} +\usage{ +\method{roxy_tag_rd}{roxy_tag_mcp}(x, base_path, env) +} +\arguments{ +\item{x}{Roxygen2 tag object} + +\item{base_path}{Base path for the package} + +\item{env}{Environment} +} +\value{ +NULL (invisible) +} +\description{ +Roxygen2 tag for @mcp +This function is called by Roxygen2 to generate documentation for the @mcp tag +} diff --git a/man/roxy_tag_rd.roxy_tag_type.Rd b/man/roxy_tag_rd.roxy_tag_type.Rd new file mode 100644 index 0000000..e1b3904 --- /dev/null +++ b/man/roxy_tag_rd.roxy_tag_type.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/roclet.R +\name{roxy_tag_rd.roxy_tag_type} +\alias{roxy_tag_rd.roxy_tag_type} +\title{Roxygen2 tag handler for @type +This function is called by Roxygen2 to generate documentation for the @type} +\usage{ +\method{roxy_tag_rd}{roxy_tag_type}(x, base_path, env) +} +\arguments{ +\item{x}{Roxygen2 tag object} + +\item{base_path}{Base path for the package} + +\item{env}{Environment} +} +\value{ +NULL (invisible) +} +\description{ +Roxygen2 tag handler for @type +This function is called by Roxygen2 to generate documentation for the @type +} diff --git a/man/schema.Rd b/man/schema.Rd index e2f7153..52b4b98 100644 --- a/man/schema.Rd +++ b/man/schema.Rd @@ -7,11 +7,11 @@ schema(properties, type = "object", additional_properties = FALSE) } \arguments{ -\item{properties}{List of property definitions} +\item{properties}{List of property definitions created with properties()} -\item{type}{Type of the schema} +\item{type}{Type of the schema (default: "object")} -\item{additional_properties}{Logical indicating if additional properties are allowed} +\item{additional_properties}{Whether additional properties are allowed} } \value{ A list representing a JSON Schema object diff --git a/man/serve_io.Rd b/man/serve_io.Rd index 05f1d6b..ce0f93b 100644 --- a/man/serve_io.Rd +++ b/man/serve_io.Rd @@ -7,7 +7,7 @@ serve_io(mcp) } \arguments{ -\item{mcp}{An MCP server object} +\item{mcp}{An MCP server object created with new_server()} } \value{ Nothing, runs indefinitely in normal mode, or the response in test mode
Coene J (2025). mcpr: Model Context Protocol for R. -R package version 0.0.1.9000, https://mcpr.opifex.org/. +R package version 0.0.2.9000, https://mcpr.opifex.org/.
@Manual{, title = {mcpr: Model Context Protocol for R}, author = {John Coene}, year = {2025}, - note = {R package version 0.0.1.9000}, + note = {R package version 0.0.2.9000}, url = {https://mcpr.opifex.org/}, }
Now supports ellmer tools, you can use ellmer’s or mcpr’s tools, interchangeably.
See the example below, taken from the ellmer documentation
-current_time <- ellmer::tool( +# create an ellmer tool +current_time <- ellmer::tool( \(tz = "UTC") { format(Sys.time(), tz = tz, usetz = TRUE) }, @@ -220,9 +222,9 @@ ellmer integration= "1.0.0" ) +# register ellmer tool with mcpr server mcp <- add_capability(mcp, current_time) -# Start the server (listening on stdin/stdout) serve_io(mcp)
current_time <- ellmer::tool( +# create an ellmer tool +current_time <- ellmer::tool( \(tz = "UTC") { format(Sys.time(), tz = tz, usetz = TRUE) }, @@ -220,9 +222,9 @@ ellmer integration= "1.0.0" ) +# register ellmer tool with mcpr server mcp <- add_capability(mcp, current_time) -# Start the server (listening on stdin/stdout) serve_io(mcp)
# create an ellmer tool +current_time <- ellmer::tool( \(tz = "UTC") { format(Sys.time(), tz = tz, usetz = TRUE) }, @@ -220,9 +222,9 @@ ellmer integration= "1.0.0" ) +# register ellmer tool with mcpr server mcp <- add_capability(mcp, current_time) -# Start the server (listening on stdin/stdout) serve_io(mcp)
NEWS.md
ellmer::tool
An MCP object
An MCP server object
A capability object
A tool, resource, or prompt capability object
R/roclet.R
build_param_info.Rd
Build parameter information from @param and @type tags
build_param_info(param_tags, type_tags = list())
List of @param tags
List of @type tags
List of parameter information
R/ellmer-to-mcpr.R
convert_ellmer_type_to_mcpr_property.Rd
Convert a single ellmer type to an mcpr property
convert_ellmer_type_to_mcpr_property(ellmer_type, prop_name)
An ellmer Type object (TypeBasic, TypeArray, etc.)
The name of the property (for better error messages)
An mcpr property object
convert_ellmer_types_to_mcpr.Rd
Convert ellmer TypeObject to mcpr schema
convert_ellmer_types_to_mcpr(type_object)
An ellmer TypeObject containing the function arguments
An mcpr schema object
R/ellmer.R
R/mcpr-to-ellmer.R
create_ellmer_handler.Rd
create_ellmer_type.Rd
create_ellmer_types.Rd
ellmer_to_mcpr_tool.Rd
This function converts tools from the ellmer package to a format compatible +with the mcpr package. It takes an ellmer ToolDef object and creates an +mcpr tool object with the appropriate input schema and handler function.
ellmer_to_mcpr_tool(ellmer_tool)
An ellmer ToolDef object created with ellmer::tool()
ellmer::tool()
An mcpr tool object compatible with new_tool()
new_tool()
new_tool(), ellmer::tool(), add_capability()
add_capability()
if (FALSE) { # \dontrun{ +# Create an ellmer tool +ellmer_rnorm <- ellmer::tool( + rnorm, + "Generate random normal numbers", + n = ellmer::type_integer("Number of observations"), + mean = ellmer::type_number("Mean value", required = FALSE), + sd = ellmer::type_number("Standard deviation", required = FALSE) +) + +# Convert to mcpr format +mcpr_tool <- ellmer_to_mcpr_tool(ellmer_rnorm) + +# Add to an mcpr server +server <- new_server("MyServer", "Test server", "1.0.0") +add_capability(server, mcpr_tool) +} # } + +
extract_mcp_result.Rd
generate_handler_code.Rd
Generate handler code that calls the original function
generate_handler_code(tool)
Tool information
Character vector of handler code lines
generate_mcp_server.Rd
Generate MCP server R code
generate_mcp_server(tools, base_path)
List of tool information
Base path for the package
Character vector of R code lines
generate_property_code.Rd
Generate property code for a parameter
generate_property_code(param)
Parameter information
Character string with property code
generate_tool_code.Rd
Generate R code for a single tool
generate_tool_code(tool, index)
Tool information list
Tool index for naming
R/client.R
get_name.Rd
Get the name of a client
get_name(x)
A client object
The name of the client
get_name()
Functions for extending roxygen2 with MCP server generation
mcp_roclet()
roxy_tag_parse(<roxy_tag_mcp>)
roxy_tag_parse(<roxy_tag_type>)
roclet_process(<roclet_mcp>)
roxy_tag_rd(<roxy_tag_mcp>)
roxy_tag_rd(<roxy_tag_type>)
roclet_output(<roclet_mcp>)
Functions for integrating with the Ellmer package
mcp_roclet.Rd
This roclet automatically generates MCP (Model Context Protocol) servers +from R functions annotated with @mcp tags.
if (FALSE) { # \dontrun{ +# Use the roclet in roxygenise +roxygen2::roxygenise(roclets = c("rd", "mcpr::mcp_roclet")) +} # } +
mcpr_clients_to_ellmer_tools.Rd
mcpr_to_ellmer_tools.Rd
Function to handle the prompt
Function to handle the prompt execution
Mime type of the resource
MIME type of the resource (optional)
Function to handle the resource
Function to handle the resource request
Name of the MCP
Name of the MCP server
Description of the MCP
Description of the MCP server
Version of the MCP
Version of the MCP server
List of tools
List of tools (optional)
List of resources
List of resources (optional)
List of prompts
List of prompts (optional)
Input schema for the tool
Input schema for the tool (must be a schema object)
Function to handle the tool
Function to handle the tool execution
process_mcp_block.Rd
Process a single block with @mcp tag
process_mcp_block(block)
A roxy_block object
A list with tool information or NULL
Optional logical for exclusive minimum
Whether minimum is exclusive
Optional logical for exclusive maximum
Whether maximum is exclusive
Logical indicating if the number should be an integer
Whether the number should be an integer
Optional format (e.g., "date-time", "email", "uri")
Optional format constraint
register_mcpr_tools.Rd
Text content
Text content for the response
roclet_output.roclet_mcp.Rd
Generate MCP server output
# S3 method for class 'roclet_mcp' +roclet_output(x, results, base_path, ...)
MCP roclet object
List of processed tools
Base path
Additional arguments
NULL (invisible)
roclet_process.roclet_mcp.Rd
Process blocks for MCP roclet
# S3 method for class 'roclet_mcp' +roclet_process(x, blocks, env, base_path)
List of roxy_block objects
Environment
List of processed MCP tools
roxy_tag_parse.roxy_tag_mcp.Rd
Parses @mcp tags to extract tool name and description.
# S3 method for class 'roxy_tag_mcp' +roxy_tag_parse(x)
A roxy_tag object
roxy_tag_parse.roxy_tag_type.Rd
Parses @type tags to extract parameter type information. +Format: @type param_name type enum_values
# S3 method for class 'roxy_tag_type' +roxy_tag_parse(x)
roxy_tag_rd.roxy_tag_mcp.Rd
Roxygen2 tag for @mcp +This function is called by Roxygen2 to generate documentation for the @mcp tag
# S3 method for class 'roxy_tag_mcp' +roxy_tag_rd(x, base_path, env)
Roxygen2 tag object
roxy_tag_rd.roxy_tag_type.Rd
Roxygen2 tag handler for @type +This function is called by Roxygen2 to generate documentation for the @type
# S3 method for class 'roxy_tag_type' +roxy_tag_rd(x, base_path, env)
List of property definitions
List of property definitions created with properties()
Type of the schema
Type of the schema (default: "object")
Logical indicating if additional properties are allowed
Whether additional properties are allowed
An MCP server object created with new_server()