Skip to main content
Practical recipes showing how to use CodeCall’s meta-tools for common real-world scenarios. Each example includes the full AgentScript code and expected output.
These examples assume tools are registered and available via CodeCall. See the Quick Start for setup instructions.

CRM: Multi-Tool CRUD

Combine user and activity tools to build a complete CRM workflow. Based on the CRM Demo.

App Wiring

src/app.ts

Tool Catalog

Script: Active Admin Dashboard

This script fetches all active administrators, pulls their recent activity in parallel, and returns a summary object suitable for rendering in a dashboard UI.

Script: Create User and Log Activity

A common pattern is to create a record and immediately log a related activity. This script chains two sequential tool calls.

Data Pipeline: ETL with Filtering

Fetch data from multiple sources, join, filter, and return a clean result. This pattern is especially powerful because the join and filtering logic runs inside the MCP server, keeping token usage low.
The join and filter happen inside the MCP server, not in the LLM context. This saves thousands of tokens compared to returning raw data to the model.

Batch Processing with Parallel Execution

Process a list of items in parallel with controlled concurrency. The maxConcurrency option prevents overwhelming downstream services with too many simultaneous requests.
__safe_parallel has a maximum of 100 operations. For larger batches, paginate and process in chunks.

Chunked Batch Processing

When your batch exceeds the 100-operation limit, split the work into pages and process each page sequentially while running items within each page in parallel.

Aggregation Dashboard

Pull data from multiple services and combine into a single dashboard object. This pattern reduces multiple LLM round-trips into a single codecall:execute call.

Error-Resilient Workflow

Combine retry, fallback, and partial success patterns for a robust workflow. This recipe demonstrates three resilience techniques:
  1. Retry with backoff — automatically retry transient failures while skipping validation errors.
  2. Cache-then-database fallback — try a fast cache first, fall back to a slower source on miss.
  3. Partial success collection — gather results from multiple channels, continuing even if some fail.

Conditional Tool Selection

Branching logic based on tool results, running entirely server-side. The LLM calls codecall:search separately to discover tools, then writes a script that handles different cases.

Data Validation and Cleanup

Use AgentScript to validate records in bulk and flag or fix inconsistencies before they reach downstream consumers.
Validation scripts make excellent scheduled workflows. Pair them with a cron-triggered prompt to run nightly data quality checks.

Common Patterns Reference

These short snippets illustrate patterns you can reuse across any recipe.

Sequential Chain

When one call depends on the output of a previous call, use plain await:

Fan-Out / Fan-In

Dispatch multiple independent calls, then combine the results:

Guard Clause

Exit early when preconditions are not met:

Accumulator Loop

Build up a result across multiple pages of data:

Next Steps

AgentScript Guide

Master the scripting language: APIs, patterns, and best practices

Configuration

Tool visibility modes, VM presets, and embedding strategies

Security Model

How scripts are validated and sandboxed

CRM Demo Guide

Run the full CRM reference app locally