Skip to main content
Glama

OpenAI MCP Server

by bhjo0930
test_client.jsβ€’3.67 kB
const { spawn } = require('child_process'); class MCPTestClient { constructor() { this.server = null; this.requestId = 1; } async start() { return new Promise((resolve, reject) => { this.server = spawn('npx', ['openai-mcp-server'], { stdio: ['pipe', 'pipe', 'pipe'], cwd: process.cwd() }); this.server.stderr.on('data', (data) => { const output = data.toString(); if (output.includes('OpenAI MCP Server started')) { console.log('βœ… MCP Server started successfully'); resolve(); } else if (output.includes('ERROR')) { reject(new Error(output)); } }); this.server.on('error', reject); }); } async callTool(name, args) { return new Promise((resolve, reject) => { const request = { jsonrpc: '2.0', id: this.requestId++, method: 'tools/call', params: { name, arguments: args } }; let responseData = ''; const timeout = setTimeout(() => { reject(new Error('Request timeout')); }, 30000); const onData = (data) => { responseData += data.toString(); try { const response = JSON.parse(responseData); clearTimeout(timeout); this.server.stdout.off('data', onData); if (response.error) { reject(new Error(response.error.message)); } else { resolve(response.result); } } catch (e) { // Still receiving data } }; this.server.stdout.on('data', onData); this.server.stdin.write(JSON.stringify(request) + '\n'); }); } stop() { if (this.server) { this.server.kill(); } } } async function runTests() { const client = new MCPTestClient(); try { console.log('πŸš€ Starting MCP Server...'); await client.start(); console.log('πŸ“ Testing web development question...'); // Test 1: Web development analysis const result1 = await client.callTool('call_gpt5', { prompt: "λͺ¨λ˜ μ›Ή ν”„λ‘ νŠΈμ—”λ“œ κ°œλ°œμ—μ„œ React와 Vue.js 쀑 μ–΄λ–€ 것을 선택해야 ν• κΉŒμš”? 각각의 μž₯단점을 λΉ„κ΅ν•΄μ£Όμ„Έμš”.", taskType: "analysis", domain: "frontend", context: { projectType: "enterprise", teamSize: "medium", timeline: "6months" } }); console.log('βœ… Test 1 - Frontend Framework Analysis:'); console.log('Response:', result1.content[0].text.substring(0, 200) + '...'); // Test 2: Code generation const result2 = await client.callTool('call_gpt5', { prompt: "Reactμ—μ„œ μ‚¬μš©μž 인증을 μœ„ν•œ μ»€μŠ€ν…€ 훅을 λ§Œλ“€μ–΄μ£Όμ„Έμš”. JWT 토큰 관리λ₯Ό 포함해야 ν•©λ‹ˆλ‹€.", taskType: "coding", domain: "authentication", optimizationLevel: "precise" }); console.log('βœ… Test 2 - Code Generation:'); console.log('Response:', result2.content[0].text.substring(0, 200) + '...'); // Test 3: Creative solution const result3 = await client.callTool('call_gpt5', { prompt: "μ›Ή 접근성을 κ³ λ €ν•œ 창의적인 UI/UX 아이디어λ₯Ό μ œμ•ˆν•΄μ£Όμ„Έμš”.", taskType: "generation", domain: "design", optimizationLevel: "creative" }); console.log('βœ… Test 3 - Creative Design Ideas:'); console.log('Response:', result3.content[0].text.substring(0, 200) + '...'); console.log('πŸŽ‰ All tests completed successfully!'); } catch (error) { console.error('❌ Test failed:', error.message); } finally { client.stop(); } } runTests();

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/bhjo0930/openai_mcp'

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