Skip to main content
Glama
hiltonbrown

Next.js MCP Server Template

by hiltonbrown
redis.ts912 B
import { createClient } from 'redis'; if (!process.env.REDIS_URL && process.env.NODE_ENV === 'production') { throw new Error('REDIS_URL environment variable is required in production'); } const redisUrl = process.env.REDIS_URL || 'redis://localhost:6379'; const redisClient = createClient({ url: redisUrl, socket: { connectTimeout: 5000, reconnectStrategy: (retries) => Math.min(retries * 50, 1000), tls: process.env.NODE_ENV === 'production', // Enable TLS in production }, }); redisClient.on('error', (err) => console.error('Redis Client Error', err)); let connectionPromise: Promise<typeof redisClient> | null = null; export async function getRedisClient() { if (!connectionPromise) { connectionPromise = redisClient.connect() .then(() => redisClient) .catch(err => { connectionPromise = null; throw err; }); } return connectionPromise; }

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/hiltonbrown/xero-mcp-with-next-js'

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