Skip to content
Merged
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
34 changes: 22 additions & 12 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,30 @@ async Task<HttpResponseMessage> PostWithRetryAsync(string requestUri, object bod
name: "tavily_search",
description: "A search engine optimized for comprehensive, accurate, and trusted results.");

// Microsoft Learn's remote MCP server exposes docs search/fetch tools the
// Researcher can call alongside Tavily for authoritative Microsoft/Azure content.
await using McpClient microsoftLearnMcp = await McpClient.CreateAsync(
new HttpClientTransport(new HttpClientTransportOptions
{
Endpoint = new Uri("https://learn.microsoft.com/api/mcp"),
Name = "microsoft-learn",
}));
IList<McpClientTool> microsoftLearnTools = await microsoftLearnMcp.ListToolsAsync();

List<AIFunction> researcherTools = [tavilyTool, .. microsoftLearnTools];

// Creating a callable object
using ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());
ILogger startupLogger = loggerFactory.CreateLogger("BlogWriter.Startup");

// Microsoft Learn's remote MCP server exposes docs search/fetch tools the
// Researcher can call alongside Tavily for authoritative Microsoft/Azure content.
// If the remote endpoint is unreachable/slow/erroring at startup, don't let it
// take down the whole app — fall back to Tavily-only tools.
List<AIFunction> researcherTools = [tavilyTool];
try
{
McpClient microsoftLearnMcp = await McpClient.CreateAsync(
new HttpClientTransport(new HttpClientTransportOptions
{
Endpoint = new Uri("https://learn.microsoft.com/api/mcp"),
Name = "microsoft-learn",
}));
IList<McpClientTool> microsoftLearnTools = await microsoftLearnMcp.ListToolsAsync();
researcherTools.AddRange(microsoftLearnTools);
}
Comment on lines +127 to +138
catch (Exception ex)
{
startupLogger.LogWarning(ex, "Microsoft Learn MCP server unavailable; continuing with Tavily-only research tools.");
}
Comment on lines +139 to +142

var bloggerAgent = new BloggerAgent(llm, chatOptions, loggerFactory.CreateLogger<BloggerAgent>());
var researcherAgent = new ResearcherAgent(llm, chatOptions, researcherTools, loggerFactory.CreateLogger<ResearcherAgent>());
Expand Down
5 changes: 2 additions & 3 deletions ResearcherAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ public ResearcherAgent(IChatClient llm, ChatOptions chatOptions, IEnumerable<AIF
.Use(async (agent, context, next, cancellationToken) =>
{
_logger.LogInformation(
"Researcher invoking tool '{Tool}' with arguments {Arguments}",
context.Function.Name,
context.Arguments);
"Researcher invoking tool '{Tool}'...",
context.Function.Name);

return await next(context, cancellationToken);
})
Expand Down