MCP基线文件上传服务器
用于将文件上传到Baserow的模型上下文协议(MCP)服务器。支持基于URL的上传和从本地文件系统直接上传文件。
安装
npm install用法
设置环境变量:
export BASEROW_API_URL="https://api.baserow.io"
export BASEROW_API_TOKEN="your_token_here"运行服务器:
npx mcp-baserow-imageClaude MCP配置
要将此服务器与Claude Desktop一起使用,请将以下内容添加到您的Claude MCP配置文件中:
位置
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - 视窗:
%APPDATA%/Claude/claude_desktop_config.json
配置
{
"mcpServers": {
"baserow-file-upload": {
"command": "node",
"args": ["/absolute/path/to/mcp_baserow_image.js"],
"env": {
"BASEROW_API_URL": "https://api.baserow.io",
"BASEROW_API_TOKEN": "your_baserow_token_here"
}
}
}
}替代方案:全球安装
如果您希望全局安装:
npm install -g mcp-baserow-image然后使用此配置:
{
"mcpServers": {
"baserow-file-upload": {
"command": "mcp-baserow-image",
"env": {
"BASEROW_API_URL": "https://api.baserow.io",
"BASEROW_API_TOKEN": "your_baserow_token_here"
}
}
}
}获取您的Baserow代币
- 登录您的Baserow帐户
- 转到“设置”→ 账户→ API令牌
- 创建具有适当权限的新令牌
- 复制令牌值
添加配置后,重新启动Claude Desktop以加载MCP服务器。
MCP协议
此服务器提供两个工具用于将文件上传到Baserow:
可用工具
1.上传图片url
将图像从URL上传到Baserow,并可选择更新表行。
2.上传文件
将文件直接从本地文件系统上传到Baserow,并可选择更新表行。
3.read_baserow-structure
阅读Baserow中所有表和字段的结构,以了解可用于更新的内容。
工具选择指南
- 基于URL的上传:使用
upload_image_url对于网络上可用的图像 - 本地文件上传:使用
upload_file用于本地系统上的文件 - 结构发现:使用
read_baserow_structure探索您的Baserow设置
读取基线结构
在上传文件和更新行之前,您可以探索您的基线结构:
read_baserow_structure使用示例数据:
read_baserow_structure includeRows=true maxRows=3这将向您展示:
- 所有工作区及其ID
- 所有应用程序(数据库)及其ID
- 所有表及其ID
- 所有字段、其类型和ID
- 文件字段及其配置
- 行数据示例(如果需要)
使用此信息确定正确的 tableId, rowId,以及 fieldName 为您的上传。
1.上传图片url
将图像从URL上传到Baserow。
输入格式:
{
"tool": "upload_image_url",
"args": {
"url": "https://example.com/image.jpg",
"filename": "custom_name.jpg",
"tableId": "123",
"rowId": "456",
"fieldName": "image_field"
}
}2.上传文件
将文件直接从本地文件系统上传到Baserow。
重要提示: 此工具要求文件实际存在于运行MCP服务器的本地文件系统上。文件路径必须可供服务器进程访问。
输入格式:
{
"tool": "upload_file",
"args": {
"filePath": "/path/to/local/file.jpg",
"filename": "custom_name.jpg",
"tableId": "123",
"rowId": "456",
"fieldName": "file_field"
}
}注: 这 filePath 参数必须指向本地文件系统上的现有文件。此工具不支持远程URL或云存储路径-请使用 upload_image_url 用于基于URL的上传。
输出格式
这两个工具返回相同的格式:
{
"success": true,
"uploaded_file": {
"name": "uploaded_file_name.jpg",
"url": "https://api.baserow.io/media/user_files/..."
},
"updated_row": {
"id": 456,
"file_field": [...]
}
}发展
运行测试
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage代码检查
# Run linter
npm run lint
# Fix linting issues
npm run lint:fixAPI
upload_image_url(url、文件名、表ID、行ID、字段名)
将图像从URL上传到Baserow,并可选择更新行。
参数:
url(string)-要上传的图像URLfilename(字符串,可选)-上传文件的自定义文件名tableId(字符串,可选)-基行表IDrowId(字符串,可选)-要更新的现有行IDfieldName(string,可选)-文件字段的字段名
退货: 承诺 - { success: true, uploaded_file: object, updated_row?: object }
upload_file(文件路径、文件名、表ID、行ID、字段名)
将文件从本地文件系统上传到Baserow,并可选择更新行。
重要提示: 该文件必须存在于运行MCP服务器的本地文件系统上。
参数:
filePath(string)-要上传的本地文件路径(必须是文件系统上的现有文件)filename(字符串,可选)-上传文件的自定义文件名tableId(字符串,可选)-基行表IDrowId(字符串,可选)-要更新的现有行IDfieldName(string,可选)-文件字段的字段名
退货: 承诺 - { success: true, uploaded_file: object, updated_row?: object }
示例文件路径:
/Users/username/Documents/image.jpg(macOS/Linux)C:\Users\username\Documents\image.jpg(Windows)./uploads/file.pdf(相对于服务器工作目录)
read_baserow_structure(包括Rows、maxRows)
读取Baserow工作区的完整结构,包括所有表和字段。
参数:
includeRows(boolean,可选)-是否包含样本行数据(默认值:false)maxRows(number,可选)-每个表的最大样本行数(默认值:5)
退货: 承诺 -包含工作区、应用程序、表和字段的完整工作区结构
完整工作流示例
以下是将文件上传到Baserow数据库的典型工作流程:
第一步:探索你的基线结构
read_baserow_structure这将向您显示以下内容:
🏢 Workspace: My Workspace (ID: 123)
📱 Application: My Database (ID: 456)
📋 Table: Products (ID: 789)
📝 Fields (5):
• Name (text) - ID: 1001
• Description (long_text) - ID: 1002
• Image (file) - ID: 1003
File Types: Any, Multiple: false
• Price (number) - ID: 1004
• Category (single_select) - ID: 1005步骤2:上传文件并更新行
一旦你知道你的结构,上传一个文件到特定的行:
// Upload from URL and update row 42 in the Products table
upload_image_url(
url="https://example.com/product.jpg",
tableId="789",
rowId="42",
fieldName="Image"
)
// Or upload from local file
upload_file(
filePath="/Users/me/product-photo.jpg",
tableId="789",
rowId="42",
fieldName="Image"
)文件将上传到Baserow,指定的行将使用文件引用进行更新。
环境变量
BASEROW_API_URL-基行API基URL(例如,“https://api.baserow.io")BASEROW_API_TOKEN-基行API身份验证令牌
