search_dashboards
Search Grafana dashboards using a query string to find relevant monitoring dashboards with details like title, UID, folder, tags, and URL.
Instructions
Search for Grafana dashboards by a query string. Returns a list of matching dashboards with details like title, UID, folder, tags, and URL.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The query to search for |
Input Schema (JSON Schema)
{
"properties": {
"query": {
"description": "The query to search for",
"type": "string"
}
},
"required": [
"query"
],
"type": "object"
}
Implementation Reference
- src/tools/search.ts:13-32 (handler)The handler function for the 'search_dashboards' tool that instantiates GrafanaClient, performs the dashboard search with the input query, formats the results for readability, and returns success or error.handler: async (params, context: ToolContext) => { try { const client = new GrafanaClient(context.config.grafanaConfig); const results = await client.searchDashboards(params.query); // Format results for better readability const formatted = results.map(dashboard => ({ uid: dashboard.uid, title: dashboard.title, url: dashboard.url, tags: dashboard.tags || [], folderTitle: dashboard.folderTitle, type: dashboard.type, })); return createToolResult(formatted); } catch (error: any) { return createErrorResult(error.message); } },
- src/tools/search.ts:5-7 (schema)Zod input schema for the 'search_dashboards' tool defining the required 'query' string parameter.const SearchDashboardsSchema = z.object({ query: z.string().describe('The query to search for'), });
- src/tools/search.ts:35-37 (registration)Registration function that registers the 'search_dashboards' tool with the MCP server.export function registerSearchTools(server: any) { server.registerTool(searchDashboards); }
- src/cli.ts:98-100 (registration)Conditional invocation of search tools registration (including 'search_dashboards') when the 'search' category is enabled.if (enabledTools.has('search')) { registerSearchTools(server); }
- src/clients/grafana-client.ts:54-63 (helper)GrafanaClient helper method that calls the Grafana API /api/search endpoint to search for dashboards by query, filtering by dashboard type.async searchDashboards(query: string): Promise<any[]> { try { const response = await this.client.get('/api/search', { params: { query, type: 'dash-db' }, }); return response.data; } catch (error) { this.handleError(error); } }