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:
- MCP server is configured and connected
- Logged in to Lovrabet platform
- Understand basic development terms (datasets, fields, APIs, etc.)
Scenario 1: Data Exploration & Understanding
When to Use
- Taking over a new project and need to understand data structure
- Confirming field types and constraints
- Finding related datasets
Prompt Examples
List all datasets containing "customer"
View the detailed information of the customer dataset, including all fields
What are the primary key fields and required fields in the customer table?
What is the relationship between the customer and order tables?
What AI Will Do
- Call
search_datasetsorlist_datasetstools - Call
get_dataset_detailto get complete field information - Analyze relationships between fields
- Return structured data structure description
Scenario 2: List Page Development
When to Use
- Developing data management pages (table display)
- Need pagination, search, and sorting functionality
- 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: display name, phone, status, creation time
Generate code for an order list page:
- Support filtering by status
- Support querying by date range
- 20 items per page, sorted by creation time in descending order
What AI Will Do
- Get dataset details to confirm field names and types
- Generate SDK code following Filter query specifications
- Generate Ant Design Table component code
- Include complete type definitions and error handling
Filter Query Key Specifications
// 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'
Scenario 3: Form Page Development
When to Use
- Form pages for creating/editing data
- 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
- Prompt and refresh list after successful submission
What AI Will Do
- Analyze field metadata (required, enum values, etc.)
- Generate form components matching field types
- Add form validation rules
- Generate submit SDK code
Scenario 4: Custom SQL Report Development
When to Use
- Complex data statistics queries
- Cross-table join queries
- Monthly/annual 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, please strictly follow these steps:
1. Use list_sql_queries to query existing SQL, confirm if it already exists
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"
- Display customer name, order count, total amount
What AI Will Do
- Check if SQL already exists
- Get table structure to confirm field names
- Generate SQL with correct syntax
- Validate SQL correctness
- Save and test execution
- Generate SDK code
Common SQL Errors
-- Wrong: Field name may be inaccurate
SELECT customerName FROM customer
-- Correct: First get table structure to confirm field names
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
Scenario 5: Backend Function Script Development
When to Use
- Data permission filtering (non-admins can only see their own data)
- Data masking (phone numbers, ID numbers)
- Auto-fill fields (creator, creation time)
- Related query enhancement (order list displays user name)
Script Type Descriptions
| Type | Trigger Timing | Typical Use Cases |
|---|---|---|
| Before | Before API execution | Permission filtering, parameter validation, auto-fill |
| After | After API execution | Data masking, field calculation, column hiding |
| ENDPOINT | Independent endpoint | Complex business logic, transaction processing |
Prompt Examples
Help me write a Before script for data permission filtering:
Requirement: When non-admin users query orders, they can only see orders they created
Please 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 using $and to combine original query conditions
5. Add complete top-level comment documentation
Write an After script for phone number masking:
Requirement: When non-admin users view customer list, display middle four 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 related query enhancement:
Requirement: Order list displays customer name and level
- Use filter to query user table
- Append user info to order data
- Add new column definitions
Key Specifications
// Filter interface 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 interface 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;
}
Field Analysis Requirements
Before writing scripts, you must analyze dataset fields:
Please analyze the fields of the order dataset:
1. Which fields are used for permission filtering?
2. Which fields are used for related queries?
3. Which fields need masking?
4. What is the type of each field?
Scenario 6: API Integration & Type Generation
When to Use
- Need to auto-generate TypeScript types
- Keep code synchronized 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 in descending order
- 20 items per page
- Return only specified fields
SDK Return Value Handling
// Success: Returns data directly
const result = await client.models.customer.create({ name: "Zhang San" });
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);
}
}
Scenario 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
| Error Symptom | Cause | Solution |
|---|---|---|
| No query results | Forgot to use operators | Use { field: { $eq: value } } |
| Parameter format error | Wrong parameter name | Use select instead of fields |
| Sorting not working | Wrong sort format | Use orderBy: [{ field: 'desc' }] |
| Pagination not working | Wrong parameter name | Use currentPage/pageSize |
SQL Related Errors
| Error Symptom | Cause | Solution |
|---|---|---|
| Field doesn't exist | Didn't confirm table structure | First use get_dataset_detail to confirm fields |
| SQL save failed | Syntax error | Use validate_sql_content to validate first |
| No results | SQL code incorrect | Use execute_custom_sql to test |
Backend Function Errors
| Error Symptom | Cause | Solution |
|---|---|---|
| Condition not working | Wrong operator for regular interface | Filter interface uses ytWhere, regular interface direct assignment |
| Query error | Forgot to use await | All database operations must be awaited |
| Infinite loop | Recursive call to itself | Prohibit scripts from calling current dataset interface |
Effective Conversation Techniques
1. Explicitly Specify Using MCP Tools
Use get_dataset_detail to get customer details
Use list_sql_queries to find all SQLs
Use generate_sdk_code to generate code for order filter
2. Describe Complex Requirements Step by Step
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 Information
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: enabled/disabled)
4. Request Following Specifications
When generating code, please follow these specifications:
- Use Filter query operators ($eq, $gte, etc.)
- Add dataset and table comments
- Include complete error handling
- Do not use getList, use filter instead
Complete Example: Developing a 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 searching by name and phone
- Pagination: 20 items per page
- Sorting: default by creation time descending
- Columns: name, phone, status, creation time, actions
- Actions: edit and delete buttons
- Follow Filter query specifications
- Add complete comments
AI will automatically:
- Call MCP tools to get dataset information
- Generate SDK code following specifications
- Generate complete React component
- Include error handling and loading states
Get Help
- Tool Reference - Complete MCP tool documentation
- SDK Return Value Guide - SDK call considerations
- GitHub Issues