这是一个提供与 NocoDB(开源的 Airtable 替代品)全面接口的 Model Context Protocol (MCP) 服务器。此服务器使AI代理能够与 NocoDB 数据库进行交互,非常适合存储和管理多个AI团队的操作数据。
npm install -g @andrewlwn77/nocodb-mcp
npx @andrewlwn77/nocodb-mcp
在你的项目根目录下创建一个 .env 文件:
# 必需
NOCODB_BASE_URL=http://localhost:8080
NOCODB_API_TOKEN=your_api_token_here
# 可选
NOCODB_DEFAULT_BASE=your_default_base_id
添加到您的 Claude Desktop 配置文件中:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"nocodb": {
"command": "npx",
"args": ["@andrewlwn77/nocodb-mcp"],
"env": {
"NOCODB_BASE_URL": "http://localhost:8080",
"NOCODB_API_TOKEN": "your_api_token_here"
}
}
}
}
或者如果已全局安装:
{
"mcpServers": {
"nocodb": {
"command": "nocodb-mcp",
"env": {
"NOCODB_BASE_URL": "http://localhost:8080",
"NOCODB_API_TOKEN": "your_api_token_here"
}
}
}
}
list_bases - 列出所有可用的数据库/项目get_base_info - 获取特定数据库的详细信息list_tables - 列出数据库中的所有表get_table_info - 获取表模式和列信息create_table - 使用自定义模式创建新表delete_table - 删除表add_column - 向现有表添加新列delete_column - 从表中删除列insert_record - 插入单个记录bulk_insert - 一次插入多条记录get_record - 根据ID检索特定记录list_records - 列出记录,带有过滤和分页update_record - 更新现有记录delete_record - 删除记录search_records - 在记录中进行全文搜索query - 使用多个条件进行高级过滤aggregate - 执行SUM、COUNT、AVG、MIN、MAX操作group_by - 按列分组记录list_views - 列出表的所有视图create_view - 创建新的视图get_view_data - 从特定视图获取记录upload_attachment - 将本地文件上传到 NocoDB 存储upload_attachment_by_url - 从URL上传文件attach_file_to_record - 上传并附加文件到记录get_attachment_info - 从记录中获取附件信息{
"tool": "create_table",
"arguments": {
"base_id": "p_abc123",
"table_name": "customers",
"columns": [
{
"title": "Name",
"uidt": "SingleLineText",
"rqd": true
},
{
"title": "Email",
"uidt": "Email",
"unique": true
},
{
"title": "Revenue",
[...]
},
{
"title": "Status",
"uidt": "SingleSelect",
"dtxp": "'active','inactive','pending'"
}
]
}
}
add_column 工具允许您动态地向现有表添加列。这里有一些例子:
{
"tool": "add_column",
"arguments": {
"table_id": "table_id_here",
"title": "Description",
"uidt": "LongText"
}
}
{
"tool": "add_column",
"arguments": {
"table_id": "table_id_here",
"title": "Product Code",
"uidt": "SingleLineText",
"unique": true,
"rqd": true
}
}
{
"tool": "add_column",
"arguments": {
"table_id": "table_id_here",
"title": "Priority",
"uidt": "SingleSelect",
"meta": {
"options": [
{"title": "Low", "color": "#059669"},
{"title": "Medium", "color": "#d97706"},
{"title": "High", "color": "#dc2626"},
{"title": "Critical", "color": "#7c3aed"}
]
}
}
}
{
"tool": "add_column",
"arguments": {
"table_id": "table_id_here",
"title": "Price",
"uidt": "Currency",
"meta": {
"currency_code": "USD"
}
}
}
更多列类型的示例,请参见 Column Types Examples。
delete_column 工具允许您从现有表中删除列。您可以根据列ID或名称来识别要删除的列。
{
"tool": "delete_column",
"arguments": {
"table_id": "table_id_here",
"column_id": "column_id_to_delete"
}
}
{
"tool": "delete_column",
"arguments": {
"table_id": "table_id_here",
"column_name": "ColumnToDelete"
}
}
注意:该工具会搜索匹配 column_name 或 title 字段的列,使其适应不同的命名约定。
{
"tool": "insert_record",
"arguments": {
"base_id": "p_abc123",
"table_name": "customers",
"data": {
"Name": "Acme Corp",
"Email": "contact@acme.com",
"Revenue": 50000,
"Status": "active"
}
}
}
{
"tool": "query",
"arguments": {
"base_id": "p_abc123",
"table_name": "customers",
"where": "(Status,eq,active)~and(Revenue,gt,10000)",
"sort": ["-Revenue", "Name"],
"fields": ["Name", "Email", "Revenue"],
"limit": 10
}
}
{
"tool": "aggregate",
"arguments": {
"base_id": "p_abc123",
"table_name": "customers",
"column_name": "Revenue",
"function": "sum",
"where": "(Status,eq,active)"
}
}
{
"tool": "upload_attachment",
"arguments": {
"file_path": "/path/to/document.pdf",
"storage_path": "documents/2024"
}
}
{
"tool": "upload_attachment_by_url",
"arguments": {
"urls": [
"https://example.com/image1.png",
"https://example.com/image2.jpg"
],
"storage_path": "images"
}
}
{
"tool": "attach_file_to_record",
"arguments": {
"base_id": "p_abc123",
"table_name": "products",
"record_id": "42",
"attachment_field": "ProductImages",
"file_path": "/path/to/product-photo.jpg"
}
}
{
"tool": "get_attachment_info",
"arguments": {
"base_id": "p_abc123",
"table_name": "products",
"record_id": "42",
"attachment_field": "ProductImages"
}
}
列支持的UI数据类型(uidt):
SingleLineText - 短文本字段LongText - 多行文本Number - 整数数值Decimal - 具有精度的小数Checkbox - 布尔值(真/假)Date - 无时间的日期DateTime - 带时间的日期Time - 时间Duration - 时间持续Email - 带验证的电子邮件地址URL - 网络链接PhoneNumber - 电话号码(注意:使用 "PhoneNumber" 而不是 "Phone")Currency - 货币值(需要 meta.currency_code)Percent - 百分数值Rating - 星级评分SingleSelect - 单一选择的下拉菜单(需要 meta.options)MultiSelect - 多重选择(需要 meta.options)Attachment - 文件上传JSON - JSON 数据存储Formula - 计算字段Rollup - 汇总相关记录Lookup - 查找相关记录的值QrCode - 生成二维码(需要 meta.fk_qr_value_column_id)Barcode - 生成条形码(需要 meta.fk_barcode_value_column_id)LinkToAnotherRecord - 表之间的关系Links - 多对多关系某些列类型需要在 meta 字段中提供额外的参数:
meta.options 包含 {title, color} 对象的数组meta.currency_code(例如:"USD","EUR")meta.fk_qr_value_column_id - 编码列的IDmeta.fk_barcode_value_column_id - 编码列的ID,可选 meta.barcode_formatNocoDB 使用特定的语法进行过滤:
(field,operator,value) - 基本条件~and - AND 操作符~or - OR 操作符~not - NOT 操作符eq - 等于neq - 不等于gt - 大于ge - 大于或等于lt - 小于le - 小于或等于like - 包含(使用 % 作为通配符)nlike - 不包含null - 是空notnull - 不是空(Status,eq,active) - 状态等于 "active"(Revenue,gt,1000)~and(Status,eq,active) - 收入 > 1000 并且状态 = "active"(Name,like,%Corp%) - 名称包含 "Corp"# 克隆仓库
git clone https://github.com/your-org/nocodb-mcp.git
cd nocodb-mcp
# 安装依赖
npm install
# 构建项目
npm run build
# 在开发模式下运行
npm run dev
npm test
服务器提供了常见问题的详细错误消息:
bulk_insert 插入多条记录欢迎贡献!请随时提交Pull Request。
MIT
对于问题和功能请求,请在GitHub仓库上创建Issue。