Skip to main content
Glama
Arize-ai

@arizeai/phoenix-mcp

Official
by Arize-ai

get-spans

Retrieve individual operations or units of work from a project with filtering options for time range and pagination.

Instructions

Get spans from a project with filtering criteria.

Spans represent individual operations or units of work within a trace. They contain timing information, attributes, and context about the operation being performed.

Example usage: Get recent spans from project "my-project" Get spans in a time range from project "my-project"

Expected return: Object containing spans array and optional next cursor for pagination. Example: { "spans": [ { "id": "span123", "name": "http_request", "context": { "trace_id": "trace456", "span_id": "span123" }, "start_time": "2024-01-01T12:00:00Z", "end_time": "2024-01-01T12:00:01Z", "attributes": { "http.method": "GET", "http.url": "/api/users" } } ], "nextCursor": "cursor_for_pagination" }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectNameYes
startTimeNo
endTimeNo
cursorNo
limitNo

Implementation Reference

  • The handler function for the 'get-spans' tool. It builds query parameters from the input arguments and uses the PhoenixClient to GET spans from the '/v1/projects/{project_identifier}/spans' endpoint. Returns a structured MCP response with JSON-stringified spans data and pagination cursor.
    async ({ projectName, startTime, endTime, cursor, limit = 100 }) => {
      const params: NonNullable<
        Types["V1"]["operations"]["getSpans"]["parameters"]["query"]
      > = {
        limit,
      };
    
      if (cursor) {
        params.cursor = cursor;
      }
    
      if (startTime) {
        params.start_time = startTime;
      }
    
      if (endTime) {
        params.end_time = endTime;
      }
    
      const response = await client.GET(
        "/v1/projects/{project_identifier}/spans",
        {
          params: {
            path: {
              project_identifier: projectName,
            },
            query: params,
          },
        }
      );
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              {
                spans: response.data?.data ?? [],
                nextCursor: response.data?.next_cursor ?? null,
              },
              null,
              2
            ),
          },
        ],
      };
    }
  • Input validation schema for 'get-spans' tool using Zod. Requires projectName (string); optional: startTime, endTime, cursor (strings); limit (number, 1-1000, default 100).
      projectName: z.string(),
      startTime: z.string().optional(),
      endTime: z.string().optional(),
      cursor: z.string().optional(),
      limit: z.number().min(1).max(1000).default(100).optional(),
    },
  • Registers the 'get-spans' MCP tool on the server with its name, description, input schema, and handler function.
      "get-spans",
      GET_SPANS_DESCRIPTION,
      {
        projectName: z.string(),
        startTime: z.string().optional(),
        endTime: z.string().optional(),
        cursor: z.string().optional(),
        limit: z.number().min(1).max(1000).default(100).optional(),
      },
      async ({ projectName, startTime, endTime, cursor, limit = 100 }) => {
        const params: NonNullable<
          Types["V1"]["operations"]["getSpans"]["parameters"]["query"]
        > = {
          limit,
        };
    
        if (cursor) {
          params.cursor = cursor;
        }
    
        if (startTime) {
          params.start_time = startTime;
        }
    
        if (endTime) {
          params.end_time = endTime;
        }
    
        const response = await client.GET(
          "/v1/projects/{project_identifier}/spans",
          {
            params: {
              path: {
                project_identifier: projectName,
              },
              query: params,
            },
          }
        );
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  spans: response.data?.data ?? [],
                  nextCursor: response.data?.next_cursor ?? null,
                },
                null,
                2
              ),
            },
          ],
        };
      }
    );
  • Top-level call to initializeSpanTools during MCP server setup, which registers the 'get-spans' tool among others.
    initializeSpanTools({ client, server });
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 explains that the tool returns paginated results ('optional next cursor for pagination'), includes a detailed example of the return structure, and mentions filtering capabilities. However, it doesn't cover potential side effects, rate limits, authentication needs, or error conditions, which are important for a read operation 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 well-structured with a clear purpose statement, explanatory context about spans, usage examples, and a detailed return example. It's appropriately sized for a tool with 5 parameters and no annotations, though the return example is quite lengthy. Every section adds value, but it could be more front-loaded by placing the purpose statement more prominently.

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?

Given the complexity (5 parameters, no annotations, no output schema), the description does a good job of covering the tool's behavior, return format, and usage. It includes a comprehensive example output, which compensates for the lack of output schema. However, it could improve by explicitly addressing all parameters, error handling, or authentication requirements to be fully complete.

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 0%, so the description must compensate. It mentions 'filtering criteria' and provides examples that imply usage of 'projectName', 'startTime', and 'endTime', but doesn't explicitly explain all 5 parameters (e.g., 'cursor' and 'limit' are only hinted at via pagination). The description adds some semantic value but doesn't fully document the parameters, leaving gaps for undocumented ones like 'limit' defaults.

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: 'Get spans from a project with filtering criteria.' It specifies the verb ('Get'), resource ('spans'), and scope ('from a project'), though it doesn't explicitly differentiate from sibling tools like 'get-span-annotations' or other get-* tools. The explanation of what spans are adds helpful context but doesn't directly enhance purpose clarity beyond the initial statement.

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 provides example usage scenarios ('Get recent spans from project' and 'Get spans in a time range'), which imply when to use the tool for time-based filtering. However, it doesn't explicitly state when to use this tool versus alternatives like 'get-span-annotations' or other sibling tools, nor does it mention prerequisites or exclusions. The guidance is helpful but incomplete.

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