@rashidazarang/airtable-mcp 1.6.0 → 2.1.1

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 (57) hide show
  1. package/README.md +1 -0
  2. package/airtable_simple_production.js +532 -0
  3. package/package.json +15 -6
  4. package/.claude/settings.local.json +0 -12
  5. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  6. package/.github/ISSUE_TEMPLATE/custom.md +0 -10
  7. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  8. package/CAPABILITY_REPORT.md +0 -118
  9. package/CLAUDE_INTEGRATION.md +0 -96
  10. package/CONTRIBUTING.md +0 -81
  11. package/DEVELOPMENT.md +0 -190
  12. package/Dockerfile +0 -39
  13. package/Dockerfile.node +0 -20
  14. package/IMPROVEMENT_PROPOSAL.md +0 -371
  15. package/INSTALLATION.md +0 -183
  16. package/ISSUE_RESPONSES.md +0 -171
  17. package/MCP_REVIEW_SUMMARY.md +0 -142
  18. package/QUICK_START.md +0 -60
  19. package/RELEASE_NOTES_v1.2.0.md +0 -50
  20. package/RELEASE_NOTES_v1.2.1.md +0 -40
  21. package/RELEASE_NOTES_v1.2.2.md +0 -48
  22. package/RELEASE_NOTES_v1.2.3.md +0 -105
  23. package/RELEASE_NOTES_v1.2.4.md +0 -60
  24. package/RELEASE_NOTES_v1.4.0.md +0 -104
  25. package/RELEASE_NOTES_v1.5.0.md +0 -185
  26. package/RELEASE_NOTES_v1.6.0.md +0 -248
  27. package/SECURITY_NOTICE.md +0 -40
  28. package/airtable-mcp-1.1.0.tgz +0 -0
  29. package/airtable_enhanced.js +0 -499
  30. package/airtable_mcp/__init__.py +0 -5
  31. package/airtable_mcp/src/server.py +0 -329
  32. package/airtable_simple_v1.2.4_backup.js +0 -277
  33. package/airtable_v1.4.0.js +0 -654
  34. package/cleanup.sh +0 -71
  35. package/index.js +0 -179
  36. package/inspector.py +0 -148
  37. package/inspector_server.py +0 -337
  38. package/publish-steps.txt +0 -27
  39. package/quick_test.sh +0 -30
  40. package/rashidazarang-airtable-mcp-1.1.0.tgz +0 -0
  41. package/rashidazarang-airtable-mcp-1.2.0.tgz +0 -0
  42. package/rashidazarang-airtable-mcp-1.2.1.tgz +0 -0
  43. package/requirements.txt +0 -10
  44. package/setup.py +0 -29
  45. package/simple_airtable_server.py +0 -151
  46. package/smithery.yaml +0 -45
  47. package/test_all_features.sh +0 -146
  48. package/test_all_operations.sh +0 -120
  49. package/test_client.py +0 -70
  50. package/test_enhanced_features.js +0 -389
  51. package/test_mcp_comprehensive.js +0 -163
  52. package/test_mock_server.js +0 -180
  53. package/test_v1.4.0_final.sh +0 -131
  54. package/test_v1.5.0_comprehensive.sh +0 -96
  55. package/test_v1.5.0_final.sh +0 -224
  56. package/test_v1.6.0_comprehensive.sh +0 -187
  57. package/test_webhooks.sh +0 -105
@@ -1,654 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const http = require('http');
4
- const https = require('https');
5
- const fs = require('fs');
6
- const path = require('path');
7
-
8
- // Load environment variables from .env file if it exists
9
- const envPath = path.join(__dirname, '.env');
10
- if (fs.existsSync(envPath)) {
11
- require('dotenv').config({ path: envPath });
12
- }
13
-
14
- // Parse command line arguments with environment variable fallback
15
- const args = process.argv.slice(2);
16
- let tokenIndex = args.indexOf('--token');
17
- let baseIndex = args.indexOf('--base');
18
-
19
- // Use environment variables as fallback
20
- const token = tokenIndex !== -1 ? args[tokenIndex + 1] : process.env.AIRTABLE_TOKEN || process.env.AIRTABLE_API_TOKEN;
21
- const baseId = baseIndex !== -1 ? args[baseIndex + 1] : process.env.AIRTABLE_BASE_ID || process.env.AIRTABLE_BASE;
22
-
23
- if (!token || !baseId) {
24
- console.error('Error: Missing Airtable credentials');
25
- console.error('\nUsage options:');
26
- console.error(' 1. Command line: node airtable_enhanced.js --token YOUR_TOKEN --base YOUR_BASE_ID');
27
- console.error(' 2. Environment variables: AIRTABLE_TOKEN and AIRTABLE_BASE_ID');
28
- console.error(' 3. .env file with AIRTABLE_TOKEN and AIRTABLE_BASE_ID');
29
- process.exit(1);
30
- }
31
-
32
- // Configure logging levels
33
- const LOG_LEVELS = {
34
- ERROR: 0,
35
- WARN: 1,
36
- INFO: 2,
37
- DEBUG: 3
38
- };
39
-
40
- const currentLogLevel = process.env.LOG_LEVEL ? LOG_LEVELS[process.env.LOG_LEVEL.toUpperCase()] || LOG_LEVELS.INFO : LOG_LEVELS.INFO;
41
-
42
- function log(level, message, ...args) {
43
- const levelName = Object.keys(LOG_LEVELS).find(key => LOG_LEVELS[key] === level);
44
- const timestamp = new Date().toISOString();
45
-
46
- if (level <= currentLogLevel) {
47
- const prefix = `[${timestamp}] [${levelName}]`;
48
- if (level === LOG_LEVELS.ERROR) {
49
- console.error(prefix, message, ...args);
50
- } else if (level === LOG_LEVELS.WARN) {
51
- console.warn(prefix, message, ...args);
52
- } else {
53
- console.log(prefix, message, ...args);
54
- }
55
- }
56
- }
57
-
58
- log(LOG_LEVELS.INFO, `Starting Enhanced Airtable MCP server v1.4.0`);
59
- log(LOG_LEVELS.INFO, `Token: ${token.slice(0, 5)}...${token.slice(-5)}`);
60
- log(LOG_LEVELS.INFO, `Base ID: ${baseId}`);
61
-
62
- // Enhanced Airtable API function with full HTTP method support
63
- function callAirtableAPI(endpoint, method = 'GET', body = null, queryParams = {}) {
64
- return new Promise((resolve, reject) => {
65
- const isBaseEndpoint = !endpoint.startsWith('meta/');
66
- const baseUrl = isBaseEndpoint ? `${baseId}/${endpoint}` : endpoint;
67
-
68
- // Build query string
69
- const queryString = Object.keys(queryParams).length > 0
70
- ? '?' + new URLSearchParams(queryParams).toString()
71
- : '';
72
-
73
- const url = `https://api.airtable.com/v0/${baseUrl}${queryString}`;
74
- const urlObj = new URL(url);
75
-
76
- log(LOG_LEVELS.DEBUG, `API Request: ${method} ${url}`);
77
- if (body) {
78
- log(LOG_LEVELS.DEBUG, `Request body:`, JSON.stringify(body, null, 2));
79
- }
80
-
81
- const options = {
82
- hostname: urlObj.hostname,
83
- path: urlObj.pathname + urlObj.search,
84
- method: method,
85
- headers: {
86
- 'Authorization': `Bearer ${token}`,
87
- 'Content-Type': 'application/json'
88
- }
89
- };
90
-
91
- const req = https.request(options, (response) => {
92
- let data = '';
93
-
94
- response.on('data', (chunk) => {
95
- data += chunk;
96
- });
97
-
98
- response.on('end', () => {
99
- log(LOG_LEVELS.DEBUG, `Response status: ${response.statusCode}`);
100
- log(LOG_LEVELS.DEBUG, `Response data:`, data);
101
-
102
- try {
103
- const parsed = data ? JSON.parse(data) : {};
104
-
105
- if (response.statusCode >= 200 && response.statusCode < 300) {
106
- resolve(parsed);
107
- } else {
108
- const error = parsed.error || {};
109
- reject(new Error(`Airtable API error (${response.statusCode}): ${error.message || error.type || 'Unknown error'}`));
110
- }
111
- } catch (e) {
112
- reject(new Error(`Failed to parse Airtable response: ${e.message}`));
113
- }
114
- });
115
- });
116
-
117
- req.on('error', (error) => {
118
- reject(new Error(`Airtable API request failed: ${error.message}`));
119
- });
120
-
121
- if (body) {
122
- req.write(JSON.stringify(body));
123
- }
124
-
125
- req.end();
126
- });
127
- }
128
-
129
- // Create HTTP server
130
- const server = http.createServer(async (req, res) => {
131
- // Enable CORS
132
- res.setHeader('Access-Control-Allow-Origin', '*');
133
- res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS');
134
- res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
135
-
136
- // Handle preflight request
137
- if (req.method === 'OPTIONS') {
138
- res.writeHead(200);
139
- res.end();
140
- return;
141
- }
142
-
143
- // Only handle POST requests to /mcp
144
- if (req.method !== 'POST' || !req.url.endsWith('/mcp')) {
145
- res.writeHead(404);
146
- res.end();
147
- return;
148
- }
149
-
150
- let body = '';
151
- req.on('data', chunk => {
152
- body += chunk.toString();
153
- });
154
-
155
- req.on('end', async () => {
156
- try {
157
- const request = JSON.parse(body);
158
- log(LOG_LEVELS.DEBUG, 'Received request:', JSON.stringify(request, null, 2));
159
-
160
- // Handle JSON-RPC methods
161
- if (request.method === 'tools/list') {
162
- const response = {
163
- jsonrpc: '2.0',
164
- id: request.id,
165
- result: {
166
- tools: [
167
- {
168
- name: 'list_tables',
169
- description: 'List all tables in the Airtable base',
170
- inputSchema: {
171
- type: 'object',
172
- properties: {}
173
- }
174
- },
175
- {
176
- name: 'list_records',
177
- description: 'List records from a specific table',
178
- inputSchema: {
179
- type: 'object',
180
- properties: {
181
- table: { type: 'string', description: 'Table name or ID' },
182
- maxRecords: { type: 'number', description: 'Maximum number of records to return' },
183
- view: { type: 'string', description: 'View name or ID' }
184
- },
185
- required: ['table']
186
- }
187
- },
188
- {
189
- name: 'get_record',
190
- description: 'Get a single record by ID',
191
- inputSchema: {
192
- type: 'object',
193
- properties: {
194
- table: { type: 'string', description: 'Table name or ID' },
195
- recordId: { type: 'string', description: 'Record ID' }
196
- },
197
- required: ['table', 'recordId']
198
- }
199
- },
200
- {
201
- name: 'create_record',
202
- description: 'Create a new record in a table',
203
- inputSchema: {
204
- type: 'object',
205
- properties: {
206
- table: { type: 'string', description: 'Table name or ID' },
207
- fields: { type: 'object', description: 'Field values for the new record' }
208
- },
209
- required: ['table', 'fields']
210
- }
211
- },
212
- {
213
- name: 'update_record',
214
- description: 'Update an existing record',
215
- inputSchema: {
216
- type: 'object',
217
- properties: {
218
- table: { type: 'string', description: 'Table name or ID' },
219
- recordId: { type: 'string', description: 'Record ID to update' },
220
- fields: { type: 'object', description: 'Fields to update' }
221
- },
222
- required: ['table', 'recordId', 'fields']
223
- }
224
- },
225
- {
226
- name: 'delete_record',
227
- description: 'Delete a record from a table',
228
- inputSchema: {
229
- type: 'object',
230
- properties: {
231
- table: { type: 'string', description: 'Table name or ID' },
232
- recordId: { type: 'string', description: 'Record ID to delete' }
233
- },
234
- required: ['table', 'recordId']
235
- }
236
- },
237
- {
238
- name: 'search_records',
239
- description: 'Search records with filtering and sorting',
240
- inputSchema: {
241
- type: 'object',
242
- properties: {
243
- table: { type: 'string', description: 'Table name or ID' },
244
- filterByFormula: { type: 'string', description: 'Airtable formula to filter records' },
245
- sort: { type: 'array', description: 'Sort configuration' },
246
- maxRecords: { type: 'number', description: 'Maximum records to return' },
247
- fields: { type: 'array', description: 'Fields to return' }
248
- },
249
- required: ['table']
250
- }
251
- },
252
- {
253
- name: 'list_webhooks',
254
- description: 'List all webhooks for the base',
255
- inputSchema: {
256
- type: 'object',
257
- properties: {}
258
- }
259
- },
260
- {
261
- name: 'create_webhook',
262
- description: 'Create a new webhook for a table',
263
- inputSchema: {
264
- type: 'object',
265
- properties: {
266
- notificationUrl: { type: 'string', description: 'URL to receive webhook notifications' },
267
- specification: {
268
- type: 'object',
269
- description: 'Webhook specification',
270
- properties: {
271
- options: {
272
- type: 'object',
273
- properties: {
274
- filters: {
275
- type: 'object',
276
- properties: {
277
- dataTypes: { type: 'array', items: { type: 'string' } },
278
- recordChangeScope: { type: 'string' }
279
- }
280
- }
281
- }
282
- }
283
- }
284
- }
285
- },
286
- required: ['notificationUrl']
287
- }
288
- },
289
- {
290
- name: 'delete_webhook',
291
- description: 'Delete a webhook',
292
- inputSchema: {
293
- type: 'object',
294
- properties: {
295
- webhookId: { type: 'string', description: 'Webhook ID to delete' }
296
- },
297
- required: ['webhookId']
298
- }
299
- },
300
- {
301
- name: 'get_webhook_payloads',
302
- description: 'Get webhook payload history',
303
- inputSchema: {
304
- type: 'object',
305
- properties: {
306
- webhookId: { type: 'string', description: 'Webhook ID' },
307
- cursor: { type: 'number', description: 'Cursor for pagination' }
308
- },
309
- required: ['webhookId']
310
- }
311
- },
312
- {
313
- name: 'refresh_webhook',
314
- description: 'Refresh a webhook to extend its expiration',
315
- inputSchema: {
316
- type: 'object',
317
- properties: {
318
- webhookId: { type: 'string', description: 'Webhook ID to refresh' }
319
- },
320
- required: ['webhookId']
321
- }
322
- }
323
- ]
324
- }
325
- };
326
- res.writeHead(200, { 'Content-Type': 'application/json' });
327
- res.end(JSON.stringify(response));
328
- return;
329
- }
330
-
331
- if (request.method === 'resources/list') {
332
- const response = {
333
- jsonrpc: '2.0',
334
- id: request.id,
335
- result: {
336
- resources: [
337
- {
338
- id: 'airtable_tables',
339
- name: 'Airtable Tables',
340
- description: 'Tables in your Airtable base'
341
- }
342
- ]
343
- }
344
- };
345
- res.writeHead(200, { 'Content-Type': 'application/json' });
346
- res.end(JSON.stringify(response));
347
- return;
348
- }
349
-
350
- if (request.method === 'prompts/list') {
351
- const response = {
352
- jsonrpc: '2.0',
353
- id: request.id,
354
- result: {
355
- prompts: [
356
- {
357
- id: 'tables_prompt',
358
- name: 'List Tables',
359
- description: 'List all tables'
360
- }
361
- ]
362
- }
363
- };
364
- res.writeHead(200, { 'Content-Type': 'application/json' });
365
- res.end(JSON.stringify(response));
366
- return;
367
- }
368
-
369
- // Handle tool calls
370
- if (request.method === 'tools/call') {
371
- const toolName = request.params.name;
372
- const toolParams = request.params.arguments || {};
373
-
374
- let result;
375
- let responseText;
376
-
377
- try {
378
- // LIST TABLES
379
- if (toolName === 'list_tables') {
380
- result = await callAirtableAPI(`meta/bases/${baseId}/tables`);
381
- const tables = result.tables || [];
382
-
383
- responseText = tables.length > 0
384
- ? `Found ${tables.length} table(s):\n` + tables.map((table, i) =>
385
- `${i+1}. ${table.name} (ID: ${table.id}, Fields: ${table.fields?.length || 0})`
386
- ).join('\n')
387
- : 'No tables found in this base.';
388
- }
389
-
390
- // LIST RECORDS
391
- else if (toolName === 'list_records') {
392
- const { table, maxRecords, view } = toolParams;
393
-
394
- const queryParams = {};
395
- if (maxRecords) queryParams.maxRecords = maxRecords;
396
- if (view) queryParams.view = view;
397
-
398
- result = await callAirtableAPI(`${table}`, 'GET', null, queryParams);
399
- const records = result.records || [];
400
-
401
- responseText = records.length > 0
402
- ? `Found ${records.length} record(s) in table "${table}":\n` +
403
- records.map((record, i) =>
404
- `${i+1}. ID: ${record.id}\n Fields: ${JSON.stringify(record.fields, null, 2)}`
405
- ).join('\n\n')
406
- : `No records found in table "${table}".`;
407
- }
408
-
409
- // GET SINGLE RECORD
410
- else if (toolName === 'get_record') {
411
- const { table, recordId } = toolParams;
412
-
413
- result = await callAirtableAPI(`${table}/${recordId}`);
414
-
415
- responseText = `Record ${recordId} from table "${table}":\n` +
416
- JSON.stringify(result.fields, null, 2) +
417
- `\n\nCreated: ${result.createdTime}`;
418
- }
419
-
420
- // CREATE RECORD
421
- else if (toolName === 'create_record') {
422
- const { table, fields } = toolParams;
423
-
424
- const body = {
425
- fields: fields
426
- };
427
-
428
- result = await callAirtableAPI(table, 'POST', body);
429
-
430
- responseText = `Successfully created record in table "${table}":\n` +
431
- `Record ID: ${result.id}\n` +
432
- `Fields: ${JSON.stringify(result.fields, null, 2)}\n` +
433
- `Created at: ${result.createdTime}`;
434
- }
435
-
436
- // UPDATE RECORD
437
- else if (toolName === 'update_record') {
438
- const { table, recordId, fields } = toolParams;
439
-
440
- const body = {
441
- fields: fields
442
- };
443
-
444
- result = await callAirtableAPI(`${table}/${recordId}`, 'PATCH', body);
445
-
446
- responseText = `Successfully updated record ${recordId} in table "${table}":\n` +
447
- `Updated fields: ${JSON.stringify(result.fields, null, 2)}`;
448
- }
449
-
450
- // DELETE RECORD
451
- else if (toolName === 'delete_record') {
452
- const { table, recordId } = toolParams;
453
-
454
- result = await callAirtableAPI(`${table}/${recordId}`, 'DELETE');
455
-
456
- responseText = `Successfully deleted record ${recordId} from table "${table}".\n` +
457
- `Deleted record ID: ${result.id}\n` +
458
- `Deleted: ${result.deleted}`;
459
- }
460
-
461
- // SEARCH RECORDS
462
- else if (toolName === 'search_records') {
463
- const { table, filterByFormula, sort, maxRecords, fields } = toolParams;
464
-
465
- const queryParams = {};
466
- if (filterByFormula) queryParams.filterByFormula = filterByFormula;
467
- if (maxRecords) queryParams.maxRecords = maxRecords;
468
- if (fields && fields.length > 0) queryParams.fields = fields;
469
- if (sort && sort.length > 0) {
470
- sort.forEach((s, i) => {
471
- queryParams[`sort[${i}][field]`] = s.field;
472
- queryParams[`sort[${i}][direction]`] = s.direction || 'asc';
473
- });
474
- }
475
-
476
- result = await callAirtableAPI(table, 'GET', null, queryParams);
477
- const records = result.records || [];
478
-
479
- responseText = records.length > 0
480
- ? `Found ${records.length} matching record(s) in table "${table}":\n` +
481
- records.map((record, i) =>
482
- `${i+1}. ID: ${record.id}\n Fields: ${JSON.stringify(record.fields, null, 2)}`
483
- ).join('\n\n')
484
- : `No records found matching the search criteria in table "${table}".`;
485
- }
486
-
487
- // LIST WEBHOOKS
488
- else if (toolName === 'list_webhooks') {
489
- result = await callAirtableAPI(`bases/${baseId}/webhooks`, 'GET');
490
- const webhooks = result.webhooks || [];
491
-
492
- responseText = webhooks.length > 0
493
- ? `Found ${webhooks.length} webhook(s):\n` +
494
- webhooks.map((webhook, i) =>
495
- `${i+1}. ID: ${webhook.id}\n` +
496
- ` URL: ${webhook.notificationUrl}\n` +
497
- ` Active: ${webhook.isHookEnabled}\n` +
498
- ` Created: ${webhook.createdTime}\n` +
499
- ` Expires: ${webhook.expirationTime}`
500
- ).join('\n\n')
501
- : 'No webhooks configured for this base.';
502
- }
503
-
504
- // CREATE WEBHOOK
505
- else if (toolName === 'create_webhook') {
506
- const { notificationUrl, specification } = toolParams;
507
-
508
- const body = {
509
- notificationUrl: notificationUrl,
510
- specification: specification || {
511
- options: {
512
- filters: {
513
- dataTypes: ['tableData'],
514
- recordChangeScope: baseId
515
- }
516
- }
517
- }
518
- };
519
-
520
- result = await callAirtableAPI(`bases/${baseId}/webhooks`, 'POST', body);
521
-
522
- responseText = `Successfully created webhook:\n` +
523
- `Webhook ID: ${result.id}\n` +
524
- `URL: ${result.notificationUrl}\n` +
525
- `MAC Secret: ${result.macSecretBase64}\n` +
526
- `Expiration: ${result.expirationTime}\n` +
527
- `Cursor: ${result.cursorForNextPayload}\n\n` +
528
- `⚠️ IMPORTANT: Save the MAC secret - it won't be shown again!`;
529
- }
530
-
531
- // DELETE WEBHOOK
532
- else if (toolName === 'delete_webhook') {
533
- const { webhookId } = toolParams;
534
-
535
- await callAirtableAPI(`bases/${baseId}/webhooks/${webhookId}`, 'DELETE');
536
-
537
- responseText = `Successfully deleted webhook ${webhookId}`;
538
- }
539
-
540
- // GET WEBHOOK PAYLOADS
541
- else if (toolName === 'get_webhook_payloads') {
542
- const { webhookId, cursor } = toolParams;
543
-
544
- const queryParams = {};
545
- if (cursor) queryParams.cursor = cursor;
546
-
547
- result = await callAirtableAPI(`bases/${baseId}/webhooks/${webhookId}/payloads`, 'GET', null, queryParams);
548
-
549
- const payloads = result.payloads || [];
550
- responseText = payloads.length > 0
551
- ? `Found ${payloads.length} webhook payload(s):\n` +
552
- payloads.map((payload, i) =>
553
- `${i+1}. Timestamp: ${payload.timestamp}\n` +
554
- ` Base/Table: ${payload.baseTransactionNumber}\n` +
555
- ` Change Types: ${JSON.stringify(payload.changePayload?.changedTablesById || {})}`
556
- ).join('\n\n') +
557
- (result.cursor ? `\n\nNext cursor: ${result.cursor}` : '')
558
- : 'No payloads found for this webhook.';
559
- }
560
-
561
- // REFRESH WEBHOOK
562
- else if (toolName === 'refresh_webhook') {
563
- const { webhookId } = toolParams;
564
-
565
- result = await callAirtableAPI(`bases/${baseId}/webhooks/${webhookId}/refresh`, 'POST');
566
-
567
- responseText = `Successfully refreshed webhook ${webhookId}:\n` +
568
- `New expiration: ${result.expirationTime}`;
569
- }
570
-
571
- else {
572
- throw new Error(`Unknown tool: ${toolName}`);
573
- }
574
-
575
- const response = {
576
- jsonrpc: '2.0',
577
- id: request.id,
578
- result: {
579
- content: [
580
- {
581
- type: 'text',
582
- text: responseText
583
- }
584
- ]
585
- }
586
- };
587
- res.writeHead(200, { 'Content-Type': 'application/json' });
588
- res.end(JSON.stringify(response));
589
-
590
- } catch (error) {
591
- log(LOG_LEVELS.ERROR, `Tool ${toolName} error:`, error.message);
592
-
593
- const response = {
594
- jsonrpc: '2.0',
595
- id: request.id,
596
- result: {
597
- content: [
598
- {
599
- type: 'text',
600
- text: `Error executing ${toolName}: ${error.message}`
601
- }
602
- ]
603
- }
604
- };
605
- res.writeHead(200, { 'Content-Type': 'application/json' });
606
- res.end(JSON.stringify(response));
607
- }
608
-
609
- return;
610
- }
611
-
612
- // Method not found
613
- const response = {
614
- jsonrpc: '2.0',
615
- id: request.id,
616
- error: {
617
- code: -32601,
618
- message: `Method ${request.method} not found`
619
- }
620
- };
621
- res.writeHead(200, { 'Content-Type': 'application/json' });
622
- res.end(JSON.stringify(response));
623
-
624
- } catch (error) {
625
- log(LOG_LEVELS.ERROR, 'Error processing request:', error);
626
- const response = {
627
- jsonrpc: '2.0',
628
- id: request.id || null,
629
- error: {
630
- code: -32000,
631
- message: error.message || 'Unknown error'
632
- }
633
- };
634
- res.writeHead(200, { 'Content-Type': 'application/json' });
635
- res.end(JSON.stringify(response));
636
- }
637
- });
638
- });
639
-
640
- // Start server
641
- const PORT = process.env.PORT || 8010;
642
- server.listen(PORT, () => {
643
- log(LOG_LEVELS.INFO, `Enhanced Airtable MCP server v1.4.0 running at http://localhost:${PORT}/mcp`);
644
- console.log(`For Claude, use this URL: http://localhost:${PORT}/mcp`);
645
- });
646
-
647
- // Graceful shutdown
648
- process.on('SIGINT', () => {
649
- log(LOG_LEVELS.INFO, 'Shutting down server...');
650
- server.close(() => {
651
- log(LOG_LEVELS.INFO, 'Server stopped');
652
- process.exit(0);
653
- });
654
- });