We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/sbroenne/mcp-server-excel'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
SessionService.cs•1.58 kB
using Sbroenne.ExcelMcp.ComInterop.Session;
namespace Sbroenne.ExcelMcp.CLI.Infrastructure.Session;
internal sealed class SessionService : ISessionService, IDisposable
{
private readonly SessionManager _sessionManager = new();
private bool _disposed;
public string Create(string filePath)
{
EnsureNotDisposed();
return _sessionManager.CreateSession(filePath);
}
public bool Save(string sessionId)
{
EnsureNotDisposed();
// Save by closing with save=true then re-opening
// This is a workaround since SaveSession was removed
throw new NotSupportedException("Separate save operation is no longer supported. Use Close with save parameter.");
}
public bool Close(string sessionId)
{
EnsureNotDisposed();
return _sessionManager.CloseSession(sessionId, save: false);
}
public IReadOnlyList<SessionDescriptor> List()
{
EnsureNotDisposed();
return _sessionManager.GetActiveSessions();
}
public IExcelBatch GetBatch(string sessionId)
{
EnsureNotDisposed();
var batch = _sessionManager.GetSession(sessionId);
if (batch == null)
{
throw new InvalidOperationException($"Session '{sessionId}' not found.");
}
return batch;
}
public void Dispose()
{
if (_disposed)
{
return;
}
_sessionManager.Dispose();
_disposed = true;
}
private void EnsureNotDisposed() => ObjectDisposedException.ThrowIf(_disposed, this);
}