EdgeDB数据库管理工具

基于模型上下文协议(MCP)的EdgeDB数据库查询和管理工具,可作为命令行工具或集成到其他项目中。

  • by obiwan90
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 obiwan90/mcp-server-edgedb

使用说明

@obiwan90/edgedb-mcp服务器

EdgeDB MCP Server是一个基于模型上下文协议(MCP)的工具,为EdgeDB数据库提供查询和管理功能。它可以用作命令行工具,也可以作为库集成到其他项目中。

特性

  • 数据库管理工具

    • 连接到数据库(支持DSN和实例名称)
    • 列出可用数据库
    • 创建新数据库
    • 切换当前数据库
    • 获取当前数据库信息
  • 查询工具

    • 执行EdgeQL查询
    • 使用参数执行EdgeQL查询
    • 查找单个记录
    • 查找多条记录(具有过滤、排序、分页功能)
  • 架构管理工具

    • 列表类型(可选包括系统类型)
    • 获取类型详细信息
    • 比较模式结构

安装

临时执行(不安装)

npx -y @obiwan90/edgedb-mcp-server@latest

全球安装

npm install -g @obiwan90/edgedb-mcp-server

作为项目依赖

npm install @obiwan90/edgedb-mcp-server

用法

命令行用法

# If installed globally
edgedb-mcp-server

# Or via npx for temporary execution
npx -y @obiwan90/edgedb-mcp-server

整合为图书馆

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { registerAllTools } from "@obiwan90/edgedb-mcp-server/build/tools/index.js";
import { registerAllResources } from "@obiwan90/edgedb-mcp-server/build/resources/index.js";

// Initialize MCP server
const server = new McpServer({
    transport: new StdioServerTransport(),
    name: "EdgeDB MCP Server",
    description: "Providing EdgeDB database services through MCP protocol",
    version: "1.0.0"
});

// Register resources and tools
registerAllResources(server);
registerAllTools(server);

// Start the server
(async function() {
    try {
        const transport = new StdioServerTransport();
        await server.connect(transport);
        console.log("MCP server connected, waiting for client requests...");
    } catch (error) {
        console.error("Server startup failed:", error);
        process.exit(1);
    }
})();

环境变量

  • EDGEDB_DSN -EdgeDB数据库连接字符串
  • EDGEDB_INSTANCE -EdgeDB实例名称
  • DEBUG -启用调试模式(真/假)
  • LOG_LEVEL -日志级别(默认值:info)

项目开发

目录结构

src/
├── config/           # Configuration management
├── resources/        # MCP resource definitions
├── services/         # Service layer (EdgeDB connection management)
├── tools/            # MCP tool definitions
│   ├── database.ts   # Database management tools
│   ├── query.ts      # Query tools
│   ├── schema.ts     # Schema management tools
│   └── index.ts      # Tool exports
├── types/            # Type definitions
├── utils/            # Utility functions
└── index.ts          # Application entry point

建设项目

# Clone the project
git clone https://github.com/obiwan90/mcp-server-edgedb.git
cd mcp-server-edgedb

# Install dependencies
npm install

# Build the project
npm run build

# Start the service
npm start

光标集成

要将此MCP服务器与游标编辑器集成,请执行以下步骤:

  1. 编辑Cursor的MCP配置文件(~/.cursor/mcp.json)
  2. 添加以下配置:
"edgedb-server": {
  "command": "npx",
  "args": [
    "-y",
    "@obiwan90/edgedb-mcp-server@latest"
  ]
}
"edgedb-server": {
  "command": "npx",
  "args": [
    "-y",
    "@obiwan90/edgedb-mcp-server@latest",
    "--instanceName",
    "your-instance-name"
  ]
}
  1. 重新启动光标编辑器
  2. 现在,您可以在Cursor中使用EdgeDB工具!通过命令面板(Cmd+Shift+P)搜索“EdgeDB”或通过聊天界面访问它们。
Cursor dialog box input:

mcp_edgedb-server_connectEdgeDB(instanceName="your-instance-name")

许可证

该项目根据 MIT许可证.