Skip to main content
Glama
idoru

InfluxDB MCP Server

by idoru

write-data

Write time-series data into InfluxDB using line protocol format, specifying organization, bucket, and timestamp precision for efficient data storage.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucketYesThe bucket name
dataYesData in InfluxDB line protocol format
orgYesThe organization name
precisionNoTimestamp precision (ns, us, ms, s)

Implementation Reference

  • The primary handler function that executes the 'write-data' tool. It sends the provided line protocol data to the InfluxDB write API endpoint using fetch, handles errors, and returns success or error responses.
    export async function writeData({ org, bucket, data, precision }) {
      // Add extremely clear logging
      console.log(`=== WRITE-DATA TOOL CALLED ===`);
      console.log(
        `Writing to org: ${org}, bucket: ${bucket}, data length: ${data.length}`,
      );
    
      try {
        // Simplified approach focusing on core functionality
        let endpoint = `/api/v2/write?org=${encodeURIComponent(org)}&bucket=${encodeURIComponent(bucket)
          }`;
        if (precision) {
          endpoint += `&precision=${precision}`;
        }
    
        console.log(`Write URL: ${INFLUXDB_URL}${endpoint}`);
    
        // Use fetch directly instead of our wrapper to eliminate any potential issues
        const response = await fetch(`${INFLUXDB_URL}${endpoint}`, {
          method: "POST",
          headers: {
            "Content-Type": "text/plain; charset=utf-8",
            "Authorization": `Token ${INFLUXDB_TOKEN}`,
          },
          body: data,
        });
    
        console.log(`Write response status: ${response.status}`);
    
        if (!response.ok) {
          const errorText = await response.text();
          throw new Error(
            `Failed to write data: ${response.status} ${errorText}`,
          );
        }
    
        console.log(`=== WRITE-DATA TOOL COMPLETED SUCCESSFULLY ===`);
        return {
          content: [{
            type: "text",
            text: "Data written successfully",
          }],
        };
      } catch (error) {
        console.error(`=== WRITE-DATA TOOL ERROR: ${error.message} ===`);
        return {
          content: [{
            type: "text",
            text: `Error writing data: ${error.message}`,
          }],
          isError: true,
        };
      }
    }
  • src/index.js:76-102 (registration)
    Registers the 'write-data' tool with the MCP server, including the tool name, description, input schema using Zod, and reference to the handler function.
      "write-data",
      "Stream newline-delimited line protocol records into a bucket. Use this after composing measurements so the LLM can insert real telemetry, optionally controlling timestamp precision.",
      {
        org: z
          .string()
          .describe(
            "Human-readable organization name that owns the destination bucket (the same value returned by the orgs resource).",
          ),
        bucket: z
          .string()
          .describe(
            "Bucket name to receive the points. Make sure it already exists or call create-bucket first.",
          ),
        data: z
          .string()
          .describe(
            "Payload containing one or more line protocol lines (measurements, tags, fields, timestamps) separated by newlines.",
          ),
        precision: z
          .enum(["ns", "us", "ms", "s"])
          .optional()
          .describe(
            "Optional timestamp precision. Provide it only when the line protocol omits unit suffix context; defaults to nanoseconds.",
          ),
      },
      writeData,
    );
  • The Zod schema defining the input parameters for the 'write-data' tool: org (string), bucket (string), data (string), precision (optional enum).
        org: z
          .string()
          .describe(
            "Human-readable organization name that owns the destination bucket (the same value returned by the orgs resource).",
          ),
        bucket: z
          .string()
          .describe(
            "Bucket name to receive the points. Make sure it already exists or call create-bucket first.",
          ),
        data: z
          .string()
          .describe(
            "Payload containing one or more line protocol lines (measurements, tags, fields, timestamps) separated by newlines.",
          ),
        precision: z
          .enum(["ns", "us", "ms", "s"])
          .optional()
          .describe(
            "Optional timestamp precision. Provide it only when the line protocol omits unit suffix context; defaults to nanoseconds.",
          ),
      },
      writeData,
    );
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/idoru/influxdb-mcp-server'

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