lightdash mcp服务器
](https://smithery.ai/server/@syucream/lightdash-mcp-server) ](https://badge.fury.io/js/lightdash-mcp-server)
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 PATLIGHTDASH_API_URL:API基础URL
用法
lightdash mcp服务器支持两种传输模式: 工作室 (默认)和 超文本传输协议.
标准传输(默认)
- 启动MCP服务器:
npx lightdash-mcp-server- 编辑您的MCP配置json:
...
"lightdash": {
"command": "npx",
"args": [
"-y",
"lightdash-mcp-server"
],
"env": {
"LIGHTDASH_API_KEY": "",
"LIGHTDASH_API_URL": "https://"
}
},
...HTTP传输(流式HTTP)
- 以HTTP模式启动MCP服务器:
npx lightdash-mcp-server -port 8080这将使用StreamableHTTPServerTransport启动服务器,使其可以在以下位置通过HTTP访问 http://localhost:8080/mcp.
- 配置您的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-运行示例脚本
贡献
- 分叉存储库
- 创建功能分支
- 运行测试和梳理:
npm run lint - 提交您的更改
- 推到分支
- 创建拉取请求

