Skip to main content
Glama

MCP Time Server Node

by pshempel
mcp-server-env-test.js2.6 kB
#!/usr/bin/env node /** * Test MCP server environment variable propagation * This simulates how the MCP client spawns the server process */ const { spawn } = require('child_process'); const path = require('path'); console.log('=== Testing MCP Server Environment Variable Propagation ===\n'); // Test 1: Spawn with environment variables console.log('Test 1: Spawning MCP server with RATE_LIMIT=50, RATE_LIMIT_WINDOW=30000'); console.log('Also enabling debug: DEBUG=mcp:*\n'); const env = { ...process.env, RATE_LIMIT: '50', RATE_LIMIT_WINDOW: '30000', DEBUG: 'mcp:*', }; const serverPath = path.join(__dirname, '..', 'dist', 'index.js'); const child = spawn('node', [serverPath], { env: env, stdio: ['pipe', 'pipe', 'pipe'], // stdin, stdout, stderr }); // Capture stderr (where debug logs go) child.stderr.on('data', (data) => { console.log('STDERR:', data.toString()); }); // Send a simple request to see if server starts properly setTimeout(() => { console.log('\nSending test JSON-RPC request...'); // Send a list tools request const request = { jsonrpc: '2.0', id: 1, method: 'tools/list', params: {}, }; child.stdin.write(JSON.stringify(request) + '\n'); }, 100); // Handle stdout (JSON-RPC responses) let buffer = ''; child.stdout.on('data', (data) => { buffer += data.toString(); const lines = buffer.split('\n'); buffer = lines.pop() || ''; for (const line of lines) { if (line.trim()) { try { const response = JSON.parse(line); console.log('\nReceived response:', JSON.stringify(response, null, 2)); } catch (e) { console.log('Non-JSON output:', line); } } } }); // Give it some time then kill setTimeout(() => { console.log('\nKilling server process...'); child.kill(); }, 1000); child.on('exit', (code) => { console.log(`\nServer process exited with code ${code}`); // Test 2: Check if rate limiter constructor is being called with env vars console.log('\n=== Direct Import Test ==='); console.log('Setting RATE_LIMIT=75, RATE_LIMIT_WINDOW=45000'); process.env.RATE_LIMIT = '75'; process.env.RATE_LIMIT_WINDOW = '45000'; // Clear module cache and re-import delete require.cache[require.resolve('../dist/utils/rateLimit')]; const { SlidingWindowRateLimiter } = require('../dist/utils/rateLimit'); const limiter = new SlidingWindowRateLimiter(); const info = limiter.getInfo(); console.log('Rate limiter info:', info); console.log('Expected limit: 75, actual:', info.limit); console.log('Expected window: 45000, actual:', info.window); });

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/pshempel/mcp-time-server-node'

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