Skip to main content

SDK Return Value Description

SDK code generated by MCP follows these return value conventions. Understanding these conventions helps with proper data handling.

On Success

SDK methods directly return the content of the data field:

// API full response: { success: true, data: { id: 123, name: "..." }, msg: "" }
// SDK returns: { id: 123, name: "..." }
const result = await client.models.customer.create({ name: "Zhang San" });
console.log(result.id); // Direct data access

On Failure

SDK throws LovrabetError exception:

try {
const result = await client.models.customer.create({ name: "" });
} catch (error) {
if (error instanceof LovrabetError) {
console.error("Error message:", error.message);
console.error("HTTP status code:", error.status);
console.error("Business error code:", error.code);
console.error("Full response:", error.data);
}
}

SQL Queries

SQL query return value structure is different, requiring execution status check:

const data = await client.api.executeSql("sql-code", { param1: "value" });

// Must check execution status
if (!data.execSuccess) {
throw new Error(data.execError || "SQL execution failed");
}

// Get results
const results = data.execResult || [];

v1.2.0 New Features

Modern Architecture

v1.2.0 completed major upgrade of MCP SDK architecture:

  • McpServer API: Migrated from deprecated Server API to officially recommended McpServer API
  • Tool Metadata: All 8 tools support title and annotations (readOnlyHint, destructiveHint, idempotentHint)
  • Complete Test Coverage: 17 end-to-end automated test cases

SDK Code Generation Enhancement

New aliasHint field provides smarter model access suggestions:

aliasHint: {
defaultAlias: "customer", // Default alias (camelCase table name)
datasetSDKKey: "dataset_customer", // SDK key (requires SDK >= 1.2.0)
note: "Check custom alias in createClient or registerModels",
versionNote: "Using alias access requires @lovrabet/sdk >= 1.2.0"
}

Two Access Modes

ModeFormatDescription
Standard Modeclient.models.dataset_[code].operation()Stable, no configuration needed
Alias Modeclient.models.[alias].operation()Human-friendly, requires SDK >= 1.2.0

Enhanced Field Metadata

Field information adds database type fields:

{
name: "customer_id",
type: "NUMBER",
dbType: "BIGINT", // Database type
dbTypeLen: 20, // Type length
autoIncrement: true, // Auto-increment flag
}