set-trace-tag
Add a custom key-value tag to a trace to annotate or categorize it.
Instructions
Add a custom key-value tag to a trace
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| traceId | Yes | ||
| key | Yes | Tag key | |
| value | Yes | Tag value |
Implementation Reference
- src/tools/traces.ts:94-100 (handler)The function that executes the set-trace-tag tool logic. It sends a PATCH request to /api/2.0/mlflow/traces/{traceId}/tags with the key and value.
export async function setTraceTag(params: z.infer<typeof setTraceTagSchema>) { assertWriteAllowed(); return mlflowClient.patch( `/api/2.0/mlflow/traces/${encodeURIComponent(params.traceId)}/tags`, { key: params.key, value: params.value }, ); } - src/tools/traces.ts:88-92 (schema)Zod schema for setTraceTag input validation: traceId (string), key (string), value (string).
export const setTraceTagSchema = z.object({ traceId: z.string(), key: z.string().describe("Tag key"), value: z.string().describe("Tag value"), }); - src/index.ts:238-238 (registration)Registration of the 'set-trace-tag' MCP tool with its schema and handler.
tool("set-trace-tag", "Add a custom key-value tag to a trace", setTraceTagSchema.shape, wrapToolHandler(setTraceTag)); - src/tools/traces.ts:3-3 (helper)Imported helper assertWriteAllowed ensures writes are permitted before executing the tool.
import { applyExtractFields, assertWriteAllowed, resolveExperimentId } from "./utils.js";