Skip to main content
Glama
comet-ml

Opik MCP Server

by comet-ml

get-metrics

Retrieve metrics data from the Opik MCP Server by specifying filters like metric name, project ID, project name, or date range for precise analysis.

Instructions

Get metrics data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endDateNoEnd date in ISO format (YYYY-MM-DD)
metricNameNoOptional metric name to filter
projectIdNoOptional project ID to filter metrics
projectNameNoOptional project name to filter metrics
startDateNoStart date in ISO format (YYYY-MM-DD)

Implementation Reference

  • The main handler for the 'get-metrics' tool. It constructs an API URL with optional query parameters for filtering metrics by name, project, and date range. If no project is specified, it fetches the first available project. Returns metrics data as JSON or an error message.
      async (args: any) => {
        const { metricName, projectId, projectName, startDate, endDate } = args;
        let url = `/v1/private/metrics`;
    
        const queryParams = [];
        if (metricName) queryParams.push(`metric_name=${metricName}`);
    
        // Add project filtering - API requires either project_id or project_name
        if (projectId) {
          queryParams.push(`project_id=${projectId}`);
        } else if (projectName) {
          queryParams.push(`project_name=${encodeURIComponent(projectName)}`);
        } else {
          // If no project specified, we need to find one for the API to work
          const projectsResponse = await makeApiRequest<ProjectResponse>(
            `/v1/private/projects?page=1&size=1`
          );
    
          if (
            projectsResponse.data &&
            projectsResponse.data.content &&
            projectsResponse.data.content.length > 0
          ) {
            const firstProject = projectsResponse.data.content[0];
            queryParams.push(`project_id=${firstProject.id}`);
            logToFile(
              `No project specified, using first available: ${firstProject.name} (${firstProject.id})`
            );
          } else {
            return {
              content: [
                {
                  type: 'text',
                  text: 'Error: No project ID or name provided, and no projects found',
                },
              ],
            };
          }
        }
    
        if (startDate) queryParams.push(`start_date=${startDate}`);
        if (endDate) queryParams.push(`end_date=${endDate}`);
    
        if (queryParams.length > 0) {
          url += `?${queryParams.join('&')}`;
        }
    
        const response = await makeApiRequest<MetricsResponse>(url);
    
        if (!response.data) {
          return {
            content: [{ type: 'text', text: response.error || 'Failed to fetch metrics' }],
          };
        }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(response.data, null, 2),
            },
          ],
        };
      }
    );
  • Input parameter schema for the 'get-metrics' tool, defined using Zod with optional string parameters for metricName, projectId, projectName, startDate, and endDate.
    {
      metricName: z.string().optional().describe('Optional metric name to filter'),
      projectId: z.string().optional().describe('Optional project ID to filter metrics'),
      projectName: z.string().optional().describe('Optional project name to filter metrics'),
      startDate: z.string().optional().describe('Start date in ISO format (YYYY-MM-DD)'),
      endDate: z.string().optional().describe('End date in ISO format (YYYY-MM-DD)'),
    },
  • The loadMetricTools function that registers the 'get-metrics' tool on the MCP server using server.tool, including schema and handler.
    export const loadMetricTools = (server: any) => {
      server.tool(
        'get-metrics',
        'Get metrics data',
        {
          metricName: z.string().optional().describe('Optional metric name to filter'),
          projectId: z.string().optional().describe('Optional project ID to filter metrics'),
          projectName: z.string().optional().describe('Optional project name to filter metrics'),
          startDate: z.string().optional().describe('Start date in ISO format (YYYY-MM-DD)'),
          endDate: z.string().optional().describe('End date in ISO format (YYYY-MM-DD)'),
        },
        async (args: any) => {
          const { metricName, projectId, projectName, startDate, endDate } = args;
          let url = `/v1/private/metrics`;
    
          const queryParams = [];
          if (metricName) queryParams.push(`metric_name=${metricName}`);
    
          // Add project filtering - API requires either project_id or project_name
          if (projectId) {
            queryParams.push(`project_id=${projectId}`);
          } else if (projectName) {
            queryParams.push(`project_name=${encodeURIComponent(projectName)}`);
          } else {
            // If no project specified, we need to find one for the API to work
            const projectsResponse = await makeApiRequest<ProjectResponse>(
              `/v1/private/projects?page=1&size=1`
            );
    
            if (
              projectsResponse.data &&
              projectsResponse.data.content &&
              projectsResponse.data.content.length > 0
            ) {
              const firstProject = projectsResponse.data.content[0];
              queryParams.push(`project_id=${firstProject.id}`);
              logToFile(
                `No project specified, using first available: ${firstProject.name} (${firstProject.id})`
              );
            } else {
              return {
                content: [
                  {
                    type: 'text',
                    text: 'Error: No project ID or name provided, and no projects found',
                  },
                ],
              };
            }
          }
    
          if (startDate) queryParams.push(`start_date=${startDate}`);
          if (endDate) queryParams.push(`end_date=${endDate}`);
    
          if (queryParams.length > 0) {
            url += `?${queryParams.join('&')}`;
          }
    
          const response = await makeApiRequest<MetricsResponse>(url);
    
          if (!response.data) {
            return {
              content: [{ type: 'text', text: response.error || 'Failed to fetch metrics' }],
            };
          }
    
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(response.data, null, 2),
              },
            ],
          };
        }
      );
    
      return server;
    };
  • src/index.ts:96-98 (registration)
    Conditional registration of the metrics tools by calling loadMetricTools when 'metrics' is in enabledToolsets.
    if (config.enabledToolsets.includes('metrics')) {
      server = loadMetricTools(server);
      logToFile('Loaded metrics toolset');
Behavior1/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but fails completely. 'Get metrics data' reveals nothing about whether this is a read-only operation, whether it requires authentication, what rate limits might apply, what format the data returns in, or any other behavioral characteristics. For a data retrieval tool with zero annotation coverage, this is a critical gap that leaves the agent with no understanding of how the tool behaves.

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 extremely concise at just three words. While this represents severe under-specification in terms of content, from a pure conciseness perspective it contains zero wasted words and is front-loaded with the core action. Every word earns its place, even though that place is inadequate for proper tool understanding.

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

Completeness1/5

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

Given a 5-parameter tool with no annotations and no output schema, the description 'Get metrics data' is completely inadequate. It provides no information about what metrics are available, what system they come from, what the return format looks like, or any behavioral characteristics. For a data retrieval tool of this complexity, the description fails to provide the minimal contextual information needed for an agent to use it effectively.

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 schema description coverage is 100%, meaning all 5 parameters are well-documented in the input schema itself. The description adds absolutely no additional parameter information beyond what's already in the schema. According to the scoring rules, when schema coverage is high (>80%), the baseline score is 3 even with no parameter information in the description, which applies here.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get metrics data' is a tautology that essentially restates the tool name 'get-metrics'. It provides no specific information about what kind of metrics, from what system, or what scope. While it includes a verb ('Get') and resource ('metrics data'), it lacks any distinguishing details that would help differentiate it from potential sibling tools or clarify its specific function beyond the obvious.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides absolutely no guidance on when to use this tool versus alternatives. There are no mentions of prerequisites, appropriate contexts, or comparisons to sibling tools like 'get-trace-stats' or 'get-trace-by-id' that might handle similar data. The agent receives no help in determining when this specific metrics retrieval tool is appropriate versus other data-fetching tools in the server.

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

Related 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/comet-ml/opik-mcp'

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