UNPKG

@zxkane/quip-mcp-server

Version:

MCP server for interacting with Quip spreadsheets

165 lines (164 loc) 5.61 kB
import { StorageInterface, StorageOptions } from './types'; /** * Local file system storage implementation */ export declare class LocalStorage implements StorageInterface { private storagePath; private isFileProtocol; /** * Initialize local storage * * @param storagePath Storage path * @param isFileProtocol Whether to use file protocol for resource URIs */ constructor(storagePath: string, isFileProtocol: boolean); /** * Get file path for a thread and sheet * * @param threadId Quip document thread ID * @param sheetName Sheet name (optional) * @returns File path */ private getFilePath; /** * Save CSV content to local file * * @param threadId Quip document thread ID * @param csvContent CSV content * @param sheetName Sheet name (optional) * @returns Promise resolving to file path */ saveCSV(threadId: string, csvContent: string, sheetName?: string): Promise<string>; /** * Get CSV content from local file * * @param threadId Quip document thread ID * @param sheetName Sheet name (optional) * @returns Promise resolving to CSV content, or null if file doesn't exist */ getCSV(threadId: string, sheetName?: string): Promise<string | null>; /** * Get resource URI * * @param threadId Quip document thread ID * @param sheetName Sheet name (optional) * @returns Resource URI */ getResourceURI(threadId: string, sheetName?: string): string; /** * Get metadata for the stored CSV * * @param threadId Quip document thread ID * @param sheetName Sheet name (optional) * @returns Promise resolving to metadata including total_rows, total_size, etc. */ getMetadata(threadId: string, sheetName?: string): Promise<Record<string, any>>; /** * Get cache key for a thread and sheet * * @param threadId Quip document thread ID * @param sheetName Sheet name (optional) * @returns Cache key */ private getCacheKey; } /** * S3 storage implementation */ export declare class S3Storage implements StorageInterface { private s3Client; private bucket; private prefix; private urlExpiration; /** * Initialize S3 storage * * @param bucket S3 bucket name * @param region S3 region * @param prefix S3 object key prefix (optional) * @param urlExpiration URL expiration in seconds (default: 3600) */ constructor(bucket: string, region: string, prefix?: string, urlExpiration?: number); /** * Get S3 object key for a thread and sheet * * @param threadId Quip document thread ID * @param sheetName Sheet name (optional) * @returns S3 object key */ private getObjectKey; /** * Save CSV content to S3 * * @param threadId Quip document thread ID * @param csvContent CSV content * @param sheetName Sheet name (optional) * @returns Promise resolving to S3 object key */ saveCSV(threadId: string, csvContent: string, sheetName?: string): Promise<string>; /** * Get CSV content from S3 * * @param threadId Quip document thread ID * @param sheetName Sheet name (optional) * @returns Promise resolving to CSV content, or null if object doesn't exist */ /** * Send a command to S3 * * @param command Command to send * @returns Promise resolving to command response */ protected sendCommand(command: any): Promise<any>; getCSV(threadId: string, sheetName?: string): Promise<string | null>; /** * Get resource URI * * @param threadId Quip document thread ID * @param sheetName Sheet name (optional) * @returns Resource URI (presigned S3 URL or s3:// URI) */ getResourceURI(threadId: string, sheetName?: string): string; /** * Generate a presigned URL for accessing the S3 object * This is a new method that can be used when an actual presigned URL is needed * * @param threadId Quip document thread ID * @param sheetName Sheet name (optional) * @returns Promise resolving to a presigned URL */ generatePresignedUrl(threadId: string, sheetName?: string): Promise<string>; /** * Get metadata for the stored CSV * * @param threadId Quip document thread ID * @param sheetName Sheet name (optional) * @returns Promise resolving to metadata including total_rows, total_size, etc. */ getMetadata(threadId: string, sheetName?: string): Promise<Record<string, any>>; /** * Get cache key for a thread and sheet * * @param threadId Quip document thread ID * @param sheetName Sheet name (optional) * @returns Cache key */ private getCacheKey; } /** * Truncate CSV content to be under the specified maximum size while maintaining valid CSV structure * * @param csvContent Original CSV content * @param maxSize Maximum size in bytes (default: 10KB) * @returns Tuple of truncated CSV content and a boolean indicating if truncation occurred */ export declare function truncateCSVContent(csvContent: string, maxSize?: number): [string, boolean]; /** * Factory function to create storage instance * * @param storageType Storage type, supports "local" and "s3" * @param options Parameters passed to storage constructor * @returns Storage instance * @throws Error if storage type is not supported */ export declare function createStorage(storageType: string, options: StorageOptions): StorageInterface;