返回市场
轻量级仪表MCP服务器

轻量级仪表MCP服务器

作者:syucream20 星标更新:2025-06-09

项目介绍

lightdash-mcp-server

smithery 徽章 npm 版本

一个可以访问 LightdashMCP(Model Context Protocol) 服务器。

此服务器提供了与 Lightdash API 兼容的访问,允许AI助手通过标准化接口与您的Lightdash数据进行交互。

<a href="https://glama.ai/mcp/servers/e1gbb6sflq"> <img width="380" height="200" src="https://gips0.baidu.com/it/u=1529496097,3521038898&fm=3081&app=3081&f=PNG?w=760&h=400" alt="Lightdash Server MCP 服务器" /> </a>

功能

可用工具:

  • list_projects - 列出组织中的所有项目
  • 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 安装

要通过 Smithery 自动安装 Lightdash MCP 服务器到 Claude Desktop:

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-server 支持两种传输模式:Stdio(默认)和 HTTP

Stdio 传输(默认)

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

HTTP 传输(流式 HTTP)

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

这将使用 StreamableHTTPServerTransport 启动服务器,并在 http://localhost:8080/mcp 上通过 HTTP 访问。

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

对于 Claude Desktop 和其他 MCP 客户端:

编辑您的 MCP 配置 json,使用 url 字段代替 commandargs

...
    "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_KEYLIGHTDASH_API_URL 在服务器运行的环境中设置,因为它们不能通过 MCP 客户端配置传递。

参见 examples/list_spaces_http.ts 以获取完整的连接到 HTTP 服务器的编程示例。

开发

可用脚本

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

贡献

  1. 分叉仓库
  2. 创建您的功能分支
  3. 运行测试和代码检查:npm run lint
  4. 提交更改
  5. 推送到分支
  6. 创建拉取请求