post-rebase fixes

This commit is contained in:
Basil Hosmer 2025-05-21 17:12:42 -04:00
commit a89f950222
No known key found for this signature in database
2 changed files with 6 additions and 5 deletions

View file

@ -16,7 +16,7 @@ import {
ResourceListChangedNotificationSchema,
ElicitRequestSchema,
} from '../../types.js';
import { Ajv } from 'ajv';
import Ajv from "ajv";
// Create readline interface for user input
const readline = createInterface({
@ -215,7 +215,7 @@ async function connect(url?: string): Promise<void> {
const required = schema.required || [];
// Set up AJV validator for the requested schema
const ajv = new Ajv({ strict: false, validateFormats: true });
const ajv = new Ajv();
const validate = ajv.compile(schema);
let attempts = 0;
@ -352,7 +352,7 @@ async function connect(url?: string): Promise<void> {
if (!isValid) {
console.log('❌ Validation errors:');
validate.errors?.forEach(error => {
console.log(` - ${error.instancePath || 'root'}: ${error.message}`);
console.log(` - ${error.dataPath || 'root'}: ${error.message}`);
});
if (attempts < maxAttempts) {

View file

@ -33,7 +33,8 @@ import {
ServerResult,
SUPPORTED_PROTOCOL_VERSIONS,
} from "../types.js";
import { Ajv } from "ajv";
import Ajv from "ajv";
import type { ValidateFunction } from "ajv";
export type ServerOptions = ProtocolOptions & {
/**
@ -321,7 +322,7 @@ export class Server<
// Validate the response content against the requested schema if action is "accept"
if (result.action === "accept" && result.content) {
try {
const ajv = new Ajv({ strict: false, validateFormats: true });
const ajv = new Ajv();
const validate = ajv.compile(params.requestedSchema);
const isValid = validate(result.content);