@addai/tables-mcp 0.7.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 (90) hide show
  1. package/README.md +127 -0
  2. package/dist/api-client.d.ts +12 -0
  3. package/dist/api-client.d.ts.map +1 -0
  4. package/dist/api-client.js +53 -0
  5. package/dist/api-client.js.map +1 -0
  6. package/dist/helpers/column-settings.d.ts +25 -0
  7. package/dist/helpers/column-settings.d.ts.map +1 -0
  8. package/dist/helpers/column-settings.js +96 -0
  9. package/dist/helpers/column-settings.js.map +1 -0
  10. package/dist/helpers/column-types.d.ts +8 -0
  11. package/dist/helpers/column-types.d.ts.map +1 -0
  12. package/dist/helpers/column-types.js +83 -0
  13. package/dist/helpers/column-types.js.map +1 -0
  14. package/dist/helpers/errors.d.ts +16 -0
  15. package/dist/helpers/errors.d.ts.map +1 -0
  16. package/dist/helpers/errors.js +19 -0
  17. package/dist/helpers/errors.js.map +1 -0
  18. package/dist/helpers/mapped-columns.d.ts +21 -0
  19. package/dist/helpers/mapped-columns.d.ts.map +1 -0
  20. package/dist/helpers/mapped-columns.js +119 -0
  21. package/dist/helpers/mapped-columns.js.map +1 -0
  22. package/dist/helpers/validate-options.d.ts +34 -0
  23. package/dist/helpers/validate-options.d.ts.map +1 -0
  24. package/dist/helpers/validate-options.js +120 -0
  25. package/dist/helpers/validate-options.js.map +1 -0
  26. package/dist/index.d.ts +3 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +34 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/logo.d.ts +2 -0
  31. package/dist/logo.d.ts.map +1 -0
  32. package/dist/logo.js +64 -0
  33. package/dist/logo.js.map +1 -0
  34. package/dist/preview.d.ts +3 -0
  35. package/dist/preview.d.ts.map +1 -0
  36. package/dist/preview.js +4 -0
  37. package/dist/preview.js.map +1 -0
  38. package/dist/server.d.ts +3 -0
  39. package/dist/server.d.ts.map +1 -0
  40. package/dist/server.js +136 -0
  41. package/dist/server.js.map +1 -0
  42. package/dist/setup.d.ts +2 -0
  43. package/dist/setup.d.ts.map +1 -0
  44. package/dist/setup.js +128 -0
  45. package/dist/setup.js.map +1 -0
  46. package/dist/tools/comments.d.ts +4 -0
  47. package/dist/tools/comments.d.ts.map +1 -0
  48. package/dist/tools/comments.js +63 -0
  49. package/dist/tools/comments.js.map +1 -0
  50. package/dist/tools/dashboards.d.ts +4 -0
  51. package/dist/tools/dashboards.d.ts.map +1 -0
  52. package/dist/tools/dashboards.js +560 -0
  53. package/dist/tools/dashboards.js.map +1 -0
  54. package/dist/tools/discovery.d.ts +4 -0
  55. package/dist/tools/discovery.d.ts.map +1 -0
  56. package/dist/tools/discovery.js +115 -0
  57. package/dist/tools/discovery.js.map +1 -0
  58. package/dist/tools/files.d.ts +4 -0
  59. package/dist/tools/files.d.ts.map +1 -0
  60. package/dist/tools/files.js +115 -0
  61. package/dist/tools/files.js.map +1 -0
  62. package/dist/tools/folders.d.ts +4 -0
  63. package/dist/tools/folders.d.ts.map +1 -0
  64. package/dist/tools/folders.js +164 -0
  65. package/dist/tools/folders.js.map +1 -0
  66. package/dist/tools/history.d.ts +4 -0
  67. package/dist/tools/history.d.ts.map +1 -0
  68. package/dist/tools/history.js +50 -0
  69. package/dist/tools/history.js.map +1 -0
  70. package/dist/tools/rows.d.ts +4 -0
  71. package/dist/tools/rows.d.ts.map +1 -0
  72. package/dist/tools/rows.js +244 -0
  73. package/dist/tools/rows.js.map +1 -0
  74. package/dist/tools/search.d.ts +4 -0
  75. package/dist/tools/search.d.ts.map +1 -0
  76. package/dist/tools/search.js +89 -0
  77. package/dist/tools/search.js.map +1 -0
  78. package/dist/tools/structure.d.ts +4 -0
  79. package/dist/tools/structure.d.ts.map +1 -0
  80. package/dist/tools/structure.js +172 -0
  81. package/dist/tools/structure.js.map +1 -0
  82. package/dist/tools/views.d.ts +4 -0
  83. package/dist/tools/views.d.ts.map +1 -0
  84. package/dist/tools/views.js +169 -0
  85. package/dist/tools/views.js.map +1 -0
  86. package/dist/types.d.ts +76 -0
  87. package/dist/types.d.ts.map +1 -0
  88. package/dist/types.js +3 -0
  89. package/dist/types.js.map +1 -0
  90. package/package.json +38 -0
@@ -0,0 +1,34 @@
1
+ import type { AiTablesClient } from '../api-client.js';
2
+ import type { ColumnMap } from './mapped-columns.js';
3
+ export interface OptionViolation {
4
+ column: string;
5
+ columnId: string;
6
+ type: string;
7
+ invalidValues: string[];
8
+ validOptions: string[];
9
+ }
10
+ /**
11
+ * Scan name-keyed row payloads for select/multiselect values that don't match the
12
+ * column's configured options. Aggregates invalid values per column across all rows.
13
+ * Columns with no configured options are skipped — there's nothing to validate
14
+ * against, and rejecting would break writes to legitimately option-less columns.
15
+ */
16
+ export declare function findOptionViolations(rows: Record<string, unknown>[], map: ColumnMap): OptionViolation[];
17
+ /**
18
+ * Human-readable rejection message listing each offending column, its bad values,
19
+ * and the valid options — plus how to opt into adding them.
20
+ */
21
+ export declare function formatOptionViolations(violations: OptionViolation[]): string;
22
+ /**
23
+ * Add each violation's invalid values as new options on its column, preserving
24
+ * existing options and their colors (reuses the same merge as update_column).
25
+ * Returns an error string on the first failure.
26
+ */
27
+ export declare function addMissingOptions(client: AiTablesClient, tableId: string, violations: OptionViolation[], map: ColumnMap): Promise<{
28
+ error?: string;
29
+ added: {
30
+ column: string;
31
+ options: string[];
32
+ }[];
33
+ }>;
34
+ //# sourceMappingURL=validate-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-options.d.ts","sourceRoot":"","sources":["../../src/helpers/validate-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AASrD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AA0BD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,GAAG,EAAE,SAAS,GACb,eAAe,EAAE,CAqCnB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,eAAe,EAAE,GAAG,MAAM,CAa5E;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,eAAe,EAAE,EAC7B,GAAG,EAAE,SAAS,GACb,OAAO,CAAC;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAA;CAAE,CAAC,CA0B7E"}
@@ -0,0 +1,120 @@
1
+ import { mergeSelectOptions } from './column-settings.js';
2
+ // Column types whose cell values must match a configured option set.
3
+ // Intentionally scoped to select + multiselect: `tags` are free-form by design,
4
+ // and `label` seeds preset options that callers don't necessarily want enforced.
5
+ const VALIDATED_TYPES = new Set(['select', 'multiselect']);
6
+ /** Extract the configured option value strings for a select/multiselect column. */
7
+ function configuredOptionValues(col) {
8
+ const settings = (col.column_settings || {});
9
+ const opts = settings.options || [];
10
+ return opts
11
+ .map((o) => (typeof o === 'string' ? o : o?.value))
12
+ .filter((v) => typeof v === 'string');
13
+ }
14
+ /** Pull the string value(s) a caller supplied for a select/multiselect cell. */
15
+ function candidateValues(value) {
16
+ if (value === null || value === undefined || value === '')
17
+ return [];
18
+ const arr = Array.isArray(value) ? value : [value];
19
+ const out = [];
20
+ for (const v of arr) {
21
+ if (typeof v === 'string') {
22
+ if (v.length > 0)
23
+ out.push(v);
24
+ }
25
+ else if (v && typeof v === 'object' && typeof v.value === 'string') {
26
+ out.push(v.value);
27
+ }
28
+ }
29
+ return out;
30
+ }
31
+ /**
32
+ * Scan name-keyed row payloads for select/multiselect values that don't match the
33
+ * column's configured options. Aggregates invalid values per column across all rows.
34
+ * Columns with no configured options are skipped — there's nothing to validate
35
+ * against, and rejecting would break writes to legitimately option-less columns.
36
+ */
37
+ export function findOptionViolations(rows, map) {
38
+ const colById = new Map(map.columns.map((c) => [c.id, c]));
39
+ const agg = new Map();
40
+ for (const row of rows) {
41
+ for (const [key, value] of Object.entries(row)) {
42
+ // Resolve key → column, accepting either a human name or a raw column id
43
+ // (mirrors translateToIds so validation and translation agree on the target).
44
+ const columnId = map.nameToId.get(key) ?? (colById.has(key) ? key : undefined);
45
+ if (!columnId)
46
+ continue;
47
+ const col = colById.get(columnId);
48
+ if (!col || !VALIDATED_TYPES.has(col.column_type))
49
+ continue;
50
+ const valid = configuredOptionValues(col);
51
+ if (valid.length === 0)
52
+ continue;
53
+ const validSet = new Set(valid);
54
+ for (const cand of candidateValues(value)) {
55
+ if (!validSet.has(cand)) {
56
+ let entry = agg.get(col.id);
57
+ if (!entry) {
58
+ entry = { col, invalid: new Set(), valid };
59
+ agg.set(col.id, entry);
60
+ }
61
+ entry.invalid.add(cand);
62
+ }
63
+ }
64
+ }
65
+ }
66
+ return [...agg.values()].map((e) => ({
67
+ column: e.col.name,
68
+ columnId: e.col.id,
69
+ type: e.col.column_type,
70
+ invalidValues: [...e.invalid],
71
+ validOptions: e.valid,
72
+ }));
73
+ }
74
+ /**
75
+ * Human-readable rejection message listing each offending column, its bad values,
76
+ * and the valid options — plus how to opt into adding them.
77
+ */
78
+ export function formatOptionViolations(violations) {
79
+ const lines = violations.map((v) => {
80
+ const bad = v.invalidValues.map((s) => `"${s}"`).join(', ');
81
+ const valid = v.validOptions.length ? v.validOptions.join(', ') : '(none configured)';
82
+ const label = v.invalidValues.length > 1 ? 'values' : 'value';
83
+ return ` • "${v.column}" (${v.type}): invalid ${label} ${bad}. Valid options: ${valid}`;
84
+ });
85
+ return ("Rejected — some select/multiselect values do not match the column's configured options:\n" +
86
+ lines.join('\n') +
87
+ '\n\nFix the value(s) to match an option above, or call again with add_missing_options: true ' +
88
+ 'to add the new option(s) to the column before writing.');
89
+ }
90
+ /**
91
+ * Add each violation's invalid values as new options on its column, preserving
92
+ * existing options and their colors (reuses the same merge as update_column).
93
+ * Returns an error string on the first failure.
94
+ */
95
+ export async function addMissingOptions(client, tableId, violations, map) {
96
+ const colById = new Map(map.columns.map((c) => [c.id, c]));
97
+ const added = [];
98
+ for (const v of violations) {
99
+ const col = colById.get(v.columnId);
100
+ if (!col)
101
+ continue;
102
+ const existingSettings = (col.column_settings || {});
103
+ const existingOptions = existingSettings.options || [];
104
+ const existingValues = existingOptions.map((o) => o.value);
105
+ const fullList = [
106
+ ...existingValues,
107
+ ...v.invalidValues.filter((val) => !existingValues.includes(val)),
108
+ ];
109
+ const merged = mergeSelectOptions(existingOptions, fullList);
110
+ const res = await client.patch(`/tables/${tableId}/columns/${v.columnId}`, {
111
+ column_settings: { ...existingSettings, options: merged },
112
+ });
113
+ if (res.error) {
114
+ return { error: `Failed to add option(s) to "${v.column}": ${res.error.message}`, added };
115
+ }
116
+ added.push({ column: v.column, options: v.invalidValues });
117
+ }
118
+ return { added };
119
+ }
120
+ //# sourceMappingURL=validate-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-options.js","sourceRoot":"","sources":["../../src/helpers/validate-options.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,qEAAqE;AACrE,gFAAgF;AAChF,iFAAiF;AACjF,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC;AAU3D,mFAAmF;AACnF,SAAS,sBAAsB,CAAC,GAAW;IACzC,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,eAAe,IAAI,EAAE,CAA4B,CAAC;IACxE,MAAM,IAAI,G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,EAAE,OAAO,EAAE,MAAM,EAAE;SAC1D,CAAC,CAAC;QACH,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;YACd,OAAO,EAAE,KAAK,EAAE,+BAA+B,CAAC,CAAC,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC;QAC5F,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,CAAC;AACnB,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+ // If --setup flag is passed, run interactive setup instead of MCP server
3
+ if (process.argv.includes('--setup') || process.argv.includes('setup')) {
4
+ await import('./setup.js');
5
+ }
6
+ else {
7
+ const { StdioServerTransport } = await import('@modelcontextprotocol/sdk/server/stdio.js');
8
+ const { createServer } = await import('./server.js');
9
+ const apiKey = process.env.AITABLES_API_KEY;
10
+ if (!apiKey) {
11
+ console.error('Error: AITABLES_API_KEY environment variable is required.\n\n' +
12
+ 'Run setup to configure automatically:\n' +
13
+ ' npx aitables-mcp --setup\n\n' +
14
+ 'Or manually add to your .mcp.json:\n' +
15
+ ' {\n' +
16
+ ' "mcpServers": {\n' +
17
+ ' "aitables": {\n' +
18
+ ' "command": "npx",\n' +
19
+ ' "args": ["-y", "aitables-mcp"],\n' +
20
+ ' "env": {\n' +
21
+ ' "AITABLES_API_KEY": "ait_user_xxxx"\n' +
22
+ ' }\n' +
23
+ ' }\n' +
24
+ ' }\n' +
25
+ ' }');
26
+ process.exit(1);
27
+ }
28
+ const baseUrl = process.env.AITABLES_API_URL || undefined;
29
+ const server = createServer(apiKey, baseUrl);
30
+ const transport = new StdioServerTransport();
31
+ await server.connect(transport);
32
+ }
33
+ export {};
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,yEAAyE;AACzE,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;IACvE,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC;AAC7B,CAAC;KAAM,CAAC;IACN,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,MAAM,CAAC,2CAA2C,CAAC,CAAC;IAC3F,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;IAErD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAC5C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CACX,+DAA+D;YAC7D,yCAAyC;YACzC,gCAAgC;YAChC,sCAAsC;YACtC,OAAO;YACP,uBAAuB;YACvB,uBAAuB;YACvB,6BAA6B;YAC7B,2CAA2C;YAC3C,oBAAoB;YACpB,iDAAiD;YACjD,aAAa;YACb,WAAW;YACX,SAAS;YACT,KAAK,CACR,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,SAAS,CAAC;IAC1D,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAE7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC"}
package/dist/logo.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function printLogo(): void;
2
+ //# sourceMappingURL=logo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logo.d.ts","sourceRoot":"","sources":["../src/logo.ts"],"names":[],"mappings":"AAwCA,wBAAgB,SAAS,IAAI,IAAI,CAiChC"}
package/dist/logo.js ADDED
@@ -0,0 +1,64 @@
1
+ // AiTables logo - 2x4 color grid + sleek block-letter wordmark
2
+ const rgb = (r, g, b) => `\x1b[38;2;${r};${g};${b}m`;
3
+ const RESET = '\x1b[0m';
4
+ const BOLD = '\x1b[1m';
5
+ const B = '\u2588';
6
+ const W = 8;
7
+ const C = {
8
+ g1: rgb(228, 140, 60),
9
+ g2: rgb(210, 100, 120),
10
+ g3: rgb(180, 85, 150),
11
+ g4: rgb(150, 160, 200),
12
+ pale: rgb(230, 234, 242),
13
+ lavender: rgb(172, 166, 204),
14
+ mint: rgb(170, 224, 216),
15
+ indigo: rgb(108, 108, 172),
16
+ cyan: rgb(68, 196, 200),
17
+ blue: rgb(136, 152, 208),
18
+ teal: rgb(120, 208, 206),
19
+ };
20
+ function cell(color, width = W) {
21
+ return color + B.repeat(width) + RESET;
22
+ }
23
+ function gradCell() {
24
+ return C.g1 + B.repeat(2) + C.g2 + B.repeat(2) + C.g3 + B.repeat(2) + C.g4 + B.repeat(2) + RESET;
25
+ }
26
+ // Sleek 2-line block wordmark using ▄ ▀ █
27
+ // A i T a b l e s
28
+ const WORD_L1 = '\u2584\u2580\u2588 \u2580 \u2580\u2588\u2580 \u2584\u2580\u2588 \u2588\u2584\u2584 \u2588 \u2588\u2580\u2580 \u2588\u2580';
29
+ const WORD_L2 = '\u2588\u2580\u2588 \u2588 \u2588 \u2588\u2580\u2588 \u2588\u2584\u2588 \u2588\u2584 \u2588\u2588\u2584 \u2584\u2588';
30
+ const TC1 = rgb(170, 178, 220); // lighter blue-lavender
31
+ const TC2 = rgb(120, 140, 200); // slightly deeper
32
+ const SC = rgb(68, 196, 200);
33
+ export function printLogo() {
34
+ const logo = [
35
+ gradCell() + cell(C.pale),
36
+ gradCell() + cell(C.pale),
37
+ cell(C.lavender) + cell(C.mint),
38
+ cell(C.lavender) + cell(C.mint),
39
+ cell(C.indigo) + cell(C.cyan),
40
+ cell(C.indigo) + cell(C.cyan),
41
+ cell(C.blue) + cell(C.teal),
42
+ cell(C.blue) + cell(C.teal),
43
+ ];
44
+ // Wordmark positioned to right, vertically centered
45
+ const wordmark = [
46
+ `${BOLD}${TC1}${WORD_L1}${RESET}`,
47
+ `${BOLD}${TC2}${WORD_L2}${RESET}`,
48
+ ];
49
+ const wmOffset = 3; // start wordmark at line 3 (vertically centered)
50
+ console.log('');
51
+ for (let i = 0; i < logo.length; i++) {
52
+ let right = '';
53
+ const wIdx = i - wmOffset;
54
+ if (wIdx >= 0 && wIdx < wordmark.length) {
55
+ right = ' ' + wordmark[wIdx];
56
+ }
57
+ if (i === wmOffset + wordmark.length + 1) {
58
+ right = ` ${SC}Connect your data to Claude${RESET}`;
59
+ }
60
+ console.log(' ' + logo[i] + right);
61
+ }
62
+ console.log('');
63
+ }
64
+ //# sourceMappingURL=logo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logo.js","sourceRoot":"","sources":["../src/logo.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAE/D,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AAC7E,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,IAAI,GAAG,SAAS,CAAC;AAEvB,MAAM,CAAC,GAAG,QAAQ,CAAC;AACnB,MAAM,CAAC,GAAG,CAAC,CAAC;AAEZ,MAAM,CAAC,GAAG;IACR,EAAE,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC;IACrB,EAAE,EAAE,GAAG,CAA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,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,MAAM,IAAI,GAAG,CAAC,GAAG,QAAQ,CAAC;QAC1B,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;YACxC,KAAK,GAAG,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,CAAC,KAAK,QAAQ,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzC,KAAK,GAAG,KAAK,EAAE,8BAA8B,KAAK,EAAE,CAAC;QACvD,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=preview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../src/preview.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { printLogo } from './logo.js';
3
+ printLogo();
4
+ //# sourceMappingURL=preview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.js","sourceRoot":"","sources":["../src/preview.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,SAAS,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function createServer(apiKey: string, baseUrl?: string): McpServer;
3
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAqHpE,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAyBxE"}
package/dist/server.js ADDED
@@ -0,0 +1,136 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { AiTablesClient } from './api-client.js';
3
+ import { registerDiscoveryTools } from './tools/discovery.js';
4
+ import { registerRowTools } from './tools/rows.js';
5
+ import { registerStructureTools } from './tools/structure.js';
6
+ import { registerSearchTools } from './tools/search.js';
7
+ import { registerCommentTools } from './tools/comments.js';
8
+ import { registerDashboardTools } from './tools/dashboards.js';
9
+ import { registerFolderTools } from './tools/folders.js';
10
+ import { registerViewTools } from './tools/views.js';
11
+ import { registerHistoryTools } from './tools/history.js';
12
+ import { registerFileTools } from './tools/files.js';
13
+ const SERVER_INSTRUCTIONS = `You are connected to an AiTables database. AiTables is a database builder (like Airtable) with workspaces, databases, tables, columns, and rows.
14
+
15
+ ## Data Hierarchy
16
+ Workspace → Database → Table → Columns + Rows
17
+
18
+ ## Workflow
19
+ 1. Use list_workspaces and list_databases to discover what exists
20
+ 2. Use list_tables to see tables in a database
21
+ 3. ALWAYS call get_table_schema before reading or writing rows — you need the column names
22
+ 4. Use list_rows to read data, create_rows to add data, update_rows to modify data
23
+
24
+ ## Looking up a single record by ID
25
+ If you have a record/row ID (e.g. a task or bug id) but not its table, call **get_row** with just the row_id — the server resolves which table it belongs to (native or BYODB) and returns a "table" context block alongside the row. Use that table_id for any follow-up update_rows / add_comment. If you already know the table, pass table_id too for a faster direct fetch. Do NOT go hunting for the table_id by listing databases/tables first.
26
+
27
+ ## Column Types
28
+ When creating tables or columns, choose from:
29
+ - **Text:** text, richtext, email, url, phone
30
+ - **Numbers:** number, rating, progress, duration
31
+ - **Choices:** select (single choice), multiselect (multiple), tags, label
32
+ - **Dates:** date, timeline (date range), hour (time of day), week
33
+ - **People:** people (workspace users), team
34
+ - **Logic:** boolean (checkbox), checklist
35
+ - **Special:** country, color_picker, location, autonumber, barcode, vote
36
+
37
+ For select/multiselect columns, provide the option values (e.g. ["Todo", "In Progress", "Done"]) and colors are auto-assigned.
38
+ IMPORTANT: Do NOT create select/multiselect columns without options — they will appear as empty unusable dropdowns.
39
+
40
+ ## Row Data Format
41
+ Use column names as keys (not UUIDs). Examples:
42
+ - Select: { "Status": "In Progress" }
43
+ - Date: { "Due Date": "2026-04-01" }
44
+ - Boolean: { "Completed": true }
45
+ - Number: { "Score": 85 }
46
+ - Multiselect: { "Tags": ["urgent", "bug"] }
47
+
48
+ Values for select/multiselect must exactly match defined options.
49
+
50
+ ## Common Tasks
51
+ - **Create a tracker:** create_table with columns like Name (text), Status (select with options), Priority (select), Due Date (date), Assignee (people)
52
+ - **Add data:** get_table_schema first, then create_rows with column names from the schema
53
+ - **Update cells:** update_rows with just the columns you want to change
54
+ - **Find data:** search_rows for cross-column text search, or list_rows with filters for precise queries
55
+ - **Bulk operations:** create_rows and update_rows accept arrays for batch operations
56
+
57
+ ## Folders
58
+ Two separate kinds of folders organise the hierarchy:
59
+ - **Table folders** group TABLES inside one database. They can nest (parent_folder_id). Tools: list_table_folders, create_table_folder, update_table_folder, delete_table_folder, and move_table_to_folder (pass folder_id=null to move a table back to the database root).
60
+ - **Database folders** group DATABASES inside a workspace. Tools: list_database_folders, create_database_folder, update_database_folder, delete_database_folder, and move_database_to_folder (folder_id=null moves it to the workspace root).
61
+
62
+ Creating a folder does NOT put anything in it — create the folder, then call the matching move_*_to_folder tool. Deleting a folder only removes the grouping; the tables/databases inside survive and return to the root.
63
+
64
+ ## Editing & deleting structure
65
+ - **Databases:** get_database, update_database (name/description/icon), delete_database.
66
+ - **Tables:** update_table (name/description/icon), delete_table.
67
+ - **Columns:** delete_column.
68
+ Deletes cascade (deleting a database removes its tables/rows; deleting a table removes its rows; deleting a column drops that column's data everywhere) and cannot be undone — confirm with the user first.
69
+
70
+ ## Views
71
+ A view is a saved presentation of a table's rows. Each has a view_type (table, kanban, calendar, gallery, timeline, list, gantt, form, dashboard, document) and a view_settings JSON blob holding that view's filters, sorts, grouping, hidden columns, and type-specific config (e.g. kanban's groupBy column, calendar's date column).
72
+ - **list_views** / **get_view** / **create_view** / **update_view** / **delete_view**, plus **reorder_views**.
73
+ - A table always keeps at least one view — deleting the last one fails.
74
+ - view_settings is REPLACED wholesale on update — get_view first and merge if you only want to change part of it. The settings shape is type-specific, so inspect an existing view of the same type before building one.
75
+ - **Share links:** list_view_shares / create_view_share (returns a public share_token, view or edit level) / deactivate_view_share.
76
+
77
+ ## Edit history (read-only)
78
+ Every cell change is logged with its old value, new value, column, editor, and timestamp.
79
+ - **get_row_history** — the full change log for one row (newest first).
80
+ - **get_table_history** — paginated change log across the whole table, for auditing recent activity.
81
+
82
+ ## Files (FILE columns)
83
+ To put a real file into a FILE-type column, use **upload_file** with a local file path. It streams the bytes straight to storage (so large files work) and stores them under the table's workspace. Either:
84
+ - pass row_id + column_id (the FILE column from get_table_schema) and it writes the file into that cell directly (appending for multi-file columns), or
85
+ - omit them and it returns a "file" value object {fileId,name,url,size,type} — then call update_rows yourself with that object as the column's value.
86
+ Do NOT try to set a FILE column to a plain string/URL by hand — always upload through upload_file so the file actually exists in storage.
87
+
88
+ ## Comments
89
+ Every row can have threaded comments with emoji reactions.
90
+ - **list_comments** to see all comments on a row (includes user info, replies, reactions)
91
+ - **add_comment** to post a comment or reply to an existing comment
92
+ - **toggle_reaction** to add/remove an emoji reaction on a comment
93
+
94
+ ## Dashboards
95
+ Dashboards are views with visual panels (stats, charts, embedded views, embeds, widgets) laid out on a 12-column grid. They can attach to three scopes:
96
+ - **table** — dashboard lives on a single table (parent_id = table_id). **Fully rendered by the UI.**
97
+ - **folder** — dashboard lives in a table folder (parent_id = folder_id). **Persists but the current UI does not render per-panel cross-table data yet** — panels will appear blank.
98
+ - **database** — dashboard lives at the database level (parent_id = database_id). **Same rendering limitation as folder scope.**
99
+
100
+ **Strongly prefer table-scope.** Only create folder/database-scope dashboards if the user explicitly asks and accepts the current blank-render limitation.
101
+
102
+ All dashboard tools take **scope** + **parent_id**:
103
+ - **list_dashboards** / **get_dashboard** / **create_dashboard** / **update_dashboard** / **delete_dashboard**
104
+ - **add_panel** / **update_panel** / **delete_panel** / **move_panel** for incremental panel changes
105
+
106
+ Panel types:
107
+ - **stat** — KPI card. config: statType (count|sum|average|min|max|unique), column?, format, icon
108
+ - **chart** — bar|pie|doughnut|line. config: chartType, groupByColumn, valueColumn?, aggregation
109
+ - **view** — embedded table/gallery/list/kanban/calendar/gantt/timeline/document
110
+ - **embed** — iframe/youtube/vimeo/figma/loom. config: url, embedType
111
+ - **widget** — custom widget. config: widgetId, stateMapping
112
+
113
+ For **folder/database-scope** dashboards, set **panel.table_id** on each panel so the tool knows which table to read columns from. For table-scope dashboards, panels inherit the dashboard's table automatically.
114
+
115
+ Use **column NAMES** in panel configs and filters — tools translate to UUIDs. Call **get_table_schema** first to see available columns.`;
116
+ export function createServer(apiKey, baseUrl) {
117
+ const server = new McpServer({
118
+ name: 'aitables-mcp',
119
+ version: '0.1.0',
120
+ }, {
121
+ instructions: SERVER_INSTRUCTIONS,
122
+ });
123
+ const client = new AiTablesClient(apiKey, baseUrl);
124
+ registerDiscoveryTools(server, client);
125
+ registerRowTools(server, client);
126
+ registerStructureTools(server, client);
127
+ registerSearchTools(server, client);
128
+ registerCommentTools(server, client);
129
+ registerDashboardTools(server, client);
130
+ registerFolderTools(server, client);
131
+ registerViewTools(server, client);
132
+ registerHistoryTools(server, client);
133
+ registerFileTools(server, client);
134
+ return server;
135
+ }
136
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,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E,MAAM,CAAC,CAAC;IACrC,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAElC,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":""}
package/dist/setup.js ADDED
@@ -0,0 +1,128 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import * as os from 'os';
4
+ import * as readline from 'readline';
5
+ import { printLogo } from './logo.js';
6
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
7
+ const ask = (q) => new Promise((resolve) => rl.question(q, resolve));
8
+ const MCP_ENTRY = {
9
+ command: 'npx',
10
+ args: ['-y', 'aitables-mcp'],
11
+ env: { AITABLES_API_KEY: '' },
12
+ };
13
+ function getConfigTargets() {
14
+ const platform = os.platform();
15
+ const home = os.homedir();
16
+ const targets = [];
17
+ // Claude Desktop
18
+ if (platform === 'win32') {
19
+ targets.push({
20
+ name: 'Claude Desktop',
21
+ path: path.join(process.env.APPDATA || path.join(home, 'AppData', 'Roaming'), 'Claude', 'claude_desktop_config.json'),
22
+ wrapperKey: 'mcpServers',
23
+ });
24
+ }
25
+ else if (platform === 'darwin') {
26
+ targets.push({
27
+ name: 'Claude Desktop',
28
+ path: path.join(home, 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json'),
29
+ wrapperKey: 'mcpServers',
30
+ });
31
+ }
32
+ // Claude Code (global)
33
+ targets.push({
34
+ name: 'Claude Code (global)',
35
+ path: path.join(home, '.claude.json'),
36
+ wrapperKey: 'mcpServers',
37
+ });
38
+ return targets;
39
+ }
40
+ function readJsonFile(filePath) {
41
+ try {
42
+ const content = fs.readFileSync(filePath, 'utf-8');
43
+ return JSON.parse(content);
44
+ }
45
+ catch {
46
+ return {};
47
+ }
48
+ }
49
+ function writeJsonFile(filePath, data) {
50
+ const dir = path.dirname(filePath);
51
+ if (!fs.existsSync(dir)) {
52
+ fs.mkdirSync(dir, { recursive: true });
53
+ }
54
+ fs.writeFileSync(filePath, JSON.stringify(data, null, 2) + '\n', 'utf-8');
55
+ }
56
+ async function run() {
57
+ printLogo();
58
+ console.log(' This will configure Claude to access your AiTables data.');
59
+ console.log('');
60
+ // Ask for API key
61
+ console.log(' 1. Go to AiTables → open any database → menu → API Keys');
62
+ console.log(' 2. Create a new key and copy it');
63
+ console.log('');
64
+ const apiKey = (await ask(' Paste your API key (ait_user_...): ')).trim();
65
+ if (!apiKey) {
66
+ console.log('\n No API key provided. Setup cancelled.');
67
+ rl.close();
68
+ process.exit(1);
69
+ }
70
+ if (!apiKey.startsWith('ait_user_') && !apiKey.startsWith('ait_live_') && !apiKey.startsWith('ait_ent_')) {
71
+ console.log('\n Warning: Key doesn\'t look like an AiTables key (expected ait_user_*, ait_live_*, or ait_ent_*)');
72
+ const cont = (await ask(' Continue anyway? (y/n): ')).trim().toLowerCase();
73
+ if (cont !== 'y') {
74
+ rl.close();
75
+ process.exit(1);
76
+ }
77
+ }
78
+ // Detect available config targets
79
+ const targets = getConfigTargets();
80
+ console.log('');
81
+ console.log(' Where would you like to install?');
82
+ targets.forEach((t, i) => {
83
+ const exists = fs.existsSync(t.path);
84
+ console.log(` ${i + 1}. ${t.name}${exists ? '' : ' (will create config)'}`);
85
+ });
86
+ console.log(` ${targets.length + 1}. Both`);
87
+ console.log('');
88
+ const choice = (await ask(` Choose (1-${targets.length + 1}): `)).trim();
89
+ const choiceNum = parseInt(choice);
90
+ let selectedTargets;
91
+ if (choiceNum === targets.length + 1) {
92
+ selectedTargets = targets;
93
+ }
94
+ else if (choiceNum >= 1 && choiceNum <= targets.length) {
95
+ selectedTargets = [targets[choiceNum - 1]];
96
+ }
97
+ else {
98
+ console.log('\n Invalid choice. Setup cancelled.');
99
+ rl.close();
100
+ process.exit(1);
101
+ }
102
+ // Write config
103
+ const entry = { ...MCP_ENTRY, env: { AITABLES_API_KEY: apiKey } };
104
+ for (const target of selectedTargets) {
105
+ const config = readJsonFile(target.path);
106
+ if (!config[target.wrapperKey]) {
107
+ config[target.wrapperKey] = {};
108
+ }
109
+ config[target.wrapperKey].aitables = entry;
110
+ writeJsonFile(target.path, config);
111
+ console.log(` ✓ Configured ${target.name}`);
112
+ console.log(` ${target.path}`);
113
+ }
114
+ console.log('');
115
+ console.log(' ✅ Setup complete! Restart Claude to start using AiTables.');
116
+ console.log('');
117
+ console.log(' Try asking Claude:');
118
+ console.log(' "What databases do I have?"');
119
+ console.log(' "Show me the tables in my project tracker"');
120
+ console.log(' "Create a new task tracker with Status, Priority, and Due Date"');
121
+ console.log('');
122
+ rl.close();
123
+ }
124
+ run().catch((err) => {
125
+ console.error('Setup failed:', err.message);
126
+ process.exit(1);
127
+ });
128
+ //# sourceMappingURL=setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AACtF,MAAM,GAAG,GAAG,CAAC,CAAS,EAAmB,EAAE,C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OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;IAC3E,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,gDAAgD,CAAC,CAAC;IAC9D,OAAO,CAAC,GAAG,CAAC,qEAAqE,CAAC,CAAC;IACnF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAEhB,EAAE,CAAC,KAAK,EAAE,CAAC;AACb,CAAC;AAED,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAClB,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { AiTablesClient } from '../api-client.js';
3
+ export declare function registerCommentTools(server: McpServer, client: AiTablesClient): void;
4
+ //# sourceMappingURL=comments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comments.d.ts","sourceRoot":"","sources":["../../src/tools/comments.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGvD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,QAkF7E"}