Skip to main content
Glama

Union Unity MCP Server

by nurture-tech
SynchronizationContextExtensions.cs2.2 kB
using System; using System.Threading; using System.Threading.Tasks; using UnityEngine; namespace Nurture.MCP.Editor { public static class TaskExtensions { public static async Task<T> Run<T>( this SynchronizationContext context, Func<Task<T>> action, CancellationToken cancellationToken = default ) { TaskCompletionSource<T> tcs1 = new TaskCompletionSource<T>(); context.Post( async _ => { if (cancellationToken.IsCancellationRequested) { tcs1.TrySetCanceled(); } else { try { tcs1.TrySetResult(await action()); } catch (Exception e) { Debug.LogException(e); tcs1.TrySetException(e); } } }, null ); return await tcs1.Task; } public static async Task<T> Run<T>( this SynchronizationContext context, Func<T> action, CancellationToken cancellationToken = default ) { TaskCompletionSource<T> tcs1 = new TaskCompletionSource<T>(); context.Post( _ => { if (cancellationToken.IsCancellationRequested) { tcs1.TrySetCanceled(); } else { try { tcs1.TrySetResult(action()); } catch (Exception e) { Debug.LogException(e); tcs1.TrySetException(e); } } }, null ); return await tcs1.Task; } } }

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/nurture-tech/unity-mcp-server'

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