# InfluxDB 3 MCP Server [![CI](https://github.com/influxdata/influxdb3_mcp_server/actions/workflows/ci.yml/badge.svg)](https://github.com/influxdata/influxdb3_mcp_server/actions/workflows/ci.yml) [![Trust Score](https://archestra.ai/mcp-catalog/api/badge/quality/influxdata/influxdb3_mcp_server)](https://archestra.ai/mcp-catalog/influxdata__influxdb3_mcp_server) Use this Model Context Protocol (MCP) server to connect your MCP client to InfluxDB. The server provides tools, resources, and prompts for InfluxDB 3 Core, InfluxDB 3 Enterprise, InfluxDB 3 Cloud, InfluxDB Cloud Dedicated, InfluxDB Clustered, and InfluxDB Cloud Serverless. For what each product was tested with, see [Product coverage](#product-coverage). --- ## Prerequisites - **InfluxDB 3 Instance**: URL and token (Core, Enterprise, InfluxDB 3 Cloud, or Cloud Serverless), cluster ID and tokens (Cloud Dedicated), or URL and tokens (Clustered) - **Node.js**: 22.23.4 or a later 22.x, 24.22.1 or a later 24.x, or 26.12.1 or newer (for npm/npx usage) - **pnpm**: use the version pinned in `package.json` for local development. Run `corepack enable` to activate it. - **Docker**: (for Docker-based setup) Node.js verifies TLS servers with a root certificate store built into the `node` binary. Earlier releases include roots that chain to compromised eMudhra/emSign intermediate CAs. The Docker image uses the latest Node.js 24 release. npm/npx installations use your local Node.js, so update it to a release listed above. Node.js 20 is end of life and has no fixed release. --- ## Migrate to 2.0 Version 2.0 changes query result envelopes, health-check output, argument errors, and telemetry. Clients that parse these responses must follow the [read-only output contract](docs/read-only-output-contract.md). Read `metadata.completeness`, caps, and warnings before treating query results as a complete answer. Discovery metadata states its source and leaves unavailable values unknown. Tool names and configured profiles remain available. ## Read-only agent workflows Set `INFLUX_MCP_TOOL_PROFILE=readonly` to give an MCP client tools that explore and query data. The profile leaves out every tool that writes data, administers databases, manages tokens, or runs on the host. ### Credentials Set `INFLUX_DB_TOKEN` to an admin token, a scoped token, or an Enterprise user-authentication JWT. The server sends it without inspecting it, so the token's permissions decide which databases the tools can read. The tool profile limits which tools the client sees. It doesn't limit the token. With an admin token, the profile and the query checks below are the only boundary, so give the server a scoped token or an Enterprise JWT when the database should enforce read access too. ### Query arguments `query_sql` and `query_influxql` accept `database` for `db` and `query` for `q`. A call that gives both names with different values fails with `invalid_arguments`. Every argument error is a structured tool error and is recorded in telemetry. ### Query checks and bounds `query_sql` and `query_influxql` run one statement. You can include a trailing semicolon. A second statement fails with `multiple_statements`. The checks skip comments, string literals, and quoted identifiers, so a statement inside a comment is neither run nor counted. A SQL query must start with `SELECT`, `SHOW`, `EXPLAIN`, or `WITH`, and an InfluxQL query with `SELECT` or `SHOW`. Anything else fails with `not_read_only`. A query also fails if one of these words appears outside literals and quoted identifiers: - SQL: `INSERT`, `UPDATE`, `DELETE`, `CREATE`, `ALTER`, `DROP`, `COPY`, `EXPORT`, `ATTACH`, `GRANT`, `REVOKE`, `TRUNCATE`. - InfluxQL: `DELETE`, `DROP`, `CREATE`, `ALTER`, `GRANT`, `REVOKE`, and `INTO`, which fails with `select_into`. Quote a column whose name is one of these words. `maxRows` defaults to 1000. The most it accepts is 5000. Each query also gets these checks: - **No limit:** a `SELECT` or `WITH` query without a top-level `LIMIT` gets `LIMIT maxRows` and a `limit_added` warning. - **A larger limit:** a `LIMIT` above `maxRows` is reduced to `maxRows`, with a `limit_reduced` warning. - **A full limit:** a query that fills its own smaller `LIMIT` gets `limit_reached`, because more rows might exist. - **No time filter:** a `SELECT` or `WITH` query that never mentions `time` gets `missing_time_predicate`. Read-only results come back as `json`, `jsonl`, or `csv` on Core and Enterprise, and as `json` on Cloud Dedicated, Cloud Serverless, and Clustered. `pretty` and `parquet` fail with `unsupported_query_format`. SQL on Cloud Dedicated and Cloud Serverless goes over Flight, which doesn't accept `timeoutMs`; that fails with `unsupported_query_option`. SQL results on Cloud Dedicated and Cloud Serverless have millisecond timestamps, because the InfluxDB 3 JavaScript client library (`@influxdata/influxdb3-client`) converts timestamps to milliseconds. The `time` column is an ISO 8601 string. Any other timestamp column, such as a `date_bin` result, is a number of epoch milliseconds. An integer too large to represent exactly as a JSON number is a string. ### Discovery `list_databases` returns what the server lists, with `visibility: "unknown"`, because a listed database might still be unreadable. `health_check` returns JSON with separate health and ping outcomes. A scoped token can be denied both checks and still read its databases. `investigate_database` keeps each table's result even when another table fails, and reports how many tables it saw and whether it stopped early. The tool samples from a 24-hour window by default. Set `sampleWindowHours` to change the window. An empty window doesn't mean the table is empty. On Core and Enterprise, `describe_table` and investigation use `system.influxdb_schema` for authoritative column roles. They also read schema mode and deletion status from the `_internal` catalog when the same credential permits it, reporting `source: "server"` and the catalog table name. Unavailable values stay `unknown`. If the catalog denies access, the tools keep readable column metadata and samples. Without authoritative deletion metadata, a table name with a timestamp-shaped suffix gets an advisory `possibly_deleted` warning and stays listed. Cardinality estimates aren't supported yet. ### Errors When a call fails, read `error.code`, `error.recovery`, and `error.retryable`: - A `403` is `not_found_or_denied`. A token without access gets `403` whether or not the database exists. - A `404` is `not_found`. - A SQL query that names an unknown table has `recovery: "fix_reference"`. Call `list_tables` or `describe_table` for the right name. - A query that runs out of server memory has `recovery: "narrow"`. - A query sent to an Enterprise ingest-only node has `recovery: "change_endpoint"`. - An InfluxQL query to a Cloud Serverless bucket without a DBRP mapping fails with `influxql_bucket_not_mapped`. Cloud Serverless answers InfluxQL only for a bucket that has a mapping. Use `query_sql`, which needs no mapping, or create one with `POST /api/v2/dbrps`. - Other server failures have `recovery: "none"`. `EXPLAIN ANALYZE` runs the query within the same bounds and adds a `diagnostic_execution` warning. ### Analyst explores an unfamiliar database An analyst can connect an MCP client such as Claude Desktop, Cursor, Codex, or another agent harness and ask a question like: ```text Which sensors had the highest average temperature in the last 24 hours? ``` With the read-only profile, the agent can: 1. Call `list_databases` to see accessible databases. 2. Call `list_tables` and `describe_table` to discover measurements and columns. 3. Treat uncertain tag and field categories as `unknown`. 4. Build a bounded SQL query with `db`, `q`, and optional `params`. 5. Call `query_sql` with structured JSON output. 6. Return the result, row count, truncation status, warnings, and correlation metadata. The user gets a grounded answer and a reusable query while the agent explores and queries data without access to mutation or administration tools. For a reproducible local version of this example, see [the sensor-temperature demo](examples/sensor-temperature/README.md). ### Operator investigates an InfluxQL dashboard query An operator can troubleshoot an existing InfluxQL dashboard panel and ask: ```text Why did this panel stop showing data after the deploy? ``` With the read-only profile, the agent can: 1. Keep the user's query in InfluxQL and call `query_influxql`. 2. Use `SHOW` queries and schema discovery to verify the measurement and referenced columns. 3. Sample recent rows with bounded reads to distinguish missing data from a broken query. 4. Reject unsafe follow-up attempts, such as `SELECT INTO` or destructive statements. 5. Return `request_id`, `query_id`, and `query_id_source` so the operator can correlate the MCP result with `system.queries.id` when query history is available. 6. Emit structured logs to stderr for stdio transports so stdout remains reserved for MCP protocol messages. The user gets a practical diagnosis, such as missing data, renamed schema, a wrong time predicate, or a query failure. The investigation is traceable without logging full query text by default. --- ## Tools | Tool Name | Description | Availability | | ----------------------------- | ----------------------------------------------------------------------------------------------------- | ------------------------------------------ | | `load_database_context` | Load optional custom database context and documentation | All versions | | `get_help` | Get help and troubleshooting guidance for InfluxDB operations | All versions | | `write_line_protocol` | Write data using InfluxDB line protocol | All versions | | `create_database` | Create a new database (with cloud-specific config options) | All versions | | `update_database` | Update database configuration (retention for all; maxTables/maxColumns for Cloud Dedicated/Clustered) | All versions | | `delete_database` | Delete a database by name (irreversible) | All versions | | `execute_query` | Deprecated since 2.0.0. Use `query_sql`. Retained for compatibility | All versions | | `query_sql` | Run bounded read-only SQL with structured response metadata | All versions | | `query_influxql` | Run bounded read-only InfluxQL with structured response metadata | All versions | | `get_measurements` | List all measurements (tables) in a database | All versions | | `get_measurement_schema` | Get schema (columns/types) for a measurement/table | All versions | | `list_tables` | List tables, also called measurements, in a database | All versions | | `describe_table` | Describe table schema with conservative column categories | All versions | | `investigate_database` | Run high-level read-only database discovery and sampling | All versions | | `create_admin_token` | Create a named admin token with an optional expiration | Core/Enterprise only | | `list_admin_tokens` | List all admin tokens (with optional filtering) | Core/Enterprise only | | `create_resource_token` | Create a resource token for specific DBs and permissions | Enterprise only | | `list_resource_tokens` | List all resource tokens (with filtering and ordering) | Enterprise only | | `delete_token` | Delete a token by name | Core/Enterprise only | | `regenerate_operator_token` | Regenerate the operator token (dangerous/irreversible) | Core/Enterprise only, not InfluxDB 3 Cloud | | `cloud_list_database_tokens` | List all database tokens for Cloud-Dedicated/Clustered cluster | Cloud Dedicated/Clustered | | `cloud_get_database_token` | Get details of a specific database token by ID | Cloud Dedicated/Clustered | | `cloud_create_database_token` | Create a new database token for Cloud-Dedicated/Clustered cluster | Cloud Dedicated/Clustered | | `cloud_update_database_token` | Update an existing database token | Cloud Dedicated/Clustered | | `cloud_delete_database_token` | Delete a database token from Cloud-Dedicated/Clustered cluster | Cloud Dedicated/Clustered | | `list_databases` | List all available databases in the instance | All versions | | `health_check` | Check InfluxDB connection and health status | All versions | "All versions" includes InfluxDB 3 Cloud, which uses the Enterprise tools. On InfluxDB 3 Cloud: - `health_check`, `list_databases`, `list_tables`, `describe_table`, and `query_sql` were tested. - `regenerate_operator_token` isn't available. InfluxData manages the operator token, and customers can't use it. - `create_admin_token`, `list_admin_tokens`, `delete_token`, `create_resource_token`, and `list_resource_tokens` depend on your role's permissions in InfluxDB 3 Cloud. They haven't been tested. --- ## Resources | Resource Name | Description | | ------------------ | ------------------------------------------------------- | | `influx-config` | Read-only access to InfluxDB configuration | | `influx-status` | Real-time connection and health status | | `influx-databases` | List of all databases in the instance | | `context-file` | Custom user-provided database context and documentation | --- ## Prompts | Prompt Name | Description | | ---------------- | ------------------------------------------------- | | `list-databases` | Generate a prompt to list all available databases | | `check-health` | Generate a prompt to check InfluxDB health status | | `load-context` | Load custom database context and documentation | --- ## Set up the server ### 1. Set environment variables #### InfluxDB 3 Core and Enterprise You must provide: - `INFLUX_DB_INSTANCE_URL` (e.g. `http://localhost:8181/`) - `INFLUX_DB_TOKEN` - `INFLUX_DB_PRODUCT_TYPE` (`core` or `enterprise`) Example `.env`: ```env INFLUX_DB_INSTANCE_URL=http://localhost:8181/ INFLUX_DB_TOKEN=your_influxdb_token_here INFLUX_DB_PRODUCT_TYPE=core ``` #### InfluxDB 3 Cloud InfluxDB 3 Cloud is the fully managed, cloud-hosted version of InfluxDB 3 Enterprise, so set `INFLUX_DB_PRODUCT_TYPE=enterprise`. You must provide: - `INFLUX_DB_INSTANCE_URL`, your instance URL. Find it on the instance **Overview** page in the Admin UI. The instance host ends in `enterprise.influxdb.io`. The Admin UI URL (`console.influxdata.com`) isn't the instance URL. - `INFLUX_DB_TOKEN`, a resource token scoped to the databases the agent needs - `INFLUX_DB_PRODUCT_TYPE` (`enterprise`) Example `.env`: ```env INFLUX_DB_INSTANCE_URL=https://your_instance_host.enterprise.influxdb.io INFLUX_DB_TOKEN=your_resource_token_here INFLUX_DB_PRODUCT_TYPE=enterprise ``` A token scoped to databases can read those databases, but it can't do everything: - InfluxDB 3 Cloud has no `/health` endpoint. `health_check` reports `/health` as `endpoint_absent` and decides health from `/ping`. A database-scoped token can be denied `/ping`. `health_check` then reports `credential_cannot_check`, even when the instance is reachable. - `describe_table` returns a `catalog_metadata_unavailable` warning, because the token can't read the catalog. To confirm a connection with a database-scoped token, call `list_tables` or `query_sql`. For tool availability, see [Tools](#tools). To create an instance and tokens, see [Get started with InfluxDB 3 Cloud](https://docs.influxdata.com/influxdb3/cloud/get-started/) and [Manage tokens](https://docs.influxdata.com/influxdb3/cloud/admin/tokens/). #### InfluxDB Cloud Serverless You must provide: - `INFLUX_DB_INSTANCE_URL` (e.g. `https://us-east-1-1.aws.cloud2.influxdata.com`) - `INFLUX_DB_TOKEN` - `INFLUX_DB_PRODUCT_TYPE` (`cloud-serverless`) Example `.env`: ```env INFLUX_DB_INSTANCE_URL=https://us-east-1-1.aws.cloud2.influxdata.com INFLUX_DB_TOKEN=your_influxdb_token_here INFLUX_DB_PRODUCT_TYPE=cloud-serverless ``` #### InfluxDB Cloud Dedicated You must provide `INFLUX_DB_PRODUCT_TYPE=cloud-dedicated` and `INFLUX_DB_CLUSTER_ID`, plus one of these token combinations: **Option 1: Database Token Only** (Query/Write operations only): ```env INFLUX_DB_PRODUCT_TYPE=cloud-dedicated INFLUX_DB_CLUSTER_ID=your_cluster_id_here INFLUX_DB_TOKEN=your_database_token_here ``` **Option 2: Management Token Only** (Database management only): ```env INFLUX_DB_PRODUCT_TYPE=cloud-dedicated INFLUX_DB_CLUSTER_ID=your_cluster_id_here INFLUX_DB_ACCOUNT_ID=your_account_id_here INFLUX_DB_MANAGEMENT_TOKEN=your_management_token_here ``` **Option 3: Both Tokens** (Full functionality): ```env INFLUX_DB_PRODUCT_TYPE=cloud-dedicated INFLUX_DB_CLUSTER_ID=your_cluster_id_here INFLUX_DB_ACCOUNT_ID=your_account_id_here INFLUX_DB_TOKEN=your_database_token_here INFLUX_DB_MANAGEMENT_TOKEN=your_management_token_here ``` #### InfluxDB Clustered You must provide `INFLUX_DB_PRODUCT_TYPE=clustered` and `INFLUX_DB_INSTANCE_URL`, plus one of these token combinations: **Option 1: Database Token Only** (Query/Write operations only): ```env INFLUX_DB_PRODUCT_TYPE=clustered INFLUX_DB_INSTANCE_URL=https://your_cluster_host.com INFLUX_DB_TOKEN=your_database_token_here ``` **Option 2: Management Token Only** (Database management only): ```env INFLUX_DB_PRODUCT_TYPE=clustered INFLUX_DB_INSTANCE_URL=https://your_cluster_host.com INFLUX_DB_MANAGEMENT_TOKEN=your_management_token_here ``` **Option 3: Both Tokens** (Full functionality): ```env INFLUX_DB_PRODUCT_TYPE=clustered INFLUX_DB_INSTANCE_URL=https://your_cluster_host.com INFLUX_DB_TOKEN=your_database_token_here INFLUX_DB_MANAGEMENT_TOKEN=your_management_token_here ``` See the corresponding `env..example` file for configuration examples and details. #### Optional MCP tool profile and telemetry `INFLUX_MCP_TOOL_PROFILE` selects which tools the server advertises: | Profile | Tools | | ----------- | ------------------------------------------------------------------------------------- | | `readonly` | Tools that explore and query data. | | `readwrite` | The `readonly` tools plus `write_line_protocol`. No database or token administration. | | `operator` | Every tool, including database and token administration. The default when unset. | The server refuses to start if the value is anything else, so a misspelled profile can't silently expose the full operator tool set. ```env INFLUX_MCP_TOOL_PROFILE=readonly ``` Tool-call telemetry is enabled by default and writes structured JSON lines to `stderr`, which keeps `stdout` reserved for MCP stdio protocol messages. To disable telemetry: ```env MCP_LOG_TOOL_CALLS=false ``` To write telemetry to a file, configure the file backend: ```env MCP_LOG_BACKEND=file MCP_LOG_FILE=/logs/influxdb-mcp.jsonl ``` The telemetry log includes tool name, request ID, query ID, duration, database, row count, completeness and cap source, success state, and error code. It does not log API tokens, request headers, tool arguments, or query text. On Core and Enterprise, after a successful query the server looks for the same query text in `system.queries`. When it finds one, `metadata.query_id` is that row's `id`, `query_id_source` is `system.queries.id`, and the row's timings and `max_memory` are added to `metadata`. Otherwise, including when the token can't read `_internal`, `query_id` is a locally generated UUID with `query_id_source: "local"`, which doesn't appear in `system.queries`. The lookup costs one extra query per call, and is skipped on the other products. Sample harness profiles live in `harness-profiles/`; for approval settings and repeatable E2E prompts, see `AGENT_E2E_TESTS.md`. #### Optional HTTP transport (experimental) By default the server speaks MCP over stdio and runs next to the MCP client. Set `MCP_TRANSPORT=http` to serve MCP over [Streamable HTTP](https://modelcontextprotocol.io/specification/2026-07-28/basic/transports) instead, so that clients on other machines can connect to one shared server. This mode is experimental. It has been checked with the `readonly` profile against InfluxDB 3 Enterprise and InfluxDB 3 Cloud. Sign-in in the `oauth` mode has been checked against InfluxDB 3 Enterprise only, with Auth0 and Claude Code. Per-user InfluxDB access has been checked against InfluxDB 3 Enterprise 3.12.3, with Auth0 and Claude Code, as one user with the Member role. Other products, profiles, identity providers, and clients are untested over HTTP. ```env MCP_TRANSPORT=http MCP_HTTP_AUTH_MODE=influxdb-token-passthrough INFLUX_DB_PRODUCT_TYPE=enterprise INFLUX_DB_INSTANCE_URL=https://influxdb.internal:8181/ ``` The server keeps no session. It serves each request on its own, so any replica can answer any request and a restart loses nothing. The `/mcp` endpoint serves clients of the MCP `2026-07-28` revision, which has no handshake, and clients of earlier revisions. It accepts `POST` only and answers `GET` and `DELETE` with `405`. ##### Authentication mode `MCP_HTTP_AUTH_MODE` is required and has no default. The server refuses to start in HTTP mode until you set it. Two modes are available: | Mode | A client presents | The server reaches InfluxDB with | Use it when | | ---------------------------- | ------------------------------------------- | ------------------------------------- | ------------------------------------------------ | | `oauth` | An access token from your identity provider | The token in the server's environment | You have an identity provider. | | `influxdb-token-passthrough` | Its own InfluxDB token | That client's token | The network is trusted and has no such provider. | With InfluxDB 3 Enterprise, `oauth` mode can instead reach InfluxDB as each signed-in person. See [Per-user InfluxDB access](#per-user-influxdb-access-oauth-with-influxdb-3-enterprise). ###### OAuth sign-in (`oauth`) In this mode the server is an OAuth resource server, as the [MCP authorization specification](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization) describes. People sign in with your identity provider from their MCP client. The server issues no tokens and has no sign-in pages of its own. ```env MCP_TRANSPORT=http MCP_HTTP_AUTH_MODE=oauth MCP_OAUTH_ISSUER=https://YOUR_TENANT.us.auth0.com/ MCP_OAUTH_RESOURCE_URL=https://mcp.example.com/mcp INFLUX_DB_PRODUCT_TYPE=enterprise INFLUX_DB_INSTANCE_URL=https://influxdb.internal:8181/ INFLUX_DB_TOKEN= ``` - A request without a valid access token gets a `401` that points the client to `/.well-known/oauth-protected-resource/mcp`. That document names your identity provider, and the client starts the sign-in from there. - The server checks the token on every request: its signature against the keys your identity provider publishes, its issuer, its expiry, and its audience, which must be `MCP_OAUTH_RESOURCE_URL`. If `MCP_OAUTH_REQUIRED_SCOPES` is set, a token without those scopes gets a `403`. - The client's token is never sent to InfluxDB. The server reaches InfluxDB with the token in its own environment, as it does over stdio. > [!IMPORTANT] > Unless you turn on > [per-user InfluxDB access](#per-user-influxdb-access-oauth-with-influxdb-3-enterprise), > every signed-in person acts with the same InfluxDB token. Your identity > provider decides who can sign in. It doesn't decide what each person can > read. Give the server a token that has only the permissions all of them > should have, such as a read-only token for one database, and limit who can > sign in at the identity provider. Tool-call telemetry records the caller > information available in the access token. When the token has no subject > claim, telemetry omits `caller_sub`. When the token has no recognized client > ID claim, telemetry records `caller_client_id` as `unknown`. > > `INFLUX_MCP_TOOL_PROFILE` also applies to every signed-in person. If you set > it to `readwrite` or `operator`, everyone who can sign in can write data, or > administer databases and tokens, with the server's tokens. Your identity provider must: - Publish its metadata at a standard address (`/.well-known/oauth-authorization-server` or `/.well-known/openid-configuration`). The `issuer` in that document must equal `MCP_OAUTH_ISSUER` exactly, including any trailing slash. - Issue access tokens that are signed JWTs (RS256, ES256, or another public-key algorithm) whose audience matches `MCP_OAUTH_RESOURCE_URL`, with or without one trailing slash. MCP clients ask for that audience with the `resource` parameter ([RFC 8707](https://www.rfc-editor.org/rfc/rfc8707.html)). Opaque tokens aren't supported. - Know your MCP clients, through a client ID you registered for them, a Client ID Metadata Document, or Dynamic Client Registration. For example, with [Auth0](https://auth0.com/ai/docs/mcp): 1. Create an API whose identifier is the value of `MCP_OAUTH_RESOURCE_URL`, signed with RS256. 2. In the tenant's advanced settings, turn on **Resource Parameter Compatibility Profile**, so that Auth0 issues the token for the `resource` an MCP client asks for. 3. Create a Native application for your MCP client, and add the client's callback address to its allowed callback URLs. For Claude Code that is `http://localhost:PORT/callback`, with the port you pass as `--callback-port`. 4. Allow that application to use the API. In the API's settings, under **Application Access Policy**, set **User-Delegated Access** to **All apps allowed**, or keep **Per-app authorization** and grant the application user-delegated access on the API's **Application Access** tab. Without this, Auth0 refuses the sign-in and says the client `is not authorized to access resource server`. 5. Set `MCP_OAUTH_ISSUER` to `https://YOUR_TENANT.REGION.auth0.com/`, with the trailing slash. The API identifier can't be changed after you create the API. If it differs from `MCP_OAUTH_RESOURCE_URL` by even one character, Auth0 refuses the sign-in with `Service not found`. You can do the same setup with the [Auth0 CLI](https://github.com/auth0/auth0-cli). Sign in with `auth0 login`, and request the `create:resource_servers`, `read:resource_servers`, `create:clients`, `read:tenant_settings`, and `update:tenant_settings` scopes. Then run these commands: ```sh auth0 apis create --name "InfluxDB 3 MCP" --identifier https://mcp.example.com/mcp --signing-alg RS256 auth0 api patch "tenants/settings" --data '{"resource_parameter_profile":"compatibility"}' auth0 apps create --name "Claude Code" --type native --callbacks http://localhost:PORT/callback auth0 api get "resource-servers" | grep -A6 subject_type_authorization ``` When `apis create` asks for scopes, leave them empty unless you set `MCP_OAUTH_REQUIRED_SCOPES`. The last command shows the access policies of each API. If your API's `user` policy is `allow_all`, step 4 is already done. Otherwise, grant the application access as step 4 describes. For step 5, the issuer is your tenant's domain as `auth0 tenants list` shows it, with `https://` in front and a trailing slash. To try this mode on your own machine without an identity provider account, see [the local OAuth example](examples/oauth-local/README.md). At startup the server checks the identity provider's metadata and discovers the signing-key endpoint. If the metadata names a different issuer, the server refuses to start and prints the value to use. If the provider can't be reached, the server starts with a warning and retries discovery when it verifies a token. The server fetches signing keys when token verification needs them. If the server can't retrieve the metadata or keys it needs to verify a bearer token, it returns `503`. ###### Per-user InfluxDB access (`oauth` with InfluxDB 3 Enterprise) InfluxDB 3 Enterprise 3.12 and later can [authenticate users with your identity provider](https://docs.influxdata.com/influxdb3/enterprise/admin/security/manage-users/). When it does, the server can reach InfluxDB as the person who signed in, instead of with one shared token, so that each person's Enterprise role decides what they can read or change. Set `MCP_OAUTH_INFLUXDB_AUDIENCE` to turn this on: ```env MCP_TRANSPORT=http MCP_HTTP_AUTH_MODE=oauth MCP_OAUTH_ISSUER=https://YOUR_TENANT.us.auth0.com/ MCP_OAUTH_RESOURCE_URL=https://mcp.example.com/mcp MCP_OAUTH_INFLUXDB_AUDIENCE= MCP_OAUTH_CLIENT_ID= MCP_OAUTH_CLIENT_SECRET= INFLUX_DB_PRODUCT_TYPE=enterprise INFLUX_DB_INSTANCE_URL=https://influxdb.internal:8181/ ``` - On each request the server verifies the caller's access token as described above. It then asks your identity provider to exchange that token for one issued for InfluxDB and for the same person ([RFC 8693](https://www.rfc-editor.org/rfc/rfc8693.html) token exchange), and sends the new token to InfluxDB. - The caller's own token is never sent to InfluxDB. It was issued for this server, and InfluxDB refuses a token issued for another audience. - The server holds no InfluxDB token. `INFLUX_DB_TOKEN` in its environment is ignored, with a log line at startup. If the exchange fails, the request is refused. The server never falls back to a shared token. - InfluxDB decides what each person can do. A person must exist as a user in Enterprise, with an OAuth ID equal to the `sub` claim of their token. A person who signed in but isn't a user in Enterprise gets an InfluxDB authentication error on their first tool call. - `INFLUX_MCP_TOOL_PROFILE` still decides which tools the server advertises. InfluxDB then allows or denies each call by the person's role. - The server keeps each exchanged token in memory and reuses it until one minute before it expires, or before the caller's own token expires, whichever is earlier. It keeps at most 1000, and each replica keeps its own. A person you remove at the identity provider can therefore keep working until those tokens expire, so set a short token lifetime at the identity provider for both APIs. The server refuses to start in this configuration when `INFLUX_DB_PRODUCT_TYPE` isn't `enterprise`, when `MCP_OAUTH_CLIENT_ID` or `MCP_OAUTH_CLIENT_SECRET` is missing, when either of them is set without `MCP_OAUTH_INFLUXDB_AUDIENCE`, or when the identity provider's metadata has no `token_endpoint`. When an exchange fails, the client gets one of these answers and nothing is sent to InfluxDB: | The identity provider | The client gets | | --------------------------------------------------------------------------- | ----------------------------------------------- | | Can't be reached, times out, or answers `429` or `5xx` | `503` with `retry-after` | | Rejects the server's own client (`invalid_client`) or the request | `503` with `retry-after`, and a line in the log | | No longer accepts the caller's token (`invalid_grant`) | `401` with the sign-in challenge | | Doesn't allow the exchange (`access_denied`, `invalid_target`, and similar) | `403`, and a line in the log | Your identity provider must also: - List a `token_endpoint` in its metadata. - Support the token exchange grant with an `audience` parameter, for a client that authenticates with a client ID and secret in the request body. - Issue the exchanged token as a bearer access token that InfluxDB accepts. Microsoft Entra's on-behalf-of flow uses a different grant and isn't supported. For example, with Auth0 and the setup above: 1. Create a second API, for InfluxDB. Its identifier is the value of `MCP_OAUTH_INFLUXDB_AUDIENCE` and of `--oauth-audience` on InfluxDB. 2. Open the API you created for this server, choose **Add Application**, and create a **Custom API Client**. In that client's settings, turn on **Token Exchange** > **On-Behalf-Of Token Exchange**. Its client ID and client secret are `MCP_OAUTH_CLIENT_ID` and `MCP_OAUTH_CLIENT_SECRET`. 3. On the InfluxDB API's **Application Access** tab, check that the Custom API Client has user-delegated access. 4. Start InfluxDB 3 Enterprise with `--user-auth-type oauth`, `--oauth-issuer` set to the value of `MCP_OAUTH_ISSUER`, and `--oauth-audience` set to the InfluxDB API's identifier. Add each person as a user whose OAuth ID is their `sub` at the identity provider. Auth0 issues the exchanged token with the InfluxDB API's token lifetime, which is 24 hours unless you change it in that API's settings. ###### InfluxDB token pass-through (`influxdb-token-passthrough`) - Each client sends its own InfluxDB token as `Authorization: Bearer ` on every request. A request without one gets a `401`. - The server uses that token for that request only, and holds no InfluxDB credential of its own. InfluxDB decides what each token can read or change. - The server doesn't check a token itself. A wrong token shows up as an InfluxDB authentication error on the first tool call. > [!WARNING] > This mode doesn't follow the > [MCP authorization specification](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization), > which requires a server to accept only tokens issued for it and not to > forward a client's token to another service. Use it only on a network you > trust, such as an air-gapped site, and with MCP clients you trust to hold > InfluxDB tokens. Where you have an identity provider, use `oauth` instead. ###### In both modes - The MCP endpoint is `/mcp`. `/healthz` reports that the process is running; it needs no credential and doesn't contact InfluxDB. - The server refuses to start if tokens would cross the network unencrypted, unless you allow it. See [Encryption checks at startup](#encryption-checks-at-startup). - The InfluxDB endpoint comes from the server's environment. A client can't choose or change it. - In `influxdb-token-passthrough` mode, `INFLUX_DB_TOKEN` and `INFLUX_DB_MANAGEMENT_TOKEN` in the server's environment are ignored. Tools that need a management token (Cloud Dedicated and Clustered database and token administration) aren't available. The same applies in `oauth` mode with per-user InfluxDB access. - `INFLUX_MCP_TOOL_PROFILE` defaults to `readonly`, instead of `operator`. Set it explicitly to advertise more tools. - `load_database_context` reads the `context/` directory of the server, so all clients share it. | Variable | Default | Purpose | | ----------------------------------- | ----------- | ----------------------------------------------------------------------------------------------------------------- | | `MCP_HTTP_AUTH_MODE` | none | Required. `oauth` or `influxdb-token-passthrough`. | | `MCP_OAUTH_ISSUER` | none | `oauth` mode, required. Your identity provider's issuer URL, exactly as the provider publishes it. | | `MCP_OAUTH_RESOURCE_URL` | none | `oauth` mode, required. The URL clients use to reach this server, ending in `/mcp`. Tokens must be issued for it. | | `MCP_OAUTH_REQUIRED_SCOPES` | none | `oauth` mode. Scopes every token must carry, separated by spaces or commas. | | `MCP_OAUTH_INFLUXDB_AUDIENCE` | none | `oauth` mode. Turns on per-user InfluxDB access. The audience InfluxDB 3 Enterprise validates tokens against. | | `MCP_OAUTH_CLIENT_ID` | none | Required with `MCP_OAUTH_INFLUXDB_AUDIENCE`. This server's client ID at the identity provider. | | `MCP_OAUTH_CLIENT_SECRET` | none | Required with `MCP_OAUTH_INFLUXDB_AUDIENCE`. That client's secret. | | `MCP_OAUTH_INFLUXDB_SCOPES` | none | Scopes to ask for in the exchanged token, separated by spaces or commas. | | `MCP_HTTP_HOST` | `127.0.0.1` | Address to listen on. Use `0.0.0.0` in a container. | | `MCP_HTTP_PORT` | `3000` | Port to listen on. | | `MCP_HTTP_ALLOWED_ORIGINS` | none | Comma-separated browser origins to accept. Other origins get a `403`. | | `MCP_HTTP_ALLOW_PLAINTEXT_LISTENER` | `false` | Allow listening beyond `localhost` over plain HTTP. See the next section. | | `MCP_HTTP_ALLOW_PLAINTEXT_INFLUXDB` | `false` | Allow an `http://` InfluxDB URL on another machine. See the next section. | The server doesn't limit how many requests it serves at once, and a request body can be up to 4 MiB. Put rate limiting in a proxy in front of the server. ##### Encryption checks at startup A client's InfluxDB token travels over two connections: from the client to this server, and from this server to InfluxDB. In HTTP mode the server refuses to start if either connection would carry tokens unencrypted to another machine. | Connection | The server refuses to start when | Override | | ------------------ | ---------------------------------------------------------------------- | ---------------------------------------- | | Client to server | `MCP_HTTP_HOST` isn't a loopback address. The listener is plain HTTP. | `MCP_HTTP_ALLOW_PLAINTEXT_LISTENER=true` | | Server to InfluxDB | `INFLUX_DB_INSTANCE_URL` is `http://` and its host is another machine. | `MCP_HTTP_ALLOW_PLAINTEXT_INFLUXDB=true` | Set an override when plain HTTP is acceptable for that connection: - TLS ends in front of the server, at an ingress, load balancer, or service mesh. Set `MCP_HTTP_ALLOW_PLAINTEXT_LISTENER=true`. - The network is trusted, such as an air-gapped site or a private cluster network. Set whichever override applies, or both. With an override set, the server starts and logs a warning for that connection. `localhost`, loopback addresses, and `host.docker.internal` never need an override. Cloud Dedicated always uses `https://` for InfluxDB. The stdio transport doesn't run these checks. In `oauth` mode only the client-to-server connection is checked. The token sent to InfluxDB is the server's own, as it is over stdio, so `MCP_HTTP_ALLOW_PLAINTEXT_INFLUXDB` has no effect. The server starts without an error or a warning when `INFLUX_DB_INSTANCE_URL` is `http://` on another machine, and its own token then crosses that network unencrypted. Use an `https://` InfluxDB URL unless you trust that network. With per-user InfluxDB access, each person's own InfluxDB token goes to InfluxDB, so both connections are checked, as in `influxdb-token-passthrough` mode. To connect Claude Code to a server at `https://mcp.example.com` in `oauth` mode, with a client ID you registered at your identity provider: ```bash claude mcp add --transport http influxdb https://mcp.example.com/mcp \ --client-id YOUR_CLIENT_ID --callback-port 8080 ``` Then run `/mcp` in Claude Code and sign in. In `influxdb-token-passthrough` mode, send the InfluxDB token instead: ```bash claude mcp add --transport http influxdb https://mcp.example.com/mcp \ --header "Authorization: Bearer $INFLUX_DB_TOKEN" ``` --- ### 2. Configure your MCP client #### Run locally with pnpm 1. Install dependencies. ```bash pnpm install ``` 2. Build the server. ```bash pnpm run build ``` 3. Configure your MCP client to use the built server. See [the local configuration example](example-local.mcp.json). ```json { "mcpServers": { "influxdb": { "command": "node", "args": ["/absolute/path/to/influxdb3_mcp_server/build/index.js"], "env": { "INFLUX_DB_INSTANCE_URL": "http://localhost:8181/", "INFLUX_DB_TOKEN": "", "INFLUX_DB_PRODUCT_TYPE": "core", "INFLUX_MCP_TOOL_PROFILE": "readonly" } } } } ``` #### Run locally with npx After version 2.1.0 is published, configure your MCP client to run it with `npx`. This method requires no separate install or build step. ```json { "mcpServers": { "influxdb": { "command": "npx", "args": ["-y", "@influxdata/influxdb3-mcp-server@2.1.0"], "env": { "INFLUX_DB_INSTANCE_URL": "http://localhost:8181/", "INFLUX_DB_TOKEN": "", "INFLUX_DB_PRODUCT_TYPE": "core", "INFLUX_MCP_TOOL_PROFILE": "readonly" } } } } ``` #### Run with Docker Build the Docker image before running the Docker integration. ```bash # Option 1: Use docker compose (recommended) docker compose build # Option 2: Use pnpm script pnpm run docker:build ``` **a) Docker with remote InfluxDB instance** (see `example-docker.mcp.json`): ```json { "mcpServers": { "influxdb": { "command": "docker", "args": [ "run", "--rm", "-i", "-e", "INFLUX_DB_INSTANCE_URL", "-e", "INFLUX_DB_TOKEN", "-e", "INFLUX_DB_PRODUCT_TYPE", "mcp/influxdb" ], "env": { "INFLUX_DB_INSTANCE_URL": "http://remote-influxdb-host:8181/", "INFLUX_DB_TOKEN": "", "INFLUX_DB_PRODUCT_TYPE": "core" } } } } ``` **b) Docker with InfluxDB running in Docker on the same machine** (see `example-docker.mcp.json`): Use `host.docker.internal` as the InfluxDB URL so the MCP server container can reach the InfluxDB container: ```json { "mcpServers": { "influxdb": { "command": "docker", "args": [ "run", "--rm", "-i", "--add-host=host.docker.internal:host-gateway", "-e", "INFLUX_DB_INSTANCE_URL", "-e", "INFLUX_DB_TOKEN", "-e", "INFLUX_DB_PRODUCT_TYPE", "influxdb-mcp-server" ], "env": { "INFLUX_DB_INSTANCE_URL": "http://host.docker.internal:8181/", "INFLUX_DB_TOKEN": "", "INFLUX_DB_PRODUCT_TYPE": "enterprise" } } } } ``` --- ## Usage examples - Use your MCP client to call tools, resources, or prompts as described above. - **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. - See the `example-*.mcp.json` files for ready-to-use configuration templates: - `example-local.mcp.json` - Local development setup - `example-npx.mcp.json` - NPX-based setup - `example-docker.mcp.json` - Docker-based setup - `example-cloud-dedicated.mcp.json` - Cloud Dedicated with all variables - `example-clustered.mcp.json` - Clustered with all variables - `example-cloud-serverless.mcp.json` - Cloud Serverless configuration - See the `env.example`, `env.cloud-dedicated.example`, `env.clustered.example`, and `env.cloud-serverless.example` files for environment variable templates. - See `AGENT_E2E_TESTS.md` for MCP harness tips, read-only profile runs, and telemetry correlation checks. ### Run Cloud Serverless integration tests The Cloud Serverless test command needs these variables: - `INFLUX_DB_INSTANCE_URL` - `INFLUX_DB_TOKEN` - `INFLUX_TEST_DATABASE`, the bucket the tests use - `INFLUX_TEST_ORG` (optional) The command sets `INFLUX_TEST_ENABLED=true` and `INFLUX_DB_PRODUCT_TYPE=cloud-serverless`. To keep the token out of files, store only `op://` references in an env file and run the tests through 1Password. The token then exists only in the test process environment. ```env INFLUX_DB_INSTANCE_URL=op://VAULT/ITEM/hostname INFLUX_DB_TOKEN=op://VAULT/ITEM/token INFLUX_TEST_DATABASE=op://VAULT/ITEM/bucket ``` ```bash op run --env-file /path/to/cloud-serverless.env -- \ pnpm run test:integration:cloud-serverless ``` You can instead copy `env.cloud-serverless.example` to the ignored `.env.cloud-serverless.local` file and set the MCP runtime variables there. Then run `pnpm run test:integration:cloud-serverless` directly. To use another plaintext credentials file, set `INFLUX_TEST_ENV_FILE`: ```bash INFLUX_TEST_ENV_FILE=/path/to/serverless.env pnpm run test:integration:cloud-serverless ``` GitHub Actions runs the same command with the existing URL and token secrets from the `cloud-serverless` environment. The workflow selects the `mcp-ci-tests` bucket explicitly. ### Database retention policy examples #### Set 90-day retention on Core or Enterprise ```typescript // Set 90-day retention policy on Enterprise instance await mcp.update_database({ name: "my_database", retentionPeriod: 7776000000000000, // 90 days in nanoseconds }); ``` #### Update multiple settings on Cloud Dedicated ```typescript // Update retention, maxTables, and maxColumnsPerTable await mcp.update_database({ name: "my_database", retentionPeriod: 7776000000000000, // 90 days maxTables: 1000, maxColumnsPerTable: 250, }); ``` #### Common retention periods | Duration | Nanoseconds | | -------- | ---------------------- | | 7 days | 604,800,000,000,000 | | 30 days | 2,592,000,000,000,000 | | 90 days | 7,776,000,000,000,000 | | 180 days | 15,552,000,000,000,000 | | 1 year | 31,536,000,000,000,000 | --- ## Support and troubleshooting - Use the `get_help` tool for built-in help and troubleshooting. - For connection issues, check your environment variables and InfluxDB instance status. - For advanced configuration, see the comments in the example `.env` and MCP config files. ### Write errors When InfluxDB rejects a write, `write_line_protocol` includes the reason from InfluxDB. Common reasons include a duplicate tag key, an unauthenticated token, and a payload that exceeds the size limit. The following message shows a duplicate tag key. ```text Bad request: invalid line protocol - multiple instances of 'region' tag found ``` A failed write also has `error.code` and `error.recovery`. These have `recovery: "retry"`: - HTTP 429 and 503 return `write_unavailable`. The server refused the write and stored nothing. - A refused connection returns `write_connection_refused`. The server stored nothing. A `504`, a connection that closes before a reply, or a write the server doesn't answer in time is `write_outcome_unknown`: the write may or may not have been stored. It has `recovery: "retry"` only when every line has a timestamp, because resending such a batch stores no second copy. A line without a timestamp gets the server's time, so resending a stored write adds a second point at a later time. For those batches the recovery is `none`, and the error says to check whether the rows arrived, or to ask the user, before resending. The time limit is 30 seconds on Core, Enterprise, and Clustered, and the client library's default of 10 seconds on Cloud Dedicated and Cloud Serverless. Other write errors aren't retryable. Cloud Dedicated and Cloud Serverless store the valid lines of a batch and reject the rest. The error is `write_lines_rejected`, and `write.rejected_lines` lists the rejected lines. Resend only those lines. When the server's message doesn't name the rejected lines, `write.stored` is `unknown`. Check which rows arrived before you resend. The `acceptPartial` and `noSync` parameters apply only to Core and Enterprise. Other products ignore them. ### Product coverage 2.1.0 was tested against these products: - **InfluxDB 3 Core and Enterprise 3.12.3:** the live test suite, and agent evals for reads and writes. See [InfluxDB 3.12 compatibility](#influxdb-312-compatibility). - **InfluxDB Cloud Dedicated and Cloud Serverless:** agent evals for SQL and InfluxQL reads and for a write followed by a read. - **InfluxDB 3 Cloud:** agent evals for `health_check`, `list_databases`, `list_tables`, and `query_sql`, with an admin token and with a read-only token. - **InfluxDB Clustered:** not tested against a live cluster. ### InfluxDB 3.12 compatibility Write and query errors were checked against InfluxDB 3.12.2 and 3.12.3 Core and Enterprise, including a multi-node Enterprise cluster. The live test suite passes on 3.12.3. A write to a Core 3.12.3 node that stops mid-write gets an empty reply instead of a reset connection. This server reports both as `write_outcome_unknown`. ### InfluxDB 3.11 compatibility Verified against InfluxDB 3.11.5 Core and Enterprise, including a multi-node Enterprise cluster. Core and Enterprise write through `POST /api/v3/write_lp`, which 3.11's write-availability changes for the legacy `/api/v2/write` endpoint do not affect; only `clustered` calls `/api/v2/write`. Query and schema-discovery tools behave the same whether the target database is on Parquet (Core, or Enterprise before an upgrade) or PachaTree (Enterprise 3.11+ by default, or after `--upgrade-pacha-tree`) — new `system.pt_*` tables are excluded from `get_measurements`/`get_measurement_schema` results by the same `table_schema = 'iox'` filter that already excludes other system tables. Core and Enterprise create named admin tokens through `POST /api/v3/configure/token/named_admin`. Named admin tokens accept an optional expiration in seconds. Only Enterprise supports resource tokens, so the MCP server doesn't advertise resource-token tools for Core connections. --- ## Publish to the MCP Registry Stable GitHub releases publish the npm package first, then register `io.github.influxdata/influxdb3-mcp-server` in the [official MCP Registry](https://modelcontextprotocol.io/registry/about). The registry stores metadata. Clients install the server from npm. GitHub OIDC authenticates the release job using `id-token: write`, so no additional registry secret is needed. Releases marked as prereleases or with `-` in their tag skip registry publishing. Before tagging a release, update `package.json`, `src/config.ts`, the latest `CHANGELOG.md` entry, and both `version` fields in `server.json` together. Keep `package.json`'s `mcpName` equal to `server.json`'s `name`. Check locally: ```sh node scripts/check-versions.js bash scripts/install-mcp-publisher.sh /tmp/mcp-publisher /tmp/mcp-publisher validate ``` The installer pins and verifies the Linux amd64 publisher used in CI. The `validate` command contacts the registry and checks metadata without publishing. CI runs these checks, and the npm release job also checks the versions and tag. The first registry release must use a freshly published npm version containing `mcpName`; an existing npm version cannot be updated to add it. After publishing, verify the release at each destination: - **npm:** The exact package version must exist and include the expected `mcpName`. - **Docker Hub:** The image tagged with the release version must be available. - **MCP Registry:** The exact version endpoint must return the expected server name and version. The registry release job automates this check. From the release checkout, verify npm and the registry manually: ```sh version="$(node -p "require('./package.json').version")" pnpm view "@influxdata/influxdb3-mcp-server@$version" version mcpName docker manifest inspect "influxdata/influxdb3-mcp-server:$version" curl --fail --silent --show-error \ "https://registry.modelcontextprotocol.io/v0.1/servers/io.github.influxdata%2Finfluxdb3-mcp-server/versions/$version" \ | jq --exit-status --arg version "$version" \ '.server.name == "io.github.influxdata/influxdb3-mcp-server" and .server.version == $version' ``` With valid database environment variables configured, also smoke-test the exact published npm version using [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector): ```sh npx @modelcontextprotocol/inspector --cli \ npx -y "@influxdata/influxdb3-mcp-server@$version" --method tools/list ``` Metadata validation checks the registry description; the smoke test checks that the published package initializes and advertises tools. Keep the release-note verification checklist unchecked until the corresponding checks pass. If registry publishing fails after npm succeeds, rerun only the failed registry job. Rerunning the successful npm job would try to publish an existing version. ## License [MIT](LICENSE)