Skip to main content
Glama

tealflow_generate_module_code

Read-onlyIdempotent

Generate ready-to-use R code for adding Teal modules to a clinical trial app, with parameters pre-filled based on module specs and Flow datasets.

Instructions

Generate R code for adding a module to a Teal application.

This tool generates ready-to-use R code for adding a Teal module to your app. It includes all required parameters with sensible defaults based on the module's specifications and Flow's available datasets.

IMPORTANT - Check data compatibility first: Before generating code, use tealflow_get_dataset_info to verify: - Required variables exist in datasets (ARM, PARAMCD, AVAL, etc.) - Data types match module requirements (binary vs continuous, numeric vs categorical) - Variable names match expected configuration (ACTARM vs ARM, AVISITN vs AVISIT) - Value ranges are appropriate for the module (0/1 binary vs continuous scale)

This prevents runtime errors and enables suggesting appropriate alternatives
when standard variables are missing or incompatible.

Args: module_name (str, required): Name of the module to generate code for (e.g., 'tm_g_km', 'tm_t_coxreg', 'tm_g_scatterplot'). parameters (dict[str, Any], optional): Optional parameter overrides as JSON object. Defaults to None. (Not yet implemented) include_comments (bool, optional): Whether to include explanatory comments in the generated code. Defaults to True.

Returns: str: Complete R code snippet ready to paste into a Teal app

Includes:
- Module function call with proper syntax
- All required parameters
- Common optional parameters with defaults
- Explanatory comments (if requested)
- Usage instructions

Examples: - Generate KM plot code: module_name="tm_g_km" - Generate Cox regression code: module_name="tm_t_coxreg" - Generate without comments: module_name="tm_g_km", include_comments=False

Recommended workflow: 1. Use tealflow_get_dataset_info on relevant datasets 2. Verify variable availability and data types 3. Generate module code with this tool 4. Adjust configuration variables based on dataset inspection results 5. Validate with tealflow_check_shiny_startup

Note: Generated code uses Flow's standard dataset configuration. You may need to adjust parameters for your specific use case based on actual dataset structure discovered through tealflow_get_dataset_info.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
parametersNo
module_nameYes
include_commentsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already indicate read-only and idempotent behavior, but the description adds context: it returns a string snippet, includes comments conditionally, and discloses that the 'parameters' argument is 'Not yet implemented'. It also warns that generated code uses standard dataset configuration and may need adjustment, which is valuable behavioral info beyond the annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (IMPORTANT, Args, Returns, Examples, Recommended workflow, Note), but it has some redundancy. The first two sentences both state that it generates R code, and the 'Includes' list partly repeats the return details. It is longer than necessary but mostly earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description is extremely complete for a code generation tool: it covers prerequisites, examples, input details, return value, workflow, and potential caveats. The presence of an output schema reduces the need to explain return values, but the description still provides sufficient context. No significant gaps remain.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Despite the schema having 0% description coverage, the description fully compensates by explaining each parameter: module_name with examples, parameters as optional overrides with default None and note that it's not implemented, and include_comments with default True. It also describes the return value and includes, giving complete parameter semantics.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with 'Generate R code for adding a module to a Teal application,' which is a specific verb+resource statement. It further clarifies by listing module examples (tm_g_km, tm_t_coxreg) and explaining it produces ready-to-use R code, clearly distinguishing it from sibling tools like data loading or app template generation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides an explicit 'Recommended workflow' with 5 steps, instructing to use tealflow_get_dataset_info before generating code and tealflow_check_shiny_startup after. It also states to verify variable availability and data types, and notes when adjustments are needed. This gives clear when-to-use guidance and prerequisites, though it does not explicitly name alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Appsilon/TealFlowMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server