Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,24 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,

try
{
IHttpClientFactory? httpClientFactory = null;
try
{
httpClientFactory = context.GetService<IHttpClientFactory>();
}
catch (InvalidOperationException)
{
// IHttpClientFactory not registered - this is fine for production scenarios
}

var service = context.GetService<IFoundryService>();
var response = await service.ConnectAgent(
options.AgentId!,
options.Query!,
options.Endpoint!,
options.Tenant,
options.RetryPolicy,
httpClientFactory,
cancellationToken: cancellationToken);

context.Response.Results = ResponseResult.Create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,24 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,

try
{
IHttpClientFactory? httpClientFactory = null;
try
{
httpClientFactory = context.GetService<IHttpClientFactory>();
}
catch (InvalidOperationException)
{
// IHttpClientFactory not registered - this is fine for production scenarios
}

var service = context.GetService<IFoundryService>();
AgentsCreateResult result = await service.CreateAgent(
options.Endpoint!,
options.ModelDeploymentName!,
options.AgentName!,
options.SystemInstruction!,
options.Tenant,
httpClientFactory: httpClientFactory,
cancellationToken: cancellationToken
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,

try
{
IHttpClientFactory? httpClientFactory = null;
try
{
httpClientFactory = context.GetService<IHttpClientFactory>();
}
catch (InvalidOperationException)
{
// IHttpClientFactory not registered - this is fine for production scenarios
}

var service = context.GetService<IFoundryService>();
var result = await service.EvaluateAgent(
options.EvaluatorName!,
Expand All @@ -77,6 +87,7 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
options.AzureOpenAIEndpoint!,
options.AzureOpenAIDeployment!,
options.ToolDefinitions,
httpClientFactory: httpClientFactory,
cancellationToken: cancellationToken);

context.Response.Results = ResponseResult.Create(
Expand Down
11 changes: 11 additions & 0 deletions tools/Azure.Mcp.Tools.Foundry/src/Commands/AgentsListCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,22 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,

try
{
IHttpClientFactory? httpClientFactory = null;
try
{
httpClientFactory = context.GetService<IHttpClientFactory>();
}
catch (InvalidOperationException)
{
// IHttpClientFactory not registered - this is fine for production scenarios
}

var service = context.GetService<IFoundryService>();
var agents = await service.ListAgents(
options.Endpoint!,
options.Tenant,
options.RetryPolicy,
httpClientFactory,
cancellationToken: cancellationToken);

context.Response.Results = agents?.Count > 0 ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,

try
{
IHttpClientFactory? httpClientFactory = null;
try
{
httpClientFactory = context.GetService<IHttpClientFactory>();
}
catch (InvalidOperationException)
{
// IHttpClientFactory not registered - this is fine for production scenarios
}

var service = context.GetService<IFoundryService>();
var result = await service.QueryAndEvaluateAgent(
options.AgentId!,
Expand All @@ -79,6 +89,7 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
options.AzureOpenAIDeployment!,
options.Tenant,
options.Evaluators?.Split(',').Select(e => e.Trim()).ToList(),
httpClientFactory: httpClientFactory,
cancellationToken: cancellationToken);

context.Response.Results = ResponseResult.Create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,22 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,

try
{
IHttpClientFactory? httpClientFactory = null;
try
{
httpClientFactory = context.GetService<IHttpClientFactory>();
}
catch (InvalidOperationException)
{
// IHttpClientFactory not registered - this is fine for production scenarios
}

var service = context.GetService<IFoundryService>();
var deployments = await service.ListDeployments(
options.Endpoint!,
options.Tenant,
options.RetryPolicy,
httpClientFactory,
cancellationToken: cancellationToken);

context.Response.Results = ResponseResult.Create(new(deployments ?? []), FoundryJsonContext.Default.DeploymentsListCommandResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,22 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,

try
{
IHttpClientFactory? httpClientFactory = null;
try
{
httpClientFactory = context.GetService<IHttpClientFactory>();
}
catch (InvalidOperationException)
{
// IHttpClientFactory not registered - this is fine for production scenarios
}

var service = context.GetService<IFoundryService>();
var indexes = await service.ListKnowledgeIndexes(
options.Endpoint!,
options.Tenant,
options.RetryPolicy,
httpClientFactory,
cancellationToken: cancellationToken);

context.Response.Results = ResponseResult.Create(new(indexes ?? []), FoundryJsonContext.Default.KnowledgeIndexListCommandResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,23 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,

try
{
IHttpClientFactory? httpClientFactory = null;
try
{
httpClientFactory = context.GetService<IHttpClientFactory>();
}
catch (InvalidOperationException)
{
// IHttpClientFactory not registered - this is fine for production scenarios
}

var service = context.GetService<IFoundryService>();
var indexSchema = await service.GetKnowledgeIndexSchema(
options.Endpoint!,
options.IndexName!,
options.Tenant,
options.RetryPolicy,
httpClientFactory,
cancellationToken: cancellationToken);

if (indexSchema == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,22 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,

try
{
IHttpClientFactory? httpClientFactory = null;
try
{
httpClientFactory = context.GetService<IHttpClientFactory>();
}
catch (InvalidOperationException)
{
// IHttpClientFactory not registered - this is fine for production scenarios
}

var service = context.GetService<IFoundryService>();
ThreadCreateResult result = await service.CreateThread(
options.Endpoint!,
options.UserMessage!,
options.Tenant,
httpClientFactory: httpClientFactory,
cancellationToken: cancellationToken
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,22 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,

try
{
IHttpClientFactory? httpClientFactory = null;
try
{
httpClientFactory = context.GetService<IHttpClientFactory>();
}
catch (InvalidOperationException)
{
// IHttpClientFactory not registered - this is fine for production scenarios
}

var service = context.GetService<IFoundryService>();
ThreadGetMessagesResult result = await service.GetMessages(
options.Endpoint!,
options.ThreadId!,
options.Tenant,
httpClientFactory: httpClientFactory,
cancellationToken: cancellationToken
);

Expand Down
11 changes: 11 additions & 0 deletions tools/Azure.Mcp.Tools.Foundry/src/Commands/ThreadListCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,21 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,

try
{
IHttpClientFactory? httpClientFactory = null;
try
{
httpClientFactory = context.GetService<IHttpClientFactory>();
}
catch (InvalidOperationException)
{
// IHttpClientFactory not registered - this is fine for production scenarios
}

var service = context.GetService<IFoundryService>();
ThreadListResult result = await service.ListThreads(
options.Endpoint!,
options.Tenant,
httpClientFactory: httpClientFactory,
cancellationToken: cancellationToken
);

Expand Down
Loading
Loading