Skip to main content
Glama
Arize-ai

@arizeai/phoenix-mcp

Official
by Arize-ai

get-span-annotations

Retrieve metadata, scores, and labels for spans to analyze and categorize them in your project.

Instructions

Get span annotations for a list of span IDs.

Span annotations provide additional metadata, scores, or labels for spans. They can be created by humans, LLMs, or code and help in analyzing and categorizing spans.

Example usage: Get annotations for spans ["span1", "span2"] from project "my-project" Get quality score annotations for span "span1" from project "my-project"

Expected return: Object containing annotations array and optional next cursor for pagination. Example: { "annotations": [ { "id": "annotation123", "span_id": "span1", "name": "quality_score", "result": { "label": "good", "score": 0.95, "explanation": null }, "annotator_kind": "LLM", "metadata": { "model": "gpt-4" } } ], "nextCursor": "cursor_for_pagination" }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectNameYes
spanIdsYes
includeAnnotationNamesNo
excludeAnnotationNamesNo
cursorNo
limitNo

Implementation Reference

  • Handler function that implements the get-span-annotations tool by querying the Phoenix API for span annotations based on project name, span IDs, filters, and pagination.
    async ({
      projectName,
      spanIds,
      includeAnnotationNames,
      excludeAnnotationNames,
      cursor,
      limit = 100,
    }) => {
      const params: NonNullable<
        Types["V1"]["operations"]["listSpanAnnotationsBySpanIds"]["parameters"]["query"]
      > = {
        span_ids: spanIds,
        limit,
      };
    
      if (cursor) {
        params.cursor = cursor;
      }
    
      if (includeAnnotationNames) {
        params.include_annotation_names = includeAnnotationNames;
      }
    
      if (excludeAnnotationNames) {
        params.exclude_annotation_names = excludeAnnotationNames;
      }
    
      const response = await client.GET(
        "/v1/projects/{project_identifier}/span_annotations",
        {
          params: {
            path: {
              project_identifier: projectName,
            },
            query: params,
          },
        }
      );
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              {
                annotations: response.data?.data ?? [],
                nextCursor: response.data?.next_cursor ?? null,
              },
              null,
              2
            ),
          },
        ],
      };
    }
  • Zod schema defining the input parameters for the get-span-annotations tool.
    {
      projectName: z.string(),
      spanIds: z.array(z.string()),
      includeAnnotationNames: z.array(z.string()).optional(),
      excludeAnnotationNames: z.array(z.string()).optional(),
      cursor: z.string().optional(),
      limit: z.number().min(1).max(1000).default(100).optional(),
    },
  • Registration of the get-span-annotations tool with the MCP server inside initializeSpanTools function.
      server.tool(
        "get-span-annotations",
        GET_SPAN_ANNOTATIONS_DESCRIPTION,
        {
          projectName: z.string(),
          spanIds: z.array(z.string()),
          includeAnnotationNames: z.array(z.string()).optional(),
          excludeAnnotationNames: z.array(z.string()).optional(),
          cursor: z.string().optional(),
          limit: z.number().min(1).max(1000).default(100).optional(),
        },
        async ({
          projectName,
          spanIds,
          includeAnnotationNames,
          excludeAnnotationNames,
          cursor,
          limit = 100,
        }) => {
          const params: NonNullable<
            Types["V1"]["operations"]["listSpanAnnotationsBySpanIds"]["parameters"]["query"]
          > = {
            span_ids: spanIds,
            limit,
          };
    
          if (cursor) {
            params.cursor = cursor;
          }
    
          if (includeAnnotationNames) {
            params.include_annotation_names = includeAnnotationNames;
          }
    
          if (excludeAnnotationNames) {
            params.exclude_annotation_names = excludeAnnotationNames;
          }
    
          const response = await client.GET(
            "/v1/projects/{project_identifier}/span_annotations",
            {
              params: {
                path: {
                  project_identifier: projectName,
                },
                query: params,
              },
            }
          );
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  {
                    annotations: response.data?.data ?? [],
                    nextCursor: response.data?.next_cursor ?? null,
                  },
                  null,
                  2
                ),
              },
            ],
          };
        }
      );
    };
Behavior4/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. It effectively describes key behaviors: it's a read operation (implied by 'Get'), supports pagination (via 'next cursor'), and returns structured data with an array of annotations. However, it lacks details on permissions, rate limits, or error handling, which are important for a tool with multiple parameters.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, starting with the core purpose. The examples and expected return details are useful but slightly verbose; however, every sentence adds value (e.g., explaining what span annotations are, providing usage scenarios, and detailing the output structure). Minor trimming could improve conciseness without losing clarity.

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

Completeness4/5

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

For a tool with 6 parameters, 0% schema coverage, and no output schema, the description is quite complete. It covers the purpose, usage examples, and detailed return format, which compensates for the lack of structured documentation. However, it could be more complete by explicitly mentioning all parameters (e.g., 'cursor', 'limit', 'include/excludeAnnotationNames') and their roles in the description text.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Given 0% schema description coverage, the description compensates well by explaining parameter semantics through examples and the expected return structure. It clarifies that 'spanIds' is an array of strings, 'projectName' is required, and annotations can be filtered by names (implied via examples like 'quality score annotations'), adding significant meaning beyond the bare schema.

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

Purpose5/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 ('Get') and resource ('span annotations for a list of span IDs'), distinguishing it from siblings like 'get-spans' (which likely retrieves spans themselves rather than annotations). It explains what span annotations are and their purpose, providing clear differentiation.

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

Usage Guidelines3/5

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

The description implies usage through examples (e.g., 'Get annotations for spans...'), but does not explicitly state when to use this tool versus alternatives like 'get-spans' or other sibling tools. No guidance is provided on exclusions or prerequisites, leaving usage context somewhat implicit.

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/Arize-ai/phoenix'

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