Skip to main content
Glama
Arize-ai

@arizeai/phoenix-mcp

Official
by Arize-ai

add-dataset-examples

Extend datasets by adding examples with inputs, outputs, and metadata. Use this to enrich datasets, cover edge cases, and ensure data consistency by avoiding duplicates.

Instructions

Add examples to an existing dataset.

This tool adds one or more examples to an existing dataset. Each example includes an input, output, and metadata. The metadata will automatically include information indicating that these examples were synthetically generated via MCP. When calling this tool, check existing examples using the "get-dataset-examples" tool to ensure that you are not adding duplicate examples and following existing patterns for how data should be structured.

Example usage: Look at the analyze "my-dataset" and augment them with new examples to cover relevant edge cases

Expected return: Confirmation of successful addition of examples to the dataset. Example: { "dataset_name": "my-dataset", "message": "Successfully added examples to dataset" }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
datasetNameYes
examplesYes

Implementation Reference

  • The handler function adds MCP source metadata to examples, appends them to the specified dataset via PhoenixClient POST to /v1/datasets/upload with action='append', handles error if no dataset_id, and returns JSON confirmation with dataset_name, dataset_id, and success message.
    async ({ datasetName, examples }) => { // Add MCP metadata to each example const examplesWithMetadata = examples.map((example) => ({ ...example, metadata: { ...example.metadata, source: "Synthetic Example added via MCP", }, })); const response = await client.POST("/v1/datasets/upload", { body: { action: "append", name: datasetName, inputs: examplesWithMetadata.map((e) => e.input), outputs: examplesWithMetadata.map((e) => e.output), metadata: examplesWithMetadata.map((e) => e.metadata), }, params: { query: { sync: true, }, }, }); if (!response.data?.data?.dataset_id) { throw new Error( "Failed to add examples to dataset: No dataset ID received" ); } return { content: [ { type: "text", text: JSON.stringify( { dataset_name: datasetName, dataset_id: response.data.data.dataset_id, message: "Successfully added examples to dataset", }, null, 2 ), }, ], }; }
  • Zod input schema defining datasetName as string and examples as array of objects each with input (record<any>), output (record<any>), and optional metadata (record<any>).
    datasetName: z.string(), examples: z.array( z.object({ input: z.record(z.any()), output: z.record(z.any()), metadata: z.record(z.any()).optional(), }) ),
  • Registers the 'add-dataset-examples' tool on the McpServer with name, description (ADD_DATASET_EXAMPLES_DESCRIPTION), input schema, and inline handler function within initializeDatasetTools.
    server.tool( "add-dataset-examples", ADD_DATASET_EXAMPLES_DESCRIPTION, { datasetName: z.string(), examples: z.array( z.object({ input: z.record(z.any()), output: z.record(z.any()), metadata: z.record(z.any()).optional(), }) ), }, async ({ datasetName, examples }) => { // Add MCP metadata to each example const examplesWithMetadata = examples.map((example) => ({ ...example, metadata: { ...example.metadata, source: "Synthetic Example added via MCP", }, })); const response = await client.POST("/v1/datasets/upload", { body: { action: "append", name: datasetName, inputs: examplesWithMetadata.map((e) => e.input), outputs: examplesWithMetadata.map((e) => e.output), metadata: examplesWithMetadata.map((e) => e.metadata), }, params: { query: { sync: true, }, }, }); if (!response.data?.data?.dataset_id) { throw new Error( "Failed to add examples to dataset: No dataset ID received" ); } return { content: [ { type: "text", text: JSON.stringify( { dataset_name: datasetName, dataset_id: response.data.data.dataset_id, message: "Successfully added examples to dataset", }, null, 2 ), }, ], }; } );

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