本项目可让你仅使用API令牌,就能将支持AI的集成开发环境(IDE)连接到DigitalOcean数据库!它兼容多种流行的IDE和AI工具,如Cursor AI、Claude Desktop、Windsurf等。
本模型上下文协议(MCP)服务器可实现支持AI的开发环境与你的DigitalOcean托管数据库之间的无缝集成。它适用于Cursor AI、Claude Desktop、Windsurf、带有AI扩展的VS Code以及任何其他支持MCP的IDE。你无需手动管理数据库凭证,只需使用DigitalOcean API令牌即可自动发现并连接到你的任何数据库集群。
连接后,你可以通过自然语言与数据库进行交互:
git clone https://github.com/oladejibidmus/DigitalOcean-Database-MCP-Server.git
cd digitalocean-database-mcp
npm install
npm run build
选择你的开发环境并按照相应的设置进行操作:
Ctrl+Shift+P
(在Mac上为 Cmd+Shift+P
)并搜索 "Cursor Settings"digitalocean-database
node
/absolute/path/to/digitalocean-database-mcp/dist/index.js
或者,在你的项目目录中创建一个 .cursor/mcp.json
文件:
{
"mcpServers": {
"digitalocean-database": {
"command": "node",
"args": ["/absolute/path/to/digitalocean-database-mcp/dist/index.js"]
}
}
}
claude_desktop_config.json
{
"mcpServers": {
"digitalocean-database": {
"command": "node",
"args": ["/absolute/path/to/digitalocean-database-mcp/dist/index.js"]
}
}
}
Ctrl+Shift+P
并搜索 "Open Windsurf Settings"{
"mcpServers": {
"digitalocean-database": {
"command": "node",
"args": ["/absolute/path/to/digitalocean-database-mcp/dist/index.js"]
}
}
}
对于GitHub Copilot Agent模式(内置):
chat.mcp.enabled
.vscode/mcp.json
文件:{
"servers": {
"digitalocean-database": {
"type": "stdio",
"command": "node",
"args": ["/absolute/path/to/digitalocean-database-mcp/dist/index.js"]
}
}
}
对于Continue.dev扩展:
.continue/mcpServers/digitalocean-db.yaml
:name: DigitalOcean Database
mcpServer:
version: 0.0.1
schema: v1
mcpServers:
- name: DigitalOcean DB
command: node
args:
- "/absolute/path/to/digitalocean-database-mcp/dist/index.js"
{
"context_servers": {
"digitalocean-database": {
"source": "custom",
"command": {
"path": "node",
"args": ["/absolute/path/to/digitalocean-database-mcp/dist/index.js"],
"env": {}
}
}
}
}
对于任何其他支持MCP的客户端,使用以下标准参数:
stdio
node
["/absolute/path/to/digitalocean-database-mcp/dist/index.js"]
DO_API_TOKEN
用于预设置身份验证配置完成后:
注意:将 /absolute/path/to/digitalocean-database-mcp
替换为你克隆的仓库的实际完整路径。
在你的AI助手(Cursor、Claude Desktop、Windsurf等)中,只需说:
Set my DigitalOcean API token: dop_v1_your_actual_token_here
Show me all my database clusters
Connect to my database cluster named "production-api"
Show me all tables in this database
Execute this query: SELECT COUNT(*) FROM users WHERE created_at > '2024-01-01'
Describe the structure of the orders table
// Connect to your analytics database
"Connect to my cluster named 'analytics-prod'"
// Explore the data
"Show me all tables and describe the events table"
// Run analysis
"SELECT DATE(created_at) as date, COUNT(*) as events
FROM events
WHERE created_at >= CURRENT_DATE - INTERVAL '30 days'
GROUP BY DATE(created_at)
ORDER BY date"
// Check current schema
"List all tables and their row counts"
// Create new table
"CREATE TABLE blog_posts (
id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
content TEXT,
author_id INTEGER,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)"
// Verify creation
"Describe the blog_posts table"
set_api_token
- 设置你的DigitalOcean API令牌list_database_clusters
- 列出你所有的数据库集群connect_by_name
- 按名称连接到集群execute_query
- 运行带有可选参数的SQL查询list_tables
- 显示数据库中的所有表describe_table
- 获取详细的表模式get_database_info
- 获取数据库版本和集群信息disconnect_database
- 关闭当前连接connect_database
- 如果需要,使用手动凭证进行连接┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ AI Assistant │◄──►│ MCP Server │◄──►│ DigitalOcean DB │
│ │ │ │ │ Clusters │
│ • Cursor AI │ │ • API Client │ │ • PostgreSQL │
│ • Claude Desktop│ │ • DB Connectors │ │ • MySQL │
│ • Windsurf │ │ • Query Engine │ │ • SSL Enabled │
│ • VS Code │ │ • Pool Manager │ │ • Auto-scaling │
│ • Any MCP Client│ │ │ │ │
└─────────────────┘ └─────────────────┘ └─────────────────┘
digitalocean-database-mcp/
├── src/
│ └── index.ts # 主要的MCP服务器实现
├── dist/ # 编译后的JavaScript输出
├── package.json # 依赖项和脚本
├── tsconfig.json # TypeScript配置
└── README.md # 本文件
# 开发时热重载
npm run dev
# 生产环境构建
npm run build
# 启动生产服务器
npm start
git checkout -b feature/new-feature
src/index.ts
中进行更改"Invalid API token"
dop_v1_
前缀的完整令牌"Database cluster not found"
list_database_clusters
查看可用的集群"SSL connection failed"
"MCP server not found"
node dist/index.js
"Server not responding"
"Connection timeout"
我们欢迎贡献!请参阅我们的贡献指南:
本项目采用MIT许可证 - 有关详细信息,请参阅 LICENSE 文件。
Made with ❤️ for the AI-powered development community
GitHub star badge: https://github.com/oladejibidmus/DigitalOcean-Database-MCP-Server
Works with: 🎯 Cursor AI • 🤖 Claude Desktop • 🌊 Windsurf • 💻 VS Code • ⚡ Zed • 🔧 Any MCP Client