UNPKG

@ivelin-web/tempo-mcp-server

Version:

MCP server for managing Tempo worklogs in Jira

56 lines (55 loc) 2.3 kB
import { z } from 'zod'; // Common validation schemas export const dateSchema = () => z.string().regex(/^\d{4}-\d{2}-\d{2}$/, 'Date must be in YYYY-MM-DD format'); export const timeSchema = () => z .string() .regex(/^([01]\d|2[0-3]):([0-5]\d)$/, 'Time must be in HH:MM format'); export const issueKeySchema = () => z.string().min(1, 'Issue key cannot be empty'); export const issueIdSchema = () => z.union([ z.string().min(1, 'Issue ID cannot be empty'), z.number().int().positive('Issue ID must be a positive integer'), ]); export const idOrKeySchema = () => z.union([issueKeySchema(), issueIdSchema()]); // Environment validation export const envSchema = z.object({ TEMPO_API_TOKEN: z.string().min(1, 'TEMPO_API_TOKEN is required'), JIRA_BASE_URL: z.string().min(1, 'JIRA_BASE_URL is required'), JIRA_API_TOKEN: z.string().min(1, 'JIRA_API_TOKEN is required'), JIRA_EMAIL: z.string().min(1, 'JIRA_EMAIL is required'), JIRA_TEMPO_ACCOUNT_CUSTOM_FIELD_ID: z.string().optional(), }); // Worklog entry schema export const worklogEntrySchema = z.object({ issueKey: issueKeySchema(), timeSpentHours: z.number().positive('Time spent must be positive'), date: dateSchema(), description: z.string().optional(), startTime: timeSchema().optional(), }); // MCP tool schemas export const retrieveWorklogsSchema = z.object({ startDate: dateSchema(), endDate: dateSchema(), }); export const createWorklogSchema = z.object({ issueKey: issueKeySchema(), timeSpentHours: z.number().positive('Time spent must be positive'), date: dateSchema(), description: z.string().optional().default(''), startTime: timeSchema().optional(), }); export const bulkCreateWorklogsSchema = z.object({ worklogEntries: z .array(worklogEntrySchema) .min(1, 'At least one worklog entry is required'), }); export const editWorklogSchema = z.object({ worklogId: z.string().min(1, 'Worklog ID is required'), timeSpentHours: z.number().positive('Time spent must be positive'), description: z.string().optional().nullable(), date: dateSchema().optional().nullable(), startTime: timeSchema().optional(), }); export const deleteWorklogSchema = z.object({ worklogId: z.string().min(1, 'Worklog ID is required'), });