Skip to contents

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

Usage

get_prompt(
  prompt,
  args = list(),
  package = testthat::testing_package(),
  timeout = 90,
  answer = NULL,
  sample = NULL,
  roots = NULL
)

Arguments

prompt

Name of the prompt.

args

Named list of arguments, each a string.

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 prompts/get: a list with messages.

Examples

if (FALSE) { # \dontrun{
# In the tests of a package made by create_mordew():
get_prompt(
  "review_run",
  list(
    run_id = "2025-03-01"
  )
)
} # }