Skip to main content
Glama

Gemini Context MCP Server

by ogoldberg
storage.ts1.24 kB
import fs from 'fs/promises'; import path from 'path'; import { ContextEntry } from './context-manager.js'; import { Logger } from './logger.js'; export class Storage { private filePath: string; private _entries: ContextEntry[] = []; constructor(filePath: string) { this.filePath = filePath; } async init(): Promise<void> { try { // Ensure directory exists await fs.mkdir(path.dirname(this.filePath), { recursive: true }); // Try to read existing file try { const data = await fs.readFile(this.filePath, 'utf-8'); this._entries = JSON.parse(data); } catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') { throw error; } // File doesn't exist, use empty array this._entries = []; } } catch (error) { Logger.error('[storage] Error initializing storage:', error); throw error; } } async save(): Promise<void> { try { await fs.writeFile(this.filePath, JSON.stringify(this._entries, null, 2)); } catch (error) { Logger.error('[storage] Error saving storage:', error); throw error; } } get entries(): ContextEntry[] { return this._entries; } }

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/ogoldberg/gemini-context-mcp-server'

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