Skip to main content
Glama
0xteamhq

Grafana MCP Server

by 0xteamhq

get_datasource_by_uid

Retrieve detailed information about a specific Grafana datasource using its unique identifier (UID) to streamline data access and management.

Instructions

Retrieves detailed information about a specific datasource using its UID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uidYesThe uid of the datasource

Implementation Reference

  • The ToolDefinition object defining the 'get_datasource_by_uid' tool, including its handler function that instantiates GrafanaClient and calls getDatasourceByUid.
    export const getDatasourceByUid: ToolDefinition = {
      name: 'get_datasource_by_uid',
      description: 'Retrieves detailed information about a specific datasource using its UID.',
      inputSchema: GetDatasourceByUidSchema,
      handler: async (params, context: ToolContext) => {
        try {
          const client = new GrafanaClient(context.config.grafanaConfig);
          const datasource = await client.getDatasourceByUid(params.uid);
          return createToolResult(datasource);
        } catch (error: any) {
          return createErrorResult(error.message);
        }
      },
    };
  • Zod schema defining the input parameters for the 'get_datasource_by_uid' tool (requires 'uid' string).
    const GetDatasourceByUidSchema = z.object({
      uid: z.string().describe('The uid of the datasource'),
    });
  • Function that registers the datasource-related tools, including 'get_datasource_by_uid', to the MCP server.
    export function registerDatasourceTools(server: any) {
      server.registerTool(listDatasources);
      server.registerTool(getDatasourceByUid);
      server.registerTool(getDatasourceByName);
    }
  • GrafanaClient helper method that performs the actual API request to Grafana to fetch datasource by UID.
    async getDatasourceByUid(uid: string): Promise<Datasource> {
      try {
        const response = await this.client.get(`/api/datasources/uid/${uid}`);
        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 of behavioral disclosure. It states this is a retrieval operation, implying read-only behavior, but doesn't mention any constraints like authentication requirements, rate limits, error conditions, or what 'detailed information' includes. For a tool with no annotation coverage, this is insufficient.

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 functionality without unnecessary words. It's front-loaded with the main action and resource, making it easy to parse. Every part of the sentence serves a clear purpose.

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 no annotations and no output schema, the description is incomplete for a retrieval tool. It doesn't specify what 'detailed information' includes, potential error cases, or how to handle missing datasources. With 100% schema coverage, the input is documented, but the lack of behavioral and output details leaves significant gaps for the agent.

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 100%, with the single parameter 'uid' documented as 'The uid of the datasource'. The description adds that it's used to retrieve 'detailed information about a specific datasource', reinforcing the parameter's purpose but not providing additional semantic context beyond what the schema already covers. This meets the baseline for high schema coverage.

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 ('Retrieves') and resource ('detailed information about a specific datasource'), making the purpose unambiguous. It distinguishes from list_datasources by specifying retrieval by UID rather than listing all. However, it doesn't explicitly contrast with get_datasource_by_name, which is a sibling tool, leaving some room for improvement.

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_name or list_datasources. It mentions using a UID but doesn't explain when UID-based lookup is preferred over name-based lookup or listing all datasources, leaving the agent to infer usage context.

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