Tensorlake MCP服务器
为文档处理提供云沙盒环境的MCP服务器。上传文档,用人工智能解析它们,并使用熟悉的线束工程工具(bash、文件读取/编辑、grep、glob)处理结果。
先决条件
- Tensorlake API密钥(在 Tensorlake)
安装
使用安装 go install
go install github.com/sixt/tensorlake-mcp@latest在您的 GOPATH/bin 目录:
$ which tensorlake-mcp
/Users//go/bin/tensorlake-mcp从源头构建
git clone https://github.com/sixt/tensorlake-mcp.git
cd tensorlake-mcp
go build -o tensorlake-mcp .配置
环境变量
| 变量 | 必填 | 默认 | 描述 |
|---|---|---|---|
TENSORLAKE_API_KEY | 是 | - | 您的Tensorlake API密钥 |
TENSORLAKE_API_BASE_URL | 没有 | https://api.tensorlake.ai/documents/v2 | tensorlake API基础URL |
TENSORLAKE_SANDBOX_API_BASE_URL | 否 | SDK默认值 | 沙盒API基本URL |
TENSORLAKE_SANDBOX_PROXY_BASE_URL | 否 | SDK默认值 | 沙盒代理基础URL |
TENSORLAKE_SANDBOX_TIMEOUT_SECS | 没有 | 3600 | 沙盒会话超时(秒) |
TENSORLAKE_MCP_LOG_LEVEL | 没有 | debug | 日志级别: debug, info, warn |
TENSORLAKE_SANDBOX_ID | 否 | -- | 重用现有沙盒,而不是创建新沙盒 |
MCP主机设置
克劳德桌面版
添加 ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)或 %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"tensorlake-mcp": {
"command": "/absolute/path/to/tensorlake-mcp",
"env": {
"TENSORLAKE_API_KEY": "your-api-key-here",
"TENSORLAKE_SANDBOX_API_BASE_URL": "https://api.tensorlake.ai/sandboxes",
"TENSORLAKE_SANDBOX_PROXY_BASE_URL": "https://sandbox.tensorlake.ai"
}
}
}
}克劳德代码
claude mcp add tensorlake-mcp /absolute/path/to/tensorlake-mcp \
-e TENSORLAKE_API_KEY=your-api-key-here \
-e TENSORLAKE_SANDBOX_API_BASE_URL=https://api.tensorlake.ai/sandboxes \
-e TENSORLAKE_SANDBOX_PROXY_BASE_URL=https://sandbox.tensorlake.ai光标
添加 .cursor/mcp.json 在项目根目录中:
{
"mcpServers": {
"tensorlake-mcp": {
"command": "/absolute/path/to/tensorlake-mcp",
"env": {
"TENSORLAKE_API_KEY": "your-api-key-here",
"TENSORLAKE_SANDBOX_API_BASE_URL": "https://api.tensorlake.ai/sandboxes",
"TENSORLAKE_SANDBOX_PROXY_BASE_URL": "https://sandbox.tensorlake.ai"
}
}
}
}另请参见: 其他MCP客户端
工具
所有工具都在云沙盒文件系统上运行。沙箱在首次使用时会延迟创建,所有文件都位于其下 /data。沙盒会话在服务器重新启动时保持不变——如果沙盒仍在运行,它将自动重用。
服务器指示AI客户端根据线束工程最佳实践,在文件操作方面更喜欢专用工具而不是bash。
bash
在沙盒中执行shell命令。返回退出代码、stdout和stderr。在长时间运行的命令期间发送MCP进度通知。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
command | string | Yes | 要执行的shell命令 |
timeout_sec | integer | 否 | 超时(秒)(最大300)。默认值30 |
working_dir | string | 否 | 工作目录。默认 /data |
description | string | 否 | 命令功能的人类可读描述 |
run_in_background | boolean | 否 | 在后台运行。返回a process_id 立即 |
bash_status
检查后台bash命令的状态或检索结果。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
process_id | string | 是 | 来自后台bash命令的进程ID |
file_read
从沙箱中读取带有行号的文件(cat-n格式)。检测二进制文件,返回图像文件的base64图像内容,并支持带页面范围的PDF文本提取。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
path | string | 是 | 文件的绝对路径 |
offset | integer | 否 | 基于0的行偏移。默认值0 |
limit | integer | 否 | 要读取的行数。默认值2000 |
pages | string | 否 | PDF页面范围,例如。 1-5, 3 |
file_write
将文件写入沙盒。完全创建或覆盖。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
path | string | 是 | 文件的绝对路径 |
content | string | 是 | 要写的全部内容 |
file_edit
使用精确的字符串替换来编辑文件。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
path | string | 是 | 文件的绝对路径 |
old_string | string | 是 | 要查找的文本(为空可创建新文件) |
new_string | string | 是 | 替换文本 |
replace_all | boolean | 否 | 替换所有匹配项。默认值为false |
grep
按正则表达式模式搜索文件内容。支持多种输出模式、上下文行和不区分大小写的搜索。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
pattern | string | 是 | 要搜索的正则表达式模式 |
path | string | 否 | 要搜索的目录。默认 /data |
glob | string | 否 | 文件全局过滤器,例如。 *.py |
output_mode | string | 否 | content (默认), files_with_matches,或 count |
before | integer | 否 | 匹配前的上下文行(-B) |
after | integer | 否 | 匹配后的上下文行(-A) |
context | integer | 否 | 前后上下文行(-C) |
ignore_case | boolean | 否 | 不区分大小写的搜索 |
head_limit | integer | 否 | 截断N行的输出。默认值200 |
glob
按名称模式查找文件。支持递归 ** 模式。按修改时间排序的结果。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
pattern | string | Yes | Glob模式,例如。 *.pdf, **/*.py |
path | string | 否 | 基本目录。默认 /data |
upload
从URL、本地路径或数据URI将文件上传到沙盒中。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
source | string | 是 | https://..., file://...,或 data:... |
destination | string | 否 | 沙盒路径。默认 /data/ |
parse
使用Tensorlake AI解析文档。将结果写为markdown。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
path | string | 是 | 沙盒中文档的路径 |
output_path | string | 否 | 输出路径。默认 /data/parsed/.md |
交互示例
User: Parse this invoice at https://example.com/invoice.pdf and find the total amount.
AI: [Uses upload to fetch the PDF into the sandbox]
[Uses parse to extract content as markdown]
[Uses file_read to inspect the parsed result]
[Uses grep to search for the total amount]
The total amount on the invoice is $1,234.56.发展
export TENSORLAKE_API_KEY="your-api-key"
go build && ./tensorlake-mcp测试
集成测试需要有效的API密钥:
TENSORLAKE_API_KEY="your-api-key" go test -v ./...MCP检查员
npx @modelcontextprotocol/inspector /absolute/path/to/tensorlake-mcp许可证
版权所有2025 SIXT SE。根据Apache许可证2.0版许可。看 许可证 了解详情。
