Skip to main content
Glama
yshk-mrt
by yshk-mrt

StopStream

Stop live streaming in OBS through automated commands from Claude AI, enabling creators to end broadcasts without manual technical management.

Instructions

Stops the OBS stream.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler implementation for the StopStream MCP tool. It calls sendToObs with OBS requestType 'StopStream' and empty requestData, forwarding the OBS WebSocket API directly.
    obsResponseData = await sendToObs("StopStream", {}, context, action.name); break; case "StartRecording":
  • src/index.ts:364-368 (registration)
    Registration of the StopStream tool (and others) via dynamic server.tool call in the loop over toolDefinitions.actions from obs_mcp_tool_def.json. The handler function contains the switch dispatching to StopStream logic.
    server.tool( action.name, action.description || "", requestSchema ? { params: requestSchema } : {}, async (params: any, context: any) => { // Using any for context if ToolContext is not easily available
  • Core helper function sendToObs used by StopStream handler to send the 'StopStream' request to OBS WebSocket, manage pending requests, handle responses/errors/timeouts, and ensure connection.
    async function sendToObs<T = any>(requestType: string, requestData?: any, mcpContext?: any, actionName?: string): Promise<T> { if (!obsClient || obsClient.readyState !== WebSocket.OPEN) { if (!isObsConnecting) { // Avoid multiple concurrent connection attempts from sendToObs console.log("OBS not connected. Attempting to connect before sending."); try { await connectToObs(); // Attempt to connect first if (!obsClient || obsClient.readyState !== WebSocket.OPEN) { // Check again after attempt throw new Error("OBS WebSocket is not connected after attempt."); } } catch (connectError) { console.error("Failed to connect to OBS for sendToObs:", connectError); throw new Error(`OBS Connection Error: ${(connectError as Error).message}`); } } else { // If it's already connecting, we should ideally wait for obsConnectionPromise // For now, throwing an error or queuing the request might be options. // Let's throw, as the logic to queue and wait can get complex quickly here. console.warn("OBS is currently connecting. Request will likely fail or be delayed."); // Fall through to try sending, but it might fail if connection isn't ready. } } // Re-check after potential connectToObs call if (!obsClient || obsClient.readyState !== WebSocket.OPEN) { throw new Error("OBS WebSocket is not connected or ready."); } const obsRequestId = await generateRequestId(); const payload: ObsRequest = { op: 6, // Request d: { requestType, requestId: obsRequestId, requestData, }, }; console.log("Full OBS request payload:", JSON.stringify(payload, null, 2)); return new Promise((resolve, reject) => { if (mcpContext && actionName) { // Only store if it's an MCP-initiated request needing response mapping pendingObsRequests.set(obsRequestId, { resolve, reject, mcpContext, actionName }); } else { // If not from MCP tool (e.g. internal calls), handle response directly or differently // For now, still use pendingObsRequests for simplicity pendingObsRequests.set(obsRequestId, { resolve, reject, mcpContext: mcpContext!, actionName: actionName || requestType }); } // console.log("OBS TX:", JSON.stringify(payload, null, 2)); obsClient!.send(JSON.stringify(payload), (err) => { if (err) { console.error(`Error sending to OBS for request '${requestType}':`, err); pendingObsRequests.delete(obsRequestId); reject(err); } }); // Timeout for OBS requests setTimeout(() => { if (pendingObsRequests.has(obsRequestId)) { console.warn(`OBS request '${requestType}' (ID: ${obsRequestId}) timed out.`); pendingObsRequests.get(obsRequestId)?.reject(new Error(`OBS request '${requestType}' timed out.`)); pendingObsRequests.delete(obsRequestId); } }, 10000); // 10 seconds timeout }); }

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/yshk-mrt/obs-mcp'

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