mcp-quickbase 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/.sdd/tickets/RELS_relationship-management/README.md +98 -0
  2. package/.sdd/tickets/RELS_relationship-management/planning/analysis.md +190 -0
  3. package/.sdd/tickets/RELS_relationship-management/planning/architecture.md +413 -0
  4. package/.sdd/tickets/RELS_relationship-management/planning/plan.md +177 -0
  5. package/.sdd/tickets/RELS_relationship-management/planning/quality-strategy.md +335 -0
  6. package/.sdd/tickets/RELS_relationship-management/planning/review-updates.md +95 -0
  7. package/.sdd/tickets/RELS_relationship-management/planning/security-review.md +213 -0
  8. package/.sdd/tickets/RELS_relationship-management/planning/ticket-review.md +885 -0
  9. package/.sdd/tickets/RELS_relationship-management/tasks/RELS.1001_domain-setup.md +96 -0
  10. package/.sdd/tickets/RELS_relationship-management/tasks/RELS.1002_get-relationships-tool.md +142 -0
  11. package/.sdd/tickets/RELS_relationship-management/tasks/RELS.1003_register-phase1-tools.md +105 -0
  12. package/.sdd/tickets/RELS_relationship-management/tasks/RELS.2001_create-relationship-tool.md +151 -0
  13. package/.sdd/tickets/RELS_relationship-management/tasks/RELS.2002_update-relationship-tool.md +145 -0
  14. package/.sdd/tickets/RELS_relationship-management/tasks/RELS.3001_delete-relationship-tool.md +154 -0
  15. package/.sdd/tickets/RELS_relationship-management/tasks/RELS.4001_integration-testing.md +159 -0
  16. package/.sdd/tickets/RELS_relationship-management/tasks/RELS.4002_final-verification.md +182 -0
  17. package/.sdd/tickets/RELS_relationship-management/tasks/RELS_TASK_INDEX.md +179 -0
  18. package/dist/tools/apps/list_tables.d.ts +5 -5
  19. package/dist/tools/apps/list_tables.js +1 -1
  20. package/dist/tools/index.d.ts +1 -0
  21. package/dist/tools/index.js +4 -1
  22. package/dist/tools/index.js.map +1 -1
  23. package/dist/tools/records/query_records.d.ts +33 -0
  24. package/dist/tools/records/query_records.js +40 -2
  25. package/dist/tools/records/query_records.js.map +1 -1
  26. package/dist/tools/relationships/create_relationship.d.ts +150 -0
  27. package/dist/tools/relationships/create_relationship.js +181 -0
  28. package/dist/tools/relationships/create_relationship.js.map +1 -0
  29. package/dist/tools/relationships/delete_relationship.d.ts +66 -0
  30. package/dist/tools/relationships/delete_relationship.js +85 -0
  31. package/dist/tools/relationships/delete_relationship.js.map +1 -0
  32. package/dist/tools/relationships/get_relationships.d.ts +126 -0
  33. package/dist/tools/relationships/get_relationships.js +126 -0
  34. package/dist/tools/relationships/get_relationships.js.map +1 -0
  35. package/dist/tools/relationships/index.d.ts +14 -0
  36. package/dist/tools/relationships/index.js +37 -0
  37. package/dist/tools/relationships/index.js.map +1 -0
  38. package/dist/tools/relationships/update_relationship.d.ts +139 -0
  39. package/dist/tools/relationships/update_relationship.js +168 -0
  40. package/dist/tools/relationships/update_relationship.js.map +1 -0
  41. package/package.json +1 -1
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdateRelationshipTool = void 0;
4
+ const base_1 = require("../base");
5
+ const logger_1 = require("../../utils/logger");
6
+ const logger = (0, logger_1.createLogger)("UpdateRelationshipTool");
7
+ /**
8
+ * Tool for updating an existing table-to-table relationship in Quickbase.
9
+ *
10
+ * ADDITIVE ONLY - adds lookup fields and/or summary fields to existing relationships.
11
+ * Does not delete existing fields from the relationship.
12
+ */
13
+ class UpdateRelationshipTool extends base_1.BaseTool {
14
+ /**
15
+ * Constructor
16
+ * @param client Quickbase client
17
+ */
18
+ constructor(client) {
19
+ super(client);
20
+ this.name = "update_relationship";
21
+ this.description = "Adds lookup fields and/or summary fields to an existing relationship. This operation " +
22
+ "is ADDITIVE ONLY - it will not delete existing lookup or summary fields. Use this to " +
23
+ "enhance relationships with additional calculated fields. To remove fields from a " +
24
+ "relationship, you must delete them individually using the field deletion tools.";
25
+ /**
26
+ * Parameter schema for update_relationship with conditional validation
27
+ */
28
+ this.paramSchema = {
29
+ type: "object",
30
+ properties: {
31
+ table_id: {
32
+ type: "string",
33
+ description: "The ID of the child Quickbase table (DBID) containing the relationship",
34
+ },
35
+ relationship_id: {
36
+ type: "number",
37
+ description: "The ID of the relationship to update (same as the foreign key field ID)",
38
+ },
39
+ lookup_field_ids: {
40
+ type: "array",
41
+ items: {
42
+ type: "number",
43
+ },
44
+ description: "Optional array of parent field IDs to add as lookup fields in the child table",
45
+ },
46
+ summary_field_id: {
47
+ type: "number",
48
+ description: "Optional child field ID to summarize in the parent table",
49
+ },
50
+ summary_label: {
51
+ type: "string",
52
+ description: "Optional label for the summary field created in the parent table",
53
+ },
54
+ summary_accumulation_type: {
55
+ type: "string",
56
+ enum: ["SUM", "COUNT", "AVG", "MAX", "MIN"],
57
+ description: "Accumulation type for the summary field. Required when summary_field_id is provided. " +
58
+ "Valid values: SUM, COUNT, AVG, MAX, MIN",
59
+ },
60
+ summary_where: {
61
+ type: "string",
62
+ description: "Optional Quickbase query filter for the summary field (e.g., \"{6.EX.'Active'}\")",
63
+ },
64
+ },
65
+ required: ["table_id", "relationship_id"],
66
+ // Conditional validation: summary_accumulation_type is required when summary_field_id is provided
67
+ if: {
68
+ properties: { summary_field_id: { type: "number" } },
69
+ required: ["summary_field_id"],
70
+ },
71
+ then: {
72
+ required: ["summary_accumulation_type"],
73
+ },
74
+ };
75
+ }
76
+ /**
77
+ * Run the update_relationship tool
78
+ * @param params Tool parameters
79
+ * @returns Updated relationship details
80
+ */
81
+ async run(params) {
82
+ const { table_id, relationship_id, lookup_field_ids, summary_field_id, summary_label, summary_accumulation_type, summary_where, } = params;
83
+ logger.info("Updating relationship", {
84
+ childTableId: table_id,
85
+ relationshipId: relationship_id,
86
+ hasLookupFields: !!lookup_field_ids?.length,
87
+ hasSummaryField: !!summary_field_id,
88
+ });
89
+ // Validate conditional requirement: summary_accumulation_type required when summary_field_id is provided
90
+ if (summary_field_id !== undefined && !summary_accumulation_type) {
91
+ const errorMessage = "summary_accumulation_type is required when summary_field_id is provided. " +
92
+ "Valid values: SUM, COUNT, AVG, MAX, MIN";
93
+ logger.error("Validation failed", { error: errorMessage });
94
+ throw new Error(errorMessage);
95
+ }
96
+ // Build the request body according to Quickbase API format
97
+ const body = {};
98
+ // Add lookup fields if provided
99
+ if (lookup_field_ids && lookup_field_ids.length > 0) {
100
+ body.lookupFieldIds = lookup_field_ids;
101
+ }
102
+ // Add summary field configuration if provided
103
+ if (summary_field_id !== undefined && summary_accumulation_type) {
104
+ const summaryField = {
105
+ summaryFid: summary_field_id,
106
+ accumulationType: summary_accumulation_type,
107
+ };
108
+ if (summary_label) {
109
+ summaryField.label = summary_label;
110
+ }
111
+ if (summary_where) {
112
+ summaryField.where = summary_where;
113
+ }
114
+ body.summaryFields = [summaryField];
115
+ }
116
+ // Update the relationship
117
+ const response = await this.client.request({
118
+ method: "POST",
119
+ path: `/tables/${table_id}/relationship/${relationship_id}`,
120
+ body,
121
+ });
122
+ if (!response.success || !response.data) {
123
+ logger.error("Failed to update relationship", {
124
+ error: response.error,
125
+ childTableId: table_id,
126
+ relationshipId: relationship_id,
127
+ });
128
+ throw new Error(response.error?.message || "Failed to update relationship");
129
+ }
130
+ // Parse and transform the API response
131
+ const data = response.data;
132
+ const foreignKeyField = data.foreignKeyField;
133
+ const lookupFields = data.lookupFields;
134
+ const summaryFields = data.summaryFields;
135
+ const result = {
136
+ id: data.id,
137
+ parentTableId: data.parentTableId,
138
+ childTableId: data.childTableId,
139
+ foreignKeyField: foreignKeyField
140
+ ? {
141
+ id: foreignKeyField.id,
142
+ label: foreignKeyField.label,
143
+ type: foreignKeyField.type,
144
+ }
145
+ : { id: 0, label: "", type: "" },
146
+ lookupFields: (lookupFields || []).map((field) => ({
147
+ id: field.id,
148
+ label: field.label,
149
+ type: field.type,
150
+ })),
151
+ summaryFields: (summaryFields || []).map((field) => ({
152
+ id: field.id,
153
+ label: field.label,
154
+ type: field.type,
155
+ })),
156
+ };
157
+ logger.info("Successfully updated relationship", {
158
+ relationshipId: result.id,
159
+ childTableId: result.childTableId,
160
+ parentTableId: result.parentTableId,
161
+ totalLookupFields: result.lookupFields.length,
162
+ totalSummaryFields: result.summaryFields.length,
163
+ });
164
+ return result;
165
+ }
166
+ }
167
+ exports.UpdateRelationshipTool = UpdateRelationshipTool;
168
+ //# sourceMappingURL=update_relationship.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update_relationship.js","sourceRoot":"","sources":["../../../src/tools/relationships/update_relationship.ts"],"names":[],"mappings":";;;AAAA,kCAAmC;AAEnC,+CAAkD;AAIlD,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,wBAAwB,CAAC,CAAC;AA6EtD;;;;;GAKG;AACH,MAAa,sBAAuB,SAAQ,eAG3C;IAiEC;;;OAGG;IACH,YAAY,MAAuB;QACjC,KAAK,CAAC,MAAM,CAAC,CAAC;QArET,SAAI,GAAG,qBAAqB,CAAC;QAC7B,gBAAW,GAChB,uFAAuF;YACvF,uFAAuF;YACvF,mFAAmF;YACnF,iFAAiF,CAAC;QAEpF;;WAEG;QACI,gBAAW,GAAG;YACnB,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,wEAAwE;iBAC3E;gBACD,eAAe,EAAE;oBACf,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,yEAAyE;iBAC5E;gBACD,gBAAgB,EAAE;oBAChB,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;qBACf;oBACD,WAAW,EACT,+EAA+E;iBAClF;gBACD,gBAAgB,EAAE;oBAChB,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,0DAA0D;iBACxE;gBACD,aAAa,EAAE;oBACb,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,kEAAkE;iBACrE;gBACD,yBAAyB,EAAE;oBACzB,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,KAAK,EA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1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-quickbase",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "description": "Work with Quickbase via Model Context Protocol",
5
5
  "main": "dist/mcp-stdio-server.js",
6
6
  "types": "dist/mcp-stdio-server.d.ts",