Skip to main content
Glama

Union Unity MCP Server

by nurture-tech
Logger.cs2.29 kB
using System; using System.Linq; using Microsoft.Extensions.Logging; using UnityEngine; using ILogger = Microsoft.Extensions.Logging.ILogger; using Object = UnityEngine.Object; namespace Nurture.MCP.Editor { class UnityMcpLogger : ILogger { private readonly string _categoryName; private readonly LogLevel[] _levels; public UnityMcpLogger(string categoryName = null, LogLevel[] levels = null) { _categoryName = categoryName; _levels = levels; } public IDisposable BeginScope<TState>(TState state) where TState : notnull { throw new NotImplementedException(); } public bool IsEnabled(LogLevel logLevel) { return _levels == null || _levels.Contains(logLevel); } public void Log<TState>( LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter ) { Debug.Log($"[MCP] {logLevel}: {formatter(state, exception)}"); } } class UnityLoggerFactory : ILoggerFactory { private LogLevel[] _levels; public UnityLoggerFactory(LogLevel[] levels) { _levels = levels; } public void Dispose() { } public ILogger CreateLogger(string categoryName) { return new UnityMcpLogger(categoryName, _levels); } public void AddProvider(ILoggerProvider provider) { throw new System.NotImplementedException(); } } class UnityMcpLogHandler : ILogHandler { private static ILogHandler _defaultLogger; public UnityMcpLogHandler() { _defaultLogger = Debug.unityLogger.logHandler; } public void LogFormat(LogType logType, Object context, string format, params object[] args) { if (!format.StartsWith("{")) { return; } _defaultLogger.LogFormat(logType, context, format, args); ; } public void LogException(Exception exception, Object context) { return; } } }

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