amazon-seller-mcp
Version:
Model Context Protocol (MCP) client for Amazon Selling Partner API
174 lines (173 loc) • 4.74 kB
TypeScript
/**
* Common type definitions used across the application
*/
/**
* Constants for common types
*/
export declare const COMMON_CONSTANTS: {
/** JSON-RPC version for MCP requests */
readonly JSONRPC_VERSION: "2.0";
/** Default HTTP status codes */
readonly HTTP_STATUS: {
readonly OK: 200;
readonly BAD_REQUEST: 400;
readonly UNAUTHORIZED: 401;
readonly FORBIDDEN: 403;
readonly NOT_FOUND: 404;
readonly INTERNAL_SERVER_ERROR: 500;
};
/** Common error codes */
readonly ERROR_CODES: {
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
readonly AUTHENTICATION_ERROR: "AUTHENTICATION_ERROR";
readonly RATE_LIMIT_ERROR: "RATE_LIMIT_ERROR";
readonly SERVER_ERROR: "SERVER_ERROR";
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
};
/** Default retry configuration */
readonly DEFAULT_RETRY_CONFIG: {
readonly maxRetries: 3;
readonly shouldRetry: true;
};
};
/**
* Utility functions for common types
*/
export declare const CommonUtils: {
/**
* Creates a basic error details object
*/
readonly createErrorDetails: (code: string, statusCode?: number) => ErrorDetails;
/**
* Creates a basic log metadata object
*/
readonly createLogMetadata: (operation: string, requestId?: string) => LogMetadata;
/**
* Creates a basic MCP request body
*/
readonly createMcpRequest: (method: string, params?: Record<string, unknown>) => McpRequestBody;
/**
* Checks if an HTTP status code indicates success
*/
readonly isSuccessStatus: (statusCode: number) => boolean;
/**
* Checks if an HTTP status code indicates a client error
*/
readonly isClientError: (statusCode: number) => boolean;
/**
* Checks if an HTTP status code indicates a server error
*/
readonly isServerError: (statusCode: number) => boolean;
};
/**
* Error details for Amazon Seller MCP errors
*/
export interface ErrorDetails {
/** Error code from Amazon API */
code?: string;
/** HTTP status code */
statusCode?: number;
/** Request ID for tracking */
requestId?: string;
/** Timestamp when error occurred */
timestamp?: string;
/** HTTP headers from error response */
headers?: Record<string, string>;
/** Additional error context */
[key: string]: unknown;
}
/**
* Metadata for logging operations
*/
export interface LogMetadata {
/** Request ID for correlation */
requestId?: string;
/** User ID if available */
userId?: string;
/** Operation being performed */
operation?: string;
/** Duration in milliseconds */
duration?: number;
/** HTTP status code */
statusCode?: number;
/** Error code if applicable */
errorCode?: string;
/** Additional metadata */
[key: string]: unknown;
}
/**
* Request context for error recovery
*/
export interface ErrorRecoveryContext {
/** Operation function to retry */
operation?: (() => Promise<unknown>) | string;
/** Request parameters */
params?: Record<string, unknown>;
/** Retry attempt number */
retryCount?: number;
/** Maximum retries allowed */
maxRetries?: number;
/** Request ID for tracking */
requestId?: string;
/** Whether retry should be attempted */
shouldRetry?: boolean;
/** API request options */
options?: Record<string, unknown>;
/** Additional context data */
[key: string]: unknown;
}
/**
* Tool input validation schema
*/
export interface ToolInput {
/** Input parameters */
[key: string]: unknown;
}
/**
* MCP request body structure
*/
export interface McpRequestBody {
/** JSON-RPC version */
jsonrpc: '2.0';
/** Request method */
method: string;
/** Request parameters */
params?: Record<string, unknown>;
/** Request ID */
id?: string | number;
}
/**
* Event notification data
*/
export interface NotificationData {
/** Event type */
type: string;
/** Event timestamp */
timestamp: string;
/** Event payload */
payload: Record<string, unknown>;
/** Source of the event */
source?: string;
}
/**
* HTTP request object for logging middleware
*/
export interface HttpRequest {
/** HTTP method */
method: string;
/** Request URL */
url: string;
/** Client IP address */
ip?: string;
/** Request headers */
headers: Record<string, string | string[] | undefined>;
}
/**
* HTTP response object for logging middleware
*/
export interface HttpResponse {
/** HTTP status code */
statusCode: number;
/** Event listener registration */
on(event: string, listener: () => void): void;
}