mcpField
L
lintbase-mcp

lintbase-mcp

本地服务
github.com/lintbase数据库314 周前更新

关于 lintbase-mcp

lintbase-mcp 是面向编码 Agent 的本地 MCP 服务,可读取 Firestore 架构并审计数据库。它帮助开发者依据真实字段名编写 Firestore 代码,且仅以只读方式访问数据库。

主要功能

  1. 01读取字段、类型和出现率
  2. 02审计架构漂移、安全、性能与成本
  3. 03筛选报告的问题
  4. 04以只读方式本地运行
  5. 05安装 Agent Skill 以自动检查

适用场景

  1. 01编写 Firestore 代码前核对集合字段
  2. 02重构前查找架构不一致
  3. 03部署前检查安全与成本问题

MCP 相关

该 MCP 服务提供扫描 Firestore、获取集合架构和按条件查询问题的工具。它通过 stdio 在本地运行,且只执行读取操作。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"madia333-lintbase": {
"command": "npx",
"args": [
"-y",
"lintbase-mcp"
]
}
}
}
启动命令npx -y lintbase-mcp

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npmlintbase-mcp0.1.3

工具

3

收录的工具列表 · 更新于 2 周前

参数类型必填说明
keyPathstring是Firebase 服务账号 JSON 文件的绝对路径或相对路径。
sampleSizeinteger否每个集合采样的最大文档数(默认值:50,最大值:500)。
collectionsarray否要扫描的集合名称可选列表。省略时扫描所有集合。

详细介绍

lintbase-mcp

为你的 AI 编码 Agent 提供实时的 Firestore 架构上下文,让它不再臆造字段名称。

npm version npm downloads License: MIT MCP


问题

当你让 Cursor、Claude 或 Windsurf 编写 Firestore 代码时,它会猜测你的架构。

// What your AI writes:
await db.collection('users').doc(id).update({ name: value });

// What's actually in your DB:
{ displayName, uid, email, createdAt, plan }   ← no "name" field

结果就是:悄无声息的错误、运行时崩溃,以及由 AI 助手引入的架构偏移。

解决方案

lintbase-mcp 是一个 Model Context Protocol 服务,可将你的 AI Agent 直接连接到 Firestore 数据库。在编写任何代码之前,Agent 会检查实际存在的内容。

You: "Add a subscription status field to users"

Agent → lintbase_get_schema({ collection: "users" })
      ← { uid, email, createdAt, plan, displayName }

Agent: "I can see users has uid, email, createdAt, plan, displayName.
        I'll add subscriptionStatus as a string field alongside plan..."

不再臆造,不再偏移。每次都基于真实架构。


工具

工具功能
lintbase_scan全面审计数据库 — 检查架构偏移、安全问题、性能问题和成本漏洞。返回包含 0–100 风险评分的结构化报告。
lintbase_get_schema返回一个或所有集合的真实字段名称、类型和出现率。在编写任何数据库代码前使用。
lintbase_get_issues返回筛选后的问题。可提出有针对性的问题:“users 中有错误吗?”、“所有安全问题?”、“只看架构偏移?”

🤖 Agent Skill

将 LintBase Agent Skill 安装到任意项目中,让你的 AI Agent 在编写 Firestore 代码前自动使用 LintBase — 无需提示:

npx -p lintbase-mcp lintbase-mcp-install-skill

这会将 SKILL.md 文件复制到项目中的 .agent/skills/lintbase/。Cursor、Claude Code、Gemini CLI 和其他兼容 MCP 的 Agent 会在启动时读取此文件,并自动遵循其中的说明。

格式与 Firebase 官方 Agent Skills 相同。✅


设置

你需要为项目准备一个 Firebase 服务账号 JSON 密钥。

Cursor

将以下内容添加到项目根目录下的 .cursor/mcp.json:

{
  "mcpServers": {
    "lintbase": {
      "command": "npx",
      "args": ["-y", "lintbase-mcp"]
    }
  }
}

然后在对话中输入:

"Check my Firestore schema before writing this code. Key is at ./service-account.json"
Claude Desktop

将以下内容添加到 ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "lintbase": {
      "command": "npx",
      "args": ["-y", "lintbase-mcp"]
    }
  }
}

重启 Claude Desktop 并开始新的对话。

Windsurf

将以下内容添加到 Windsurf 的 MCP 配置中:

{
  "mcpServers": {
    "lintbase": {
      "command": "npx",
      "args": ["-y", "lintbase-mcp"]
    }
  }
}

使用示例

连接后,你的 AI Agent 就可以使用三个工具。你可以在对话中自然地调用它们;在相关情况下,Agent 也会自动使用。

获取集合的架构
"What fields are in the users collection?"
→ lintbase_get_schema({ keyPath: "./sa.json", collection: "users" })

返回:

## users  (50 docs sampled)
| Field       | Type      | Presence | Stable |
|-------------|-----------|----------|--------|
| uid         | string    | 100%     | ✅     |
| email       | string    | 100%     | ✅     |
| createdAt   | timestamp | 100%     | ✅     |
| plan        | string    | 95%      | ✅     |
| displayName | string    | 62%      | ⚠️  ← mark as optional |
运行全面审计
"Run a full LintBase scan before I start this refactor"
→ lintbase_scan({ keyPath: "./sa.json", sampleSize: 100 })

**返回:**完整报告,包含风险评分,以及 4 个分析器发现的所有问题(架构偏移、安全、性能、成本)。

部署前检查错误
"Any blocking errors I should know about?"
→ lintbase_get_issues({ keyPath: "./sa.json", severity: "error" })
仅检查安全问题
"Are there any security problems with my database?"
→ lintbase_get_issues({ keyPath: "./sa.json", rule: "security/" })

安全

  • 完全在本地运行 — 服务账号密钥和 Firestore 数据不会离开你的设备
  • MCP 服务作为由 IDE 启动的本地 stdio 进程运行
  • 检查架构期间不会向任何 LintBase 服务发送数据
  • 此服务仅对 Firestore 数据库执行读取操作

lintbase_get_issues 的可用筛选条件

筛选条件值示例
severityerror、warning、info仅显示阻断性错误
collection任意集合名称仅显示 users 中的问题
rule规则前缀schema/、security/、perf/、cost/

规则参考

规则分析器检查内容
schema/field-type-mismatch架构同一字段在不同文档中具有多种类型
schema/sparse-field架构超过 40% 的文档缺少该字段
schema/high-field-variance架构不同文档的字段数量差异很大
security/sensitive-collection安全集合名称暗示其中存有未受保护的个人身份信息
security/field-contains-secret安全字段名称暗示其中存储了密钥或令牌
security/debug-data-in-production安全调试或测试集合遗留在生产环境中
perf/excessive-nesting性能文档嵌套超过 5 层
perf/document-too-large性能文档接近 Firestore 的 1 MB 限制
cost/large-avg-document成本文档平均大小导致带宽成本增加
cost/logging-sink成本集合被用作无界写入接收器

相关项目

  • lintbase — 命令行工具。运行 npx lintbase scan firestore --key ./sa.json,即可获取完整的终端报告。
  • lintbase.com — 面向团队的仪表板:保存扫描历史记录、跟踪风险评分随时间的变化、分享报告。

许可证

MIT © Mamadou Dia

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。