@influxdata/influxdb3-mcp-server 1.3.0
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.
- package/CHANGELOG.md +194 -0
- package/Dockerfile +22 -0
- package/LICENSE +6 -0
- package/LICENSE-APACHE.txt +201 -0
- package/LICENSE-MIT.txt +25 -0
- package/README.md +318 -0
- package/build/config.js +85 -0
- package/build/helpers/enums/influx-product-types.enum.js +8 -0
- package/build/index.js +33 -0
- package/build/prompts/index.js +98 -0
- package/build/resources/index.js +223 -0
- package/build/server/index.js +104 -0
- package/build/services/base-connection.service.js +318 -0
- package/build/services/cloud-token-management.service.js +179 -0
- package/build/services/context-file.service.js +97 -0
- package/build/services/database-management.service.js +549 -0
- package/build/services/help.service.js +241 -0
- package/build/services/http-client.service.js +109 -0
- package/build/services/influxdb-master.service.js +117 -0
- package/build/services/query.service.js +499 -0
- package/build/services/serverless-schema-management.service.js +266 -0
- package/build/services/token-management.service.js +215 -0
- package/build/services/write.service.js +153 -0
- package/build/tools/categories/cloud-token.tools.js +321 -0
- package/build/tools/categories/database.tools.js +299 -0
- package/build/tools/categories/health.tools.js +75 -0
- package/build/tools/categories/help.tools.js +104 -0
- package/build/tools/categories/query.tools.js +180 -0
- package/build/tools/categories/schema.tools.js +308 -0
- package/build/tools/categories/token.tools.js +378 -0
- package/build/tools/categories/write.tools.js +104 -0
- package/build/tools/index.js +27 -0
- package/env.example +17 -0
- package/example-cloud-dedicated.mcp.json +15 -0
- package/example-cloud-serverless.mcp.json +13 -0
- package/example-clustered.mcp.json +14 -0
- package/example-docker.mcp.json +25 -0
- package/example-local.mcp.json +13 -0
- package/example-npx.mcp.json +13 -0
- package/package.json +78 -0
package/README.md
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
# InfluxDB MCP Server
|
|
2
|
+
|
|
3
|
+
[](https://github.com/influxdata/influxdb3_mcp_server/actions/workflows/ci.yml)
|
|
4
|
+
<!-- [](https://github.com/influxdata/influxdb3_mcp_server/actions/workflows/unit.yml) -->
|
|
5
|
+
<!-- [](https://github.com/influxdata/influxdb3_mcp_server/actions/workflows/lint.yml) -->
|
|
6
|
+
[](https://archestra.ai/mcp-catalog/influxdata__influxdb3_mcp_server)
|
|
7
|
+
|
|
8
|
+
Model Context Protocol (MCP) server for InfluxDB 3 integration. Provides tools, resources, and prompts for interacting with InfluxDB v3 (Core/Enterprise/Cloud Dedicated/Clustered/Cloud Serverless) via MCP clients.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Prerequisites
|
|
13
|
+
|
|
14
|
+
- **InfluxDB 3 Instance**: URL and token (Core/Enterprise/Cloud Serverless) or Cluster ID and tokens (Cloud Dedicated/Clustered)
|
|
15
|
+
- **Node.js**: v20.11 or newer (for npm/npx usage)
|
|
16
|
+
- **npm**: v9 or newer (for npm/npx usage)
|
|
17
|
+
- **Docker**: (for Docker-based setup)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Available Tools
|
|
22
|
+
|
|
23
|
+
| Tool Name | Description | Availability |
|
|
24
|
+
| ----------------------------- | ----------------------------------------------------------------- | ------------------------------------ |
|
|
25
|
+
| `load_database_context` | Load optional custom database context and documentation | All versions |
|
|
26
|
+
| `get_help` | Get help and troubleshooting guidance for InfluxDB operations | All versions |
|
|
27
|
+
| `write_line_protocol` | Write data using InfluxDB line protocol | All versions |
|
|
28
|
+
| `create_database` | Create a new database (with cloud-specific config options) | All versions |
|
|
29
|
+
| `update_database` | Update database configuration (retention, etc.) | Cloud Dedicated/Clustered/Serverless |
|
|
30
|
+
| `delete_database` | Delete a database by name (irreversible) | All versions |
|
|
31
|
+
| `execute_query` | Run a SQL query against a database (supports multiple formats) | All versions |
|
|
32
|
+
| `get_measurements` | List all measurements (tables) in a database | All versions |
|
|
33
|
+
| `get_measurement_schema` | Get schema (columns/types) for a measurement/table | All versions |
|
|
34
|
+
| `create_admin_token` | Create a new admin token (full permissions) | Core/Enterprise only |
|
|
35
|
+
| `list_admin_tokens` | List all admin tokens (with optional filtering) | Core/Enterprise only |
|
|
36
|
+
| `create_resource_token` | Create a resource token for specific DBs and permissions | Core/Enterprise only |
|
|
37
|
+
| `list_resource_tokens` | List all resource tokens (with filtering and ordering) | Core/Enterprise only |
|
|
38
|
+
| `delete_token` | Delete a token by name | Core/Enterprise only |
|
|
39
|
+
| `regenerate_operator_token` | Regenerate the operator token (dangerous/irreversible) | Core/Enterprise only |
|
|
40
|
+
| `cloud_list_database_tokens` | List all database tokens for Cloud-Dedicated/Clustered cluster | Cloud Dedicated/Clustered |
|
|
41
|
+
| `cloud_get_database_token` | Get details of a specific database token by ID | Cloud Dedicated/Clustered |
|
|
42
|
+
| `cloud_create_database_token` | Create a new database token for Cloud-Dedicated/Clustered cluster | Cloud Dedicated/Clustered |
|
|
43
|
+
| `cloud_update_database_token` | Update an existing database token | Cloud Dedicated/Clustered |
|
|
44
|
+
| `cloud_delete_database_token` | Delete a database token from Cloud-Dedicated/Clustered cluster | Cloud Dedicated/Clustered |
|
|
45
|
+
| `list_databases` | List all available databases in the instance | All versions |
|
|
46
|
+
| `health_check` | Check InfluxDB connection and health status | All versions |
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Available Resources
|
|
51
|
+
|
|
52
|
+
| Resource Name | Description |
|
|
53
|
+
| ------------------ | ------------------------------------------------------- |
|
|
54
|
+
| `influx-config` | Read-only access to InfluxDB configuration |
|
|
55
|
+
| `influx-status` | Real-time connection and health status |
|
|
56
|
+
| `influx-databases` | List of all databases in the instance |
|
|
57
|
+
| `context-file` | Custom user-provided database context and documentation |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Available Prompts
|
|
62
|
+
|
|
63
|
+
| Prompt Name | Description |
|
|
64
|
+
| ---------------- | ------------------------------------------------- |
|
|
65
|
+
| `list-databases` | Generate a prompt to list all available databases |
|
|
66
|
+
| `check-health` | Generate a prompt to check InfluxDB health status |
|
|
67
|
+
| `load-context` | Load custom database context and documentation |
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Setup & Integration Guide
|
|
72
|
+
|
|
73
|
+
### 1. Environment Variables
|
|
74
|
+
|
|
75
|
+
#### For Core/Enterprise InfluxDB:
|
|
76
|
+
|
|
77
|
+
You must provide:
|
|
78
|
+
|
|
79
|
+
- `INFLUX_DB_INSTANCE_URL` (e.g. `http://localhost:8181/`)
|
|
80
|
+
- `INFLUX_DB_TOKEN`
|
|
81
|
+
- `INFLUX_DB_PRODUCT_TYPE` (`core` or `enterprise`)
|
|
82
|
+
|
|
83
|
+
Example `.env`:
|
|
84
|
+
|
|
85
|
+
```env
|
|
86
|
+
INFLUX_DB_INSTANCE_URL=http://localhost:8181/
|
|
87
|
+
INFLUX_DB_TOKEN=your_influxdb_token_here
|
|
88
|
+
INFLUX_DB_PRODUCT_TYPE=core
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### For Cloud Serverless InfluxDB:
|
|
92
|
+
|
|
93
|
+
You must provide:
|
|
94
|
+
|
|
95
|
+
- `INFLUX_DB_INSTANCE_URL` (e.g. `https://us-east-1-1.aws.cloud2.influxdata.com`)
|
|
96
|
+
- `INFLUX_DB_TOKEN`
|
|
97
|
+
- `INFLUX_DB_PRODUCT_TYPE` (`cloud-serverless`)
|
|
98
|
+
|
|
99
|
+
Example `.env`:
|
|
100
|
+
|
|
101
|
+
```env
|
|
102
|
+
INFLUX_DB_INSTANCE_URL=https://us-east-1-1.aws.cloud2.influxdata.com
|
|
103
|
+
INFLUX_DB_TOKEN=your_influxdb_token_here
|
|
104
|
+
INFLUX_DB_PRODUCT_TYPE=cloud-serverless
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### For Cloud Dedicated InfluxDB:
|
|
108
|
+
|
|
109
|
+
You must provide `INFLUX_DB_PRODUCT_TYPE=cloud-dedicated` and `INFLUX_DB_CLUSTER_ID`, plus one of these token combinations:
|
|
110
|
+
|
|
111
|
+
**Option 1: Database Token Only** (Query/Write operations only):
|
|
112
|
+
|
|
113
|
+
```env
|
|
114
|
+
INFLUX_DB_PRODUCT_TYPE=cloud-dedicated
|
|
115
|
+
INFLUX_DB_CLUSTER_ID=your_cluster_id_here
|
|
116
|
+
INFLUX_DB_TOKEN=your_database_token_here
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Option 2: Management Token Only** (Database management only):
|
|
120
|
+
|
|
121
|
+
```env
|
|
122
|
+
INFLUX_DB_PRODUCT_TYPE=cloud-dedicated
|
|
123
|
+
INFLUX_DB_CLUSTER_ID=your_cluster_id_here
|
|
124
|
+
INFLUX_DB_ACCOUNT_ID=your_account_id_here
|
|
125
|
+
INFLUX_DB_MANAGEMENT_TOKEN=your_management_token_here
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Option 3: Both Tokens** (Full functionality):
|
|
129
|
+
|
|
130
|
+
```env
|
|
131
|
+
INFLUX_DB_PRODUCT_TYPE=cloud-dedicated
|
|
132
|
+
INFLUX_DB_CLUSTER_ID=your_cluster_id_here
|
|
133
|
+
INFLUX_DB_ACCOUNT_ID=your_account_id_here
|
|
134
|
+
INFLUX_DB_TOKEN=your_database_token_here
|
|
135
|
+
INFLUX_DB_MANAGEMENT_TOKEN=your_management_token_here
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
#### For Clustered InfluxDB:
|
|
139
|
+
|
|
140
|
+
You must provide `INFLUX_DB_PRODUCT_TYPE=clustered` and `INFLUX_DB_INSTANCE_URL`, plus one of these token combinations:
|
|
141
|
+
|
|
142
|
+
**Option 1: Database Token Only** (Query/Write operations only):
|
|
143
|
+
|
|
144
|
+
```env
|
|
145
|
+
INFLUX_DB_PRODUCT_TYPE=clustered
|
|
146
|
+
INFLUX_DB_INSTANCE_URL=https://your_cluster_host.com
|
|
147
|
+
INFLUX_DB_TOKEN=your_database_token_here
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Option 2: Management Token Only** (Database management only):
|
|
151
|
+
|
|
152
|
+
```env
|
|
153
|
+
INFLUX_DB_PRODUCT_TYPE=clustered
|
|
154
|
+
INFLUX_DB_INSTANCE_URL=https://your_cluster_host.com
|
|
155
|
+
INFLUX_DB_MANAGEMENT_TOKEN=your_management_token_here
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**Option 3: Both Tokens** (Full functionality):
|
|
159
|
+
|
|
160
|
+
```env
|
|
161
|
+
INFLUX_DB_PRODUCT_TYPE=clustered
|
|
162
|
+
INFLUX_DB_INSTANCE_URL=https://your_cluster_host.com
|
|
163
|
+
INFLUX_DB_TOKEN=your_database_token_here
|
|
164
|
+
INFLUX_DB_MANAGEMENT_TOKEN=your_management_token_here
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
See corresponding `env.<instancetype>.example` for examples and detailed info.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
### 2. Integration with MCP Clients
|
|
172
|
+
|
|
173
|
+
#### A. Local (npm install & run)
|
|
174
|
+
|
|
175
|
+
1. **Install dependencies:**
|
|
176
|
+
```bash
|
|
177
|
+
npm install
|
|
178
|
+
```
|
|
179
|
+
2. **Build the server:**
|
|
180
|
+
```bash
|
|
181
|
+
npm run build
|
|
182
|
+
```
|
|
183
|
+
3. **Configure your MCP client** to use the built server. Example (see `example-local.mcp.json`):
|
|
184
|
+
```json
|
|
185
|
+
{
|
|
186
|
+
"mcpServers": {
|
|
187
|
+
"influxdb": {
|
|
188
|
+
"command": "node",
|
|
189
|
+
"args": ["/path/to/influx-mcp-standalone/build/index.js"],
|
|
190
|
+
"env": {
|
|
191
|
+
"INFLUX_DB_INSTANCE_URL": "http://localhost:8181/",
|
|
192
|
+
"INFLUX_DB_TOKEN": "<YOUR_INFLUXDB_TOKEN>",
|
|
193
|
+
"INFLUX_DB_PRODUCT_TYPE": "core"
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### B. Local (npx, no install/build required)
|
|
201
|
+
|
|
202
|
+
1. **Run directly with npx** (after publishing to npm, won't work yet):
|
|
203
|
+
```json
|
|
204
|
+
{
|
|
205
|
+
"mcpServers": {
|
|
206
|
+
"influxdb": {
|
|
207
|
+
"command": "npx",
|
|
208
|
+
"args": ["-y", "@influxdata/influxdb3-mcp-server"],
|
|
209
|
+
"env": {
|
|
210
|
+
"INFLUX_DB_INSTANCE_URL": "http://localhost:8181/",
|
|
211
|
+
"INFLUX_DB_TOKEN": "<YOUR_INFLUXDB_TOKEN>",
|
|
212
|
+
"INFLUX_DB_PRODUCT_TYPE": "core"
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
#### C. Docker
|
|
220
|
+
|
|
221
|
+
Before running the Docker integration, you must build the Docker image:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
# Option 1: Use docker compose (recommended)
|
|
225
|
+
docker compose build
|
|
226
|
+
# Option 2: Use npm script
|
|
227
|
+
npm run docker:build
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**a) Docker with remote InfluxDB instance** (see `example-docker.mcp.json`):
|
|
231
|
+
|
|
232
|
+
```json
|
|
233
|
+
{
|
|
234
|
+
"mcpServers": {
|
|
235
|
+
"influxdb": {
|
|
236
|
+
"command": "docker",
|
|
237
|
+
"args": [
|
|
238
|
+
"run",
|
|
239
|
+
"--rm",
|
|
240
|
+
"-i",
|
|
241
|
+
"-e",
|
|
242
|
+
"INFLUX_DB_INSTANCE_URL",
|
|
243
|
+
"-e",
|
|
244
|
+
"INFLUX_DB_TOKEN",
|
|
245
|
+
"-e",
|
|
246
|
+
"INFLUX_DB_PRODUCT_TYPE",
|
|
247
|
+
"mcp/influxdb"
|
|
248
|
+
],
|
|
249
|
+
"env": {
|
|
250
|
+
"INFLUX_DB_INSTANCE_URL": "http://remote-influxdb-host:8181/",
|
|
251
|
+
"INFLUX_DB_TOKEN": "<YOUR_INFLUXDB_TOKEN>",
|
|
252
|
+
"INFLUX_DB_PRODUCT_TYPE": "core"
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**b) Docker with InfluxDB running in Docker on the same machine** (see `example-docker.mcp.json`):
|
|
260
|
+
|
|
261
|
+
Use `host.docker.internal` as the InfluxDB URL so the MCP server container can reach the InfluxDB container:
|
|
262
|
+
|
|
263
|
+
```json
|
|
264
|
+
{
|
|
265
|
+
"mcpServers": {
|
|
266
|
+
"influxdb": {
|
|
267
|
+
"command": "docker",
|
|
268
|
+
"args": [
|
|
269
|
+
"run",
|
|
270
|
+
"--rm",
|
|
271
|
+
"-i",
|
|
272
|
+
"--add-host=host.docker.internal:host-gateway",
|
|
273
|
+
"-e",
|
|
274
|
+
"INFLUX_DB_INSTANCE_URL",
|
|
275
|
+
"-e",
|
|
276
|
+
"INFLUX_DB_TOKEN",
|
|
277
|
+
"-e",
|
|
278
|
+
"INFLUX_DB_PRODUCT_TYPE",
|
|
279
|
+
"influxdb-mcp-server"
|
|
280
|
+
],
|
|
281
|
+
"env": {
|
|
282
|
+
"INFLUX_DB_INSTANCE_URL": "http://host.docker.internal:8181/",
|
|
283
|
+
"INFLUX_DB_TOKEN": "<YOUR_INFLUXDB_TOKEN>",
|
|
284
|
+
"INFLUX_DB_PRODUCT_TYPE": "enterprise"
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Example Usage
|
|
294
|
+
|
|
295
|
+
- Use your MCP client to call tools, resources, or prompts as described above.
|
|
296
|
+
- **Custom Context**: Edit the provided `context/database-context.md` file or remove it and create your own context file with "context" in the name (`.json`, `.txt`, `.md`) to provide database documentation. Use the `load_database_context` tool or `load-context` prompt to access it.
|
|
297
|
+
- See the `example-*.mcp.json` files for ready-to-use configuration templates:
|
|
298
|
+
- `example-local.mcp.json` - Local development setup
|
|
299
|
+
- `example-npx.mcp.json` - NPX-based setup
|
|
300
|
+
- `example-docker.mcp.json` - Docker-based setup
|
|
301
|
+
- `example-cloud-dedicated.mcp.json` - Cloud Dedicated with all variables
|
|
302
|
+
- `example-clustered.mcp.json` - Clustered with all variables
|
|
303
|
+
- `example-cloud-serverless.mcp.json` - Cloud Serverless configuration
|
|
304
|
+
- See the `env.example`, `env.cloud-dedicated.example`, `env.clustered.example`, and `env.cloud-serverless.example` files for environment variable templates.
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## Support & Troubleshooting
|
|
309
|
+
|
|
310
|
+
- Use the `get_help` tool for built-in help and troubleshooting.
|
|
311
|
+
- For connection issues, check your environment variables and InfluxDB instance status.
|
|
312
|
+
- For advanced configuration, see the comments in the example `.env` and MCP config files.
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## License
|
|
317
|
+
|
|
318
|
+
[MIT](LICENSE)
|
package/build/config.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server Configuration
|
|
3
|
+
*
|
|
4
|
+
* Handles environment variables and configuration for the standalone MCP server
|
|
5
|
+
*/
|
|
6
|
+
import dotenv from "dotenv";
|
|
7
|
+
import { InfluxProductType } from "./helpers/enums/influx-product-types.enum.js";
|
|
8
|
+
dotenv.config();
|
|
9
|
+
/**
|
|
10
|
+
* Load configuration from environment variables
|
|
11
|
+
*/
|
|
12
|
+
export function loadConfig() {
|
|
13
|
+
return {
|
|
14
|
+
influx: {
|
|
15
|
+
url: process.env.INFLUX_DB_INSTANCE_URL,
|
|
16
|
+
token: process.env.INFLUX_DB_TOKEN ||
|
|
17
|
+
process.env.INFLUX_DB_DATABASE_TOKEN ||
|
|
18
|
+
undefined,
|
|
19
|
+
management_token: process.env.INFLUX_DB_MANAGEMENT_TOKEN || undefined,
|
|
20
|
+
type: process.env.INFLUX_DB_PRODUCT_TYPE || "unknown",
|
|
21
|
+
account_id: process.env.INFLUX_DB_ACCOUNT_ID,
|
|
22
|
+
cluster_id: process.env.INFLUX_DB_CLUSTER_ID,
|
|
23
|
+
},
|
|
24
|
+
server: {
|
|
25
|
+
name: "influxdb-mcp-server",
|
|
26
|
+
version: "1.3.0",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Validate that required configuration is present
|
|
32
|
+
*/
|
|
33
|
+
export function validateConfig(config) {
|
|
34
|
+
const errors = [];
|
|
35
|
+
if (!config.influx.type ||
|
|
36
|
+
![
|
|
37
|
+
InfluxProductType.Enterprise,
|
|
38
|
+
InfluxProductType.Core,
|
|
39
|
+
InfluxProductType.CloudDedicated,
|
|
40
|
+
InfluxProductType.CloudServerless,
|
|
41
|
+
InfluxProductType.Clustered,
|
|
42
|
+
].includes(config.influx.type)) {
|
|
43
|
+
errors.push(`INFLUX_DB_PRODUCT_TYPE is required and must be one of: ${InfluxProductType.Enterprise}, ${InfluxProductType.Core}, ${InfluxProductType.CloudDedicated}, ${InfluxProductType.CloudServerless}, ${InfluxProductType.Clustered}`);
|
|
44
|
+
}
|
|
45
|
+
if (config.influx.type === InfluxProductType.CloudDedicated) {
|
|
46
|
+
if (!config.influx.cluster_id) {
|
|
47
|
+
errors.push("INFLUX_DB_CLUSTER_ID is required for cloud-dedicated");
|
|
48
|
+
}
|
|
49
|
+
const hasQueryWrite = config.influx.cluster_id && config.influx.token;
|
|
50
|
+
const hasManagement = config.influx.cluster_id &&
|
|
51
|
+
config.influx.account_id &&
|
|
52
|
+
config.influx.management_token;
|
|
53
|
+
if (!hasQueryWrite && !hasManagement) {
|
|
54
|
+
errors.push("For cloud-dedicated, provide at least either: (CLUSTER_ID + DB TOKEN) for query/write, or (CLUSTER_ID + ACCOUNT_ID + MANAGEMENT TOKEN) for management API.");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else if (config.influx.type === InfluxProductType.Clustered) {
|
|
58
|
+
const hasQueryWrite = config.influx.token;
|
|
59
|
+
const hasManagement = config.influx.management_token;
|
|
60
|
+
config.influx.account_id = "11111111-1111-1111-1111-111111111111"; // Dummy account ID for clustered for compatibility with cloud-dedicated handlers
|
|
61
|
+
config.influx.cluster_id = "11111111-1111-1111-1111-111111111111"; // Dummy cluster ID for clustered for compatibility with cloud-dedicated handlers
|
|
62
|
+
if (!hasQueryWrite && !hasManagement) {
|
|
63
|
+
errors.push("For clustered, provide at least either: DB TOKEN for query/write, or MANAGEMENT TOKEN for management API.");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else if (config.influx.type === InfluxProductType.CloudServerless) {
|
|
67
|
+
if (!config.influx.url) {
|
|
68
|
+
errors.push("INFLUX_DB_INSTANCE_URL is required for cloud-serverless");
|
|
69
|
+
}
|
|
70
|
+
if (!config.influx.token) {
|
|
71
|
+
errors.push("INFLUX_DB_TOKEN is required for cloud-serverless");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else if ([InfluxProductType.Enterprise, InfluxProductType.Core].includes(config.influx.type)) {
|
|
75
|
+
if (!config.influx.url) {
|
|
76
|
+
errors.push("INFLUX_DB_INSTANCE_URL is required for core/enterprise");
|
|
77
|
+
}
|
|
78
|
+
if (!config.influx.token) {
|
|
79
|
+
errors.push("INFLUX_DB_TOKEN is required for core/enterprise");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (errors.length > 0) {
|
|
83
|
+
throw new Error(`Configuration validation failed:\n${errors.join("\n")}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var InfluxProductType;
|
|
2
|
+
(function (InfluxProductType) {
|
|
3
|
+
InfluxProductType["Core"] = "core";
|
|
4
|
+
InfluxProductType["Enterprise"] = "enterprise";
|
|
5
|
+
InfluxProductType["CloudDedicated"] = "cloud-dedicated";
|
|
6
|
+
InfluxProductType["CloudServerless"] = "cloud-serverless";
|
|
7
|
+
InfluxProductType["Clustered"] = "clustered";
|
|
8
|
+
})(InfluxProductType || (InfluxProductType = {}));
|
package/build/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Standalone InfluxDB MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Main entry point for the MCP server that provides InfluxDB integration
|
|
6
|
+
* for Claude Desktop and other MCP clients.
|
|
7
|
+
*/
|
|
8
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
9
|
+
import { createServer } from "./server/index.js";
|
|
10
|
+
async function main() {
|
|
11
|
+
try {
|
|
12
|
+
const server = createServer();
|
|
13
|
+
const transport = new StdioServerTransport();
|
|
14
|
+
await server.connect(transport);
|
|
15
|
+
console.error("[MCP] InfluxDB MCP Server started successfully");
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
console.error("[MCP] Failed to start server:", error);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
process.on("SIGINT", async () => {
|
|
23
|
+
console.error("[MCP] Shutting down...");
|
|
24
|
+
process.exit(0);
|
|
25
|
+
});
|
|
26
|
+
process.on("SIGTERM", async () => {
|
|
27
|
+
console.error("[MCP] Shutting down...");
|
|
28
|
+
process.exit(0);
|
|
29
|
+
});
|
|
30
|
+
main().catch((error) => {
|
|
31
|
+
console.error("[MCP] Server error:", error);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Prompts Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines reusable prompt templates for InfluxDB operations
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Create simple MCP prompts for InfluxDB operations
|
|
8
|
+
*/
|
|
9
|
+
export function createPrompts(influxService) {
|
|
10
|
+
return [
|
|
11
|
+
{
|
|
12
|
+
name: "list-databases",
|
|
13
|
+
description: "Generate a prompt to list all available databases",
|
|
14
|
+
handler: async () => {
|
|
15
|
+
return {
|
|
16
|
+
description: "List all available InfluxDB databases",
|
|
17
|
+
messages: [
|
|
18
|
+
{
|
|
19
|
+
role: "user",
|
|
20
|
+
content: {
|
|
21
|
+
type: "text",
|
|
22
|
+
text: "Please list all available databases in this InfluxDB instance. Use the list_databases tool to show me what databases are available.",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "check-health",
|
|
31
|
+
description: "Generate a prompt to check InfluxDB health status",
|
|
32
|
+
handler: async () => {
|
|
33
|
+
return {
|
|
34
|
+
description: "Check InfluxDB server health and connection status",
|
|
35
|
+
messages: [
|
|
36
|
+
{
|
|
37
|
+
role: "user",
|
|
38
|
+
content: {
|
|
39
|
+
type: "text",
|
|
40
|
+
text: "Please check the health status of the InfluxDB server. Use the health_check tool to verify the connection and show me the server status.",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "load-context",
|
|
49
|
+
description: "Load custom database context and documentation",
|
|
50
|
+
handler: async () => {
|
|
51
|
+
const contextFile = await influxService.contextFile.loadContextFile();
|
|
52
|
+
if (!contextFile) {
|
|
53
|
+
return {
|
|
54
|
+
description: "No context file found",
|
|
55
|
+
messages: [
|
|
56
|
+
{
|
|
57
|
+
role: "user",
|
|
58
|
+
content: {
|
|
59
|
+
type: "text",
|
|
60
|
+
text: "No context file was found. Create a file in /context/ folder or name a file with 'context' in the name (.json, .txt, .md) to provide custom database documentation.",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
let mimeType = "text/plain";
|
|
67
|
+
switch (contextFile.extension) {
|
|
68
|
+
case "json":
|
|
69
|
+
mimeType = "application/json";
|
|
70
|
+
break;
|
|
71
|
+
case "md":
|
|
72
|
+
mimeType = "text/markdown";
|
|
73
|
+
break;
|
|
74
|
+
case "txt":
|
|
75
|
+
default:
|
|
76
|
+
mimeType = "text/plain";
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
description: `Load context from ${contextFile.name}.${contextFile.extension}`,
|
|
81
|
+
messages: [
|
|
82
|
+
{
|
|
83
|
+
role: "user",
|
|
84
|
+
content: {
|
|
85
|
+
type: "resource",
|
|
86
|
+
resource: {
|
|
87
|
+
uri: "influx://context",
|
|
88
|
+
mimeType: mimeType,
|
|
89
|
+
text: contextFile.content,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
}
|