A TypeScript server that handles Airtable requests using natural language, powered by local LLMs via LM Studio.
This server lets you interact with Airtable using plain English! Just send a message like:
- "Find all contacts with gmail addresses"
- "Create a new task called 'Learn TypeScript'"
- "Show me the 5 most recent entries"
The server uses a local LLM (via LM Studio) to understand your request and automatically calls the right Airtable operations.
This follows a modular agent pattern:
User Request → Server → Agent Selection → LLM Parsing → Airtable API → Response
- Express Server: Handles HTTP requests (like Flask in Python)
- Base Agent: Abstract class defining the agent interface
- Concrete Agents: QueryAgent, CreateAgent, etc.
- LLM Client: Communicates with LM Studio to parse requests
- Type Safety: TypeScript ensures type correctness at compile time
- Node.js (v18 or higher) - Download here
- LM Studio - Download here
- Install and start LM Studio
- Load a model (any instruct model works)
- Airtable Account - Sign up here
- Install dependencies:
npm install- Configure environment variables:
'cp .env.example .env'
- Edit
.envfile with your credentials:
- Edit
# Get Airtable API key: https://airtable.com/create/tokens
AIRTABLE_API_KEY=your_key_here
# Get Base ID from your Airtable URL
AIRTABLE_BASE_ID=appXXXXXXXXXXXXXX- Build the TypeScript code:
npm run buildnpm run devnpm run build
npm startcurl http://localhost:3000/healthcurl -X POST http://localhost:3000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "Find all records in the table"}
]
}'two different endpoints depending on structure of request: POST /v1/chat/completions (OpenAI format) POST /api/chat (Ollama format)
src/
├── server.ts # Main Express server
├── config.ts # Configuration & env variables
├── types.ts # TypeScript type definitions
├── base-agent.ts # Abstract base class for agents
├── llm-client.ts # LM Studio client
└── agents/
├── query-agent.ts # Handles search/query operations
└── create-agent.ts # Handles record creation
- Create a new file in
src/agents/ - Extend
BaseAgentclass - Implement required methods:
getName(): Agent identifiergetDescription(): What it doescanHandle(): Check if message matchesprocess(): Handle the request
- Register in
server.ts:
const agents: BaseAgent[] = [
new QueryAgent(),
new CreateAgent(),
new YourNewAgent(), // Add here!
];- Static Typing: Variables have fixed types (caught at compile time)
- Interfaces: Define the shape of objects
- Abstract Classes: Templates for other classes to implement
- Async/Await: Handle asynchronous operations (like Python)
- Generics: Type-safe reusable code
- Make sure LM Studio is running
- Check that a model is loaded
- Verify the port in
.envmatches LM Studio (default: 1234)
- Make sure you've edited
.envwith your actual credentials - Don't use quotes around the values in
.env