此模型上下文协议(MCP)服务器能够将 Apache Cassandra 数据库与 Claude Desktop 集成,借助自然语言交互的方式实现数据库操作。
首先,您需要将包发布到 npm(或者在本地使用)。
npx @sahil1115/mcp-cassandra-server
所需的环境变量(您可以在运行前设置,或者将其放在 .env
文件中):
export CASSANDRA_PASSWORD=your_password
export CASSANDRA_CONTACT_POINTS=host1,host2
export CASSANDRA_LOCAL_DC=your_datacenter
export CASSANDRA_KEYSPACE=your_keyspace # 可选
export CASSANDRA_USERNAME=your_username # 默认为 "cassandra"
您需要在 Claude Desktop 配置文件(通常是 claude-desktop.config.json
)中添加以下内容:
{
"tools": [
{
"name": "mcp-cassandra-server",
"command": "npx @sahil1115/mcp-cassandra-server",
"env": {
"CASSANDRA_PASSWORD": "your_password",
"CASSANDRA_CONTACT_POINTS": "host1,host2",
"CASSANDRA_LOCAL_DC": "your_datacenter",
"CASSANDRA_KEYSPACE": "your_keyspace"
},
"stdio": true
}
]
}
此模型上下文协议(MCP)服务器能够将 Apache Cassandra 数据库与 Claude Desktop 集成,通过自然语言交互实现数据库操作。
execute_query:在 Cassandra 数据库上执行 CQL 查询
create_table:创建新的 Cassandra 数据库表
insert_data:向 Cassandra 表中插入数据
update_data:更新现有数据中的数据
delete_data:从 Cassandra 表中删除数据
使用示例
显示‘users’表中的所有用户
插入一个新用户,用户名为 John Doe,邮箱为 john@example.com
更新用户 John Doe 的邮箱为 newjohn@example.com
删除用户名为 John Doe 的用户
# 使用 NPX 运行 Cassandra MCP 服务器
npx @sahil1115/mcp-cassandra-server
# 添加到 Claude Desktop 配置
{
"tools": [
{
"name": "mcp-cassandra-server",
"command": "npx @sahil1115/mcp-cassandra-server",
"env": {
"CASSANDRA_PASSWORD": "your_password",
"CASSANDRA_CONTACT_POINTS": "host1,host2",
"CASSANDRA_LOCAL_DC": "your_datacenter",
"CASSANDRA_KEYSPACE": "your_keyspace"
},
"stdio": true
}
]
}
⚠️ 重要提示
- 确保 Cassandra 服务已运行且网络可达。
- 验证环境变量是否正确设置,特别是联系点 (
CASSANDRA_CONTACT_POINTS
) 和本地数据中心 (CASSANDRA_LOCAL_DC
)。- 如果未指定,默认用户名为
cassandra
,密码为空或根据您的配置。
通过以上步骤,您可以轻松将 Cassandra 数据库集成到 Claude Desktop,并利用自然语言交互进行高效的数据操作。