tana-mcp编码模式
代码模式MCP服务器 塔纳.AI编写直接针对Tana本地API执行的TypeScript。
要求: 启用本地API的Tana桌面+API令牌(设置→ API).
安装
二进制 --下载自 , chmod +x,跑。
npm (Node.js≥20):
npm install -g tana-mcp-codemode来源 (Bun): git clone → bun install → bun run src/entry-bun.ts
设置
运行交互式安装脚本--检测您的安装,提示输入凭据,并自动配置Claude Code和/或Claude Desktop:
bun run setup
# or for team-shared config:
bun run setup --scope project手动MCP配置
{
"mcpServers": {
"tana": {
"command": "tana-mcp-codemode",
"env": {
"TANA_API_TOKEN": "your-token-here",
"MAIN_TANA_WORKSPACE": "My Workspace"
}
}
}
}对于二进制:set command 到二进制路径。来源: "command": "bun", "args": ["run", "/path/to/src/entry-bun.ts"].
环境变量
| 变量 | 默认值 | 描述 |
|---|---|---|
TANA_API_TOKEN | 必需 | 来自Tana Desktop的承载令牌 |
TANA_API_URL | http://127.0.0.1:8262 | Tana本地API URL |
MAIN_TANA_WORKSPACE | -- | 默认工作区名称或ID |
TANA_SEARCH_WORKSPACES | -- | 逗号分隔的搜索范围工作区 |
TANA_TIMEOUT | 10000 | 请求超时(毫秒) |
TANA_HISTORY_PATH | 平台默认 | 自定义SQLite历史路径 |
使用示例
// Search nodes
const results = await tana.nodes.search("project ideas", {
workspaceIds: [tana.workspace.id]
});
// Import with tags and fields
await tana.import(tana.workspace.id, `
%%tana%%
- Meeting notes #meeting
- Date:: [[2024-01-15]]
- Attendees:: Alice, Bob
`);API 参考
| 命名空间 | 方法 |
|---|---|
tana.workspace | 预先解析的默认工作区 |
tana.workspaces | list() |
tana.nodes | search(), read(), getChildren(), edit(), move(), trash(), check(), uncheck(), open() |
tana.tags | listAll(), getSchema(), create(), modify(), addField(), setCheckbox() |
tana.fields | setOption(), setContent(), getFieldOptions() |
tana.calendar | getOrCreate() |
tana.import() | 导入Tana Paste内容 |
tana.health() | API健康检查 |
发展
bun run start # MCP server
bun run dev # watch mode
bun run test # tests
bun run build # Node.js dist (tsup)
bun run build:binary # self-contained binary
bun run debug # debug UI at :3333许可证
麻省理工学院
