Utilizes environment variables for configuration of StarRocks database connections and server settings
Supports project setup through git clone operations
References GitHub for project hosting and contribution workflow
Uses npm for package management, dependency installation, and running scripts
Built with TypeScript for type safety and complete type definitions
StarRocks MCP Server
一个专业的 TypeScript 版本的 StarRocks MCP (Model Context Protocol) 服务器实现。
功能特性
- 🔌 完整的 MCP 协议支持 - 实现了标准的 MCP 协议
- 🗄️ StarRocks 数据库集成 - 支持 StarRocks 数据库的所有操作
- 🛠️ 多种 SQL 操作 - 支持 SELECT、INSERT、UPDATE、DELETE、CREATE TABLE 等
- 🔒 安全性 - 内置 SQL 验证和错误处理
- 📝 完整的日志系统 - 支持不同级别的日志记录
- 🧪 测试覆盖 - 包含完整的单元测试
- 📦 TypeScript 支持 - 完整的类型定义和类型安全
支持的 MCP 工具
工具名称 | 描述 | 参数 |
---|---|---|
run_sql_query | 执行只读 SQL 查询(仅限 SELECT 语句) | query: string |
create_table | 在 StarRocks 数据库中创建新表 | query: string |
insert_data | 向 StarRocks 数据库表插入数据 | query: string |
update_data | 更新 StarRocks 数据库表中的数据 | query: string |
delete_data | 从 StarRocks 数据库表中删除数据 | query: string |
execute_sql | 执行任意非 SELECT 的 SQL 语句 | query: string |
安装和设置
1. 克隆项目
2. 安装依赖
3. 配置环境变量
复制环境变量示例文件:
编辑 .env
文件,配置你的 StarRocks 数据库连接信息:
4. 构建项目
5. 运行服务器
开发
开发模式运行
运行测试
代码检查
代码格式化
项目结构
使用示例
1. 查询数据
2. 创建表
3. 插入数据
配置选项
数据库配置
配置项 | 默认值 | 描述 |
---|---|---|
STARROCKS_HOST | localhost | StarRocks 服务器主机 |
STARROCKS_PORT | 9030 | StarRocks 服务器端口 |
STARROCKS_USER | root | 数据库用户名 |
STARROCKS_PASSWORD | '' | 数据库密码 |
STARROCKS_DATABASE | undefined | 默认数据库名 |
STARROCKS_CHARSET | utf8mb4 | 字符集 |
STARROCKS_TIMEZONE | local | 时区 |
连接配置
配置项 | 默认值 | 描述 |
---|---|---|
STARROCKS_CONNECTION_LIMIT | 10 | 连接池大小 |
STARROCKS_ACQUIRE_TIMEOUT | 60000 | 获取连接超时时间(毫秒) |
STARROCKS_TIMEOUT | 60000 | 查询超时时间(毫秒) |
日志配置
配置项 | 默认值 | 描述 |
---|---|---|
LOG_LEVEL | info | 日志级别(debug, info, warn, error) |
NODE_ENV | production | 运行环境 |
错误处理
服务器包含完整的错误处理机制:
- 连接错误 - 自动重连和错误恢复
- SQL 错误 - 详细的错误信息和建议
- MCP 协议错误 - 标准化的错误响应
- 日志记录 - 完整的错误日志记录
安全性
- ✅ SQL 注入防护
- ✅ 参数化查询
- ✅ 输入验证
- ✅ 错误信息过滤
- ✅ 连接池管理
贡献
欢迎提交 Issue 和 Pull Request!
开发指南
- Fork 项目
- 创建功能分支 (
git checkout -b feature/amazing-feature
) - 提交更改 (
git commit -m 'Add some amazing feature'
) - 推送到分支 (
git push origin feature/amazing-feature
) - 打开 Pull Request
许可证
MIT License - 详见 LICENSE 文件
支持
如果你遇到问题或有建议,请:
- 查看 Issues
- 创建新的 Issue
- 联系维护团队
StarRocks MCP Server - 让 StarRocks 数据库操作更简单、更安全!
This server cannot be installed
A TypeScript implementation of a Model Context Protocol server that enables interaction with StarRocks databases, supporting SQL operations like queries, table creation, and data manipulation through standardized MCP tools.
Related MCP Servers
- AsecurityFlicenseAqualityA TypeScript-based template for developing Model Context Protocol servers with features like dependency injection and service-based architecture, facilitating the creation and integration of custom data processing tools.Last updated -194TypeScript
- AsecurityAlicenseAqualityA TypeScript-based template for building Model Context Protocol servers, featuring fast testing, automated version management, and a clean structure for MCP tool implementations.Last updated -15684TypeScriptMIT License
- AsecurityAlicenseAqualityA TypeScript implementation of a Model Context Protocol server providing tools to help developers work with Starwind UI components.Last updated -6TypeScriptMIT License
- -securityFlicense-qualityA Model Context Protocol server implementation that provides a simple interface to interact with PostgreSQL databases, enabling SQL queries, database operations, and schema management through MCP.Last updated -Python