From 91c46a0ff1504ef4916239140722864ebce7901b Mon Sep 17 00:00:00 2001 From: Adam Jones Date: Mon, 3 Feb 2025 21:56:45 +0000 Subject: [PATCH] feat: Prefer environment variable to command line Easier to standardise configuration and tool setup this way --- README.md | 8 +++++--- src/airtableService.ts | 2 +- src/index.ts | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1bb04ec..2388412 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,11 @@ To use this server with the Claude Desktop app, add the following configuration "command": "npx", "args": [ "-y", - "airtable-mcp-server", - "pat123.abc123" - ] + "airtable-mcp-server" + ], + "env": { + "AIRTABLE_API_KEY": "pat123.abc123" + } } } } diff --git a/src/airtableService.ts b/src/airtableService.ts index 637e03a..bdbc612 100644 --- a/src/airtableService.ts +++ b/src/airtableService.ts @@ -28,7 +28,7 @@ export class AirtableService implements IAirtableService { fetch: typeof nodeFetch = nodeFetch, ) { if (!apiKey) { - throw new Error('No API key set. Either:\n1. Pass it in as a command-line argument, for example `airtable-mcp-server `\n2. Set it in the `AIRTABLE_API_KEY` environment variable'); + throw new Error('airtable-mcp-server: No API key provided. Set it in the `AIRTABLE_API_KEY` environment variable'); } this.apiKey = apiKey; diff --git a/src/index.ts b/src/index.ts index 3f2b20f..be29c43 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,6 +6,10 @@ import { AirtableMCPServer } from './mcpServer.js'; const main = async () => { const apiKey = process.argv.slice(2)[0]; + if (apiKey) { + // Deprecation warning + console.warn('warning (airtable-mcp-server): Passing in an API key as a command-line argument is deprecated and may be removed in a future version. Instead, set the `AIRTABLE_API_KEY` environment variable. See https://github.com/domdomegg/airtable-mcp-server/blob/master/README.md#usage for an example with Claude Desktop.'); + } const airtableService = new AirtableService(apiKey); const server = new AirtableMCPServer(airtableService); const transport = new StdioServerTransport();