get_available_spaces
Retrieve all available Kibana spaces with detailed information using the provided context to manage and organize data efficiently.
Instructions
Get all available Kibana spaces with current context
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| include_details | No | Include detailed space information (name, description, etc.) |
Implementation Reference
- src/base-tools.ts:330-370 (registration)Registration of the 'get_available_spaces' tool including inline schema and handler. The handler fetches available Kibana spaces using kibanaClient.get('/api/spaces/space'), formats the response with default space info and optional details, handles errors.server.tool( "get_available_spaces", "Get all available Kibana spaces with current context", z.object({ include_details: z.boolean().optional().default(true).describe("Include detailed space information (name, description, etc.)") }), async ({ include_details = true }): Promise<ToolResponse> => { try { const response = await kibanaClient.get('/api/spaces/space'); const result = { current_default_space: defaultSpace, total_count: response.length, available_spaces: include_details ? response : response.map((space: any) => ({ id: space.id, name: space.name })) }; return { content: [ { type: "text", text: JSON.stringify(result, null, 2) } ] }; } catch (error) { console.error(`Failed to get available spaces: ${error}`); return { content: [ { type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );
- index.ts:299-299 (registration)Top-level call to registerBaseTools which includes the 'get_available_spaces' tool among base tools.registerBaseTools(serverBase, kibanaClient, defaultSpace),
- src/base-tools.ts:336-369 (handler)The core handler logic for executing the 'get_available_spaces' tool: retrieves spaces from Kibana API, processes and returns as JSON with error handling.async ({ include_details = true }): Promise<ToolResponse> => { try { const response = await kibanaClient.get('/api/spaces/space'); const result = { current_default_space: defaultSpace, total_count: response.length, available_spaces: include_details ? response : response.map((space: any) => ({ id: space.id, name: space.name })) }; return { content: [ { type: "text", text: JSON.stringify(result, null, 2) } ] }; } catch (error) { console.error(`Failed to get available spaces: ${error}`); return { content: [ { type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
- src/base-tools.ts:333-335 (schema)Input schema for the tool using Zod: optional boolean to include full space details.z.object({ include_details: z.boolean().optional().default(true).describe("Include detailed space information (name, description, etc.)") }),