Sensors MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Sensors MCP Server query the number of page views for the last 7 days"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Sensors MCP Server
基于 MCP(Model Context Protocol) 的神策分析数据服务,让 AI 助手通过自然语言直接查询和分析神策平台中的用户行为数据。
功能概览
工具 | 说明 |
| 获取当前神策配置信息(调试用) |
| 验证 API 连通性和认证有效性 |
| 获取项目中的全部事件列表 |
| 获取事件标签分类信息 |
| 获取指定事件的属性定义 |
| 获取所有事件的属性列表 |
| 事件分析查询(次数、人数、维度拆分、筛选过滤) |
Related MCP server: Google Analytics MCP Server
快速开始
1. 安装依赖
npm install2. 配置环境变量
复制 .env.example 为 .env,填写你的神策分析配置:
cp .env.example .envSA_URL=https://your-sensors-analytics-url
SA_PROJECT=your_project_name
SA_API_KEY=your_api_key
SA_API_SECRET=your_api_secret # 可选API Key 在神策后台「项目管理 → 数据接口」中获取。
3. 编译与启动
# 编译
npm run build
# 生产模式
npm start
# 开发模式(直接运行 TypeScript,改完代码重启即可)
npm run dev接入 MCP 客户端
QoderWork / Claude Desktop
在 MCP 设置中添加 Server,配置启动命令:
{
"mcpServers": {
"sensors": {
"command": "node",
"args": ["/path/to/SensorsMCPServer/dist/index.js"],
"env": {
"SA_URL": "https://your-sensors-analytics-url",
"SA_PROJECT": "your_project_name",
"SA_API_KEY": "your_api_key"
}
}
}
}MCP Server 使用 stdio 协议通信,由客户端启动和管理进程,无需手动运行。
调试
推荐使用 MCP Inspector 进行调试:
npx @modelcontextprotocol/inspector node dist/index.js启动后访问 http://localhost:6274,可以手动调用工具、查看请求和响应。
使用示例
接入 MCP 客户端后,直接用自然语言提问即可:
查询上月左侧菜单点击事件的次数和人数web_workgroup_nav_menu_cli 事件有哪些属性?查询上月左侧菜单点击情况,按用户和菜单名拆分AI 会自动探索事件元数据、构建查询参数、调用 API 并解读结果。
项目结构
src/
├── index.ts # MCP Server 入口,工具注册与请求路由
├── config.ts # 环境变量配置管理
└── tools/
├── event-meta.ts # 事件列表与标签查询
├── property-meta.ts # 事件属性查询
└── segmentation.ts # 事件分析报告查询技术栈
运行环境:Node.js(ES2022+)
开发语言:TypeScript 5.x
MCP SDK:@modelcontextprotocol/sdk ^0.6.0
通信协议:stdio
API 规范:神策分析 OpenAPI v3
认证方式:Header 认证(api-key + sensorsdata-project)
License
ISC
Available Tools
7 toolsget_event_propertiesB
获取指定事件的属性列表
Inputs: events (required).
get_sensors_configA
获取当前的神策配置信息(仅用于调试)
Inputs: no named parameters.
list_event_properties_allC
获取所有事件的属性列表 (可能比较慢)
Inputs: no named parameters.
list_events_allC
获取神策分析事件列表 (元数据)
Inputs: no named parameters.
list_event_tagsA
获取神策分析事件标签列表 (元数据)
Inputs: no named parameters.
query_segmentation_reportC
查询事件分析报告。参数直接对应神策 OpenAPI 的 SegmentationReportRequest 结构。
Inputs: unit (required), to_date (required), measures (required), from_date (required), +6 more.
verify_sensors_configB
验证神策 OpenAPI 配置是否正确
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool targets a distinct aspect: specific event properties vs all properties, events vs tags, config retrieval vs verification, and a single query report. No overlapping purposes.
All tools follow a consistent verb_noun pattern in English using snake_case: get_, list_, query_, verify_. The verbs appropriately reflect the action.
7 tools is well-scoped for a Sensors analytics server, covering configuration, metadata listing, and a core reporting function without excess or deficiency.
Covers essential operations: config management, event/property/tag listing, and a segmentation report query. Minor gap in other report types, but core workflows are complete.
Maintenance
Related MCP Connectors
Ask your website analytics in plain language and set up funnels, features and dashboards.
Ask your web and product analytics: traffic, funnels, goals, revenue and sessions.
Ask business questions in plain English. Get instant answers from your database, no SQL needed.
Ask questions in plain language, get answers from your business database. No SQL required.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI assistants to search, analyze, and interact with Elasticsearch through natural language.1831 PyPIApache 2.0
- AlicenseAqualityDmaintenanceEnables AI assistants to query Google Analytics accounts, properties, and run reports using natural language through the Admin and Data APIs.626 PyPI2Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to query YashanDB using natural language through SQL operations.3MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to query and analyze databases using natural language through MCP and HTTP API, supporting 17+ databases and integration with 50+ platforms.133 npmMIT