Skip to main content
Glama
0xteamhq

Grafana MCP Server

by 0xteamhq

get_datasource_by_name

Retrieve detailed information about a specific Grafana datasource by providing its name to access configuration and connection details.

Instructions

Retrieves detailed information about a specific datasource using its name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesThe name of the datasource

Implementation Reference

  • The main handler function for the 'get_datasource_by_name' MCP tool. It instantiates a GrafanaClient using the server config and calls getDatasourceByName on it to retrieve and return the datasource details.
    export const getDatasourceByName: ToolDefinition = {
      name: 'get_datasource_by_name',
      description: 'Retrieves detailed information about a specific datasource using its name.',
      inputSchema: GetDatasourceByNameSchema,
      handler: async (params, context: ToolContext) => {
        try {
          const client = new GrafanaClient(context.config.grafanaConfig);
          const datasource = await client.getDatasourceByName(params.name);
          return createToolResult(datasource);
        } catch (error: any) {
          return createErrorResult(error.message);
        }
      },
    };
  • Zod schema defining the input for the tool: an object with a required 'name' string parameter.
    const GetDatasourceByNameSchema = z.object({
      name: z.string().describe('The name of the datasource'),
    });
  • src/cli.ts:105-105 (registration)
    Call to registerDatasourceTools which registers the get_datasource_by_name tool (along with others) on the MCP server, conditional on 'datasource' tools being enabled.
    registerDatasourceTools(server);
  • Supporting method in GrafanaClient class that makes the Grafana API request to fetch a datasource by its name and handles errors.
    async getDatasourceByName(name: string): Promise<Datasource> {
      try {
        const response = await this.client.get(`/api/datasources/name/${name}`);
        return response.data;
      } catch (error) {
        this.handleError(error);
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states this is a retrieval operation, implying read-only behavior, but doesn't disclose any behavioral traits such as error handling (e.g., what happens if the datasource doesn't exist), authentication requirements, rate limits, or the format of the returned information. This leaves significant gaps for an agent.

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, well-structured sentence that efficiently conveys the core purpose without any wasted words. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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

Completeness3/5

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

Given the tool's low complexity (single parameter, no output schema, no annotations), the description is minimally adequate but incomplete. It covers the basic operation but lacks behavioral details (e.g., error cases) and contextual guidance, which are needed for full agent understanding in a server with many sibling tools.

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?

The input schema has 100% description coverage, with the single parameter 'name' clearly documented. The description adds no additional semantic context beyond what's in the schema (e.g., it doesn't specify name format or constraints), so it meets the baseline of 3 where the schema does the heavy lifting.

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 tool's purpose with a specific verb ('Retrieves') and resource ('detailed information about a specific datasource'), and it specifies the lookup method ('using its name'). However, it doesn't explicitly differentiate from sibling tools like 'get_datasource_by_uid' or 'list_datasources', which would require a 5.

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 provides no guidance on when to use this tool versus alternatives like 'get_datasource_by_uid' (which uses UID instead of name) or 'list_datasources' (which lists all datasources). It only states what it does, not when it's appropriate relative to other tools.

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

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/0xteamhq/mcp-grafana'

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