Developers are entering a new era where AI can understand context and build with you.
AI-powered editors like Cursor blur the line between development and automation, while Appwrite provides the unified backend that turns those AI-generated ideas into production-ready applications.
Together, they represent the next leap forward, where AI helps you go from idea β API β local app in minutes.
I chose to use Cursor as it's my favorite coding agent. We all have our favorite, and I'll definitely keep building with Cursor as it's just more user friendly.
In this tutorial, youβll:
- Connect Cursor to Appwrite using MCP
- Build a TanStack Start app with authentication and CRUD
- Run it locally
What is MCP and why it matters
MCP (Model Context Protocol) lets AI tools like Cursor securely connect to APIs and databases.
The Appwrite MCP server gives Cursor access to your Appwrite project so it can create tables, write code, and query real data.
π Add Appwrite MCP to Cursor
Setting up the Appwrite MCP Server
1. Create an API Key in Appwrite Cloud
- Log in to Appwrite Cloud.
- Create a new API key with the following scopes:
databases.readanddatabases.write(ortables.readandtables.write)users.readandusers.write
- Copy the key.
You can find it at Overview -> Integrations -> API keys
Note: If you encounter permission errors, you can temporarily use "all scopes" for troubleshooting, but we recommend using specific scopes for better security.
2. Copy your Project ID
Go to Project β Overview, hover over Project ID, and copy it.
3. Add the MCP Server in Cursor
In Cursor β Tools β Installed MCP Servers β Add Custom MCP:
You can specify specific routes instead of choosing --all, such as --tables, --users, --functions since having too many may degrade performance in Cursor.
| Field | Example |
Name | appwrite |
Command | uvx mcp-server-appwrite --all |
APPWRITE_ENDPOINT | https://[REGION].cloud.appwrite.io/v1 |
APPWRITE_PROJECT_ID | <YOUR_PROJECT_ID> |
APPWRITE_API_KEY | <YOUR_API_KEY> |
Make sure you update your region, project ID, and API key, which is all found in your Appwrite Console.
Click Install, then verify it appears in your MCP list.
Troubleshooting MCP
| Issue | Fix |
uvx not recognized | Install uv:<br>Windows β `irm https://astral.sh/uv/install.ps1 |
Only βusersβ endpoint visible | Use --all flag or add endpoints manually in config |
MCP not found | Open a new Cursor conversation or restart Cursor |
Building the notes app
Fully local CRUD app with Appwrite.
Preview: Here's what we'll build by the end of this tutorial.
Create a project folder
mkdir ai-notes && cd ai-notes
cursor .
Scaffold TanStack Start (SSR)
Prompt (Cursor):
Create a TanStack Start project named "ai-notes" with TypeScript and SSR.
Set up a clean src structure with routes, components, and lib folders.
Commands:
npm create tanstack@latest
Choose: Start (SSR), TypeScript
npm i
π‘ Cursor may prompt:
npm install --save-dev tsxβ that's expected for SSR dev mode.
Remove scaffolded docs + create routes
Note: TanStack Start scaffolds a demo/docs route. You'll replace it with real app routes.
Prompt (Cursor):
Remove any TanStack Start demo/docs routes. Replace them with:
- / β Landing page (redirects to /notes if logged in, else /login)
- /login β Login page
- /signup β Signup page
- /notes β Notes app (protected, requires login)
Ensure "/" never shows the TanStack Start docs page.
Create .env.local from MCP
Prompt (Cursor):
Create a .env.local file and populate:
VITE_APPWRITE_ENDPOINT and VITE_APPWRITE_PROJECT_ID
Use values from my connected Appwrite MCP server (use regional endpoint with /v1).
Example:
VITE_APPWRITE_ENDPOINT=https://nyc.cloud.appwrite.io/v1
VITE_APPWRITE_PROJECT_ID=<YOUR_PROJECT_ID>
Restart npm run dev after editing .env.local.
Configure the Appwrite SDK
Prompt (Cursor):
Install the Appwrite Web SDK as a normal dependency (not dev).
Create a client helper that reads from VITE_APPWRITE_ENDPOINT and VITE_APPWRITE_PROJECT_ID.
Commands:
npm i appwrite
Helper:
// src/lib/appwrite.ts
import { Client, Account, TablesDB, ID } from 'appwrite';
const client = new Client()
.setEndpoint(import.meta.env.VITE_APPWRITE_ENDPOINT!)
.setProject(import.meta.env.VITE_APPWRITE_PROJECT_ID!);
export const account = new Account(client);
export const tablesDB = new TablesDB(client);
export { ID };
Create Database & Table via MCP
Prompt (Cursor):
Using the Appwrite MCP server, create a database with ID "notes-db" (name it "Notes Database") and a table with ID "notes" (name it "Notes") with columns:
title, content, userId, createdAt, updatedAt.
Grant authenticated user read/write and save IDs to src/lib/config.ts.
Add Authentication (session-safe, no auto-login)
Prompt (Cursor):
Create an auth helper with session-safe login/logout. Import the account instance from ./lib/appwrite.ts (not creating a new one).
Requirements:
- login(email, password):
1. Check if a session exists; if yes, delete all sessions first.
2. Create a new email/password session.
3. If "session already active" error occurs, delete all sessions and retry once.
4. Return the current user via account.get().
- logout(): delete all sessions.
- getCurrentUser(): return account.get(); if unauthenticated, return null.
Update the /login page:
- NEVER auto-redirect away from /login. Always show the form so users can switch accounts.
- On successful login, navigate to /notes.
- Show clear errors if something fails.
Update route guards:
- /notes loader/server check: if no session, redirect to /login.
- / index loader/server check: if session β /notes, else β /login.
Helper (src/lib/auth.ts):
import { ID } from 'appwrite';
import { account } from './appwrite';
export async function getCurrentUser() {
try {
return await account.get();
} catch {
return null;
}
}
export async function deleteAllSessions() {
try {
await account.deleteSessions();
} catch {
// ignore; we might not have a session
}
}
export async function login(email: string, password: string) {
await deleteAllSessions();
try {
await account.createEmailPasswordSession(email, password);
} catch (err: any) {
const msg = err?.message?.toLowerCase() ?? '';
if (msg.includes('session') && msg.includes('active')) {
await deleteAllSessions();
await account.createEmailPasswordSession(email, password);
} else {
throw err;
}
}
return await account.get();
}
export async function signup(email: string, password: string, name?: string) {
await account.create(ID.unique(), email, password, name);
return await login(email, password);
}
export async function logout() {
await deleteAllSessions();
}
Add CRUD for notes
Prompt (Cursor):
Create a /notes route that lists, creates, updates, and deletes notes using Appwrite TablesDB API.
Include loading, error, and empty states.
Style and quality pass (Tailwind v4, accessibility)
Prompt (Cursor):
Add Tailwind CSS v4 and basic styling.
Fix any invalid utilities like focus-visible:ring-opacity-* or custom @apply utilities.
Add accessible focus styles (focus-visible:outline-none focus-visible:ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-blue-500/100).
Note: You can just add the first part "Add Tailwind CSS v4 and basic styling. I added the 2nd line in the prompt as I had issues with Tailwind utility errors I wasn't familiar with, so this prevents that issue from occurring.
Run locally
Prompt (Cursor):
Ensure npm scripts for dev, build, and preview exist.
Run npm run dev first, then npm run build && npm run preview to verify before deployment.
Commands:
npm run dev
npm run build
npm run preview
β Verify routes:
/β redirects to/notesif logged in,/loginif not/login+/signupβ show correct forms/notesβ works only when logged in- No TanStack Start docs page appears
Troubleshooting
| Issue | Fix |
/ shows TanStack docs page | Delete demo/docs routes and create /, /login, /signup, /notes manually. |
focus-visible-ring or ring-opacity-* errors | Tailwind v4 removed those utilities β use color/alpha rings instead. |
Missing .env file | Create .env.local using values from Appwrite MCP. |
401/403 errors | Verify API key scopes + table permissions. |
"Creation of a session is prohibited when a session is active." | Use session-safe login flow. Delete all sessions first, retry once if needed, and remove auto-login logic from /login. |
Still having issues?
Everyone has a different experience going through a tutorial. Luckily, with using Cursor, you can enter any errors or problems you are having, and it should fix it and adjust your code as needed.
Master prompt list
1οΈβ£ Scaffold app
Create a TanStack Start project named "ai-notes" with TypeScript and SSR.
2οΈβ£ Fix routes
Remove scaffolded docs routes. Create "/", "/login", "/signup", "/notes" with redirects using Appwrite Account API.
3οΈβ£ Appwrite SDK helper
Install appwrite SDK. Create client helper using VITE_APPWRITE_* envs.
4οΈβ£ .env file
Create a .env.local file and populate VITE_APPWRITE_ENDPOINT and VITE_APPWRITE_PROJECT_ID using values from Appwrite MCP.
5οΈβ£ Database + Table
Create database with ID "notes-db" (name it "Notes Database") and table with ID "notes" (name it "Notes") via MCP with appropriate columns and permissions.
6οΈβ£ Authentication
Add /login and /signup pages; protect /notes for logged-in users.
Ensure session-safe login logic to prevent duplicate sessions.
7οΈβ£ CRUD
Create /notes route with list, create, update, delete using Appwrite TablesDB API.
8οΈβ£ Polish
Add types, a11y checks, and Tailwind v4-safe styling.
9οΈβ£ Local test
Run npm run dev, then npm run build && npm run preview.
Verify all routes and auth logic.
If AI can handle the setup, what will you build next?



