Skip to main content
Glama

MCP MIDI Bridge

by tezza1971
python-server.ts1.72 kB
import { spawn, ChildProcess } from 'child_process'; import path from 'path'; import fs from 'fs'; import { app } from 'electron'; interface PythonServer { process: ChildProcess; url: string; } /** * Start the Python Magenta server * @param {boolean} isDev - Whether the app is running in development mode * @returns {Object} - The Python process and server URL */ export function startPythonServer(isDev = false): PythonServer { // Determine the path to the Python executable and script let pythonPath: string; let scriptPath: string; if (isDev) { // In development, use the local Python environment pythonPath = path.join(__dirname, '..', 'python', 'venv', 'Scripts', 'python.exe'); scriptPath = path.join(__dirname, '..', 'python', 'magenta_wrapper.py'); } else { // In production, use the bundled Python files pythonPath = path.join(process.resourcesPath, 'python', 'venv', 'Scripts', 'python.exe'); scriptPath = path.join(process.resourcesPath, 'python', 'magenta_wrapper.py'); } // Check if the Python script exists if (!fs.existsSync(scriptPath)) { throw new Error(`Python script not found at: ${scriptPath}`); } // Start the Python server const pythonProcess = spawn(pythonPath, [scriptPath, 'server', '--port', '5000']); // Log Python output pythonProcess.stdout?.on('data', (data) => { console.log(`Python server: ${data}`); }); pythonProcess.stderr?.on('data', (data) => { console.error(`Python server error: ${data}`); }); pythonProcess.on('close', (code) => { console.log(`Python server exited with code ${code}`); }); return { process: pythonProcess, url: 'http://localhost:5000' }; }

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/tezza1971/mcp-midi'

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