Skip to contents

Starts the package's MCP server in a separate R process and reads the resource over stdio, as an MCP client does: call_tool() for a resource.

Usage

read_resource(
  uri,
  package = testthat::testing_package(),
  timeout = 90,
  answer = NULL,
  sample = NULL,
  roots = NULL
)

Arguments

uri

URI of the resource.

package

Package that serves the tool, by default the one being tested.

timeout

Seconds to wait for each answer of the server, with the "mordew" client: longer by default than the 60 seconds a server lets a call run, so that a call too long gets the error of the server.

answer

What the user answers when the tool asks before it runs (@mcpConfirm, @mcpElicit), with the "mordew" client: a named list of the fields of the form, accepted, list() to accept a confirmation, or "decline" or "cancel", also the answer to every form of ask(). NULL calls as a client that cannot ask the user.

sample

The text the model of the client writes when the tool asks for one (@mcpSample, input_sample()), with the "mordew" client. NULL calls as a client that cannot sample.

roots

The URIs of the roots of the client, a character vector, when the tool asks for them (input_roots()), with the "mordew" client. NULL calls as a client without roots.

Value

The result of resources/read: a list with contents.

Examples

if (FALSE) { # \dontrun{
# In the tests of a package made by create_mordew():
read_resource(
  "runlog://surfaces"
)
} # }