[v2] Minor task-related refactors (#1758)

Co-authored-by: Luca Chang <lucalc@amazon.com>
Co-authored-by: Luca Chang <131398524+LucaButBoring@users.noreply.github.com>
Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com>
This commit is contained in:
Konstantin Konstantinov 2026-03-27 22:25:06 +02:00 • committed by GitHub
commit e86b1835cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,5 @@
import { isTerminal } from '@modelcontextprotocol/core';
import type { Task } from '@modelcontextprotocol/server';
import type { Task } from '@modelcontextprotocol/core';
import { isTerminal, TaskCreationParamsSchema } from '@modelcontextprotocol/core';
import { describe, expect, it } from 'vitest';
describe('Task utility functions', () => {
@ -115,3 +115,30 @@ describe('Task Schema Validation', () => {
}
});
});
describe('TaskCreationParams Schema Validation', () => {
it('should accept ttl as a number', () => {
const result = TaskCreationParamsSchema.safeParse({ ttl: 60_000 });
expect(result.success).toBe(true);
});
it('should accept missing ttl (optional)', () => {
const result = TaskCreationParamsSchema.safeParse({});
expect(result.success).toBe(true);
});
it('should reject null ttl (not allowed in request, only response)', () => {
const result = TaskCreationParamsSchema.safeParse({ ttl: null });
expect(result.success).toBe(false);
});
it('should accept pollInterval as a number', () => {
const result = TaskCreationParamsSchema.safeParse({ pollInterval: 1000 });
expect(result.success).toBe(true);
});
it('should accept both ttl and pollInterval', () => {
const result = TaskCreationParamsSchema.safeParse({ ttl: 60_000, pollInterval: 1000 });
expect(result.success).toBe(true);
});
});