Skip to main content
Glama
sdk-adapter.tsβ€’1.5 kB
/** * SDK Adapter for MCP Server * Provides singleton access to SnapBack SDK components */ import path from "node:path"; import type { FileInput } from "@snapback/contracts"; import { LocalStorage, SnapshotManager } from "@snapback/sdk"; // Singleton instances let snapshotManagerInstance: SnapshotManager | null = null; let storageInstance: LocalStorage | null = null; /** * Get or create the SnapshotManager instance */ export function getSnapshotManager(): SnapshotManager { if (!snapshotManagerInstance) { const storage = getStorage(); snapshotManagerInstance = new SnapshotManager(storage, { enableDeduplication: true, namingStrategy: "semantic", autoProtect: false, }); } return snapshotManagerInstance; } /** * Get or create the LocalStorage instance */ export function getStorage(): LocalStorage { if (!storageInstance) { const workspaceDir = process.env.SNAPBACK_WORKSPACE || process.cwd(); const storePath = path.join(workspaceDir, ".snapback", "snapshots.db"); storageInstance = new LocalStorage(storePath); } return storageInstance; } /** * Reset singleton instances (for testing) */ export function resetSingletons(): void { snapshotManagerInstance = null; storageInstance = null; } /** * Convert MCP file format to SDK FileInput format */ export function toFileInputs(files: Array<{ path: string; content: string }>): FileInput[] { return files.map((f) => ({ path: f.path, content: f.content, action: "modify" as const, })); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/snapback-dev/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server