mcp-ai-agent-guidelines
Version:
A comprehensive Model Context Protocol server providing advanced tools, resources, and prompts for implementing AI agent best practices
24 lines • 1.29 kB
JavaScript
import { ErrorCode } from "./error-codes.js";
import { McpToolError } from "./errors.js";
export function validationError(message, context) {
return new McpToolError(ErrorCode.VALIDATION_FAILED, message, context);
}
export function missingRequiredError(fieldName, context) {
return new McpToolError(ErrorCode.MISSING_REQUIRED_FIELD, `Missing required field: ${fieldName}`, { fieldName, ...context });
}
export function sessionNotFoundError(sessionId) {
return new McpToolError(ErrorCode.SESSION_NOT_FOUND, `Session not found: ${sessionId}`, { sessionId });
}
export function fileSystemError(operation, path, cause) {
const code = operation === "read"
? ErrorCode.FILE_READ_ERROR
: ErrorCode.FILE_WRITE_ERROR;
return new McpToolError(code, `File ${operation} failed: ${path}`, { path }, cause);
}
export function schemaViolationError(zodError, context) {
return new McpToolError(ErrorCode.SCHEMA_VIOLATION, "Schema validation failed", { zodError, ...context });
}
export function phaseTransitionError(currentPhase, targetPhase, reason) {
return new McpToolError(ErrorCode.INVALID_PHASE_TRANSITION, `Cannot transition from ${currentPhase} to ${targetPhase}: ${reason}`, { currentPhase, targetPhase, reason });
}
//# sourceMappingURL=error-factory.js.map