
Articles
38 |All vignettes
42 | 43 | 44 |- Integrating mcpr with MCP Clients 45 |
- 46 |
- Using the MCP Client 47 |
- 48 |
- Getting Started with mcpr 49 |
- 50 |
- Practical MCP Examples with R 51 |
- 52 |
├── .gitignore ├── docs ├── logo.png ├── favicon.ico ├── favicon-96x96.png ├── apple-touch-icon.png ├── reference │ ├── figures │ │ └── logo.png │ ├── new_client_http.html │ ├── new_client_io.html │ ├── new_mcp.html │ ├── response_file.html │ ├── response_item.html │ ├── response_text.html │ ├── response_audio.html │ ├── response_error.html │ ├── response_image.html │ ├── response_resource.html │ ├── response_video.html │ ├── JSONRPC_PARSE_ERROR.html │ ├── get_name.html │ ├── tools_list.html │ ├── roxy_tag_parse.roxy_tag_mcp.html │ ├── prompts_list.html │ ├── resources_list.html │ ├── validate_request.html │ ├── process_mcp_block.html │ ├── serve_io.html │ ├── generate_property_code.html │ ├── roxy_tag_parse.roxy_tag_type.html │ ├── initialize.html │ └── from_json.html ├── web-app-manifest-192x192.png ├── web-app-manifest-512x512.png ├── deps │ ├── font-awesome-6.5.2 │ │ └── webfonts │ │ │ ├── fa-solid-900.ttf │ │ │ ├── fa-brands-400.ttf │ │ │ ├── fa-regular-400.ttf │ │ │ ├── fa-solid-900.woff2 │ │ │ ├── fa-brands-400.woff2 │ │ │ ├── fa-regular-400.woff2 │ │ │ ├── fa-v4compatibility.ttf │ │ │ └── fa-v4compatibility.woff2 │ ├── headroom-0.11.0 │ │ ├── jQuery.headroom.min.js │ │ └── headroom.min.js │ ├── data-deps.txt │ └── bootstrap-toc-1.0.1 │ │ └── bootstrap-toc.min.js ├── pkgdown.yml ├── site.webmanifest ├── katex-auto.js ├── link.svg ├── extra.css ├── lightswitch.js ├── articles │ └── index.html ├── 404.html ├── pkgdown.js ├── authors.html └── sitemap.xml ├── pkgdown ├── mcpr.png ├── _pkgdown.yml ├── favicon │ ├── favicon.ico │ ├── favicon-96x96.png │ ├── apple-touch-icon.png │ ├── web-app-manifest-192x192.png │ ├── web-app-manifest-512x512.png │ └── site.webmanifest └── extra.css ├── man ├── figures │ └── logo.png ├── get_name.Rd ├── tools_list.Rd ├── prompts_list.Rd ├── resources_list.Rd ├── roxy_tag_parse.roxy_tag_mcp.Rd ├── JSONRPC_PARSE_ERROR.Rd ├── initialize.Rd ├── serve_io.Rd ├── validate_request.Rd ├── from_json.Rd ├── process_mcp_block.Rd ├── to_json.Rd ├── roxy_tag_parse.roxy_tag_type.Rd ├── read.Rd ├── generate_property_code.Rd ├── process_request.Rd ├── create_ellmer_type.Rd ├── process_batch.Rd ├── add_capability.Rd ├── generate_tool_code.Rd ├── create_response.Rd ├── generate_handler_code.Rd ├── mcp_roclet.Rd ├── parse_request.Rd ├── generate_mcp_server.Rd ├── create_ellmer_types.Rd ├── register_mcpr_tools.Rd ├── convert_ellmer_types_to_mcpr.Rd ├── build_param_info.Rd ├── tools_call.Rd ├── prompts_get.Rd ├── roclet_output.roclet_mcp.Rd ├── create_error.Rd ├── properties.Rd ├── resources_read.Rd ├── roclet_process.roclet_mcp.Rd ├── serve_http.Rd ├── create_ellmer_handler.Rd ├── write.Rd ├── convert_ellmer_type_to_mcpr_property.Rd ├── roxy_tag_rd.roxy_tag_mcp.Rd ├── roxy_tag_rd.roxy_tag_type.Rd ├── new_property.Rd ├── client.Rd ├── property_boolean.Rd ├── property_enum.Rd ├── schema.Rd ├── mcpr_to_ellmer_tools.Rd ├── new_resource.Rd ├── new_server.Rd ├── new_tool.Rd ├── new_prompt.Rd ├── mcpr_clients_to_ellmer_tools.Rd ├── property_array.Rd ├── property_object.Rd ├── property_string.Rd ├── property_number.Rd ├── ellmer_to_mcpr_tool.Rd └── response.Rd ├── R ├── utils.R ├── io.R ├── client.R ├── http.R ├── request.R └── response.R ├── .Rbuildignore ├── makefile ├── examples ├── calculator │ ├── client.R │ └── server.R └── ellmer │ ├── client.R │ └── server.R ├── DESCRIPTION ├── NEWS.md ├── _pkgdown.yml ├── NAMESPACE └── vignettes ├── get-started.Rmd ├── client-usage.Rmd └── client-integration.Rmd /.gitignore: -------------------------------------------------------------------------------- 1 | .claude/ 2 | -------------------------------------------------------------------------------- /docs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/docs/logo.png -------------------------------------------------------------------------------- /docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/docs/favicon.ico -------------------------------------------------------------------------------- /pkgdown/mcpr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/pkgdown/mcpr.png -------------------------------------------------------------------------------- /man/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/man/figures/logo.png -------------------------------------------------------------------------------- /pkgdown/_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: https://mcpr.opifex.org 2 | template: 3 | bootstrap: 5 4 | 5 | -------------------------------------------------------------------------------- /docs/favicon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/docs/favicon-96x96.png -------------------------------------------------------------------------------- /docs/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/docs/apple-touch-icon.png -------------------------------------------------------------------------------- /R/utils.R: -------------------------------------------------------------------------------- 1 | generate_id <- function() { 2 | trunc(as.numeric(Sys.time()) * 1000000) # microseconds 3 | } 4 | -------------------------------------------------------------------------------- /pkgdown/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/pkgdown/favicon/favicon.ico -------------------------------------------------------------------------------- /docs/reference/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/docs/reference/figures/logo.png -------------------------------------------------------------------------------- /docs/web-app-manifest-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/docs/web-app-manifest-192x192.png -------------------------------------------------------------------------------- /docs/web-app-manifest-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/docs/web-app-manifest-512x512.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/pkgdown/favicon/favicon-96x96.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/pkgdown/favicon/apple-touch-icon.png -------------------------------------------------------------------------------- /pkgdown/favicon/web-app-manifest-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/pkgdown/favicon/web-app-manifest-192x192.png -------------------------------------------------------------------------------- /pkgdown/favicon/web-app-manifest-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/pkgdown/favicon/web-app-manifest-512x512.png -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.ttf -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^makefile$ 2 | ^LICENSE\.md$ 3 | ^test\.R$ 4 | ^_pkgdown\.yml$ 5 | ^docs$ 6 | ^pkgdown$ 7 | ^examples$ 8 | ^\.github$ 9 | ^\.claude$ 10 | -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devOpifex/mcpr/HEAD/docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.woff2 -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | default: install 2 | 3 | document: 4 | R -s -e "devtools::document()" 5 | 6 | check: document 7 | R -s -e "devtools::check(document = FALSE)" 8 | 9 | install: check 10 | R -s -e "devtools::install()" 11 | 12 | site: document 13 | R -s -e "pkgdown::build_site()" 14 | -------------------------------------------------------------------------------- /docs/reference/new_client_http.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/new_client_io.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/new_mcp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/response_file.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/response_item.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/response_text.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/response_audio.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/response_error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/response_image.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/response_resource.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/response_video.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /man/get_name.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/client.R 3 | \name{get_name} 4 | \alias{get_name} 5 | \title{Get the name of a client} 6 | \usage{ 7 | get_name(x) 8 | } 9 | \arguments{ 10 | \item{x}{A client object} 11 | } 12 | \value{ 13 | The name of the client 14 | } 15 | \description{ 16 | Get the name of a client 17 | } 18 | -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: 3.1.3 2 | pkgdown: 2.1.2 3 | pkgdown_sha: ~ 4 | articles: 5 | client-integration: client-integration.html 6 | client-usage: client-usage.html 7 | get-started: get-started.html 8 | practical-examples: practical-examples.html 9 | last_built: 2025-06-20T08:07Z 10 | urls: 11 | reference: https://mcpr.opifex.org/reference 12 | article: https://mcpr.opifex.org/articles 13 | -------------------------------------------------------------------------------- /man/tools_list.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods.R 3 | \name{tools_list} 4 | \alias{tools_list} 5 | \title{List all available tools} 6 | \usage{ 7 | tools_list(mcp) 8 | } 9 | \arguments{ 10 | \item{mcp}{A server object} 11 | } 12 | \value{ 13 | A list containing all available tools 14 | } 15 | \description{ 16 | List all available tools 17 | } 18 | -------------------------------------------------------------------------------- /man/prompts_list.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods.R 3 | \name{prompts_list} 4 | \alias{prompts_list} 5 | \title{List all available prompts} 6 | \usage{ 7 | prompts_list(mcp) 8 | } 9 | \arguments{ 10 | \item{mcp}{A server object} 11 | } 12 | \value{ 13 | A list containing all available prompts 14 | } 15 | \description{ 16 | List all available prompts 17 | } 18 | -------------------------------------------------------------------------------- /man/resources_list.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods.R 3 | \name{resources_list} 4 | \alias{resources_list} 5 | \title{List all available resources} 6 | \usage{ 7 | resources_list(mcp) 8 | } 9 | \arguments{ 10 | \item{mcp}{A server object} 11 | } 12 | \value{ 13 | A list containing all available resources 14 | } 15 | \description{ 16 | List all available resources 17 | } 18 | -------------------------------------------------------------------------------- /man/roxy_tag_parse.roxy_tag_mcp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/roclet.R 3 | \name{roxy_tag_parse.roxy_tag_mcp} 4 | \alias{roxy_tag_parse.roxy_tag_mcp} 5 | \title{Parse @mcp tag} 6 | \usage{ 7 | \method{roxy_tag_parse}{roxy_tag_mcp}(x) 8 | } 9 | \arguments{ 10 | \item{x}{A roxy_tag object} 11 | } 12 | \description{ 13 | Parses @mcp tags to extract tool name and description. 14 | } 15 | -------------------------------------------------------------------------------- /man/JSONRPC_PARSE_ERROR.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/jsonrpc.R 3 | \docType{data} 4 | \name{JSONRPC_PARSE_ERROR} 5 | \alias{JSONRPC_PARSE_ERROR} 6 | \title{JSON-RPC 2.0 Standard Error Codes} 7 | \format{ 8 | An object of class \code{numeric} of length 1. 9 | } 10 | \usage{ 11 | JSONRPC_PARSE_ERROR 12 | } 13 | \description{ 14 | JSON-RPC 2.0 Standard Error Codes 15 | } 16 | \keyword{internal} 17 | -------------------------------------------------------------------------------- /man/initialize.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods.R 3 | \name{initialize} 4 | \alias{initialize} 5 | \title{Initialize the server with protocol information} 6 | \usage{ 7 | initialize(mcp) 8 | } 9 | \arguments{ 10 | \item{mcp}{A server object} 11 | } 12 | \value{ 13 | A list containing protocol version, server info, and capabilities 14 | } 15 | \description{ 16 | Initialize the server with protocol information 17 | } 18 | -------------------------------------------------------------------------------- /examples/calculator/client.R: -------------------------------------------------------------------------------- 1 | devtools::load_all() 2 | 3 | client <- new_client_io( 4 | "Rscript", 5 | "/home/john/Opifex/Packages/mcpr/examples/calculator/server.R", 6 | name = "calculator", 7 | version = "1.0.0" 8 | ) 9 | 10 | #client <- new_client_http( 11 | # "http://localhost:3000/mcp", 12 | # name = "calculator", 13 | # version = "1.0.0" 14 | #) 15 | 16 | res <- initialize(client) 17 | 18 | print(res) 19 | 20 | res <- tools_list(client) 21 | 22 | print(res) 23 | -------------------------------------------------------------------------------- /man/serve_io.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/io.R 3 | \name{serve_io} 4 | \alias{serve_io} 5 | \title{Serve an MCP server using stdin/stdout} 6 | \usage{ 7 | serve_io(mcp) 8 | } 9 | \arguments{ 10 | \item{mcp}{An MCP server object created with new_server()} 11 | } 12 | \value{ 13 | Nothing, runs indefinitely in normal mode, or the response in test mode 14 | } 15 | \description{ 16 | Serve an MCP server using stdin/stdout 17 | } 18 | -------------------------------------------------------------------------------- /man/validate_request.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/jsonrpc.R 3 | \name{validate_request} 4 | \alias{validate_request} 5 | \title{Validate a JSON-RPC 2.0 request} 6 | \usage{ 7 | validate_request(request) 8 | } 9 | \arguments{ 10 | \item{request}{Parsed request object} 11 | } 12 | \value{ 13 | NULL if valid, error response if invalid 14 | } 15 | \description{ 16 | Validate a JSON-RPC 2.0 request 17 | } 18 | \keyword{internal} 19 | -------------------------------------------------------------------------------- /man/from_json.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/jsonrpc.R 3 | \name{from_json} 4 | \alias{from_json} 5 | \title{Parse JSON to an R object} 6 | \usage{ 7 | from_json(json, ...) 8 | } 9 | \arguments{ 10 | \item{json}{JSON string to parse} 11 | 12 | \item{...}{Additional arguments passed to yyjsonr::read_json_str} 13 | } 14 | \value{ 15 | R object 16 | } 17 | \description{ 18 | Parse JSON to an R object 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/process_mcp_block.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/roclet.R 3 | \name{process_mcp_block} 4 | \alias{process_mcp_block} 5 | \title{Process a single block with @mcp tag} 6 | \usage{ 7 | process_mcp_block(block) 8 | } 9 | \arguments{ 10 | \item{block}{A roxy_block object} 11 | } 12 | \value{ 13 | A list with tool information or NULL 14 | } 15 | \description{ 16 | Process a single block with @mcp tag 17 | } 18 | \keyword{internal} 19 | -------------------------------------------------------------------------------- /man/to_json.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/jsonrpc.R 3 | \name{to_json} 4 | \alias{to_json} 5 | \title{Convert an R object to JSON} 6 | \usage{ 7 | to_json(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{R object to convert to JSON} 11 | 12 | \item{...}{Additional arguments passed to yyjsonr::write_json_str} 13 | } 14 | \value{ 15 | JSON string 16 | } 17 | \description{ 18 | Convert an R object to JSON 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/roxy_tag_parse.roxy_tag_type.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/roclet.R 3 | \name{roxy_tag_parse.roxy_tag_type} 4 | \alias{roxy_tag_parse.roxy_tag_type} 5 | \title{Parse @type tag} 6 | \usage{ 7 | \method{roxy_tag_parse}{roxy_tag_type}(x) 8 | } 9 | \arguments{ 10 | \item{x}{A roxy_tag object} 11 | } 12 | \description{ 13 | Parses @type tags to extract parameter type information. 14 | Format: @type param_name type enum_values 15 | } 16 | -------------------------------------------------------------------------------- /man/read.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/request.R 3 | \name{read} 4 | \alias{read} 5 | \title{Read a JSON-RPC response from a client provider} 6 | \usage{ 7 | read(x, timeout = 60 * 1000) 8 | } 9 | \arguments{ 10 | \item{x}{A client provider} 11 | 12 | \item{timeout}{Timeout in milliseconds for reading the response} 13 | } 14 | \value{ 15 | The response 16 | } 17 | \description{ 18 | Read a JSON-RPC response from a client provider 19 | } 20 | -------------------------------------------------------------------------------- /man/generate_property_code.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/roclet.R 3 | \name{generate_property_code} 4 | \alias{generate_property_code} 5 | \title{Generate property code for a parameter} 6 | \usage{ 7 | generate_property_code(param) 8 | } 9 | \arguments{ 10 | \item{param}{Parameter information} 11 | } 12 | \value{ 13 | Character string with property code 14 | } 15 | \description{ 16 | Generate property code for a parameter 17 | } 18 | \keyword{internal} 19 | -------------------------------------------------------------------------------- /man/process_request.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/jsonrpc.R 3 | \name{process_request} 4 | \alias{process_request} 5 | \title{Process a JSON-RPC 2.0 request} 6 | \usage{ 7 | process_request(request, mcp) 8 | } 9 | \arguments{ 10 | \item{request}{Parsed request object} 11 | 12 | \item{mcp}{MCP server object} 13 | } 14 | \value{ 15 | Response object or NULL for notifications 16 | } 17 | \description{ 18 | Process a JSON-RPC 2.0 request 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /docs/site.webmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "name": "", 3 | "short_name": "", 4 | "icons": [ 5 | { 6 | "src": "/web-app-manifest-192x192.png", 7 | "sizes": "192x192", 8 | "type": "image/png", 9 | "purpose": "maskable" 10 | }, 11 | { 12 | "src": "/web-app-manifest-512x512.png", 13 | "sizes": "512x512", 14 | "type": "image/png", 15 | "purpose": "maskable" 16 | } 17 | ], 18 | "theme_color": "#ffffff", 19 | "background_color": "#ffffff", 20 | "display": "standalone" 21 | } -------------------------------------------------------------------------------- /man/create_ellmer_type.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mcpr-to-ellmer.R 3 | \name{create_ellmer_type} 4 | \alias{create_ellmer_type} 5 | \title{Create an ellmer type function for a specific MCP property} 6 | \usage{ 7 | create_ellmer_type(prop) 8 | } 9 | \arguments{ 10 | \item{prop}{The MCP property} 11 | } 12 | \value{ 13 | An ellmer type function call 14 | } 15 | \description{ 16 | Create an ellmer type function for a specific MCP property 17 | } 18 | \keyword{internal} 19 | -------------------------------------------------------------------------------- /man/process_batch.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/jsonrpc.R 3 | \name{process_batch} 4 | \alias{process_batch} 5 | \title{Process batch JSON-RPC 2.0 requests} 6 | \usage{ 7 | process_batch(batch_requests, mcp) 8 | } 9 | \arguments{ 10 | \item{batch_requests}{List of request objects} 11 | 12 | \item{mcp}{MCP server object} 13 | } 14 | \value{ 15 | List of response objects 16 | } 17 | \description{ 18 | Process batch JSON-RPC 2.0 requests 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/add_capability.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mcp.R 3 | \name{add_capability} 4 | \alias{add_capability} 5 | \title{Add a capability to an MCP object} 6 | \usage{ 7 | add_capability(mcp, capability) 8 | } 9 | \arguments{ 10 | \item{mcp}{An MCP server object} 11 | 12 | \item{capability}{A tool, resource, or prompt capability object} 13 | } 14 | \value{ 15 | The MCP object with the capability added 16 | } 17 | \description{ 18 | Add a capability to an MCP object 19 | } 20 | -------------------------------------------------------------------------------- /man/generate_tool_code.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/roclet.R 3 | \name{generate_tool_code} 4 | \alias{generate_tool_code} 5 | \title{Generate R code for a single tool} 6 | \usage{ 7 | generate_tool_code(tool, index) 8 | } 9 | \arguments{ 10 | \item{tool}{Tool information list} 11 | 12 | \item{index}{Tool index for naming} 13 | } 14 | \value{ 15 | Character vector of R code lines 16 | } 17 | \description{ 18 | Generate R code for a single tool 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/create_response.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/jsonrpc.R 3 | \name{create_response} 4 | \alias{create_response} 5 | \title{Create a JSON-RPC 2.0 success response} 6 | \usage{ 7 | create_response(result, id = NULL) 8 | } 9 | \arguments{ 10 | \item{result}{Result data} 11 | 12 | \item{id}{Request identifier} 13 | } 14 | \value{ 15 | A structured JSON-RPC 2.0 success response 16 | } 17 | \description{ 18 | Create a JSON-RPC 2.0 success response 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/generate_handler_code.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/roclet.R 3 | \name{generate_handler_code} 4 | \alias{generate_handler_code} 5 | \title{Generate handler code that calls the original function} 6 | \usage{ 7 | generate_handler_code(tool) 8 | } 9 | \arguments{ 10 | \item{tool}{Tool information} 11 | } 12 | \value{ 13 | Character vector of handler code lines 14 | } 15 | \description{ 16 | Generate handler code that calls the original function 17 | } 18 | \keyword{internal} 19 | -------------------------------------------------------------------------------- /man/mcp_roclet.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/roclet.R 3 | \name{mcp_roclet} 4 | \alias{mcp_roclet} 5 | \title{MCP Roclet for Generating MCP Servers} 6 | \usage{ 7 | mcp_roclet() 8 | } 9 | \description{ 10 | This roclet automatically generates MCP (Model Context Protocol) servers 11 | from R functions annotated with @mcp tags. 12 | } 13 | \examples{ 14 | \dontrun{ 15 | # Use the roclet in roxygenise 16 | roxygen2::roxygenise(roclets = c("rd", "mcpr::mcp_roclet")) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /man/parse_request.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/jsonrpc.R 3 | \name{parse_request} 4 | \alias{parse_request} 5 | \title{Parse and process a JSON-RPC 2.0 request} 6 | \usage{ 7 | parse_request(json_text, mcp) 8 | } 9 | \arguments{ 10 | \item{json_text}{JSON request text} 11 | 12 | \item{mcp}{MCP server object} 13 | } 14 | \value{ 15 | JSON response text or NULL for notifications 16 | } 17 | \description{ 18 | Parse and process a JSON-RPC 2.0 request 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/generate_mcp_server.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/roclet.R 3 | \name{generate_mcp_server} 4 | \alias{generate_mcp_server} 5 | \title{Generate MCP server R code} 6 | \usage{ 7 | generate_mcp_server(tools, base_path) 8 | } 9 | \arguments{ 10 | \item{tools}{List of tool information} 11 | 12 | \item{base_path}{Base path for the package} 13 | } 14 | \value{ 15 | Character vector of R code lines 16 | } 17 | \description{ 18 | Generate MCP server R code 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /pkgdown/favicon/site.webmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "name": "", 3 | "short_name": "", 4 | "icons": [ 5 | { 6 | "src": "/web-app-manifest-192x192.png", 7 | "sizes": "192x192", 8 | "type": "image/png", 9 | "purpose": "maskable" 10 | }, 11 | { 12 | "src": "/web-app-manifest-512x512.png", 13 | "sizes": "512x512", 14 | "type": "image/png", 15 | "purpose": "maskable" 16 | } 17 | ], 18 | "theme_color": "#ffffff", 19 | "background_color": "#ffffff", 20 | "display": "standalone" 21 | } -------------------------------------------------------------------------------- /man/create_ellmer_types.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mcpr-to-ellmer.R 3 | \name{create_ellmer_types} 4 | \alias{create_ellmer_types} 5 | \title{Create ellmer type functions from MCP schema properties} 6 | \usage{ 7 | create_ellmer_types(schema) 8 | } 9 | \arguments{ 10 | \item{schema}{The MCP schema object} 11 | } 12 | \value{ 13 | A list of ellmer type function calls for each property 14 | } 15 | \description{ 16 | Create ellmer type functions from MCP schema properties 17 | } 18 | \keyword{internal} 19 | -------------------------------------------------------------------------------- /man/register_mcpr_tools.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mcpr-to-ellmer.R 3 | \name{register_mcpr_tools} 4 | \alias{register_mcpr_tools} 5 | \title{Register MCPR tools with an ellmer chat} 6 | \usage{ 7 | register_mcpr_tools(chat, client) 8 | } 9 | \arguments{ 10 | \item{chat}{An ellmer chat object} 11 | 12 | \item{client}{An mcpr client object} 13 | } 14 | \value{ 15 | The chat object (invisibly) 16 | } 17 | \description{ 18 | This function registers tools from an MCPR client with an ellmer chat instance. 19 | } 20 | -------------------------------------------------------------------------------- /man/convert_ellmer_types_to_mcpr.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ellmer-to-mcpr.R 3 | \name{convert_ellmer_types_to_mcpr} 4 | \alias{convert_ellmer_types_to_mcpr} 5 | \title{Convert ellmer TypeObject to mcpr schema} 6 | \usage{ 7 | convert_ellmer_types_to_mcpr(type_object) 8 | } 9 | \arguments{ 10 | \item{type_object}{An ellmer TypeObject containing the function arguments} 11 | } 12 | \value{ 13 | An mcpr schema object 14 | } 15 | \description{ 16 | Convert ellmer TypeObject to mcpr schema 17 | } 18 | \keyword{internal} 19 | -------------------------------------------------------------------------------- /man/build_param_info.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/roclet.R 3 | \name{build_param_info} 4 | \alias{build_param_info} 5 | \title{Build parameter information from @param and @type tags} 6 | \usage{ 7 | build_param_info(param_tags, type_tags = list()) 8 | } 9 | \arguments{ 10 | \item{param_tags}{List of @param tags} 11 | 12 | \item{type_tags}{List of @type tags} 13 | } 14 | \value{ 15 | List of parameter information 16 | } 17 | \description{ 18 | Build parameter information from @param and @type tags 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/tools_call.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods.R 3 | \name{tools_call} 4 | \alias{tools_call} 5 | \title{Call a tool with the given parameters} 6 | \usage{ 7 | tools_call(mcp, params, id = NULL) 8 | } 9 | \arguments{ 10 | \item{mcp}{A server object} 11 | 12 | \item{params}{Parameters for the tool call} 13 | 14 | \item{id}{Optional request ID for response tracking} 15 | } 16 | \value{ 17 | A response object with the tool call results or an error 18 | } 19 | \description{ 20 | Call a tool with the given parameters 21 | } 22 | -------------------------------------------------------------------------------- /man/prompts_get.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods.R 3 | \name{prompts_get} 4 | \alias{prompts_get} 5 | \title{Get a prompt with the given parameters} 6 | \usage{ 7 | prompts_get(mcp, params, id = NULL) 8 | } 9 | \arguments{ 10 | \item{mcp}{A server object} 11 | 12 | \item{params}{Parameters for the prompt request} 13 | 14 | \item{id}{Optional request ID for response tracking} 15 | } 16 | \value{ 17 | A response object with the prompt results or an error 18 | } 19 | \description{ 20 | Get a prompt with the given parameters 21 | } 22 | -------------------------------------------------------------------------------- /man/roclet_output.roclet_mcp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/roclet.R 3 | \name{roclet_output.roclet_mcp} 4 | \alias{roclet_output.roclet_mcp} 5 | \title{Generate MCP server output} 6 | \usage{ 7 | \method{roclet_output}{roclet_mcp}(x, results, base_path, ...) 8 | } 9 | \arguments{ 10 | \item{x}{MCP roclet object} 11 | 12 | \item{results}{List of processed tools} 13 | 14 | \item{base_path}{Base path} 15 | 16 | \item{...}{Additional arguments} 17 | } 18 | \value{ 19 | NULL (invisible) 20 | } 21 | \description{ 22 | Generate MCP server output 23 | } 24 | -------------------------------------------------------------------------------- /man/create_error.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/jsonrpc.R 3 | \name{create_error} 4 | \alias{create_error} 5 | \title{Create a JSON-RPC 2.0 error response} 6 | \usage{ 7 | create_error(code, message, data = NULL, id = NULL) 8 | } 9 | \arguments{ 10 | \item{code}{Error code} 11 | 12 | \item{message}{Error message} 13 | 14 | \item{data}{Optional error data} 15 | 16 | \item{id}{Request identifier} 17 | } 18 | \value{ 19 | A structured JSON-RPC 2.0 error response 20 | } 21 | \description{ 22 | Create a JSON-RPC 2.0 error response 23 | } 24 | \keyword{internal} 25 | -------------------------------------------------------------------------------- /man/properties.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/input-schema.R 3 | \name{properties} 4 | \alias{properties} 5 | \title{Create a new properties list} 6 | \usage{ 7 | properties(...) 8 | } 9 | \arguments{ 10 | \item{...}{Property objects} 11 | } 12 | \value{ 13 | A list of property objects 14 | } 15 | \description{ 16 | Create a new properties list 17 | } 18 | \examples{ 19 | properties <- properties( 20 | property_string("Name", "The name of the user", required = TRUE), 21 | property_number("Age", "The age of the user in years", minimum = 0) 22 | ) 23 | } 24 | -------------------------------------------------------------------------------- /man/resources_read.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods.R 3 | \name{resources_read} 4 | \alias{resources_read} 5 | \title{Read a resource with the given parameters} 6 | \usage{ 7 | resources_read(mcp, params, id = NULL) 8 | } 9 | \arguments{ 10 | \item{mcp}{A server object} 11 | 12 | \item{params}{Parameters for the resource read} 13 | 14 | \item{id}{Optional request ID for response tracking} 15 | } 16 | \value{ 17 | A response object with the resource read results or an error 18 | } 19 | \description{ 20 | Read a resource with the given parameters 21 | } 22 | -------------------------------------------------------------------------------- /man/roclet_process.roclet_mcp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/roclet.R 3 | \name{roclet_process.roclet_mcp} 4 | \alias{roclet_process.roclet_mcp} 5 | \title{Process blocks for MCP roclet} 6 | \usage{ 7 | \method{roclet_process}{roclet_mcp}(x, blocks, env, base_path) 8 | } 9 | \arguments{ 10 | \item{x}{MCP roclet object} 11 | 12 | \item{blocks}{List of roxy_block objects} 13 | 14 | \item{env}{Environment} 15 | 16 | \item{base_path}{Base path} 17 | } 18 | \value{ 19 | List of processed MCP tools 20 | } 21 | \description{ 22 | Process blocks for MCP roclet 23 | } 24 | -------------------------------------------------------------------------------- /man/serve_http.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/http.R 3 | \name{serve_http} 4 | \alias{serve_http} 5 | \title{Serve an MCP server over HTTP using ambiorix} 6 | \usage{ 7 | serve_http(mcp, port = Sys.getenv("SHINY_PORT", 3000), path = "/mcp") 8 | } 9 | \arguments{ 10 | \item{mcp}{An MCP server object} 11 | 12 | \item{port}{Port to listen on, defaults to 3000} 13 | 14 | \item{path}{Path to serve the MCP endpoint, defaults to "/mcp"} 15 | } 16 | \value{ 17 | Invisible, runs indefinitely 18 | } 19 | \description{ 20 | Serve an MCP server over HTTP using ambiorix 21 | } 22 | -------------------------------------------------------------------------------- /docs/deps/headroom-0.11.0/jQuery.headroom.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * headroom.js v0.9.4 - Give your page some headroom. Hide your header until you need it 3 | * Copyright (c) 2017 Nick Williams - http://wicky.nillia.ms/headroom.js 4 | * License: MIT 5 | */ 6 | 7 | !function(a){a&&(a.fn.headroom=function(b){return this.each(function(){var c=a(this),d=c.data("headroom"),e="object"==typeof b&&b;e=a.extend(!0,{},Headroom.options,e),d||(d=new Headroom(this,e),d.init(),c.data("headroom",d)),"string"==typeof b&&(d[b](),"destroy"===b&&c.removeData("headroom"))})},a("[data-headroom]").each(function(){var b=a(this);b.headroom(b.data())}))}(window.Zepto||window.jQuery); -------------------------------------------------------------------------------- /man/create_ellmer_handler.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mcpr-to-ellmer.R 3 | \name{create_ellmer_handler} 4 | \alias{create_ellmer_handler} 5 | \title{Create an ellmer handler function for an MCP tool} 6 | \usage{ 7 | create_ellmer_handler(client, tool_name, input_schema) 8 | } 9 | \arguments{ 10 | \item{client}{The mcpr client} 11 | 12 | \item{tool_name}{The name of the MCP tool} 13 | 14 | \item{input_schema}{The tool's input schema} 15 | } 16 | \value{ 17 | A function that can be used as an ellmer tool handler 18 | } 19 | \description{ 20 | Create an ellmer handler function for an MCP tool 21 | } 22 | \keyword{internal} 23 | -------------------------------------------------------------------------------- /docs/katex-auto.js: -------------------------------------------------------------------------------- 1 | // https://github.com/jgm/pandoc/blob/29fa97ab96b8e2d62d48326e1b949a71dc41f47a/src/Text/Pandoc/Writers/HTML.hs#L332-L345 2 | document.addEventListener("DOMContentLoaded", function () { 3 | var mathElements = document.getElementsByClassName("math"); 4 | var macros = []; 5 | for (var i = 0; i < mathElements.length; i++) { 6 | var texText = mathElements[i].firstChild; 7 | if (mathElements[i].tagName == "SPAN") { 8 | katex.render(texText.data, mathElements[i], { 9 | displayMode: mathElements[i].classList.contains("display"), 10 | throwOnError: false, 11 | macros: macros, 12 | fleqn: false 13 | }); 14 | }}}); 15 | -------------------------------------------------------------------------------- /man/write.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/request.R 3 | \name{write} 4 | \alias{write} 5 | \title{Write a JSON-RPC request to a client provider} 6 | \usage{ 7 | write(x, method, params = NULL, id = generate_id(), timeout = 5000) 8 | } 9 | \arguments{ 10 | \item{x}{A client provider} 11 | 12 | \item{method}{The method to call} 13 | 14 | \item{params}{The parameters to pass to the method} 15 | 16 | \item{id}{The id of the request} 17 | 18 | \item{timeout}{Timeout in milliseconds for reading the response} 19 | } 20 | \value{ 21 | The client provider 22 | } 23 | \description{ 24 | Write a JSON-RPC request to a client provider 25 | } 26 | -------------------------------------------------------------------------------- /man/convert_ellmer_type_to_mcpr_property.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ellmer-to-mcpr.R 3 | \name{convert_ellmer_type_to_mcpr_property} 4 | \alias{convert_ellmer_type_to_mcpr_property} 5 | \title{Convert a single ellmer type to an mcpr property} 6 | \usage{ 7 | convert_ellmer_type_to_mcpr_property(ellmer_type, prop_name) 8 | } 9 | \arguments{ 10 | \item{ellmer_type}{An ellmer Type object (TypeBasic, TypeArray, etc.)} 11 | 12 | \item{prop_name}{The name of the property (for better error messages)} 13 | } 14 | \value{ 15 | An mcpr property object 16 | } 17 | \description{ 18 | Convert a single ellmer type to an mcpr property 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/roxy_tag_rd.roxy_tag_mcp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/roclet.R 3 | \name{roxy_tag_rd.roxy_tag_mcp} 4 | \alias{roxy_tag_rd.roxy_tag_mcp} 5 | \title{Roxygen2 tag for @mcp 6 | This function is called by Roxygen2 to generate documentation for the @mcp tag} 7 | \usage{ 8 | \method{roxy_tag_rd}{roxy_tag_mcp}(x, base_path, env) 9 | } 10 | \arguments{ 11 | \item{x}{Roxygen2 tag object} 12 | 13 | \item{base_path}{Base path for the package} 14 | 15 | \item{env}{Environment} 16 | } 17 | \value{ 18 | NULL (invisible) 19 | } 20 | \description{ 21 | Roxygen2 tag for @mcp 22 | This function is called by Roxygen2 to generate documentation for the @mcp tag 23 | } 24 | -------------------------------------------------------------------------------- /man/roxy_tag_rd.roxy_tag_type.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/roclet.R 3 | \name{roxy_tag_rd.roxy_tag_type} 4 | \alias{roxy_tag_rd.roxy_tag_type} 5 | \title{Roxygen2 tag handler for @type 6 | This function is called by Roxygen2 to generate documentation for the @type} 7 | \usage{ 8 | \method{roxy_tag_rd}{roxy_tag_type}(x, base_path, env) 9 | } 10 | \arguments{ 11 | \item{x}{Roxygen2 tag object} 12 | 13 | \item{base_path}{Base path for the package} 14 | 15 | \item{env}{Environment} 16 | } 17 | \value{ 18 | NULL (invisible) 19 | } 20 | \description{ 21 | Roxygen2 tag handler for @type 22 | This function is called by Roxygen2 to generate documentation for the @type 23 | } 24 | -------------------------------------------------------------------------------- /man/new_property.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/input-schema.R 3 | \name{new_property} 4 | \alias{new_property} 5 | \title{Create a new property} 6 | \usage{ 7 | new_property(type, title, description, required = FALSE, ...) 8 | } 9 | \arguments{ 10 | \item{type}{Type of the property} 11 | 12 | \item{title}{Short title for the property} 13 | 14 | \item{description}{Longer description of the property} 15 | 16 | \item{required}{Whether the property is required} 17 | 18 | \item{...}{Additional attributes for the property} 19 | } 20 | \value{ 21 | A property object with the specified attributes 22 | } 23 | \description{ 24 | Create a new property 25 | } 26 | \keyword{internal} 27 | -------------------------------------------------------------------------------- /man/client.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/client.R 3 | \name{client} 4 | \alias{client} 5 | \alias{new_client_io} 6 | \alias{new_client_http} 7 | \title{Create a new mcp IO} 8 | \usage{ 9 | new_client_io(command, args = character(), name, version = "1.0.0") 10 | 11 | new_client_http(endpoint, name, version = "1.0.0") 12 | } 13 | \arguments{ 14 | \item{command}{The command to run} 15 | 16 | \item{args}{Arguments to pass to the command} 17 | 18 | \item{name}{The name of the client} 19 | 20 | \item{version}{The version of the client} 21 | 22 | \item{endpoint}{The endpoint to connect to} 23 | } 24 | \value{ 25 | A new mcp client 26 | } 27 | \description{ 28 | Create a new mcp IO 29 | } 30 | -------------------------------------------------------------------------------- /man/property_boolean.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/input-schema.R 3 | \name{property_boolean} 4 | \alias{property_boolean} 5 | \title{Create a boolean property definition} 6 | \usage{ 7 | property_boolean(title, description, required = FALSE) 8 | } 9 | \arguments{ 10 | \item{title}{Short title for the property} 11 | 12 | \item{description}{Longer description of the property} 13 | 14 | \item{required}{Whether the property is required} 15 | } 16 | \value{ 17 | A boolean property object 18 | } 19 | \description{ 20 | Create a boolean property definition 21 | } 22 | \examples{ 23 | active_prop <- property_boolean( 24 | "Active status", 25 | "Whether the user account is active", 26 | required = TRUE 27 | ) 28 | } 29 | -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | -------------------------------------------------------------------------------- /man/property_enum.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/input-schema.R 3 | \name{property_enum} 4 | \alias{property_enum} 5 | \title{Create an enum property with predefined values} 6 | \usage{ 7 | property_enum(title, description, values, required = FALSE) 8 | } 9 | \arguments{ 10 | \item{title}{Short title for the property} 11 | 12 | \item{description}{Longer description of the property} 13 | 14 | \item{values}{Character vector of allowed values} 15 | 16 | \item{required}{Whether the property is required} 17 | } 18 | \value{ 19 | An enum property object 20 | } 21 | \description{ 22 | Create an enum property with predefined values 23 | } 24 | \examples{ 25 | status_prop <- property_enum( 26 | "Status", 27 | "User account status", 28 | values = c("active", "pending", "suspended"), 29 | required = TRUE 30 | ) 31 | } 32 | -------------------------------------------------------------------------------- /examples/ellmer/client.R: -------------------------------------------------------------------------------- 1 | devtools::load_all() 2 | 3 | # Create an MCPR client connected to the calculator server 4 | client <- new_client_io( 5 | "Rscript", 6 | "/home/john/Opifex/Packages/mcpr/examples/ellmer/server.R", 7 | name = "calculator", 8 | version = "1.0.0" 9 | ) 10 | 11 | Sys.sleep(1) 12 | 13 | res <- tools_call( 14 | client, 15 | params = list( 16 | name = "math_calculator", 17 | arguments = list( 18 | operation = "add", 19 | a = 5, 20 | b = 3 21 | ) 22 | ), 23 | id = 42 24 | ) 25 | 26 | # Create a Claude chat session with ellmer 27 | chat <- ellmer::chat_anthropic() 28 | 29 | ## Convert MCPR tools to ellmer tools and register them with the chat 30 | chat <- register_mcpr_tools(chat, client) 31 | 32 | ## Try using the tools in a chat 33 | chat$chat( 34 | "What is the current time in the US/Eastern timezone?", 35 | ) 36 | -------------------------------------------------------------------------------- /man/schema.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/input-schema.R 3 | \name{schema} 4 | \alias{schema} 5 | \title{Create a new input schema} 6 | \usage{ 7 | schema(properties, type = "object", additional_properties = FALSE) 8 | } 9 | \arguments{ 10 | \item{properties}{List of property definitions created with properties()} 11 | 12 | \item{type}{Type of the schema (default: "object")} 13 | 14 | \item{additional_properties}{Whether additional properties are allowed} 15 | } 16 | \value{ 17 | A list representing a JSON Schema object 18 | } 19 | \description{ 20 | Create a new input schema 21 | } 22 | \examples{ 23 | schema <- schema( 24 | properties = properties( 25 | name = property_string("User name", "The name of the user", required = TRUE), 26 | age = property_number("User age", "The age of the user in years", minimum = 0) 27 | ) 28 | ) 29 | } 30 | -------------------------------------------------------------------------------- /docs/deps/data-deps.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /man/mcpr_to_ellmer_tools.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mcpr-to-ellmer.R 3 | \name{mcpr_to_ellmer_tools} 4 | \alias{mcpr_to_ellmer_tools} 5 | \title{Convert MCPR tools to ellmer tools} 6 | \usage{ 7 | mcpr_to_ellmer_tools(client) 8 | } 9 | \arguments{ 10 | \item{client}{An mcpr client object} 11 | } 12 | \value{ 13 | A list of ellmer-compatible tool functions 14 | } 15 | \description{ 16 | This function converts tools from an MCPR client to a format compatible 17 | with the ellmer package. It retrieves all available tools from the client 18 | and creates wrapper functions that call these tools through the MCPR protocol. 19 | } 20 | \examples{ 21 | \dontrun{ 22 | # Create an MCPR client 23 | client <- new_client_io("path/to/server") 24 | 25 | # Convert its tools to ellmer format 26 | ellmer_tools <- mcpr_to_ellmer_tools(client) 27 | 28 | # Use with ellmer 29 | chat <- ellmer::chat_claude() 30 | chat$set_tools(ellmer_tools) 31 | } 32 | } 33 | \keyword{internal} 34 | -------------------------------------------------------------------------------- /man/new_resource.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mcp.R 3 | \name{new_resource} 4 | \alias{new_resource} 5 | \title{Create a new resource} 6 | \usage{ 7 | new_resource(name, description, uri, mime_type = NULL, handler) 8 | } 9 | \arguments{ 10 | \item{name}{Name of the resource} 11 | 12 | \item{description}{Description of the resource} 13 | 14 | \item{uri}{URI of the resource} 15 | 16 | \item{mime_type}{MIME type of the resource (optional)} 17 | 18 | \item{handler}{Function to handle the resource request} 19 | } 20 | \value{ 21 | A new resource capability 22 | } 23 | \description{ 24 | Create a new resource 25 | } 26 | \examples{ 27 | resource <- new_resource( 28 | name = "My Resource", 29 | description = "This is a description", 30 | uri = "https://example.com/resource", 31 | mime_type = "text/plain", 32 | handler = function(params) { 33 | # Process the resource request 34 | return(list(content = "Resource content")) 35 | } 36 | ) 37 | } 38 | -------------------------------------------------------------------------------- /man/new_server.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mcp.R 3 | \name{new_server} 4 | \alias{new_server} 5 | \alias{new_mcp} 6 | \title{Create a new MCP object} 7 | \usage{ 8 | new_server( 9 | name, 10 | description, 11 | version, 12 | tools = list(), 13 | resources = list(), 14 | prompts = list() 15 | ) 16 | 17 | new_mcp(...) 18 | } 19 | \arguments{ 20 | \item{name}{Name of the MCP server} 21 | 22 | \item{description}{Description of the MCP server} 23 | 24 | \item{version}{Version of the MCP server} 25 | 26 | \item{tools}{List of tools (optional)} 27 | 28 | \item{resources}{List of resources (optional)} 29 | 30 | \item{prompts}{List of prompts (optional)} 31 | 32 | \item{...}{Forwarded to \code{\link[=new_server]{new_server()}}} 33 | } 34 | \value{ 35 | A new MCP object 36 | } 37 | \description{ 38 | Create a new MCP object 39 | } 40 | \examples{ 41 | mcp <- new_server( 42 | name = "My MCP", 43 | description = "This is a description", 44 | version = "1.0.0" 45 | ) 46 | } 47 | -------------------------------------------------------------------------------- /man/new_tool.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mcp.R 3 | \name{new_tool} 4 | \alias{new_tool} 5 | \title{Create a new tool} 6 | \usage{ 7 | new_tool(name, description, input_schema, handler) 8 | } 9 | \arguments{ 10 | \item{name}{Name of the tool} 11 | 12 | \item{description}{Description of the tool} 13 | 14 | \item{input_schema}{Input schema for the tool (must be a schema object)} 15 | 16 | \item{handler}{Function to handle the tool execution} 17 | } 18 | \value{ 19 | A new tool capability 20 | } 21 | \description{ 22 | Create a new tool 23 | } 24 | \examples{ 25 | tool <- new_tool( 26 | name = "My Tool", 27 | description = "This is a description", 28 | input_schema = schema( 29 | properties = list( 30 | input1 = property_string("Input 1", "Description of input 1"), 31 | input2 = property_number("Input 2", "Description of input 2") 32 | ) 33 | ), 34 | handler = function(input) { 35 | # Process the input here 36 | return(input) 37 | } 38 | ) 39 | } 40 | -------------------------------------------------------------------------------- /R/io.R: -------------------------------------------------------------------------------- 1 | #' Serve an MCP server using stdin/stdout 2 | #' 3 | #' @param mcp An MCP server object created with new_server() 4 | #' @type mcp object 5 | #' 6 | #' @return Nothing, runs indefinitely in normal mode, or the response in test mode 7 | #' @mcp start_mcp_server_io Start an MCP server using stdin/stdout transport 8 | #' @export 9 | serve_io <- function( 10 | mcp 11 | ) { 12 | # Validate MCP object 13 | if (missing(mcp)) { 14 | stop("An MCP server object is required") 15 | } 16 | 17 | if (!inherits(mcp, "server")) { 18 | stop("mcp must be an MCP server object") 19 | } 20 | 21 | # Main request-response loop 22 | while (TRUE) { 23 | # Read a line from input connection 24 | line <- readLines("stdin", n = 1, warn = FALSE) 25 | 26 | # Exit on EOF (Ctrl+D or end of file) 27 | if (length(line) == 0) break 28 | 29 | # Process the request through JSON-RPC 30 | response <- parse_request(line, mcp) 31 | 32 | if (!length(response)) { 33 | next 34 | } 35 | 36 | send(response, stdout()) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /man/new_prompt.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mcp.R 3 | \name{new_prompt} 4 | \alias{new_prompt} 5 | \title{Create a new prompt} 6 | \usage{ 7 | new_prompt(name, description, arguments = list(), handler) 8 | } 9 | \arguments{ 10 | \item{name}{Name of the prompt} 11 | 12 | \item{description}{Description of the prompt} 13 | 14 | \item{arguments}{List of arguments for the prompt} 15 | 16 | \item{handler}{Function to handle the prompt execution} 17 | } 18 | \value{ 19 | A new prompt capability 20 | } 21 | \description{ 22 | Create a new prompt 23 | } 24 | \examples{ 25 | prompt <- new_prompt( 26 | name = "My Prompt", 27 | description = "This is a description", 28 | arguments = list( 29 | input1 = list( 30 | type = "string", 31 | description = "Input 1" 32 | ), 33 | input2 = list( 34 | type = "number", 35 | description = "Input 2" 36 | ) 37 | ), 38 | handler = function(params) { 39 | # Process the prompt request 40 | return(list(text = "Generated text from prompt")) 41 | } 42 | ) 43 | } 44 | -------------------------------------------------------------------------------- /man/mcpr_clients_to_ellmer_tools.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mcpr-to-ellmer.R 3 | \name{mcpr_clients_to_ellmer_tools} 4 | \alias{mcpr_clients_to_ellmer_tools} 5 | \title{Convert multiple MCPR clients to ellmer tools} 6 | \usage{ 7 | mcpr_clients_to_ellmer_tools(...) 8 | } 9 | \arguments{ 10 | \item{...}{One or more mcpr client objects} 11 | } 12 | \value{ 13 | A list of ellmer-compatible tool functions from all clients 14 | } 15 | \description{ 16 | This function converts tools from multiple MCPR clients to a format compatible 17 | with the ellmer package. It's useful when you want to combine tools from 18 | multiple MCP servers into a single ellmer session. 19 | } 20 | \examples{ 21 | \dontrun{ 22 | # Create multiple MCPR clients 23 | client1 <- new_client_io("path/to/server1") 24 | client2 <- new_client_io("path/to/server2") 25 | 26 | # Convert all tools 27 | ellmer_tools <- mcpr_clients_to_ellmer_tools(client1, client2) 28 | 29 | # Use with ellmer 30 | chat <- ellmer::chat_claude() 31 | chat$set_tools(ellmer_tools) 32 | } 33 | } 34 | \keyword{internal} 35 | -------------------------------------------------------------------------------- /man/property_array.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/input-schema.R 3 | \name{property_array} 4 | \alias{property_array} 5 | \title{Create an array property definition} 6 | \usage{ 7 | property_array( 8 | title, 9 | description, 10 | items, 11 | required = FALSE, 12 | min_items = NULL, 13 | max_items = NULL, 14 | unique_items = FALSE 15 | ) 16 | } 17 | \arguments{ 18 | \item{title}{Short title for the property} 19 | 20 | \item{description}{Longer description of the property} 21 | 22 | \item{items}{Schema for the items in the array} 23 | 24 | \item{required}{Whether the property is required} 25 | 26 | \item{min_items}{Optional minimum number of items} 27 | 28 | \item{max_items}{Optional maximum number of items} 29 | 30 | \item{unique_items}{Logical indicating if items must be unique} 31 | } 32 | \value{ 33 | An array property object 34 | } 35 | \description{ 36 | Create an array property definition 37 | } 38 | \examples{ 39 | tags_prop <- property_array( 40 | "Tags", 41 | "List of tags for the user", 42 | items = property_string("Tag", "A user tag"), 43 | unique_items = TRUE 44 | ) 45 | } 46 | -------------------------------------------------------------------------------- /man/property_object.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/input-schema.R 3 | \name{property_object} 4 | \alias{property_object} 5 | \title{Create an object property definition} 6 | \usage{ 7 | property_object( 8 | title, 9 | description, 10 | properties, 11 | required = FALSE, 12 | additional_properties = FALSE 13 | ) 14 | } 15 | \arguments{ 16 | \item{title}{Short title for the property} 17 | 18 | \item{description}{Longer description of the property} 19 | 20 | \item{properties}{List of property definitions for this object} 21 | 22 | \item{required}{Whether the property is required} 23 | 24 | \item{additional_properties}{Logical indicating if additional properties are allowed} 25 | } 26 | \value{ 27 | An object property object 28 | } 29 | \description{ 30 | Create an object property definition 31 | } 32 | \examples{ 33 | address_prop <- property_object( 34 | "Address", 35 | "User's address information", 36 | properties = list( 37 | street = property_string("Street", "Street address", required = TRUE), 38 | city = property_string("City", "City name", required = TRUE), 39 | country = property_string("Country", "Country name") 40 | ) 41 | ) 42 | } 43 | -------------------------------------------------------------------------------- /man/property_string.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/input-schema.R 3 | \name{property_string} 4 | \alias{property_string} 5 | \title{Create a string property definition} 6 | \usage{ 7 | property_string( 8 | title, 9 | description, 10 | required = FALSE, 11 | enum = NULL, 12 | pattern = NULL, 13 | min_length = NULL, 14 | max_length = NULL, 15 | format = NULL 16 | ) 17 | } 18 | \arguments{ 19 | \item{title}{Short title for the property} 20 | 21 | \item{description}{Longer description of the property} 22 | 23 | \item{required}{Whether the property is required} 24 | 25 | \item{enum}{Optional character vector of allowed values} 26 | 27 | \item{pattern}{Optional regex pattern the string must match} 28 | 29 | \item{min_length}{Optional minimum length} 30 | 31 | \item{max_length}{Optional maximum length} 32 | 33 | \item{format}{Optional format constraint} 34 | } 35 | \value{ 36 | A string property object 37 | } 38 | \description{ 39 | Create a string property definition 40 | } 41 | \examples{ 42 | name_prop <- property_string( 43 | "User name", 44 | "The name of the user", 45 | required = TRUE, 46 | min_length = 2, 47 | max_length = 50 48 | ) 49 | } 50 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: mcpr 2 | Title: Model Context Protocol for R 3 | Version: 0.0.2.9000 4 | Authors@R: 5 | c( 6 | person(given = "John", 7 | family = "Coene", 8 | role = c("aut", "cre"), 9 | email = "jcoenep@gmail.com"), 10 | person(family = "Opifex", 11 | role = c("cph", "fnd"), 12 | email = "john@opifex.org") 13 | ) 14 | Description: Create, run, and connect to Model Context Protocol (MCP) servers, and clients in R. The package 15 | provides a framework for implementing MCP-compatible servers with tools, 16 | resources, and prompts capabilities, as well as client functionality to interact with 17 | MCP servers. It includes a JSON-RPC 2.0 implementation for communication between 18 | clients and servers. 19 | License: GPL (>= 2) 20 | Depends: R (>= 4.1.0) 21 | Encoding: UTF-8 22 | Roxygen: list(markdown = TRUE, roclets = c("collate", "rd", "namespace", "mcpr::mcp_roclet")) 23 | RoxygenNote: 7.3.2 24 | Imports: 25 | yyjsonr 26 | Suggests: 27 | ambiorix, 28 | processx, 29 | knitr, 30 | rmarkdown, 31 | httr2, 32 | ellmer, 33 | roxygen2 34 | URL: https://mcpr.opifex.org/, https://github.com/devOpifex/mcpr 35 | VignetteBuilder: knitr 36 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # mcpr 0.0.2 2 | 3 | - Added support for `ellmer::tool` 4 | - Added MCP roclet for automatic server generation: 5 | - New `@mcp` tag for marking functions as MCP tools 6 | - New `@type` tag for specifying parameter types (string, number, boolean, array, object, enum) 7 | - `mcp_roclet()` function integrates with roxygen2 to generate complete MCP servers 8 | - Automatically creates `inst/mcp_server.R` with tool definitions and handlers 9 | - Supports all standard JSON Schema types and enum values 10 | 11 | # mcpr 0.0.1 12 | 13 | ## Major Changes 14 | 15 | - Added comprehensive client support for interacting with MCP servers: 16 | - `new_client()` for creating client connections to both local process and HTTP servers 17 | - `initialize()` for initializing client connections 18 | - `tools_list()` and `tools_call()` for discovering and using server tools 19 | - `prompts_list()` and `prompts_get()` for working with server prompts 20 | - `resources_list()` and `resources_read()` for accessing server resources 21 | - Renamed `new_mcp()` (deprecated) to `new_server()` for clarity 22 | - Added example implementations for both server and client 23 | - Added client usage vignette 24 | - Fix major issue with `serve_http()` 25 | 26 | # mcpr 0.0.0 27 | 28 | * Initial CRAN submission. 29 | -------------------------------------------------------------------------------- /man/property_number.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/input-schema.R 3 | \name{property_number} 4 | \alias{property_number} 5 | \title{Create a number property definition} 6 | \usage{ 7 | property_number( 8 | title, 9 | description, 10 | required = FALSE, 11 | minimum = NULL, 12 | maximum = NULL, 13 | exclusive_minimum = NULL, 14 | exclusive_maximum = NULL, 15 | multiple_of = NULL, 16 | integer = FALSE 17 | ) 18 | } 19 | \arguments{ 20 | \item{title}{Short title for the property} 21 | 22 | \item{description}{Longer description of the property} 23 | 24 | \item{required}{Whether the property is required} 25 | 26 | \item{minimum}{Optional minimum value} 27 | 28 | \item{maximum}{Optional maximum value} 29 | 30 | \item{exclusive_minimum}{Whether minimum is exclusive} 31 | 32 | \item{exclusive_maximum}{Whether maximum is exclusive} 33 | 34 | \item{multiple_of}{Optional value the number must be a multiple of} 35 | 36 | \item{integer}{Whether the number should be an integer} 37 | } 38 | \value{ 39 | A number property object 40 | } 41 | \description{ 42 | Create a number property definition 43 | } 44 | \examples{ 45 | age_prop <- property_number( 46 | "User age", 47 | "The age of the user in years", 48 | required = TRUE, 49 | minimum = 0, 50 | integer = TRUE 51 | ) 52 | } 53 | -------------------------------------------------------------------------------- /examples/calculator/server.R: -------------------------------------------------------------------------------- 1 | devtools::load_all() 2 | 3 | # Create a calculator tool 4 | calculator <- new_tool( 5 | name = "math_calculator", 6 | description = "Performs basic arithmetic operations", 7 | input_schema = schema( 8 | properties = properties( 9 | operation = property_enum( 10 | "Operation", 11 | "Math operation to perform", 12 | values = c("add", "subtract", "multiply", "divide"), 13 | required = TRUE 14 | ), 15 | a = property_number("First number", "First operand", required = TRUE), 16 | b = property_number("Second number", "Second operand", required = TRUE) 17 | ) 18 | ), 19 | handler = function(params) { 20 | result <- switch( 21 | params$operation, 22 | "add" = params$a + params$b, 23 | "subtract" = params$a - params$b, 24 | "multiply" = params$a * params$b, 25 | "divide" = params$a / params$b 26 | ) 27 | response_text(result) 28 | } 29 | ) 30 | 31 | # Create an MCP server and add the calculator tool 32 | mcp <- new_server( 33 | name = "R Calculator Server", 34 | description = "A simple calculator server implemented in R", 35 | version = "1.0.0" 36 | ) 37 | 38 | mcp <- add_capability(mcp, calculator) 39 | 40 | # Start the server (listening on stdin/stdout) 41 | serve_io(mcp) 42 | #serve_http(mcp, path = "/mcp") 43 | -------------------------------------------------------------------------------- /man/ellmer_to_mcpr_tool.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ellmer-to-mcpr.R 3 | \name{ellmer_to_mcpr_tool} 4 | \alias{ellmer_to_mcpr_tool} 5 | \title{Convert ellmer tools to mcpr tools} 6 | \usage{ 7 | ellmer_to_mcpr_tool(ellmer_tool) 8 | } 9 | \arguments{ 10 | \item{ellmer_tool}{An ellmer ToolDef object created with \code{ellmer::tool()}} 11 | } 12 | \value{ 13 | An mcpr tool object compatible with \code{new_tool()} 14 | } 15 | \description{ 16 | This function converts tools from the ellmer package to a format compatible 17 | with the mcpr package. It takes an ellmer ToolDef object and creates an 18 | mcpr tool object with the appropriate input schema and handler function. 19 | } 20 | \examples{ 21 | \dontrun{ 22 | # Create an ellmer tool 23 | ellmer_rnorm <- ellmer::tool( 24 | rnorm, 25 | "Generate random normal numbers", 26 | n = ellmer::type_integer("Number of observations"), 27 | mean = ellmer::type_number("Mean value", required = FALSE), 28 | sd = ellmer::type_number("Standard deviation", required = FALSE) 29 | ) 30 | 31 | # Convert to mcpr format 32 | mcpr_tool <- ellmer_to_mcpr_tool(ellmer_rnorm) 33 | 34 | # Add to an mcpr server 35 | server <- new_server("MyServer", "Test server", "1.0.0") 36 | add_capability(server, mcpr_tool) 37 | } 38 | 39 | } 40 | \seealso{ 41 | \code{\link[=new_tool]{new_tool()}}, \code{\link[ellmer:tool]{ellmer::tool()}}, \code{\link[=add_capability]{add_capability()}} 42 | } 43 | -------------------------------------------------------------------------------- /examples/ellmer/server.R: -------------------------------------------------------------------------------- 1 | devtools::load_all() 2 | 3 | # Create a calculator tool 4 | calculator <- new_tool( 5 | name = "math_calculator", 6 | description = "Performs basic arithmetic operations", 7 | input_schema = schema( 8 | properties = properties( 9 | operation = property_enum( 10 | "Operation", 11 | "Math operation to perform", 12 | values = c("add", "subtract", "multiply", "divide"), 13 | required = TRUE 14 | ), 15 | a = property_number("First number", "First operand", required = TRUE), 16 | b = property_number("Second number", "Second operand", required = TRUE) 17 | ) 18 | ), 19 | handler = function(params) { 20 | result <- switch( 21 | params$operation, 22 | "add" = params$a + params$b, 23 | "subtract" = params$a - params$b, 24 | "multiply" = params$a * params$b, 25 | "divide" = params$a / params$b 26 | ) 27 | response_text( 28 | sprintf("The result from the R calculator is %s", result) 29 | ) 30 | } 31 | ) 32 | 33 | current_time <- ellmer::tool( 34 | \(tz = "UTC") { 35 | format(Sys.time(), tz = tz, usetz = TRUE) 36 | }, 37 | "Gets the current time in the given time zone.", 38 | tz = ellmer::type_string( 39 | "The time zone to get the current time in. Defaults to `\"UTC\"`.", 40 | required = FALSE 41 | ) 42 | ) 43 | 44 | # Create an MCP server and add the calculator tool 45 | mcp <- new_server( 46 | name = "R Calculator Server", 47 | description = "A simple calculator server implemented in R", 48 | version = "1.0.0" 49 | ) 50 | 51 | mcp <- add_capability(mcp, calculator) 52 | mcp <- add_capability(mcp, current_time) 53 | 54 | # Start the server (listening on stdin/stdout) 55 | serve_io(mcp) 56 | #serve_http(mcp, path = "/mcp") 57 | -------------------------------------------------------------------------------- /man/response.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/response.R 3 | \name{response} 4 | \alias{response} 5 | \alias{response_text} 6 | \alias{response_image} 7 | \alias{response_audio} 8 | \alias{response_video} 9 | \alias{response_file} 10 | \alias{response_resource} 11 | \alias{response_error} 12 | \alias{response_item} 13 | \title{Create a response object} 14 | \usage{ 15 | response_text(text) 16 | 17 | response_image(image, mime_type = "image/png") 18 | 19 | response_audio(audio, mime_type = "audio/mpeg") 20 | 21 | response_video(video, mime_type = "video/mp4") 22 | 23 | response_file(file, mime_type = "application/octet-stream") 24 | 25 | response_resource(resource) 26 | 27 | response_error(text) 28 | 29 | response_item( 30 | ..., 31 | type = c("text", "image", "audio", "video", "file", "resource") 32 | ) 33 | 34 | response(..., is_error = FALSE) 35 | } 36 | \arguments{ 37 | \item{text}{Text content for the response} 38 | 39 | \item{image}{Image content} 40 | 41 | \item{mime_type}{Mime type of the content} 42 | 43 | \item{audio}{Audio content} 44 | 45 | \item{video}{Video content} 46 | 47 | \item{file}{File content} 48 | 49 | \item{resource}{Resource content} 50 | 51 | \item{...}{Mutliple \code{response} objects or passed to \code{ggplot2::ggsave}} 52 | 53 | \item{type}{Type of the content} 54 | 55 | \item{is_error}{Whether the response is an error} 56 | } 57 | \value{ 58 | A response object 59 | } 60 | \description{ 61 | Create a response object 62 | } 63 | \details{ 64 | Use \code{response_item} to create a custom response item. 65 | } 66 | \examples{ 67 | response( 68 | response_text("Hello, world!"), 69 | response_image(system.file("extdata/logo.png", package = "mcpr")), 70 | response_audio(system.file("extdata/sound.mp3", package = "mcpr")), 71 | response_video(system.file("extdata/video.mp4", package = "mcpr")), 72 | response_file(system.file("extdata/file.txt", package = "mcpr")), 73 | response_resource(system.file("extdata/resource.json", package = "mcpr")) 74 | ) 75 | 76 | } 77 | -------------------------------------------------------------------------------- /docs/deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v1.0.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | !function(a){"use strict";window.Toc={helpers:{findOrFilter:function(e,t){var n=e.find(t);return e.filter(t).add(n).filter(":not([data-toc-skip])")},generateUniqueIdBase:function(e){return a(e).text().trim().replace(/\'/gi,"").replace(/[& +$,:;=?@"#{}|^~[`%!'<>\]\.\/\(\)\*\\\n\t\b\v]/g,"-").replace(/-{2,}/g,"-").substring(0,64).replace(/^-+|-+$/gm,"").toLowerCase()||e.tagName.toLowerCase()},generateUniqueId:function(e){for(var t=this.generateUniqueIdBase(e),n=0;;n++){var r=t;if(0

JSON-RPC 2.0 Standard Error Codes
44 |Get the name of a client
44 |List all available tools
44 |Parses @mcp tags to extract tool name and description.
44 |List all available prompts
44 |List all available resources
44 |Validate a JSON-RPC 2.0 request
44 |Process a single block with @mcp tag
44 |Serve an MCP server using stdin/stdout
44 |
R/roclet.R
39 | generate_property_code.RdGenerate property code for a parameter
44 |Parses @type tags to extract parameter type information. 46 | Format: @type param_name type enum_values
47 |
R/methods.R
39 | initialize.RdInitialize the server with protocol information
44 |