log-batch
Log multiple metrics, parameters, and tags to an MLflow run in a single batch operation. Streamline experiment tracking by submitting grouped data together.
Instructions
Log a batch of metrics, params, and tags to a run
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| runId | Yes | ||
| metrics | No | ||
| params | No | ||
| tags | No |
Implementation Reference
- src/tools/runs.ts:158-173 (schema)Zod schema for log-batch input validation, defining runId (string) and optional arrays of metrics, params, and tags.
export const logBatchSchema = z.object({ runId: z.string(), metrics: z.array(metricSchema).optional(), params: z.array(paramSchema).optional(), tags: z.array(tagSchema).optional(), }); export async function logBatch(params: z.infer<typeof logBatchSchema>) { assertWriteAllowed(); return mlflowClient.post("/runs/log-batch", { run_id: params.runId, metrics: params.metrics, params: params.params, tags: params.tags, }); } - src/tools/runs.ts:165-173 (handler)Handler function for log-batch that calls mlflowClient.post('/runs/log-batch') with the run ID, metrics, params, and tags.
export async function logBatch(params: z.infer<typeof logBatchSchema>) { assertWriteAllowed(); return mlflowClient.post("/runs/log-batch", { run_id: params.runId, metrics: params.metrics, params: params.params, tags: params.tags, }); } - src/tools/runs.ts:7-14 (helper)Supporting type schemas used by logBatchSchema: tagSchema, metricSchema, and paramSchema.
const tagSchema = z.object({ key: z.string(), value: z.string() }); const metricSchema = z.object({ key: z.string(), value: z.number(), timestamp: z.number(), step: z.number().optional(), }); const paramSchema = z.object({ key: z.string(), value: z.string() }); - src/index.ts:162-162 (registration)Registration of the 'log-batch' MCP tool with its description, schema, and wrapped handler.
tool("log-batch", "Log a batch of metrics, params, and tags to a run", logBatchSchema.shape, wrapToolHandler(logBatch));