list_teams
Search for Grafana teams using a query string to find and retrieve detailed information about matching teams within your Grafana instance.
Instructions
Search for Grafana teams by a query string. Returns a list of matching teams with details
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No | The query to search for teams |
Implementation Reference
- src/tools/admin.ts:17-34 (handler)The handler function for the 'list_teams' tool. It instantiates a GrafanaClient, calls listTeams with the optional query parameter, formats the team data (id, name, email, memberCount), and returns the result or an error.handler: async (params, context: ToolContext) => { try { const client = new GrafanaClient(context.config.grafanaConfig); const teams = await client.listTeams(params.query); // Format the response const formatted = teams.map(team => ({ id: team.id, name: team.name, email: team.email, memberCount: team.memberCount, })); return createToolResult(formatted); } catch (error: any) { return createErrorResult(error.message); } },
- src/tools/admin.ts:6-8 (schema)Zod schema defining the input for list_teams tool: optional 'query' string to search for teams.const ListTeamsSchema = z.object({ query: z.string().optional().describe('The query to search for teams'), });
- src/tools/admin.ts:65-65 (registration)Registers the 'list_teams' tool definition with the MCP server inside the registerAdminTools function.server.registerTool(listTeams);
- GrafanaClient method that performs the API call to /api/teams/search with optional query parameter, used by the tool handler.async listTeams(query?: string): Promise<Team[]> { try { const response = await this.client.get('/api/teams/search', { params: { query }, }); return response.data.teams; } catch (error) { this.handleError(error); } }
- src/cli.ts:123-123 (registration)Invocation of registerAdminTools which registers the 'list_teams' tool, conditionally if 'admin' category is enabled.registerAdminTools(server);