R implementation of the Model Context Protocol (MCP) for defining and managing MCP tools in R
MCPR exposes a single tool 'execute_r_code' with a well-structured input schema and detailed description. The schema includes proper types (string for code, integer for timeout) and clear parameter descriptions. However, the tool exhibits concerning design patterns: it is a generic code execution gateway rather than domain-specific functionality, which violates the single-responsibility principle (pattern:tool). The description is detailed (260+ chars) but lacks guidance on error recovery, categorization of retryable vs fatal errors, and does not state that this is an irreversible operation with potential side effects. The 'timeout' parameter has a reasonable default (300s) but lacks minimum/maximum constraints. Output schema is not formally documented, the description mentions 'results, output, warnings, errors' but no structured schema is provided for LLM consumption. The tool is correctly registered with a name that reflects its action (execute), but the name is overly generic and does not convey domain intent. Error handling appears present in the code (via try/catch patterns visible in mcpr-client-tools.R) but guidance on recovery is absent from the tool definition.
Execute R code in the current R session. Variables persist in the global environment across calls. Returns results, output, warnings, and errors. IMPORTANT: Output goes to the agent context only - invisible to the user. Note that cat() and message() calls also have no visible side-effect to the user; their output is captured and returned to the agent only. Avoid comments, headers, and decorative print statements in code. Communicate findings to the user via chat.
Generic code execution tool violates single-responsibility principle. 'execute_r_code' is a raw gateway, not a domain-specific operation. LLMs cannot infer intent from name alone; proper design splits this into specific analytical tasks (e.g., 'analyze_data', 'fit_model', 'generate_plot'). See pattern:tool for composition guidance.
Output schema not formally documented. Tool description states 'Returns results, output, warnings, and errors' but no structured schema (field types, presence guarantees) is provided. LLMs cannot plan downstream operations or extract specific fields without schema. See pattern:response-shaper.
No error recovery guidance. Tool description does not categorize errors as retryable vs fatal, does not explain when to retry vs escalate, and does not provide actionable next steps (e.g., 'If timeout occurs, increase timeout parameter or split computation'). See pattern:recovery-guide.
Inferred effective spec: <=2025-11-25.
| Scored | Grade | Overall | Spec posture | Rubric |
|---|---|---|---|---|
| 2026-09-22 | D | 53 | <=2025-11-25 | v2 |
Timeout parameter lacks bounds. Description states 'default: 300' and suggests increasing for long-running tasks but does not specify minimum (e.g., 1s) or maximum (e.g., 3600s). Unbounded integer lets LLM pass absurd values (e.g., timeout=999999999). See pattern:constrained-input.
Irreversible operation not flagged. Tool executes arbitrary code with side effects (file I/O, package installation, environment modification) but description does not warn of irreversibility or destructive capability. LLMs may retry without understanding consequences. Risk: IRREVERSIBLE is noted in source but not conveyed to LLM via description.
No tool annotations. Tool lacks readOnlyHint, destructiveHint, or idempotentHint fields to signal to modern MCP clients that this tool is destructive and non-idempotent. Current spec (2026-07-28) supports tool annotations; absence is a spec alignment gap.