-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
29 lines (21 loc) · 816 Bytes
/
Copy pathProgram.cs
File metadata and controls
29 lines (21 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using Azure.Core;
using Azure.Identity;
using PbiMcpServer;
var builder = WebApplication.CreateBuilder(args);
var tenantId = builder.Configuration["PowerBi:TenantId"];
var clientId = builder.Configuration["PowerBi:ClientId"];
var clientSecret = builder.Configuration["PowerBi:ClientSecret"];
TokenCredential credential = !string.IsNullOrEmpty(clientId)
? new ClientSecretCredential(tenantId, clientId, clientSecret)
: new DefaultAzureCredential(new DefaultAzureCredentialOptions { TenantId = tenantId });
builder.Services
.AddSingleton<TokenCredential>(credential)
.AddSingleton<PowerBiService>()
.AddHttpClient();
builder.Services
.AddMcpServer()
.WithHttpTransport()
.WithToolsFromAssembly();
var app = builder.Build();
app.MapMcp("/mcp");
app.Run("http://localhost:3001");