Skip to main content
Glama
TocharianOU

Kibana MCP Server

by TocharianOU

execute_kb_api

Run custom API requests in Kibana with multi-space support, enabling flexible data interactions via specified methods, paths, and parameters.

Instructions

Execute a custom API request for Kibana with multi-space support

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bodyNo
methodYes
paramsNo
pathYes
spaceNoTarget Kibana space (optional, defaults to configured space)

Implementation Reference

  • Handler function that performs the actual API execution using kibanaClient methods (get, post, put, delete) based on input parameters, constructs query strings if params provided, handles multi-space support, and returns formatted ToolResponse with JSON response or error.
    async ({ method, path, body, params, space }): Promise<ToolResponse> => {
      try {
        const targetSpace = space || defaultSpace;
        let url = path;
        if (params) {
          const queryString = new URLSearchParams(
            Object.entries(params).map(([key, value]) => [key, String(value)])
          ).toString();
          url += `?${queryString}`;
        }
    
        let response;
        switch (method.toLowerCase()) {
          case 'get':
            response = await kibanaClient.get(url, { space });
            break;
          case 'post':
            response = await kibanaClient.post(url, body, { space });
            break;
          case 'put':
            response = await kibanaClient.put(url, body, { space });
            break;
          case 'delete':
            response = await kibanaClient.delete(url, { space });
            break;
          default:
            throw new Error(`Unsupported HTTP method: ${method}`);
        }
    
        return {
          content: [
            {
              type: "text",
              text: `[Space: ${targetSpace}] API response: ${JSON.stringify(response, null, 2)}`
            }
          ]
        };
      } catch (error) {
        console.error(`API request failed: ${error}`);
        return {
          content: [
            {
              type: "text",
              text: `Error: ${error instanceof Error ? error.message : String(error)}`
            }
          ],
          isError: true
        };
      }
    }
  • Zod validation schema for tool inputs: method (required enum), path (required string), body (optional any), params (optional record of string/number/boolean), space (optional string).
    z.object({
      method: z.enum(['GET', 'POST', 'PUT', 'DELETE']),
      path: z.string(),
      body: z.any().optional(),
      params: z.record(z.union([z.string(), z.number(), z.boolean()])).optional(),
      space: z.string().optional().describe("Target Kibana space (optional, defaults to configured space)")
    }),
  • Registration of the 'execute_kb_api' tool via server.tool() call, including name, description, schema, and handler function. Called within registerBaseTools function.
      "execute_kb_api",
      `Execute a custom API request for Kibana with multi-space support`,
      z.object({
        method: z.enum(['GET', 'POST', 'PUT', 'DELETE']),
        path: z.string(),
        body: z.any().optional(),
        params: z.record(z.union([z.string(), z.number(), z.boolean()])).optional(),
        space: z.string().optional().describe("Target Kibana space (optional, defaults to configured space)")
      }),
      async ({ method, path, body, params, space }): Promise<ToolResponse> => {
        try {
          const targetSpace = space || defaultSpace;
          let url = path;
          if (params) {
            const queryString = new URLSearchParams(
              Object.entries(params).map(([key, value]) => [key, String(value)])
            ).toString();
            url += `?${queryString}`;
          }
    
          let response;
          switch (method.toLowerCase()) {
            case 'get':
              response = await kibanaClient.get(url, { space });
              break;
            case 'post':
              response = await kibanaClient.post(url, body, { space });
              break;
            case 'put':
              response = await kibanaClient.put(url, body, { space });
              break;
            case 'delete':
              response = await kibanaClient.delete(url, { space });
              break;
            default:
              throw new Error(`Unsupported HTTP method: ${method}`);
          }
    
          return {
            content: [
              {
                type: "text",
                text: `[Space: ${targetSpace}] API response: ${JSON.stringify(response, null, 2)}`
              }
            ]
          };
        } catch (error) {
          console.error(`API request failed: ${error}`);
          return {
            content: [
              {
                type: "text",
                text: `Error: ${error instanceof Error ? error.message : String(error)}`
              }
            ],
            isError: true
          };
        }
      }
    );
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'multi-space support' which adds some context about space handling, but fails to describe critical behaviors like authentication requirements, rate limits, error handling, or what 'execute' entails (e.g., whether it's idempotent, what happens on failure). For a tool that can perform write operations (PUT, DELETE), this is inadequate.

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

Conciseness5/5

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

The description is a single, efficient sentence that front-loads the core purpose ('Execute a custom API request for Kibana') and adds a key feature ('with multi-space support'). There's no wasted language or redundancy.

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

Completeness2/5

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

Given the complexity (5 parameters, no output schema, no annotations, and support for write operations), the description is incomplete. It lacks information about return values, error conditions, authentication, and how to use parameters effectively. The mention of 'multi-space support' is helpful but insufficient for a tool with this scope and potential impact.

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

Parameters3/5

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

Schema description coverage is only 20% (only the 'space' parameter has a description), so the description must compensate. It adds minimal value by implying the tool handles 'multi-space' contexts, which relates to the 'space' parameter, but doesn't explain other parameters like 'body', 'params', 'method', or 'path' beyond what the schema provides. The baseline is 3 since schema coverage is low but the description doesn't fully compensate.

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

Purpose4/5

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

The description clearly states the verb ('execute') and resource ('custom API request for Kibana'), specifying the action and target. However, it doesn't explicitly differentiate from siblings like 'get_kibana_api_detail' or 'list_all_kibana_api_paths', which appear to be read-only operations, while this tool supports multiple HTTP methods including write operations.

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

Usage Guidelines2/5

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

The description mentions 'multi-space support' but doesn't provide explicit guidance on when to use this tool versus alternatives. No context is given about prerequisites, when-not-to-use scenarios, or comparisons to sibling tools like 'get_available_spaces' or 'search_kibana_api_paths'.

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/TocharianOU/mcp-server-kibana'

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