UNPKG

ragatanga-mcp-sdk

Version:

SDK for integrating with the Ragatanga Management Control Plane (MCP) with Next.js 15, React 19, WebSocket and Arrow IPC support

326 lines (318 loc) 8.97 kB
import { MCPClient } from './client/index.js'; import { d as OntologyStats, P as PaginatedOntologyResponse, a as OntologyClass, b as OntologyProperty, Q as QueryConceptParams, S as SearchConceptsParams, E as ExecuteSparqlParams, g as SparqlQueryResult, C as ClassInfoParams, M as ModifyOntologyParams, k as ModificationResult } from './ontology-types-Dd7w-pJ8.js'; export { MCPWebSocket, createWebSocketClient } from './client/websocket.js'; export { createSSEClient } from './client/sse.js'; export { default as MCPArrowClient } from './client/arrow-ipc.js'; import { M as MCPOptions } from './types-CmbeEBKR.js'; export { AuthError, HTTPError, MCPError, NetworkError, ParseError, TenantNotFoundError, TimeoutError, UnauthorizedError, ValidationError, WebSocketError } from './errors/index.js'; import './fetcher-B6k3kybO.js'; import 'zod'; /** * Extension of the MCPClient with ontology-specific methods */ declare class OntologyClient extends MCPClient { /** * Get statistics about the ontology * * @returns Ontology statistics */ getOntologyStats(): Promise<OntologyStats>; /** * Get a list of classes from the ontology * * @param cursor Optional pagination cursor * @param limit Optional limit on number of results * @returns Paginated list of ontology classes */ getOntologyClasses(cursor?: string, limit?: number): Promise<PaginatedOntologyResponse<OntologyClass>>; /** * Get a list of properties from the ontology * * @param cursor Optional pagination cursor * @param limit Optional limit on number of results * @returns Paginated list of ontology properties */ getOntologyProperties(cursor?: string, limit?: number): Promise<PaginatedOntologyResponse<OntologyProperty>>; /** * Query a specific concept from the ontology * * @param params Query parameters (URI and depth) * @returns Details about the requested concept */ queryConcept(params: QueryConceptParams): Promise<any>; /** * Search for concepts in the ontology * * @param params Search parameters * @returns Search results with pagination */ searchConcepts(params: SearchConceptsParams): Promise<any>; /** * Execute a SPARQL query against the ontology * * @param params SPARQL query parameters * @returns Query results */ executeSparql(params: ExecuteSparqlParams): Promise<SparqlQueryResult>; /** * Get detailed information about a class * * @param params Class information parameters * @returns Detailed class information */ getClassInfo(params: ClassInfoParams): Promise<OntologyClass>; /** * Modify the ontology (add, update, remove entities) * * @param params Modification parameters * @returns Result of the modification operation */ modifyOntology(params: ModifyOntologyParams): Promise<ModificationResult>; } /** * Tenant Service Client for Ragatanga MCP * * This module provides comprehensive support for tenant management operations * matching the server-side functionality in ragatanga_mcp.shared.auth_services.tenant */ interface Tenant { id: string; name: string; description?: string; created_at: string; updated_at: string; owner_id?: string; settings?: Record<string, any>; api_keys?: ApiKey[]; status: 'active' | 'suspended' | 'deleted'; } interface ApiKey { id: string; key: string; name: string; tenant_id: string; created_at: string; expires_at?: string; last_used_at?: string; permissions?: string[]; } interface CreateTenantOptions { name: string; description?: string; owner_id?: string; settings?: Record<string, any>; } interface CreateApiKeyOptions { name: string; tenant_id: string; expires_at?: string; permissions?: string[]; } /** * Tenant Service Client * * Provides methods for managing tenants and API keys */ declare class TenantServiceClient { private baseUrl; private apiKey?; private token?; private transport; constructor(options: MCPOptions); /** * List all tenants (admin only) */ listTenants(): Promise<Tenant[]>; /** * Get a tenant by ID */ getTenant(tenantId: string): Promise<Tenant>; /** * Create a new tenant */ createTenant(options: CreateTenantOptions): Promise<Tenant>; /** * Update an existing tenant */ updateTenant(tenantId: string, data: Partial<CreateTenantOptions>): Promise<Tenant>; /** * Delete a tenant */ deleteTenant(tenantId: string): Promise<void>; /** * Get a tenant by API key */ getTenantByApiKey(apiKey: string): Promise<Tenant>; /** * Create a new API key for a tenant */ createApiKey(options: CreateApiKeyOptions): Promise<ApiKey>; /** * List API keys for a tenant */ listApiKeys(tenantId: string): Promise<ApiKey[]>; /** * Delete an API key */ deleteApiKey(tenantId: string, keyId: string): Promise<void>; } /** * Create a tenant service client */ declare function createTenantServiceClient(options: MCPOptions): TenantServiceClient; /** * Redis Client-Side Caching Service for Ragatanga MCP SDK * * This module provides client-side caching capabilities aligned with the server's Redis implementation. * It handles caching query results, rate limiting state, and enables conditional requests. */ interface RedisCacheOptions { /** * Enable client-side caching */ enabled: boolean; /** * Default TTL for cached items in seconds */ defaultTTL: number; /** * Maximum cache size (number of items) */ maxSize: number; /** * Storage type to use */ storage: 'memory' | 'localStorage' | 'sessionStorage' | 'custom'; /** * Use etags for conditional requests */ useEtags: boolean; /** * Custom storage implementation if storage is 'custom' */ customStorage?: CacheStorage; /** * Cache namespace to avoid collisions */ namespace: string; /** * Debug mode */ debug: boolean; } /** * Interface for custom cache storage implementations */ interface CacheStorage { get(key: string): Promise<string | null>; set(key: string, value: string, ttl?: number): Promise<void>; delete(key: string): Promise<void>; clear(): Promise<void>; keys(): Promise<string[]>; } /** * Rate limit information */ interface RateLimitInfo { limit: number; remaining: number; reset: number; } /** * Cache statistics */ interface CacheStats { hits: number; misses: number; size: number; keys: string[]; } /** * Redis-compatible client-side caching service */ declare class MCPRedisCache { private options; private cache; private storage; private stats; private rateLimits; /** * Create a new Redis cache client */ constructor(options?: Partial<RedisCacheOptions>); /** * Get an item from cache */ get<T = any>(key: string): Promise<{ value: T | null; etag?: string; }>; /** * Set an item in cache */ set(key: string, value: any, options?: { ttl?: number; etag?: string; }): Promise<void>; /** * Delete an item from cache */ delete(key: string): Promise<void>; /** * Clear the entire cache */ clear(): Promise<void>; /** * Store rate limit information */ setRateLimit(endpoint: string, info: RateLimitInfo): void; /** * Get rate limit information for an endpoint */ getRateLimit(endpoint: string): RateLimitInfo | undefined; /** * Check if an endpoint is rate limited */ isRateLimited(endpoint: string): boolean; /** * Get cache statistics */ getStats(): CacheStats; /** * Normalize a cache key with namespace */ private normalizeKey; /** * Evict least recently used items when cache is full */ private evictLRU; /** * Initialize from persistent storage */ private initFromStorage; /** * Create a memory storage adapter */ private createMemoryStorageAdapter; /** * Create a localStorage adapter */ private createLocalStorageAdapter; /** * Create a sessionStorage adapter */ private createSessionStorageAdapter; } /** * Create a new Redis cache client */ declare function createRedisCache(options?: Partial<RedisCacheOptions>): MCPRedisCache; /** * Ragatanga MCP SDK * Main entry point with exports of core components */ /** * Create an MCP client */ declare function createClient(options: any): MCPClient; export { MCPClient, MCPRedisCache, OntologyClient, TenantServiceClient, createClient, createRedisCache, createTenantServiceClient, createClient as default };