GovUK.Dfe.AI.Agents.Mcp
0.0.1-prerelease.459
Prefix Reserved
dotnet add package GovUK.Dfe.AI.Agents.Mcp --version 0.0.1-prerelease.459
NuGet\Install-Package GovUK.Dfe.AI.Agents.Mcp -Version 0.0.1-prerelease.459
<PackageReference Include="GovUK.Dfe.AI.Agents.Mcp" Version="0.0.1-prerelease.459" />
<PackageVersion Include="GovUK.Dfe.AI.Agents.Mcp" Version="0.0.1-prerelease.459" />
<PackageReference Include="GovUK.Dfe.AI.Agents.Mcp" />
paket add GovUK.Dfe.AI.Agents.Mcp --version 0.0.1-prerelease.459
#r "nuget: GovUK.Dfe.AI.Agents.Mcp, 0.0.1-prerelease.459"
#:package GovUK.Dfe.AI.Agents.Mcp@0.0.1-prerelease.459
#addin nuget:?package=GovUK.Dfe.AI.Agents.Mcp&version=0.0.1-prerelease.459&prerelease
#tool nuget:?package=GovUK.Dfe.AI.Agents.Mcp&version=0.0.1-prerelease.459&prerelease
GovUK.Dfe.AI.Agents.Mcp
Gives your GovUK.Dfe.AI.Agents agents tools from your own MCP servers. Tools run in your app with your credential. Foundry only sees each tool's name, description and input schema, never the server's address or a credential.
Set up
dotnet add package GovUK.Dfe.AI.Agents.Mcp
"AiAgents": {
"McpServers": {
"school-performance": {
"ServerUri": "https://mcp.internal.example/mcp",
"Scope": "api://school-performance/.default",
"AllowedToolNames": [ "get_performance_data" ]
}
}
}
builder.Services.AddAgents(builder.Configuration, agents => agents
.AddAgents(BriefingAgents.All)
.AddMcpServers());
Add an entry per server; each has its own address, scope and allowed tools. Then list the tools each agent may call:
public static readonly AgentDefinition Ofsted = new("ofsted-agent", "Ofsted")
{
AllowedTools = ["get_performance_data"],
};
Use MCP servers without agents
An app can call MCP tools itself, with no Foundry settings and no agents:
builder.Services.AddMcpServers(builder.Configuration, new ManagedIdentityCredential());
public sealed class PerformanceService([FromKeyedServices("school-performance")] IMcpToolClient server)
{
public Task<string> GetAsync(string urn, CancellationToken ct)
=> server.CallToolAsync("get_performance_data", $$"""{"urn":"{{urn}}"}""", ct);
}
It reads the same AiAgents:McpServers section. Each server signs in with its own Authentication block, else the
credential you pass. Only tools in AllowedToolNames can be called. If you later add agents with
agents.AddMcpServers(), each server is still connected only once.
How it works
- Deny by default: an agent can call a tool only if it's in both the server's
AllowedToolNamesand the agent'sAllowedTools. This is checked on every call. - Sign-in: the app's identity gets a token for each server's
Scope; tokens are cached and refreshed. To use a different identity, add anAuthenticationblock to the server, or callagents.UseMcpCredential("school-performance", credential). - Safe output: tool output is cut at
MaxToolOutputCharacters(default 40,000) and fenced as data, so the model doesn't follow instructions inside it. - Errors: a tool error is returned to the model. Calls are never retried, so side effects can't happen twice.
- Startup check: if an allowed tool doesn't exist on its server, startup fails. If a server can't be reached, startup only logs a warning, so an outage doesn't stop new instances starting.
Settings
Each entry under McpServers is keyed by a name you choose.
| Setting | Default | Purpose |
|---|---|---|
ServerUri |
Required | The server's MCP endpoint; https:// (http:// only for localhost), as each request carries a token |
Scope |
Required | The token scope, e.g. api://school-performance/.default |
AllowedToolNames |
Required | Every tool this app may use from the server |
ToolListCacheDuration |
5 minutes | How long the server's tool list is reused |
Authentication |
The default identity | A separate identity for this server, possibly in another tenant |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- GovUK.Dfe.AI.Agents (>= 0.0.1-prerelease.459)
- Microsoft.Extensions.Http (>= 10.0.12)
- ModelContextProtocol.Core (>= 2.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.1-prerelease.459 | 0 | 10/14/2026 |
| 0.0.1-prerelease.426 | 0 | 10/14/2026 |
| 0.0.1-prerelease.394 | 0 | 10/14/2026 |
| 0.0.1-prerelease.363 | 0 | 10/14/2026 |
| 0.0.1-prerelease.333 | 27 | 10/13/2026 |
| 0.0.1-prerelease.305 | 45 | 10/9/2026 |
| 0.0.1-prerelease.278 | 41 | 10/9/2026 |
| 0.0.1-prerelease.252 | 45 | 10/9/2026 |
| 0.0.1-prerelease.227 | 46 | 10/9/2026 |
| 0.0.1-prerelease.203 | 47 | 10/9/2026 |
| 0.0.1-prerelease.180 | 39 | 10/9/2026 |
| 0.0.1-prerelease.158 | 42 | 10/9/2026 |
| 0.0.1-prerelease.137 | 43 | 10/9/2026 |
| 0.0.1-prerelease.117 | 49 | 10/9/2026 |
| 0.0.1-prerelease.98 | 44 | 10/7/2026 |
| 0.0.1-prerelease.80 | 48 | 10/7/2026 |
| 0.0.1-prerelease.63 | 51 | 10/6/2026 |
| 0.0.1-prerelease.47 | 56 | 10/5/2026 |
| 0.0.1-prerelease.33 | 52 | 10/5/2026 |
| 0.0.1-prerelease.20 | 64 | 10/2/2026 |