Skip to main content
Glama

shopify-mcp

direct_test.cjs2.03 kB
const { spawn } = require('child_process');async function main() { // Start the MCP server as a child process const server = spawn('npm', ['start'], { stdio: ['pipe', 'pipe', 'inherit'], // Pipe stdin and stdout, inherit stderr }); // Handle server exit server.on('exit', (code) => { if (code !== 0) { console.error(`Server process exited with code ${code}`); } }); // Function to send a JSON-RPC message to the server const sendMessage = (message) => { const messageString = JSON.stringify(message) + '\n'; server.stdin.write(messageString); }; // Listen for responses from the server server.stdout.on('data', (data) => { const response = JSON.parse(data.toString()); console.log('Received from server:', JSON.stringify(response, null, 2)); // If we received the tool response, disconnect if (response.id === '2') { sendMessage({ jsonrpc: '2.0', method: 'disconnect', params: {}, }); } // If we received the disconnect response, kill the server if (response.id === '3') { server.kill(); } }); // 1. Initialize the connection sendMessage({ jsonrpc: '2.0', id: '1', method: 'initialize', params: { capabilities: {}, }, }); // 2. Call the create-product tool sendMessage({ jsonrpc: '2.0', id: '2', method: 'tool', params: { name: 'create-product', input: { title: 'Test Product from Direct Test', descriptionHtml: '<p>This is a test product from the direct test script.</p>', vendor: 'Direct Test Vendor', productType: 'Direct Test Type', tags: ['direct-test1', 'direct-test2'], status: 'DRAFT', }, }, }); // 3. Send a disconnect message (after a short delay to allow the tool call to complete) setTimeout(() => { sendMessage({ jsonrpc: '2.0', id: '3', method: 'disconnect', params: {}, }); }, 2000); // 2 second delay}main().catch((error) => { console.error(error); process.exit(1);});

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/GeLi2001/shopify-mcp'

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