使用说明
Xano MCP服务器
用于与Xano API交互的模型上下文协议(MCP)服务器实现。此服务器通过MCP接口提供管理Xano数据库操作的工具和资源。
特性
- 使用Xano API进行安全身份验证
- 使用TypeScript的类型安全API交互
- 基于环境的配置
- MCP兼容接口
- 工作区管理工具
- 表内容操作(创建、读取、更新)
- 通过详细消息改进错误处理
安装
# Clone the repository
git clone [your-repo-url]
cd xano_mcp
# Install dependencies
npm install
配置
- 复制示例环境文件:
cp .env.example .env
- 更新
.env使用您的Xano凭据文件:
XANO_API_KEY=your_api_key_here
XANO_API_URL=your_xano_api_url
NODE_ENV=development
API_TIMEOUT=10000
发展
# Build the project
npm run build
# Run in development mode
npm run dev
# Start the server
npm start
项目结构
xano_mcp/
├── src/
│ ├── api/
│ │ └── xano/
│ │ ├── client/ # API client implementation
│ │ ├── models/ # Data models and types
│ │ ├── services/ # API service implementations
│ │ └── utils/ # Utility functions
│ ├── mcp/
│ │ ├── server/ # MCP server implementation
│ │ ├── tools/ # MCP tool implementations
│ │ └── types/ # Tool-specific types
│ ├── config.ts # Configuration management
│ └── index.ts # Main entry point
├── .env # Environment variables (not in git)
├── .env.example # Example environment variables
└── tsconfig.json # TypeScript configuration
可用的MCP工具
工作区工具
get_workspaces:列出所有可用工作区
表格工具
create_table:在工作区中创建新表get_table_content:从支持分页的表中获取内容add_table_content:向表中添加新内容update_table_content:更新表中的现有内容get_all_tables:列出工作区中的所有表及其详细信息
使用示例
使用工作区
// List available workspaces
const result = await mcp.use_tool("get_workspaces", {});
console.log('Workspaces:', result);
管理表
// Create a new table
const createResult = await mcp.use_tool("create_table", {
workspaceId: 123,
name: "MyTable"
});
// Add content to a table
const addResult = await mcp.use_tool("add_table_content", {
workspaceId: 123,
tableId: 456,
content: {
created_at: "2024-01-22T17:07:00.000Z"
}
});
// Get table content with pagination
const getResult = await mcp.use_tool("get_table_content", {
workspaceId: 123,
tableId: 456,
pagination: {
page: 1,
items: 50
}
});
// Update table content
const updateResult = await mcp.use_tool("update_table_content", {
workspaceId: 123,
tableId: 456,
contentId: "789",
content: {
created_at: "2024-01-22T17:07:00.000Z"
}
});
// List all tables in a workspace
const tables = await mcp.use_tool("get_all_tables", {
workspaceId: 123
});
console.log('Tables:', tables);
// Returns an array of tables with their details:
// [
// {
// id: number,
// name: string,
// description: string,
// created_at: string,
// updated_at: string,
// guid: string,
// auth: boolean,
// tag: string[],
// workspaceId: number
// },
// ...
// ]
环境变量
| 变量 | 描述 | 必填 | 默认 |
|---|---|---|---|
| XANO_API_KEY | 您的XANO API身份验证密钥 | 是 | - |
| XANO_API_URL | XANO API端点URL | 是 | - |
| NODE_ENV | 环境(开发/生产) | 否 | 开发 |
| API_TIMEOUT | neneneba API请求超时(以毫秒为单位) | 否 | 1000 |
错误处理
服务器为以下对象提供详细的错误消息:
- 无效参数
- 身份验证失败
- API请求失败
- 内容验证错误
- 未知的工具请求
安全
- 环境变量用于敏感配置
- 包含TruffleLog配置以防止秘密泄露
- API密钥和敏感数据从不提交到存储库
贡献
- 创建要素分支
- 进行更改
- 提交拉取请求
许可证
国际协调委员会