@arizeai/phoenix-mcp 2.1.9 → 2.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,6 +20,7 @@ Phoenix MCP Server is an implementation of the Model Context Protocol for the Ar
20
20
  You can use Phoenix MCP Server for:
21
21
 
22
22
  - **Projects Management**: List and explore projects that organize your observability data
23
+ - **Spans & Annotations**: Retrieve spans and their annotations for analysis and debugging
23
24
  - **Prompts Management**: Create, list, update, and iterate on prompts
24
25
  - **Datasets**: Explore datasets, and syntesize new examples
25
26
  - **Experiments**: Pull experiment results and visualize them with the help of an LLM
package/build/index.js CHANGED
@@ -8,6 +8,7 @@ import { initializeDatasetTools } from "./datasetTools.js";
8
8
  import { initializeExperimentTools } from "./experimentTools.js";
9
9
  import { initializePromptTools } from "./promptTools.js";
10
10
  import { initializeProjectTools } from "./projectTools.js";
11
+ import { initializeSpanTools } from "./spanTools.js";
11
12
  import { initializeReadmeResources } from "./readmeResource.js";
12
13
  const argv = minimist(process.argv.slice(2));
13
14
  const headers = argv.apiKey
@@ -36,6 +37,7 @@ initializePromptTools({ client, server });
36
37
  initializeExperimentTools({ client, server });
37
38
  initializeDatasetTools({ client, server });
38
39
  initializeProjectTools({ client, server });
40
+ initializeSpanTools({ client, server });
39
41
  async function main() {
40
42
  // Initialize readme resources first
41
43
  if (process.env.DANGEROUSLY_READ_README_FILES === "true") {
@@ -0,0 +1,143 @@
1
+ import z from "zod";
2
+ const GET_SPANS_DESCRIPTION = `Get spans from a project with filtering criteria.
3
+
4
+ Spans represent individual operations or units of work within a trace. They contain timing information,
5
+ attributes, and context about the operation being performed.
6
+
7
+ Example usage:
8
+ Get recent spans from project "my-project"
9
+ Get spans in a time range from project "my-project"
10
+
11
+ Expected return:
12
+ Object containing spans array and optional next cursor for pagination.
13
+ Example: {
14
+ "spans": [
15
+ {
16
+ "id": "span123",
17
+ "name": "http_request",
18
+ "context": {
19
+ "trace_id": "trace456",
20
+ "span_id": "span123"
21
+ },
22
+ "start_time": "2024-01-01T12:00:00Z",
23
+ "end_time": "2024-01-01T12:00:01Z",
24
+ "attributes": {
25
+ "http.method": "GET",
26
+ "http.url": "/api/users"
27
+ }
28
+ }
29
+ ],
30
+ "nextCursor": "cursor_for_pagination"
31
+ }`;
32
+ const GET_SPAN_ANNOTATIONS_DESCRIPTION = `Get span annotations for a list of span IDs.
33
+
34
+ Span annotations provide additional metadata, scores, or labels for spans. They can be created
35
+ by humans, LLMs, or code and help in analyzing and categorizing spans.
36
+
37
+ Example usage:
38
+ Get annotations for spans ["span1", "span2"] from project "my-project"
39
+ Get quality score annotations for span "span1" from project "my-project"
40
+
41
+ Expected return:
42
+ Object containing annotations array and optional next cursor for pagination.
43
+ Example: {
44
+ "annotations": [
45
+ {
46
+ "id": "annotation123",
47
+ "span_id": "span1",
48
+ "name": "quality_score",
49
+ "result": {
50
+ "label": "good",
51
+ "score": 0.95,
52
+ "explanation": null
53
+ },
54
+ "annotator_kind": "LLM",
55
+ "metadata": {
56
+ "model": "gpt-4"
57
+ }
58
+ }
59
+ ],
60
+ "nextCursor": "cursor_for_pagination"
61
+ }`;
62
+ export const initializeSpanTools = ({ client, server, }) => {
63
+ server.tool("get-spans", GET_SPANS_DESCRIPTION, {
64
+ projectName: z.string(),
65
+ startTime: z.string().optional(),
66
+ endTime: z.string().optional(),
67
+ cursor: z.string().optional(),
68
+ limit: z.number().min(1).max(1000).default(100).optional(),
69
+ }, async ({ projectName, startTime, endTime, cursor, limit = 100 }) => {
70
+ const params = {
71
+ limit,
72
+ };
73
+ if (cursor) {
74
+ params.cursor = cursor;
75
+ }
76
+ if (startTime) {
77
+ params.start_time = startTime;
78
+ }
79
+ if (endTime) {
80
+ params.end_time = endTime;
81
+ }
82
+ const response = await client.GET("/v1/projects/{project_identifier}/spans", {
83
+ params: {
84
+ path: {
85
+ project_identifier: projectName,
86
+ },
87
+ query: params,
88
+ },
89
+ });
90
+ return {
91
+ content: [
92
+ {
93
+ type: "text",
94
+ text: JSON.stringify({
95
+ spans: response.data?.data ?? [],
96
+ nextCursor: response.data?.next_cursor ?? null,
97
+ }, null, 2),
98
+ },
99
+ ],
100
+ };
101
+ });
102
+ server.tool("get-span-annotations", GET_SPAN_ANNOTATIONS_DESCRIPTION, {
103
+ projectName: z.string(),
104
+ spanIds: z.array(z.string()),
105
+ includeAnnotationNames: z.array(z.string()).optional(),
106
+ excludeAnnotationNames: z.array(z.string()).optional(),
107
+ cursor: z.string().optional(),
108
+ limit: z.number().min(1).max(1000).default(100).optional(),
109
+ }, async ({ projectName, spanIds, includeAnnotationNames, excludeAnnotationNames, cursor, limit = 100, }) => {
110
+ const params = {
111
+ span_ids: spanIds,
112
+ limit,
113
+ };
114
+ if (cursor) {
115
+ params.cursor = cursor;
116
+ }
117
+ if (includeAnnotationNames) {
118
+ params.include_annotation_names = includeAnnotationNames;
119
+ }
120
+ if (excludeAnnotationNames) {
121
+ params.exclude_annotation_names = excludeAnnotationNames;
122
+ }
123
+ const response = await client.GET("/v1/projects/{project_identifier}/span_annotations", {
124
+ params: {
125
+ path: {
126
+ project_identifier: projectName,
127
+ },
128
+ query: params,
129
+ },
130
+ });
131
+ return {
132
+ content: [
133
+ {
134
+ type: "text",
135
+ text: JSON.stringify({
136
+ annotations: response.data?.data ?? [],
137
+ nextCursor: response.data?.next_cursor ?? null,
138
+ }, null, 2),
139
+ },
140
+ ],
141
+ };
142
+ });
143
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arizeai/phoenix-mcp",
3
- "version": "2.1.9",
3
+ "version": "2.1.11",
4
4
  "description": "A MCP server for Arize Phoenix",
5
5
  "bin": {
6
6
  "@arizeai/phoenix-mcp": "./build/index.js"
@@ -20,7 +20,7 @@
20
20
  "glob": "^11.0.1",
21
21
  "minimist": "^1.2.8",
22
22
  "zod": "^3.24.2",
23
- "@arizeai/phoenix-client": "2.1.0"
23
+ "@arizeai/phoenix-client": "2.2.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/glob": "^8.1.0",