Skip to main content
Glama
database.ts1.13 kB
export interface Database<T> { get(id: string): Promise<T | null>; set(id: string, value: T): Promise<void>; delete(id: string): Promise<boolean>; list(): Promise<T[]>; } export class InMemoryDatabase<T extends { id: string }> implements Database<T> { private store: Map<string, T> = new Map(); async get(id: string): Promise<T | null> { return this.store.get(id) || null; } async set(id: string, value: T): Promise<void> { this.store.set(id, value); } async delete(id: string): Promise<boolean> { return this.store.delete(id); } async list(): Promise<T[]> { return Array.from(this.store.values()); } async clear(): Promise<void> { this.store.clear(); } get size(): number { return this.store.size; } } export type ConnectionConfig = { host: string; port: number; username?: string; password?: string; database: string; ssl?: boolean; }; export async function connect(config: ConnectionConfig): Promise<Database<any>> { console.log(`Connecting to ${config.host}:${config.port}`); return new InMemoryDatabase(); } export default InMemoryDatabase;

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/mhalder/qdrant-mcp-server'

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