Skip to content

Commit

Permalink
feat: Prefer environment variable to command line
Browse files Browse the repository at this point in the history
Easier to standardise configuration and tool setup this way
  • Loading branch information
domdomegg committed Feb 3, 2025
1 parent 08a87ca commit 91c46a0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/airtableService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <API_KEY>`\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;
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.');

Check warning on line 11 in src/index.ts

View workflow job for this annotation

GitHub Actions / ci (lts/*)

Unexpected console statement

Check warning on line 11 in src/index.ts

View workflow job for this annotation

GitHub Actions / ci (current)

Unexpected console statement
}
const airtableService = new AirtableService(apiKey);
const server = new AirtableMCPServer(airtableService);
const transport = new StdioServerTransport();
Expand Down

0 comments on commit 91c46a0

Please sign in to comment.