Skip to main content
Glama
m4tyn0

InfluxDB MCP Server

by m4tyn0
influx_client.py1.72 kB
from influxdb import InfluxDBClient from .config import ( INFLUXDB_HOST, INFLUXDB_PORT, INFLUXDB_USERNAME, INFLUXDB_PASSWORD, INFLUXDB_SSL, INFLUXDB_VERIFY_SSL, INFLUXDB_TIMEOUT ) class InfluxClient: """Client for interacting with InfluxDB.""" def __init__(self): """Initialize the InfluxDB client with configuration from environment.""" self.client = InfluxDBClient( host=INFLUXDB_HOST, port=INFLUXDB_PORT, username=INFLUXDB_USERNAME, password=INFLUXDB_PASSWORD, ssl=INFLUXDB_SSL, verify_ssl=INFLUXDB_VERIFY_SSL, timeout=INFLUXDB_TIMEOUT ) def list_databases(self): """List all available databases.""" return self.client.get_list_database() def list_measurements(self, database): """List all measurements in a database.""" self.client.switch_database(database) return self.client.get_list_measurements() def execute_query(self, database, query): """ Execute a read-only query against InfluxDB. Args: database (str): The database to query query (str): The InfluxQL query to execute Returns: list: The query results Raises: ValueError: If the query is not read-only """ # Ensure query is read-only (starts with SELECT) query = query.strip() if not query.upper().startswith("SELECT"): raise ValueError("Only SELECT queries are allowed for read-only access") self.client.switch_database(database) return self.client.query(query).raw

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/m4tyn0/influx_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server