Lightdash MCP服务器

一个提供MCP协议兼容访问Lightdash API的服务器,允许AI助手通过标准化接口与Lightdash数据交互。

  • by syucream
  • TypeScript
  • 混合部署
  • 27 星标
  • 更新于
在 GitHub 查看 syucream/lightdash-mcp-server

使用说明

lightdash mcp服务器

A. MCP(模型上下文协议) 访问的服务器 Lightdash.

该服务器提供对Lightdash的API的MCP-兼容访问,允许AI助手通过标准化界面与Lightdash数据交互。

特性

可用工具:

  • list_projects -列出Lightdash组织中的所有项目
  • get_project -获取特定项目的详细信息
  • list_spaces -列出项目中的所有空间
  • list_charts -列出项目中的所有图表
  • list_dashboards -列出项目中的所有仪表板
  • get_custom_metrics -获取项目的自定义指标
  • get_catalog -获取项目的目录
  • get_metrics_catalog -获取项目的指标目录
  • get_charts_as_code -获取图表作为项目的代码
  • get_dashboards_as_code -将仪表板作为项目代码获取

快速开始

安装

通过Smithery安装

通过以下方式自动安装克劳德桌面版Lightdash MCP服务器 史密瑟里:

npx -y @smithery/cli install lightdash-mcp-server --client claude

手动安装

npm install lightdash-mcp-server

配置

  • LIGHTDASH_API_KEY:您的Lightdash PAT
  • LIGHTDASH_API_URL:API基础URL

用法

lightdash mcp服务器支持两种传输模式: 工作室 (默认)和 超文本传输协议.

标准传输(默认)

  1. 启动MCP服务器:
npx lightdash-mcp-server
  1. 编辑您的MCP配置json:
...
    "lightdash": {
      "command": "npx",
      "args": [
        "-y",
        "lightdash-mcp-server"
      ],
      "env": {
        "LIGHTDASH_API_KEY": "<your PAT>",
        "LIGHTDASH_API_URL": "https://<your base url>"
      }
    },
...

HTTP传输(流式HTTP)

  1. 以HTTP模式启动MCP服务器:
npx lightdash-mcp-server -port 8080

这将使用StreamableHTTPServerTransport启动服务器,使其可以在以下位置通过HTTP访问 http://localhost:8080/mcp.

  1. 配置您的MCP客户端以通过HTTP连接:

对于Claude Desktop和其他MCP客户:

编辑MCP配置json以使用 url 字段而不是 command 和 args:

...
    "lightdash": {
      "url": "http://localhost:8080/mcp"
    },
...

对于程序化访问:

使用流式HTTP客户端传输:

import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';

const client = new Client({
  name: 'my-client',
  version: '1.0.0'
}, {
  capabilities: {}
});

const transport = new StreamableHTTPClientTransport(
  new URL('http://localhost:8080/mcp')
);

await client.connect(transport);

注: 使用HTTP模式时,确保环境变量 LIGHTDASH_API_KEY 和 LIGHTDASH_API_URL 在服务器运行的环境中设置,因为它们不能通过MCP客户端配置传递。

看 examples/list_spaces_http.ts 以编程方式连接到HTTP服务器的完整示例。

发展

可用脚本

  • npm run dev -在开发模式下通过热重新加载(stdio传输)启动服务器
  • npm run dev:http -在端口8080上使用HTTP传输以开发模式启动服务器
  • npm run build -建设生产项目
  • npm run start -启动生产服务器
  • npm run lint -运行linting检查(ESLint和Prettier)
  • npm run fix -自动修复掉毛问题
  • npm run examples -运行示例脚本

贡献

  1. 分叉存储库
  2. 创建功能分支
  3. 运行测试和梳理: npm run lint
  4. 提交您的更改
  5. 推到分支
  6. 创建拉取请求