后端数据库【免费下载链接】instantInstant is the best backend for AI-coded apps. You get auth, permissions, storage, presence, and streams — everything you need to ship apps your users will love.项目地址https://gitcode.com/gh_mirrors/inst/instant点击查看免费下载本篇文章以 Instant 项目 2025 年 11 月官方月度更新为线索梳理当月落地的三项核心能力面向 AI Agent 的 MCP 服务器升级ad-hoc 查询、事务与完整 Schema 迁移、Explorer 数据管理增强多格式导出、列操作与误删恢复以及 Firebase Auth 登录接入。读完本文你将掌握如何用instantdb/mcp让 Agent 直接读写与管理你的 Instant 应用、如何在 Explorer 中导出数据和一键恢复误删的命名空间以及如何为已有 Firebase 项目或需要手机号登录的场景接通 Instant 认证。一、MCP 服务器升级Agent 现在可以完整管理 Instant 应用11 月的更新中instantdb/mcp从单纯的数据查询工具升级为可完整管理 Instant 应用的 Agent 入口新增了对ad-hoc 查询临时查询、事务写入transactions和完整 Schema 迁移的支持。这意味着接入 MCP 的编码助手如 Claude Code不仅能读数据还能改数据、改权限、做结构迁移。1.1 工具清单从源码看 MCP 实际暴露的能力从 MCP 工具注册源码 可以看到registerTools一共注册了 7 个工具工具名作用对应底层能力learn无上下文时获取 InstantDB 的使用规则AGENTS.md引导 Agent 阅读规则文件get-schema拉取指定 app 的 Schema 到本地instant.schema.ts通过instant-cli pull schema --app appId --yesget-perms拉取指定 app 的权限配置到本地instant.perms.ts通过instant-cli pull perms --app appId --yespush-schema把本地 Schema 改动推送到服务端通过instant-cli push schema --app appId --yespush-perms把本地权限改动推送到服务端通过instant-cli push perms --app appId --yesquery对 app 执行 InstaQL 查询并返回 JSON底层调用POST /admin/querytransact对 app 执行事务增、改、删、关联底层调用POST /admin/transact其中query和transact是本次更新新增的 ad-hoc 读写能力它们在 tools.ts 中的实现非常直白构造一个携带Authorization: Bearer token与App-Id请求头的 fetch 请求把 InstaQL 查询对象或事务步骤数组 POST 给管理 API并把结果以 JSON 文本返回给 Agent。整个调用还包了一层api.withRetry失败时会把错误信息写进工具的isError字段方便 Agent 感知并自我纠正。1.2 query一条示例看懂 InstaQL 查询query工具接受appId与一个 InstaQL 查询对象。源码中给出了两个示例获取所有 goals 及其关联的 todos{goals: {todos: {}}}带where条件过滤{goals: {$: {where: {status: active}}, todos: {}}}对于不确定如何写查询的 Agent工具描述会引导其查阅 InstaQL 文档。1.3 transact事务步骤的内部格式transact工具使用 Instant 内部的事务步骤格式共四类操作创建 / 更新[update, namespace, entity-id, {attr: value}]关联[link, namespace, entity-id, {linkAttr: target-id}]取消关联[unlink, namespace, entity-id, {linkAttr: target-id}]删除[delete, namespace, entity-id]例如创建一个待办事项[[update, todos, a-uuid, {title: Get fit, done: false}]]1.4 push-schema迁移时如何声明字段重命名push-schema的说明里特别强调了迁移语义默认情况下相比旧 Schema新增的字段被视为新增additions缺失的字段被视为删除deletions。如果你需要重命名字段必须显式用--rename声明否则会被当作删除旧字段 新增新字段处理npx instant-cli push schema --app appId \ --rename posts.author:posts.creator stores.owner:stores.manager --yes同样地get-schema/get-perms与push-schema/push-perms都带--yes标志以跳过确认提示这是为无人值守的 Agent 场景设计的。1.5 如何接入stdio 本地运行与远程端点MCP 服务器支持两种部署形态见 MCP README本地 stdio 模式先从 Instant Dashboard 获取 Personal Access Token然后运行npx -y instantdb/mcp --token token远程服务器Instant 官方托管在https://mcp.instantdb.com支持流式 HTTP 的现代客户端连/mcp旧客户端连/sse。从 服务端入口 可以看出stdio 模式通过--token参数或INSTANT_ACCESS_TOKEN环境变量读取访问令牌二者都缺失时直接报错退出而在 HTTP 模式下SERVER_TYPEhttp服务通过 OAuth 授权码流程换取令牌并用wrapServerWithTracing为每个工具调用注入 OpenTelemetry 追踪方便排查 Agent 的每次操作。二、LLM 规则更新统一规则文件与模型基准此前 Instant 为 Next.js 和 Expo 分别维护平台专属的 LLM 规则并为每个平台附带一个完整示例应用以获得最佳效果。本次更新对 CLI 工具、提示信息和规则文件做了统一梳理规则文件被集中管理相关生成脚本也保留在仓库中见 gen-llm-rules.ts 与开发规则说明 dev-llm-rules.md。这些规则的实际用途是让不同编码模型Codex、Claude Code、Gemini 等在编写 Instant 应用时遵循一致的数据建模、权限与事务写法。Instant 团队用这套规则构建了多版本的 Counter Strike 示例并在博客中对比了不同模型的表现相关文章见 gpt_52_on_the_counterstrike_benchmark后续又补充了 GPT 5.2 的对比结果。对开发者而言这意味着无论用哪个模型接入 MCP 后 Agent 都会先通过learn工具读取规则再按统一约定操作你的数据。三、Explorer 与沙箱更新导出、列操作与误删恢复11 月的另一大块更新集中在 Dashboard 的 Explorer数据浏览器上目标是把和你的数据打交道这件事做得更顺手。3.1 数据导出CSV / Markdown / JSON现在你可以把 Explorer 中的数据一键导出为 CSV、Markdown 或 JSON。底层实现在 inner-explorer.tsxCSV 导出使用export-to-csv库生成并触发浏览器下载Markdown 导出则用markdown-table把表头与数据拼成 Markdown 表格既可直接下载.md文件也可复制到剪贴板。JSON 导出同理走下载逻辑。三种格式覆盖了喂给表格软件、贴进文档、交给程序处理三类常见需求。3.2 列操作与偏好持久化Explorer 表格还支持拖拽调整列顺序drag to re-order拖拽调整列宽drag to re-size双击自动适配列宽click to auto-resize所有布局偏好刷新后自动保留这些交互改进让 Explorer 更像一个趁手的数据工作台而不是只读查看器。3.3 一键恢复误删的命名空间更新中最实用的一项如果开发者或 Agent 不小心删掉了一整张表namespace现在可以一键恢复。相关实现位于 recently-deleted.tsx。从源码可以梳理出这套软删除 恢复机制的关键细节数据来源useRecentlyDeletedAttrs会请求GET /dash/apps/appId/soft_deleted_attrs返回被软删除的属性列表以及grace-period-days宽限期天数默认 2 天。分组逻辑useRecentlyDeletedNamespaces按forward-identity中类型为id的属性把同一命名空间下的列归组恢复时把该组所有属性一次性找回。恢复操作点击 Restore 后通过db.core._reactor.pushOps([[restore-attr, attrId]])逐属性推送恢复指令。宽限期每个命名空间展示删除时间与过期倒计时宽限期默认 2 天内可恢复。约束降级提示恢复时如果原属性带索引indexed或必填required约束会提示Index and required constraints were dropped after restoring即恢复后这些约束不会自动带回来需要你手动重新声明。如果你的删除目标是单个属性而不是整表Explorer 同样在命名空间内部提供 Recently Deleted 区域按属性恢复并且当重名冲突record-not-unique时会明确提示先重命名现有属性再恢复。四、Firebase Auth接入已有 Firebase 项目或启用手机号登录Instant 新增了对 Firebase Auth 的委托认证支持。除了服务端登录验证它还解决了 Instant 原生不支持的一个场景在 Instant 项目里使用手机号登录Firebase 提供手机号验证能力Instant 负责后续的会话管理。4.1 第一步获取 Firebase Project ID在 Firebase 控制台打开你的项目进入Project Overview⚙Project Settings复制Project ID。4.2 第二步把 Firebase 客户端注册到 Instant app方式一Dashboard在 Instant Dashboard 的 Auth 标签页用刚复制的 Project ID 添加一个新的 Firebase client。方式二CLInpx instant-clilatest auth client add \ --type firebase --name firebase --project-id project-id从 CLI 实现 可以确认firebase与google、github、apple、linkedin、clerk并列是auth client add支持的内置客户端类型之一。该命令会做两件事校验 Project ID 格式。校验正则位于 shared.ts/^[a-z][a-z0-9-]{4,28}[a-z0-9]$/即 6~30 个字符、小写字母开头、只含小写字母/数字/连字符、且不以连字符结尾。以 Firebase 的 OIDC discovery 端点注册客户端https://securetoken.google.com/project-id/.well-known/openid-configuration见firebaseDiscoveryEndpoint。4.3 第三步前端接入注册完成后在你的应用里做三件事用 Firebase SDK 登录拿到 JWT调用 Instant 的db.auth.signInWithIdToken把 JWT 交给 Instant登出时调用db.auth.signOut。signInWithIdToken的验证流程是Instant 校验该 JWT 确实由你的 Firebase 应用签发然后使用 JWT claims 中的 email 查找已有用户或创建新用户并建立长期会话。完整示例React摘自 Firebase Auth 文档use client; import { init } from instantdb/react; import { initializeApp } from firebase/app; import { getAuth, signInWithEmailAndPassword, createUserWithEmailAndPassword, onAuthStateChanged, } from firebase/auth; import { useEffect, useState } from react; // Instant app const APP_ID __APP_ID__; const db init({ appId: APP_ID }); // Use the firebase client name you set in the Instant dashboard auth tab const FIREBASE_CLIENT_NAME REPLACE_ME; const firebaseConfig { // Use the same Project ID you set in the Instant dashboard auth tab projectId: REPLACE_ME, apiKey: REPLACE_ME, }; const firebaseApp initializeApp(firebaseConfig); const firebaseAuth getAuth(firebaseApp); function App() { const [email, setEmail] useState(); const [password, setPassword] useState(); useEffect(() { const unsubscribe onAuthStateChanged(firebaseAuth, (user) { if (user) { user.getIdToken().then((idToken) { db.auth.signInWithIdToken({ idToken, clientName: FIREBASE_CLIENT_NAME, }); }); } else { db.auth.signOut(); } }); return () unsubscribe(); }, []); const handleSignIn async (e) { e.preventDefault(); try { await signInWithEmailAndPassword(firebaseAuth, email, password); } catch (error) { console.error(Sign in error:, error); } }; const handleSignUp async (e) { e.preventDefault(); try { await createUserWithEmailAndPassword(firebaseAuth, email, password); } catch (error) { console.error(Sign up error:, error); } }; return ( db.SignedOut form onSubmit{handleSignIn} input typeemail placeholderEmail value{email} onChange{(e) setEmail(e.target.value)} / input typepassword placeholderPassword value{password} onChange{(e) setPassword(e.target.value)} / button typesubmitSign In/button button typebutton onClick{handleSignUp} Sign Up /button /form /db.SignedOut db.SignedIn SignedInComponent / /db.SignedIn / ); } function SignedInComponent() { const user db.useUser(); const handleSignOut async () { await firebaseAuth.signOut(); }; return ( div divSigned in as {user.email}!/div button onClick{handleSignOut}Sign Out/button /div ); } export default App;代码中有两个REPLACE_ME需要替换FIREBASE_CLIENT_NAME即你在 Instant Dashboard Auth 页设置的 Firebase 客户端名称和firebaseConfig中的projectId/apiKey与注册时使用同一个 Project ID。若改用手机号登录把signInWithEmailAndPassword换成 Firebase 的手机号验证流程即可后续getIdToken与signInWithIdToken的衔接完全一致。五、Examples 页面常见应用类型的开箱示例本次更新还新增了 Examples 页面集中演示如何用 queries、transactions、auth、storage 和 presence 构建常见类型的应用。仓库中对应的示例代码分布在 client/www/app/examples 目录及其配套的 lib/examples 数据源中覆盖了从基础 CRUD 到实时协作的典型形态此外根目录 examples 下还提供了 ai-chat、stripe 系列、tanstack-start、sveltekit、vue-vite 等可直接运行的完整工程可作为 Examples 页之外更深入的参考。六、快速上手从 create-instant-app 开始如果你正想在假期或业余时间动手做一个新项目可以直接用脚手架起步npx create-instant-app该命令会生成一个带 Schemainstant.schema.ts与权限instant.perms.ts的完整工程骨架脚手架实现见 create-instant-app结合上面的 MCP 配置你可以让 Agent 直接在这个工程上拉 Schema、写查询、执行事务并推送迁移实现Agent 全权管理你的 Instant 应用的开发闭环。以上就是 Instant 2025 年 11 月更新的核心内容MCP 从只读查询升级为可写、可迁移的完整管理入口Explorer 补上了导出、列交互和误删恢复Firebase Auth 则让已有 Firebase 用户与手机号登录场景可以无缝接入 Instant。如果你正用 AI 编码助手开发 Instant 应用优先把 MCP 配好如果你的数据团队频繁在 Dashboard 上处理数据Explorer 的新交互与软删除恢复机制值得立刻用起来。赞分享后端数据库【免费下载链接】instantInstant is the best backend for AI-coded apps. You get auth, permissions, storage, presence, and streams — everything you need to ship apps your users will love.项目地址https://gitcode.com/gh_mirrors/inst/instant点击查看免费下载相关推荐Instant 2025 年 2 月更新全解读Explorer 升级、级联删除、$files 存储与 InstaQL fields 子句实战Instant 2025 年 2 月更新全解读Explorer 升级、级联删除、 $files 存储与 InstaQL fields 子句实战 Instant后端数据库Instant 月度更新解读Required 约束、必填 Links、RN 原生 Google 登录与错误体验升级Instant 月度更新解读Required 约束、必填 Links、RN 原生 Google 登录与错误体验升级 本文是对 Instant instan后端数据库Instant 2025 年 3 月功能更新全解析ruleParams 权限参数、LLM 工具链与 OAuth 平台集成Instant 2025 年 3 月功能更新全解析ruleParams 权限参数、LLM 工具链与 OAuth 平台集成 导读 本文基于 Instant 官方后端数据库上一篇Haystack CometAPIChatGenerator 集成指南统一网关调用多厂商大模型下一篇Loop Engineering 记忆分层指南用 L1/L2/L3 三层记忆架构管理 AI 编码 Agent 的上下文与成本创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考