Skip to main content
Glama

Cursor Sound MCP

index.ts2.02 kB
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; import player from 'play-sound'; import path from 'path'; import { fileURLToPath } from 'url'; // Get the directory name of the current module const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const audioPlayer = player(); // Use the custom sound file from the sounds directory const COMPLETION_SOUND = path.join(__dirname, '..', 'sounds', 'completion.mp3'); // Set up a proper logging function that uses stderr const log = (message: string) => { process.stderr.write(`${message}\n`); }; async function main() { const server = new McpServer({ name: 'CursorSoundMCP', version: '1.0.0' }); // Tool to play sound after code generation server.tool( 'playCompletionSound', 'Plays a completion sound when called', async () => { try { // Play custom sound using a Promise to handle the callback properly await new Promise<void>((resolve, reject) => { audioPlayer.play(COMPLETION_SOUND, (err: Error | null) => { if (err) { log(`Error playing sound: ${err.message}`); reject(err); } else { log('Played completion sound successfully'); resolve(); } }); }); // Return proper JSON response return { content: [{ type: 'text', text: 'Played completion sound' }] }; } catch (error) { log(`Failed to play sound: ${error}`); return { content: [{ type: 'text', text: 'Failed to play sound' }] }; } } ); // Start the server using stdio transport const transport = new StdioServerTransport(); await server.connect(transport); log('Cursor Sound MCP server started...'); } main().catch(error => { log(`Failed to start MCP server: ${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/bcharleson/sound-mcp'

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