last ...
This commit is contained in:
@@ -77,6 +77,13 @@ namespace xAiApi.Providers
|
||||
|
||||
//
|
||||
#region Manager ...
|
||||
/// <summary>
|
||||
/// Get a List Of Available Tools which Provided using registered Mcp Servers ...
|
||||
/// </summary>
|
||||
/// <param name="forceOwner"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IList<McpClientTool>> GetAvailableToolsAsync(
|
||||
bool forceOwner = false,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
@@ -162,6 +169,12 @@ namespace xAiApi.Providers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test Specified Mcp Server ...
|
||||
/// </summary>
|
||||
/// <param name="server"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> TestServerAsync(
|
||||
XAiMcpServerDto server,
|
||||
CancellationToken cancellationToken = default
|
||||
@@ -190,6 +203,10 @@ namespace xAiApi.Providers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Force Refresh Mcp Servers ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task RefreshAsync()
|
||||
{
|
||||
//
|
||||
@@ -281,6 +298,17 @@ namespace xAiApi.Providers
|
||||
source: result,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
await initLock.WaitAsync(cancellationToken);
|
||||
try
|
||||
{
|
||||
await ConnectAndValidateAsync(result, cancellationToken);
|
||||
}
|
||||
finally
|
||||
{
|
||||
initLock.Release();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -367,6 +395,25 @@ namespace xAiApi.Providers
|
||||
source: result,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
await initLock.WaitAsync(cancellationToken);
|
||||
try
|
||||
{
|
||||
//
|
||||
// Remove Exists ...
|
||||
tools.Remove(result.Id);
|
||||
clients.Remove(result.Id);
|
||||
mcpServers.Remove(result.Id);
|
||||
|
||||
//
|
||||
// Update ...
|
||||
await ConnectAndValidateAsync(result, cancellationToken);
|
||||
}
|
||||
finally
|
||||
{
|
||||
initLock.Release();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -436,6 +483,21 @@ namespace xAiApi.Providers
|
||||
source: result,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
await initLock.WaitAsync(cancellationToken);
|
||||
try
|
||||
{
|
||||
//
|
||||
// Remove Exists ...
|
||||
tools.Remove(result.Id);
|
||||
clients.Remove(result.Id);
|
||||
mcpServers.Remove(result.Id);
|
||||
}
|
||||
finally
|
||||
{
|
||||
initLock.Release();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -504,6 +566,25 @@ namespace xAiApi.Providers
|
||||
);
|
||||
var result = !exists.IsNullOrDefault() && !exists.Enabled;
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
await initLock.WaitAsync(cancellationToken);
|
||||
try
|
||||
{
|
||||
//
|
||||
// Remove Exists ...
|
||||
tools.Remove(exists.Id);
|
||||
clients.Remove(exists.Id);
|
||||
mcpServers.Remove(exists.Id);
|
||||
}
|
||||
finally
|
||||
{
|
||||
initLock.Release();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -570,10 +651,25 @@ namespace xAiApi.Providers
|
||||
);
|
||||
var result = !exists.IsNullOrDefault() && exists.Enabled;
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
await initLock.WaitAsync(cancellationToken);
|
||||
try
|
||||
{
|
||||
await ConnectAndValidateAsync(exists, cancellationToken);
|
||||
}
|
||||
finally
|
||||
{
|
||||
initLock.Release();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Toggle Specified Mcp Server ...
|
||||
/// </summary>
|
||||
@@ -632,6 +728,32 @@ namespace xAiApi.Providers
|
||||
);
|
||||
var result = !exists.IsNullOrDefault();
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
await initLock.WaitAsync(cancellationToken);
|
||||
try
|
||||
{
|
||||
if (exists.Enabled)
|
||||
{
|
||||
await ConnectAndValidateAsync(exists, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Remove Exists ...
|
||||
tools.Remove(exists.Id);
|
||||
clients.Remove(exists.Id);
|
||||
mcpServers.Remove(exists.Id);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
initLock.Release();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -780,7 +902,15 @@ namespace xAiApi.Providers
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Find a Collection of Specified Mcp Servers ...
|
||||
/// </summary>
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="forceOwner"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<XAiMcpServerDto>> FindMany(
|
||||
Expression<Func<XAiMcpServer, bool>> predicate,
|
||||
bool forceOwner = false,
|
||||
@@ -845,6 +975,14 @@ namespace xAiApi.Providers
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query Registered Mcp Servers ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="forceOwner"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XQueryResult<XAiMcpServerDto>> Query(
|
||||
XQuery query,
|
||||
bool forceOwner = false,
|
||||
|
||||
Reference in New Issue
Block a user