Skip to main content

Use Cases & Prompt Examples

This document provides AI conversation examples for common business scenarios to help you use Lovrabet MCP more efficiently.


Quick Start

Before using, ensure:

  1. MCP server is configured and connected
  2. Logged in to Lovrabet platform
  3. Understand basic development terms (datasets, fields, APIs, etc.)

Use Case 1: Data Exploration

When to Use

  • Onboarding a new project and need to understand data structure
  • Confirm field types and constraints
  • Find related datasets

Prompt Examples

List all datasets containing "customer"
Get detailed information about the customer dataset, including all fields
What are the primary key and required fields in the customer table?
What is the relationship between customer and order tables?

What AI Will Do

  1. Call search_datasets or list_datasets tools
  2. Call get_dataset_detail to get complete field information
  3. Analyze relationships between fields
  4. Return structured data structure description

Use Case 2: List Page Development

When to Use

  • Developing data management pages (table display)
  • Need pagination, search, and sorting
  • Using Ant Design Pro components

Prompt Examples

Help me develop a customer list page:
1. Use get_dataset_detail to get customer dataset details
2. Use generate_sdk_code to generate filter query code
3. Generate Ant Design Table component with search, pagination, and sorting

Field requirements: show name, phone, status, creation time
Generate code for an order list page:
- Filter by status
- Filter by date range
- 20 items per page, sorted by creation time descending

What AI Will Do

  1. Get dataset details to confirm field names and types
  2. Generate SDK code following Filter query conventions
  3. Generate Ant Design Table component code
  4. Include complete type definitions and error handling

Key Filter Query Conventions

// ✅ Correct: Use operators
where: { status: { $eq: 'active' } }

// ❌ Wrong: Direct value
where: { status: 'active' }

// ✅ Correct: Array format
select: ['id', 'name', 'email']
orderBy: [{ createTime: 'desc' }]

// ❌ Wrong: String format
select: 'id,name,email'
orderBy: 'createTime desc'

Use Case 3: Form Page Development

When to Use

  • Create/edit data form pages
  • Need form validation
  • Enum field dropdown selection

Prompt Examples

Help me develop a new customer form page:
1. Get required fields from customer dataset
2. Generate Ant Design Form component
3. Include form validation rules
4. Generate SDK code for create operation
Generate code for an order edit page:
- Only allow editing specific fields (status, remarks)
- Required field validation
- Show success message and refresh list after submission

What AI Will Do

  1. Analyze field metadata (required, enum values, etc.)
  2. Generate form components matching field types
  3. Add form validation rules
  4. Generate submit SDK code

Use Case 4: Custom SQL Report Development

When to Use

  • Complex data statistics queries
  • Cross-table relationship queries
  • Monthly/yearly reports

5-Step Mandatory Workflow

Important: Creating custom SQL must follow these steps in order. Do not skip any step.

Step 1 → Step 2 → Step 3 → Step 4 → Step 5
↓ ↓ ↓ ↓ ↓
Query Generate Validate Save Test

Prompt Examples

Help me create a customer monthly statistics SQL, follow these steps strictly:

1. Use list_sql_queries to check existing SQL
2. Use get_dataset_detail to get customer table structure
3. Write SQL: count new customers by month
4. Use validate_sql_content to validate SQL syntax
5. Use save_or_update_custom_sql to save SQL
6. Use execute_custom_sql to test execution

SQL name: Customer Monthly Stats
SQL code: customer_monthly_stats
Create an order amount statistics SQL:
- Group by customer to calculate total order amount
- Only include orders with status "Completed"
- Show customer name, order count, total amount

What AI Will Do

  1. Check if SQL already exists
  2. Get table structure to confirm field names
  3. Generate SQL with correct syntax
  4. Validate SQL correctness
  5. Save and test execution
  6. Generate SDK code

Common SQL Errors

-- ❌ Wrong: Field name may be inaccurate
SELECT customerName FROM customer

-- ✅ Correct: Confirm field names from table structure first
SELECT customer_name FROM customer

-- ❌ Wrong: Using DELETE (not allowed)
DELETE FROM customer WHERE status = 0

-- ✅ Correct: Only SELECT queries allowed
SELECT * FROM customer WHERE status = 1

Use Case 5: Backend Function Script Development

When to Use

  • Data permission filtering (non-admins see only their own data)
  • Data masking (phone numbers, ID cards)
  • Auto-fill fields (creator, creation time)
  • Relationship query enhancement (order list shows user names)

Script Types

TypeTriggerTypical Use
BeforeBefore API executionPermission filtering, validation, auto-fill
AfterAfter API executionData masking, field calculation, column hiding
ENDPOINTIndependent endpointComplex business logic, transactions

Prompt Examples

Help me write a Before script for data permission filtering:
Requirement: Non-admin users can only see orders they created

Follow these steps:
1. Use get_dataset_detail to get order dataset details
2. Analyze which fields to use (created_by, user_id, etc.)
3. Write beforeFilter function
4. Ensure to use $and to combine original query conditions
5. Add complete top-level comment documentation
Write an After script for phone number masking:
Requirement: Non-admin users see phone numbers with middle 4 digits as ****

Dataset: customer
Field: phone
Write a Before script to auto-fill when creating orders:
- user_id: current user ID
- tenant_code: current tenant code
- create_time: current time
Write an After script for relationship query enhancement:
Requirement: Order list shows customer names and levels
- Use filter to query user table
- Append user info to order data
- Add new column definitions

Key Conventions

// ✅ Filter Before: Must operate on ytWhere
export default async function beforeFilter(params, context) {
if (context.userInfo.role !== "admin") {
params.ytWhere = params.ytWhere || {};
const originalWhere = { ...params.ytWhere };
params.ytWhere = {
$and: [
originalWhere,
{ created_by: { $eq: context.userInfo.id } }
]
};
}
return params;
}

// ✅ Regular Before: Direct field assignment
export default async function beforeCreate(params, context) {
params.created_by = context.userInfo.id;
params.create_time = new Date();
return params;
}

// ✅ After: Operate on tableData
export default async function afterFilter(params, context) {
params.tableData?.forEach((record) => {
if (record.phone) {
record.phone = record.phone.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
}
});
return params;
}

Use Case 6: API Integration & Type Generation

When to Use

  • Need to auto-generate TypeScript types
  • Keep code in sync with dataset definitions
  • Unified API call management

Prompt Examples

Help me generate API call code for customer and order datasets:
1. Use get_dataset_detail to get details for both datasets
2. Use generate_sdk_code to generate filter and create operation code
3. Include complete error handling
4. Add dataset and table comments
Generate code to query orders with status "In Progress":
- Use filter operation
- Sort by creation time descending
- 20 items per page
- Return only specified fields

SDK Return Value Handling

// ✅ Success: Returns data directly
const result = await client.models.customer.create({ name: "John" });
console.log(result.id); // Direct access

// ✅ Failure: Throws exception
try {
const result = await client.models.customer.create({ name: "" });
} catch (error) {
if (error instanceof LovrabetError) {
console.error("Business error:", error.message);
}
}

Use Case 7: Debugging & Troubleshooting

When to Use

  • SQL execution failed
  • Query returns empty results
  • Permission errors

Prompt Examples

Help me debug why this SQL query returns no results:
SQL code: order_stats
Use execute_custom_sql to execute and analyze errors
Check which fields are available for the filter operation on customer dataset:
1. Use get_operation_detail to get filter operation details
2. Analyze request fields and return values
Validate if this SQL content has syntax errors:
SELECT id, customer_name, create_time FROM customer WHERE status = 1

Use validate_sql_content to validate

Common Errors & Solutions

Filter Query Errors

ErrorCauseSolution
No resultsForgot to use operatorsUse { field: { $eq: value } }
Parameter format errorWrong parameter nameUse select not fields
Sorting doesn't workSort format errorUse orderBy: [{ field: 'desc' }]
Pagination doesn't workParameter name errorUse currentPage/pageSize
ErrorCauseSolution
Field doesn't existDidn't confirm table structureUse get_dataset_detail first
SQL save failedSyntax errorUse validate_sql_content first
No resultsSQL code incorrectUse execute_custom_sql to test

Backend Function Errors

ErrorCauseSolution
Condition not workingRegular interface operator errorFilter uses ytWhere, regular uses direct assignment
Query errorForgot awaitAll database operations must use await
Infinite loopRecursive call to itselfDon't call current dataset interface in script

Effective Conversation Tips

1. Specify MCP Tools Explicitly

Use get_dataset_detail to get customer details
Use list_sql_queries to find all SQL
Use generate_sdk_code to generate code for order filter operation

2. Describe Complex Requirements in Steps

Help me complete this task:
Step 1: Query existing customer statistics SQL
Step 2: If not exists, create new SQL
Step 3: Generate call code
Step 4: Test execution

3. Provide Context

Based on customer dataset (primary key id, required fields name, phone),
create a new customer form with:
- Name (text input)
- Phone (text input, validate format)
- Status (dropdown: Active/Inactive)

4. Request Following Conventions

When generating code, follow these conventions:
- Use Filter query operators ($eq, $gte, etc.)
- Add dataset and table comments
- Include complete error handling
- Don't use getList, use filter instead

Complete Example: List Page from Scratch

Help me develop a complete customer list management page:

Step 1: Use get_dataset_detail to get customer dataset details
Step 2: Use get_operation_detail to get filter operation details
Step 3: Use generate_sdk_code to generate filter and delete operation code
Step 4: Generate React + Ant Design component code

Page requirements:
- Search: support by name and phone number
- Pagination: 20 items per page
- Sorting: by creation time descending by default
- Columns: name, phone, status, creation time, actions
- Actions: edit and delete buttons
- Follow Filter query conventions
- Add complete comments

AI will automatically:

  1. Call MCP tools to get dataset information
  2. Generate SDK code following conventions
  3. Generate complete React components
  4. Include error handling and loading states

Get Help