elasticsearch-mcp-vsee 0.5.5 → 0.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +16 -13
  2. package/build/errors/handlers.d.ts +1 -0
  3. package/build/errors/handlers.d.ts.map +1 -1
  4. package/build/errors/handlers.js +61 -0
  5. package/build/errors/handlers.js.map +1 -1
  6. package/build/server.d.ts +0 -2
  7. package/build/server.d.ts.map +1 -1
  8. package/build/server.js +53 -93
  9. package/build/server.js.map +1 -1
  10. package/build/tools/find-entities-by-metric.d.ts +3 -3
  11. package/build/tools/find-entities-by-metric.d.ts.map +1 -1
  12. package/build/tools/find-entities-by-metric.js +8 -25
  13. package/build/tools/find-entities-by-metric.js.map +1 -1
  14. package/build/tools/get-index-fields.d.ts +1 -1
  15. package/build/tools/get-index-fields.d.ts.map +1 -1
  16. package/build/tools/get-index-fields.js +10 -15
  17. package/build/tools/get-index-fields.js.map +1 -1
  18. package/build/tools/get-platform-breakdown.d.ts +4 -3
  19. package/build/tools/get-platform-breakdown.d.ts.map +1 -1
  20. package/build/tools/get-platform-breakdown.js +54 -34
  21. package/build/tools/get-platform-breakdown.js.map +1 -1
  22. package/build/tools/get-rating-distribution.d.ts +3 -3
  23. package/build/tools/get-rating-distribution.d.ts.map +1 -1
  24. package/build/tools/get-rating-distribution.js +9 -8
  25. package/build/tools/get-rating-distribution.js.map +1 -1
  26. package/build/tools/get-subscription-breakdown.d.ts +0 -2
  27. package/build/tools/get-subscription-breakdown.d.ts.map +1 -1
  28. package/build/tools/get-subscription-breakdown.js +10 -43
  29. package/build/tools/get-subscription-breakdown.js.map +1 -1
  30. package/build/tools/get-usage-summary.d.ts +2 -2
  31. package/build/tools/get-usage-summary.d.ts.map +1 -1
  32. package/build/tools/get-usage-summary.js +7 -15
  33. package/build/tools/get-usage-summary.js.map +1 -1
  34. package/build/tools/get-visit-trends.d.ts +3 -3
  35. package/build/tools/get-visit-trends.d.ts.map +1 -1
  36. package/build/tools/get-visit-trends.js +53 -42
  37. package/build/tools/get-visit-trends.js.map +1 -1
  38. package/build/tools/index.d.ts +0 -4
  39. package/build/tools/index.d.ts.map +1 -1
  40. package/build/tools/index.js +1 -5
  41. package/build/tools/index.js.map +1 -1
  42. package/build/tools/top-change.d.ts +9 -7
  43. package/build/tools/top-change.d.ts.map +1 -1
  44. package/build/tools/top-change.js +60 -83
  45. package/build/tools/top-change.js.map +1 -1
  46. package/build/validation/schemas.d.ts +2 -2
  47. package/package.json +1 -1
package/README.md CHANGED
@@ -14,7 +14,7 @@
14
14
  - **🔐 Secure by Design**: Input validation, script sanitization, injection prevention
15
15
  - **☁️ Elastic Cloud Ready**: Native support for cloud ID and API key authentication
16
16
  - **⚡ High Performance**: Connection pooling, optimized query execution, efficient aggregations
17
- - **🛠️ Comprehensive Tools**: 11 specialized tools for analytics, summaries, and data exploration
17
+ - **🛠️ Comprehensive Tools**: 9 specialized tools for analytics, summaries, and data exploration
18
18
  - **📊 Advanced Querying**: Full Elasticsearch DSL support with aggregations and highlighting
19
19
  - **🔍 Smart Validation**: Zod-based schemas with security-first validation
20
20
  - **📝 Full TypeScript**: Complete type safety with strict null checks
@@ -48,7 +48,7 @@ The MCP server is configured in `vsee/mcp/config.json`:
48
48
  }
49
49
  ```
50
50
 
51
- The Open WebUI deployment automatically loads this configuration and starts the MCP server via MCPO, making all 11 tools available to the LLM for querying Elasticsearch data.
51
+ The Open WebUI deployment automatically loads this configuration and starts the MCP server via MCPO, making all 9 tools available to the LLM for querying Elasticsearch data.
52
52
 
53
53
  ## 🔄 Updating and Publishing
54
54
 
@@ -93,15 +93,14 @@ After publishing a new version to npm:
93
93
  | Tool | Description | Use Cases |
94
94
  |------|-------------|-----------|
95
95
  | `search_elasticsearch` | Advanced search with aggregations | Custom queries, data analysis |
96
- | `get_index_fields` | Discover index fields and types | Schema exploration, field discovery |
96
+ | `get_index_fields` | Discover index fields and types (defaults to stats-*) | Schema exploration, field discovery |
97
97
  | `top_change` | Find top accounts or groups with highest visit increase/decrease | Trend analysis, account/group monitoring |
98
98
  | `get_subscription_breakdown` | Compare subscription tiers with metrics per tier | Subscription-tier analysis and comparisons |
99
- | `get_account_summary` | Comprehensive statistics for a specific account | Account analytics, performance review |
100
- | `get_group_summary` | Group statistics with account breakdown | Group management, resource allocation |
101
- | `get_platform_breakdown` | Platform or platform version breakdown (provider/patient, platform/version) | Platform adoption, device preferences, version analysis |
99
+ | `get_platform_breakdown` | Platform or platform version breakdown (provider/patient, platform/version) with optional account/group filtering | Platform adoption, device preferences, version analysis |
102
100
  | `get_rating_distribution` | Rating histograms with statistics | Satisfaction analysis |
103
101
  | `get_visit_trends` | Time series visit trends (daily/weekly/monthly) | Trend visualization |
104
- | `get_usage_summary` | Comprehensive metrics summary with flexible filtering and grouping | Multi-dimensional analysis and comparisons |
102
+ | `get_usage_summary` | Comprehensive metrics summary with flexible filtering and grouping (replaces get_account_summary and get_group_summary) | Multi-dimensional analysis and comparisons |
103
+ | `find_entities_by_metric` | Find groups or accounts based on metric thresholds | Entity discovery, filtering by performance metrics |
105
104
 
106
105
  ## 📋 Tool Examples
107
106
 
@@ -137,15 +136,16 @@ After publishing a new version to npm:
137
136
  }
138
137
  ```
139
138
 
140
- ### Get Account Summary
139
+ ### Get Usage Summary (Account or Group)
141
140
 
142
141
  ```json
143
142
  {
144
- "tool": "get_account_summary",
143
+ "tool": "get_usage_summary",
145
144
  "arguments": {
146
145
  "account": "example-customer",
147
146
  "startDate": "now-1y",
148
- "endDate": "now"
147
+ "endDate": "now",
148
+ "groupBy": "none"
149
149
  }
150
150
  }
151
151
  ```
@@ -159,8 +159,8 @@ After publishing a new version to npm:
159
159
  "groupBy": "account",
160
160
  "direction": "increase",
161
161
  "topN": 10,
162
- "currentPeriodDays": 30,
163
- "previousPeriodDays": 30
162
+ "startDate": "now-30d",
163
+ "endDate": "now"
164
164
  }
165
165
  }
166
166
  ```
@@ -175,7 +175,9 @@ After publishing a new version to npm:
175
175
  "breakdownType": "version",
176
176
  "topN": 10,
177
177
  "startDate": "now-30d",
178
- "endDate": "now"
178
+ "endDate": "now",
179
+ "account": "optional-account-name",
180
+ "group": "optional-group-name"
179
181
  }
180
182
  }
181
183
  ```
@@ -355,6 +357,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
355
357
 
356
358
  ## 🏷️ Version History
357
359
 
360
+ - **v0.6.0** - Removed `get_account_summary` and `get_group_summary` (functionality consolidated into `get_usage_summary`), standardized subscription enum values, added date capping to high-risk tools, optimized queries with `track_total_hits: false`, fixed `average_per_period` calculation in grouped visit trends
358
361
  - **v0.5.0** - Added `find_entities_by_metric` tool with multi-metric filtering support, updated default limits
359
362
  - **v0.4.0** - Tool consolidation: merged 14 tools into 11 specialized analytics tools
360
363
  - **v0.3.0** - Specialized analytics tools for stats-* indices
@@ -22,6 +22,7 @@ export declare class RateLimitError extends ElasticMCPError {
22
22
  }
23
23
  export declare class ElasticsearchError extends ElasticMCPError {
24
24
  constructor(message: string, originalError?: Error, context?: Record<string, unknown>);
25
+ static fromResponseError(error: any, toolName: string, args?: unknown): ElasticsearchError;
25
26
  }
26
27
  export interface ErrorResponse {
27
28
  error: {
@@ -1 +1 @@
1
- {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/errors/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;gBAG3D,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,UAAU,GAAE,MAAY,EACxB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAUpC;AAED,qBAAa,eAAgB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AAE,aAAa,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAWrF,MAAM,CAAC,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,kBAAkB;CAkF3F;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;QAC7C,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;KAC/B,CAAC;CACH;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM;IAI1B,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,aAAa;IA+D9D,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAwBzC,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa;CA2BnD"}
@@ -61,6 +61,67 @@ class ElasticsearchError extends ElasticMCPError {
61
61
  });
62
62
  this.name = 'ElasticsearchError';
63
63
  }
64
+ static fromResponseError(error, toolName, args) {
65
+ // Check for circuit breaking exception (data too large)
66
+ const errorBody = error.body || error.meta?.body || {};
67
+ const errorType = errorBody.error?.type || errorBody.type;
68
+ const errorReason = errorBody.error?.reason || errorBody.reason || error.message || '';
69
+ // Check for circuit breaking or data-related errors
70
+ if (errorType === 'circuit_breaking_exception' ||
71
+ errorReason.toLowerCase().includes('circuit_breaking_exception') ||
72
+ errorReason.toLowerCase().includes('data too large') ||
73
+ errorReason.toLowerCase().includes('would be') ||
74
+ errorReason.toLowerCase().includes('larger than the limit')) {
75
+ const rootCauses = errorBody.error?.root_cause || [];
76
+ const dataSizeInfo = rootCauses.find((cause) => cause.reason?.includes('would be') || cause.reason?.includes('larger than'));
77
+ let dataUsageMessage = 'Query exceeded Elasticsearch data usage limits. ';
78
+ if (dataSizeInfo?.reason) {
79
+ dataUsageMessage += dataSizeInfo.reason;
80
+ }
81
+ else if (errorReason) {
82
+ dataUsageMessage += errorReason;
83
+ }
84
+ else {
85
+ dataUsageMessage += 'The query requires too much memory to execute.';
86
+ }
87
+ dataUsageMessage += ' Try reducing the date range, adding filters (account/group/subscription), or using a smaller time interval.';
88
+ return new ElasticsearchError(dataUsageMessage, error, {
89
+ tool: toolName,
90
+ args,
91
+ errorType: 'DATA_USAGE_LIMIT_EXCEEDED',
92
+ elasticsearchError: {
93
+ type: errorType,
94
+ reason: errorReason,
95
+ rootCauses: rootCauses.map((cause) => ({
96
+ type: cause.type,
97
+ reason: cause.reason,
98
+ })),
99
+ },
100
+ });
101
+ }
102
+ // Check for other common Elasticsearch errors
103
+ if (errorType === 'query_shard_exception' || errorReason.toLowerCase().includes('query_shard_exception')) {
104
+ return new ElasticsearchError(`Elasticsearch query error: ${errorReason || 'Query execution failed'}. Try adjusting your query parameters.`, error, {
105
+ tool: toolName,
106
+ args,
107
+ errorType: 'QUERY_ERROR',
108
+ elasticsearchError: {
109
+ type: errorType,
110
+ reason: errorReason,
111
+ },
112
+ });
113
+ }
114
+ // Generic Elasticsearch error with more context
115
+ return new ElasticsearchError(`Elasticsearch error: ${errorReason || error.message || 'Unknown error occurred'}`, error, {
116
+ tool: toolName,
117
+ args,
118
+ errorType: errorType || 'UNKNOWN',
119
+ elasticsearchError: {
120
+ type: errorType,
121
+ reason: errorReason,
122
+ },
123
+ });
124
+ }
64
125
  }
65
126
  exports.ElasticsearchError = ElasticsearchError;
66
127
  class ErrorHandler {
@@ -1 +1 @@
1
- {"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../src/errors/handlers.ts"],"names":[],"mappings":";;;AAEA,MAAa,eAAgB,SAA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QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAzHD,oCAyHC"}
package/build/server.d.ts CHANGED
@@ -8,8 +8,6 @@ export declare class ElasticMCPServer {
8
8
  private getIndexFieldsTool;
9
9
  private topChangeTool;
10
10
  private periodSummaryTool;
11
- private getAccountSummaryTool;
12
- private getGroupSummaryTool;
13
11
  private getPlatformBreakdownTool;
14
12
  private getRatingDistributionTool;
15
13
  private getVisitTrendsTool;
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAqBA,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,cAAc,CAAS;IAG/B,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,qBAAqB,CAAwB;IACrD,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,wBAAwB,CAA2B;IAC3D,OAAO,CAAC,yBAAyB,CAA4B;IAC7D,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,wBAAwB,CAA2B;;IAoC3D,OAAO,CAAC,aAAa;IAodrB,OAAO,CAAC,qBAAqB;IAoCvB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAmB7B;AAED,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAmBA,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,wBAAwB,CAA2B;IAC3D,OAAO,CAAC,yBAAyB,CAA4B;IAC7D,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,wBAAwB,CAA2B;;IAiC3D,OAAO,CAAC,aAAa;IAobrB,OAAO,CAAC,qBAAqB;IAoCvB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAmB7B;AAED,eAAe,gBAAgB,CAAC"}
package/build/server.js CHANGED
@@ -16,12 +16,9 @@ class ElasticMCPServer {
16
16
  elasticsearch;
17
17
  errorHandler;
18
18
  isShuttingDown = false;
19
- // Tools
20
19
  getIndexFieldsTool;
21
20
  topChangeTool;
22
21
  periodSummaryTool;
23
- getAccountSummaryTool;
24
- getGroupSummaryTool;
25
22
  getPlatformBreakdownTool;
26
23
  getRatingDistributionTool;
27
24
  getVisitTrendsTool;
@@ -40,12 +37,9 @@ class ElasticMCPServer {
40
37
  tools: {},
41
38
  },
42
39
  });
43
- // Initialize tools
44
40
  this.getIndexFieldsTool = new index_js_2.GetIndexFieldsTool(this.elasticsearch, this.logger);
45
41
  this.topChangeTool = new index_js_2.TopChangeTool(this.elasticsearch, this.logger);
46
42
  this.periodSummaryTool = new index_js_2.PeriodSummaryTool(this.elasticsearch, this.logger);
47
- this.getAccountSummaryTool = new index_js_2.GetAccountSummaryTool(this.elasticsearch, this.logger);
48
- this.getGroupSummaryTool = new index_js_2.GetGroupSummaryTool(this.elasticsearch, this.logger);
49
43
  this.getPlatformBreakdownTool = new index_js_2.GetPlatformBreakdownTool(this.elasticsearch, this.logger);
50
44
  this.getRatingDistributionTool = new index_js_2.GetRatingDistributionTool(this.elasticsearch, this.logger);
51
45
  this.getVisitTrendsTool = new index_js_2.GetVisitTrendsTool(this.elasticsearch, this.logger);
@@ -61,13 +55,14 @@ class ElasticMCPServer {
61
55
  tools: [
62
56
  {
63
57
  name: 'get_index_fields',
64
- description: 'Get all fields from an Elasticsearch index with optional filtering by field name and type. Use this tool when you need to discover available fields, their types, and correct field names before constructing queries. This is especially useful when unsure about field names or when looking for fields with specific types (e.g., keyword fields for exact matches or text fields for full-text search).',
58
+ description: 'Get all fields from an Elasticsearch index with optional filtering by field name and type. Use this tool when you need to discover available fields, their types, and correct field names before constructing queries. This is especially useful when unsure about field names or when looking for fields with specific types (e.g., keyword fields for exact matches or text fields for full-text search). ⚠️ IMPORTANT: Do NOT specify the index parameter unless the user explicitly requests fields from a different index. The tool defaults to "stats-*" which covers all standard indices. Only include the index parameter if the user specifically mentions a different index name.',
65
59
  inputSchema: {
66
60
  type: 'object',
67
61
  properties: {
68
62
  index: {
69
63
  type: 'string',
70
- description: 'Index name or pattern (supports wildcards like stats-*)',
64
+ description: 'Index name or pattern (supports wildcards like stats-*). Defaults to "stats-*" if not specified. Only specify if you need fields from a different index.',
65
+ default: 'stats-*',
71
66
  },
72
67
  fieldFilter: {
73
68
  type: 'string',
@@ -83,13 +78,13 @@ class ElasticMCPServer {
83
78
  default: true,
84
79
  },
85
80
  },
86
- required: ['index'],
81
+ required: [],
87
82
  additionalProperties: false,
88
83
  },
89
84
  },
90
85
  {
91
86
  name: 'top_change',
92
- description: 'Find top 5 accounts or groups with highest visit increase or decrease between two consecutive time periods. Returns items ranked by change with current period count, previous period count, absolute change, and percentage change. Supports filtering by subscription tier, and by group (when grouping by account). ⚠️ Data limits: Max 30 days per period (may auto-reduce to 14 days if both periods are 30). This tool aggregates ALL accounts before sorting, making it memory-intensive. Always returns top 5 results.',
87
+ description: 'Find top N accounts or groups with highest visit/usage increase or decrease between two consecutive time periods. Returns items ranked by change with current period count, previous period count, absolute change, and percentage change. The previous period is automatically calculated to match the duration of the current period, ending where the current period starts. Supports filtering by subscription tier.',
93
88
  inputSchema: {
94
89
  type: 'object',
95
90
  properties: {
@@ -103,105 +98,53 @@ class ElasticMCPServer {
103
98
  enum: ['increase', 'decrease'],
104
99
  description: 'Direction: "increase" for highest growth, "decrease" for highest decline',
105
100
  },
106
- currentPeriodDays: {
107
- type: 'number',
108
- minimum: 1,
109
- maximum: 365,
110
- default: 30,
111
- description: 'Number of days for current period (default: 30). ⚠️ Recommended: 14-30 days maximum to prevent data limit errors. Tool automatically caps at 30 days (may reduce to 14 if both periods are 30). Note: This tool aggregates ALL accounts before sorting, so large periods can cause memory issues.',
112
- },
113
- previousPeriodDays: {
101
+ topN: {
114
102
  type: 'number',
115
103
  minimum: 1,
116
- maximum: 365,
117
- description: 'Number of days for previous period (defaults to same as currentPeriodDays). ⚠️ Recommended: 14-30 days maximum. Tool automatically caps at 30 days (may reduce to 14 if both periods are 30). Note: Large periods can cause memory issues as all accounts must be aggregated first.',
118
- },
119
- subscription: {
120
- type: 'string',
121
- description: 'Optional subscription tier to filter by',
122
- },
123
- group: {
124
- type: 'string',
125
- description: 'Optional group name to filter by (only valid when groupBy is "account")',
126
- },
127
- },
128
- required: ['groupBy', 'direction'],
129
- additionalProperties: false,
130
- },
131
- },
132
- {
133
- name: 'get_subscription_breakdown',
134
- description: 'Compare subscription tiers (Plus, Basic, etc.) across a time period. Always returns metrics grouped by subscription tier with per-tier breakdown (visits, accounts, providers, patients, ratings, call duration) plus totals. Use predefined period types (weekly/monthly/yearly) or custom date ranges. Automatically filters out test visits. ⚠️ Data limits: Max 365 days for yearly, 90 days for other periods. Tool automatically caps time periods to prevent errors. Best for subscription-tier analysis and comparisons.',
135
- inputSchema: {
136
- type: 'object',
137
- properties: {
138
- period: {
139
- type: 'string',
140
- enum: ['weekly', 'monthly', 'yearly'],
141
- description: 'Time period type: "weekly" (defaults to last 7 days), "monthly" (defaults to last 30 days), or "yearly" (defaults to last 365 days)',
104
+ maximum: 50,
105
+ default: 5,
106
+ description: 'Number of top items to return (default: 5, max: 50)',
142
107
  },
143
108
  startDate: {
144
109
  type: 'string',
145
- description: 'Start date in ISO format (YYYY-MM-DD) or date math (e.g., "now-30d", "2024-01-01"). Defaults to period-appropriate range relative to now',
110
+ description: 'Start date for current period in ISO format (YYYY-MM-DD) or date math (e.g., "now-30d", "now-1y"). Defaults to "now-30d"',
146
111
  },
147
112
  endDate: {
148
113
  type: 'string',
149
- description: 'End date in ISO format (YYYY-MM-DD) or date math (e.g., "now"). Defaults to "now"',
150
- },
151
- },
152
- required: ['period'],
153
- additionalProperties: false,
154
- },
155
- },
156
- {
157
- name: 'get_account_summary',
158
- description: 'Get comprehensive statistics for a specific account over a time period. Returns subscription distribution, record counts, unique providers/patients, average call duration, and average ratings. Automatically filters out test visits and includes only valid meeting data. Default time period is last year. ⚠️ Data limits: Max 365 days. Tool automatically caps time periods to prevent errors.',
159
- inputSchema: {
160
- type: 'object',
161
- properties: {
162
- account: {
163
- type: 'string',
164
- description: 'Account name to summarize',
114
+ description: 'End date for current period in ISO format (YYYY-MM-DD) or date math (e.g., "now"). Defaults to "now"',
165
115
  },
166
- startDate: {
167
- type: 'string',
168
- description: 'Start date in ISO format (YYYY-MM-DD) or date math (e.g., "now-30d", "now-1y"). Defaults to "now-1y"',
169
- },
170
- endDate: {
116
+ subscription: {
171
117
  type: 'string',
172
- description: 'End date in ISO format (YYYY-MM-DD) or date math (e.g., "now"). Defaults to "now"',
118
+ enum: ['Enterprise', 'Premium', 'FVC', 'BVC', 'Plus'],
119
+ description: 'Optional subscription tier to filter by',
173
120
  },
174
121
  },
175
- required: ['account'],
122
+ required: ['groupBy', 'direction'],
176
123
  additionalProperties: false,
177
124
  },
178
125
  },
179
126
  {
180
- name: 'get_group_summary',
181
- description: 'Get summary statistics for a specific group over a time period, broken down by top 5 accounts plus "Other" category if needed. Returns group-level metrics and per-account breakdown for top accounts. Automatically filters out test visits and includes only valid meeting data. Default time period is last year. ⚠️ Data limits: Max 365 days. Tool automatically caps time periods to prevent errors.',
127
+ name: 'get_subscription_breakdown',
128
+ description: 'Compare subscription tiers (Enterprise, Premium, FVC, BVC, Plus) across a time period. Always returns metrics grouped by subscription tier with per-tier breakdown (visits, accounts, providers, patients, ratings, call duration) plus totals.',
182
129
  inputSchema: {
183
130
  type: 'object',
184
131
  properties: {
185
- group: {
186
- type: 'string',
187
- description: 'Group name to summarize',
188
- },
189
132
  startDate: {
190
133
  type: 'string',
191
- description: 'Start date in ISO format (YYYY-MM-DD) or date math (e.g., "now-30d", "now-1y"). Defaults to "now-1y"',
134
+ description: 'Start date in ISO format (YYYY-MM-DD) or date math (e.g., "now-30d", "now-1y"). Defaults to "now-30d"',
192
135
  },
193
136
  endDate: {
194
137
  type: 'string',
195
138
  description: 'End date in ISO format (YYYY-MM-DD) or date math (e.g., "now"). Defaults to "now"',
196
139
  },
197
140
  },
198
- required: ['group'],
141
+ required: [],
199
142
  additionalProperties: false,
200
143
  },
201
144
  },
202
145
  {
203
146
  name: 'get_platform_breakdown',
204
- description: 'Get breakdown of top N platforms or platform versions by usage over a time period. Supports both provider and patient roles, and both platform-level (Web/iOS/Android) and platform-version-level breakdowns. Returns top N items (default 10) plus "Other" category if needed, with metrics per item including visit counts, unique accounts/providers/patients, ratings, and call duration. Automatically filters out test visits and includes only valid meeting data. Default time period is last 14 days. Recommended: max 30 days to prevent data limit errors, especially for patient platform breakdowns which have many unique platforms.',
147
+ description: 'Get breakdown of top N platforms or platform versions by usage over a time period, can optionally be filtered by account or group. Supports both provider and patient roles. Returns top N items (default 10) plus "Other" category if needed, with metrics per item including visit counts, unique accounts/providers/patients, ratings, and call duration.',
205
148
  inputSchema: {
206
149
  type: 'object',
207
150
  properties: {
@@ -224,12 +167,20 @@ class ElasticMCPServer {
224
167
  },
225
168
  startDate: {
226
169
  type: 'string',
227
- description: 'Start date. Format: ISO date (YYYY-MM-DD) or date math (now-30d, now-1y). Default: now-30d. ⚠️ Tool may cap to prevent data limits (max 90 days, 60 days when grouping).',
170
+ description: 'Start date. Format: ISO date (YYYY-MM-DD) or date math (now-30d, now-1y). Default: now-30d.',
228
171
  },
229
172
  endDate: {
230
173
  type: 'string',
231
174
  description: 'End date. Format: ISO date (YYYY-MM-DD) or date math (now). Default: now.',
232
175
  },
176
+ account: {
177
+ type: 'string',
178
+ description: 'Optional account name to filter data to',
179
+ },
180
+ group: {
181
+ type: 'string',
182
+ description: 'Optional group name to filter data to',
183
+ },
233
184
  },
234
185
  required: ['role', 'breakdownType'],
235
186
  additionalProperties: false,
@@ -237,7 +188,7 @@ class ElasticMCPServer {
237
188
  },
238
189
  {
239
190
  name: 'get_rating_distribution',
240
- description: 'Get rating distribution (histogram) for provider and/or patient ratings over a time period. Returns rating buckets with counts and percentages, plus statistics (average, min, max, total count). Supports grouping by subscription, account, or group for comparative analysis. Automatically filters out test visits and includes only valid meeting data. Default time period is last 30 days. ⚠️ Data limits: Max 90 days (60 days when grouping). Tool automatically caps time periods to prevent errors.',
191
+ description: 'Get rating distribution (histogram) for provider and/or patient ratings over a time period. Returns rating buckets with counts and percentages, plus statistics (average, min, max, total count). Supports grouping by subscription, account, or group for comparative analysis.',
241
192
  inputSchema: {
242
193
  type: 'object',
243
194
  properties: {
@@ -255,7 +206,7 @@ class ElasticMCPServer {
255
206
  },
256
207
  startDate: {
257
208
  type: 'string',
258
- description: 'Start date. Format: ISO date (YYYY-MM-DD) or date math (now-30d, now-1y). Default: now-30d. ⚠️ Tool may cap to prevent data limits (max 90 days, 60 days when grouping).',
209
+ description: 'Start date. Format: ISO date (YYYY-MM-DD) or date math (now-30d, now-1y). Default: now-30d.',
259
210
  },
260
211
  endDate: {
261
212
  type: 'string',
@@ -271,6 +222,7 @@ class ElasticMCPServer {
271
222
  },
272
223
  subscription: {
273
224
  type: 'string',
225
+ enum: ['Enterprise', 'Premium', 'FVC', 'BVC', 'Plus'],
274
226
  description: 'Optional subscription tier to filter by',
275
227
  },
276
228
  groupBy: {
@@ -286,14 +238,14 @@ class ElasticMCPServer {
286
238
  },
287
239
  {
288
240
  name: 'get_visit_trends',
289
- description: 'Get visit count trends over time (daily, weekly, or monthly intervals) with optional grouping by subscription, account, or group. Returns time series data points with visit counts and unique counts (accounts, providers, patients) per period. Automatically filters out test visits and includes only valid meeting data. Recommended combinations: daily interval with 7-14 days, weekly interval with 12 weeks (3 months), monthly interval with 12 months (1 year). The tool automatically adjusts time periods to prevent data limit errors. Default time period is last 6 months (180 days).',
241
+ description: 'Get visit/usage count trends over time (daily, weekly, or monthly intervals) with optional grouping by subscription, account, or group. Returns time series data points with visit counts and unique counts (accounts, providers, patients) per period.',
290
242
  inputSchema: {
291
243
  type: 'object',
292
244
  properties: {
293
245
  interval: {
294
246
  type: 'string',
295
247
  enum: ['daily', 'weekly', 'monthly'],
296
- description: 'Time interval for trends: "daily" (recommended max 14 days), "weekly" (recommended max 12 weeks), or "monthly" (recommended max 12 months)',
248
+ description: 'Time interval for trends: "weekly"(recommended max 12 weeks), or "monthly" (recommended max 12 months)',
297
249
  },
298
250
  startDate: {
299
251
  type: 'string',
@@ -319,6 +271,7 @@ class ElasticMCPServer {
319
271
  },
320
272
  subscription: {
321
273
  type: 'string',
274
+ enum: ['Enterprise', 'Premium', 'FVC', 'BVC', 'Plus'],
322
275
  description: 'Optional subscription tier to filter by',
323
276
  },
324
277
  },
@@ -328,13 +281,13 @@ class ElasticMCPServer {
328
281
  },
329
282
  {
330
283
  name: 'get_usage_summary',
331
- description: 'Get comprehensive metrics summary for a time period. Returns overall summary (visits, unique counts, ratings, call duration) plus distribution breakdowns (subscription tiers, provider platforms, patient platforms). Supports flexible filtering (by account/group/subscription) and optional grouping (by subscription/account/group) for comparative analysis. Automatically filters out test visits. Default time period is last 30 days. ⚠️ Data limits: Max 90 days (60 days when grouping). Tool automatically caps time periods to prevent errors. Best for flexible analysis and multi-dimensional summaries.',
284
+ description: 'Get usage summary for a time period, can optionally be filtered by account, group, or subscription. Returns visits, unique counts, ratings, call duration plus distribution breakdowns (subscription tiers, provider platforms, patient platforms).',
332
285
  inputSchema: {
333
286
  type: 'object',
334
287
  properties: {
335
288
  startDate: {
336
289
  type: 'string',
337
- description: 'Start date. Format: ISO date (YYYY-MM-DD) or date math (now-30d, now-1y). Default: now-30d. ⚠️ Tool may cap to prevent data limits (max 90 days, 60 days when grouping).',
290
+ description: 'Start date. Format: ISO date (YYYY-MM-DD) or date math (now-30d, now-1y). Default: now-30d.',
338
291
  },
339
292
  endDate: {
340
293
  type: 'string',
@@ -351,6 +304,7 @@ class ElasticMCPServer {
351
304
  subscription: {
352
305
  type: 'string',
353
306
  description: 'FILTER: Optional subscription tier to filter data to',
307
+ enum: ['Enterprise', 'Premium', 'FVC', 'BVC', 'Plus'],
354
308
  },
355
309
  groupBy: {
356
310
  type: 'string',
@@ -365,7 +319,7 @@ class ElasticMCPServer {
365
319
  },
366
320
  {
367
321
  name: 'find_entities_by_metric',
368
- description: 'Find groups or accounts filtered by metrics. Supports single metric (legacy) or multiple metrics (recommended). Available metrics: account_count (groups only), visit_count, provider_rating, patient_rating, avg_call_duration, unique_providers, unique_patients, provider_rating_count, patient_rating_count. Can filter accounts by group. Returns entities matching ALL criteria with their metric values. Automatically filters out test visits. Default time period is last year.',
322
+ description: 'Find groups or accounts filtered by metrics. Supports single metric (legacy) or multiple metrics (recommended). Available metrics: account_count (groups only), visit_count, provider_rating, patient_rating, avg_call_duration, unique_providers, unique_patients, provider_rating_count, patient_rating_count. Can filter accounts by group. Returns entities matching ALL criteria with their metric values.',
369
323
  inputSchema: {
370
324
  type: 'object',
371
325
  properties: {
@@ -421,6 +375,7 @@ class ElasticMCPServer {
421
375
  },
422
376
  subscription: {
423
377
  type: 'string',
378
+ enum: ['Enterprise', 'Premium', 'FVC', 'BVC', 'Plus'],
424
379
  description: 'Optional subscription tier to filter by',
425
380
  },
426
381
  group: {
@@ -451,7 +406,6 @@ class ElasticMCPServer {
451
406
  try {
452
407
  // Don't check connection status - let the actual API calls handle connection errors
453
408
  // Connection checks often fail with limited permissions unnecessarily
454
- // Execute the appropriate tool
455
409
  let result;
456
410
  switch (name) {
457
411
  case 'get_index_fields':
@@ -463,12 +417,6 @@ class ElasticMCPServer {
463
417
  case 'get_subscription_breakdown':
464
418
  result = await this.periodSummaryTool.execute(args);
465
419
  break;
466
- case 'get_account_summary':
467
- result = await this.getAccountSummaryTool.execute(args);
468
- break;
469
- case 'get_group_summary':
470
- result = await this.getGroupSummaryTool.execute(args);
471
- break;
472
420
  case 'get_platform_breakdown':
473
421
  result = await this.getPlatformBreakdownTool.execute(args);
474
422
  break;
@@ -502,11 +450,23 @@ class ElasticMCPServer {
502
450
  toolName: name,
503
451
  error: errorResponse.error,
504
452
  });
453
+ // Format error message with more context for data usage errors
454
+ let errorText = `Error: ${errorResponse.error.message}`;
455
+ // Add additional context for data usage errors
456
+ if (errorResponse.error.code === 'ELASTICSEARCH_ERROR' &&
457
+ errorResponse.error.context?.errorType === 'DATA_USAGE_LIMIT_EXCEEDED') {
458
+ errorText = `❌ Data Usage Error: ${errorResponse.error.message}\n\n` +
459
+ `This query exceeded Elasticsearch memory limits. Suggestions:\n` +
460
+ `• Reduce the date range (e.g., use "now-30d" instead of "now-1y")\n` +
461
+ `• Add filters (account, group, or subscription)\n` +
462
+ `• Use a smaller time interval (e.g., daily instead of monthly when grouped)\n` +
463
+ `• Check the tool's date capping limits in the documentation`;
464
+ }
505
465
  return {
506
466
  content: [
507
467
  {
508
468
  type: 'text',
509
- text: `Error: ${errorResponse.error.message}`,
469
+ text: errorText,
510
470
  },
511
471
  ],
512
472
  isError: true,