mcp-quickbase
Version:
Work with Quickbase via Model Context Protocol
151 lines (150 loc) • 4.24 kB
TypeScript
import { BaseTool } from "../base";
import { QuickbaseClient } from "../../client/quickbase";
import { RelationshipFieldInfo } from "./get_relationships";
/**
* Valid accumulation types for summary fields
*/
export type SummaryAccumulationType = "SUM" | "COUNT" | "AVG" | "MAX" | "MIN";
/**
* Parameters for create_relationship tool
*/
export interface CreateRelationshipParams {
/**
* The ID of the child table (DBID) where the relationship reference field will be created
*/
table_id: string;
/**
* The ID of the parent table (DBID) to link to
*/
parent_table_id: string;
/**
* Optional label for the foreign key reference field created in the child table
*/
foreign_key_label?: string;
/**
* Optional array of parent field IDs to create as lookup fields in the child table
*/
lookup_field_ids?: number[];
/**
* Optional child field ID to summarize in the parent table
*/
summary_field_id?: number;
/**
* Optional label for the summary field created in the parent table
*/
summary_label?: string;
/**
* Accumulation type for the summary field (required if summary_field_id is provided)
*/
summary_accumulation_type?: SummaryAccumulationType;
/**
* Optional Quickbase query filter for the summary field
*/
summary_where?: string;
}
/**
* Result from creating a relationship
*/
export interface CreateRelationshipResult {
/**
* The ID of the relationship (same as the foreign key field ID)
*/
id: number;
/**
* The ID of the parent table
*/
parentTableId: string;
/**
* The ID of the child table
*/
childTableId: string;
/**
* The foreign key field created in the child table
*/
foreignKeyField: RelationshipFieldInfo;
/**
* Lookup fields created in the child table
*/
lookupFields: RelationshipFieldInfo[];
/**
* Summary fields created in the parent table
*/
summaryFields: RelationshipFieldInfo[];
}
/**
* Tool for creating a new table-to-table relationship in Quickbase.
*
* Creates a reference field in the child table linking to the parent table.
* Optionally creates lookup fields and/or summary fields.
*/
export declare class CreateRelationshipTool extends BaseTool<CreateRelationshipParams, CreateRelationshipResult> {
name: string;
description: string;
/**
* Parameter schema for create_relationship with conditional validation
*/
paramSchema: {
type: string;
properties: {
table_id: {
type: string;
description: string;
};
parent_table_id: {
type: string;
description: string;
};
foreign_key_label: {
type: string;
description: string;
};
lookup_field_ids: {
type: string;
items: {
type: string;
};
description: string;
};
summary_field_id: {
type: string;
description: string;
};
summary_label: {
type: string;
description: string;
};
summary_accumulation_type: {
type: string;
enum: string[];
description: string;
};
summary_where: {
type: string;
description: string;
};
};
required: string[];
if: {
properties: {
summary_field_id: {
type: string;
};
};
required: string[];
};
then: {
required: string[];
};
};
/**
* Constructor
* @param client Quickbase client
*/
constructor(client: QuickbaseClient);
/**
* Run the create_relationship tool
* @param params Tool parameters
* @returns Created relationship details
*/
protected run(params: CreateRelationshipParams): Promise<CreateRelationshipResult>;
}