MCP-Client fuer HTTP-Server: externe Werkzeuge durch dieselben Pruefstellen (#197)
- Core/Mcp/McpClient: Streamable HTTP (MCP 2025-06-18) - initialize, tools/list with paging, tools/call; answers as JSON or event stream; session kept and opened again when the server forgets it; answers capped at 4 MB. - McpServerTool: one server is one tool (mcp_<id>); its remote tools are the operations, so rights, preflight, staging, lead approvals, votes, audit and budget apply. On approval by default unless the human trusts an operation; reads foreign content; the server's descriptions are cut short and marked. - McpConnections: registers, refreshes every 15 minutes, follows changes. - InstanceConfig.mcpServers with protected headers; /api/mcp-servers; settings card "External MCP servers"; tool catalog includes the servers. - stdio servers are not part of this (sandbox runner, separate step). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
44844a41a0
commit
caf4323012
@@ -141,6 +141,9 @@ public sealed class AppHost : IAsyncDisposable
|
||||
/// <summary>#725: Inbound triggers — n8n or any other system hands an agent a task.</summary>
|
||||
public Core.Triggers.InboundTriggers? Triggers { get; private set; }
|
||||
|
||||
/// <summary>#197: The external MCP servers, each registered as a tool.</summary>
|
||||
public Core.Mcp.McpConnections? McpServers { get; private set; }
|
||||
|
||||
/// <summary>Modellpreise von OpenRouter - fuer Budget und Kostenprognose (#595). Laedt im Hintergrund.</summary>
|
||||
public ModelPricingCatalog? Pricing { get; private init; }
|
||||
|
||||
@@ -735,6 +738,13 @@ public sealed class AppHost : IAsyncDisposable
|
||||
spotChecks.Start();
|
||||
host._shutdown.Add(spotChecks.DisposeAsync);
|
||||
|
||||
// #197: external MCP servers, each one tool — refreshed now and every quarter of an hour.
|
||||
var mcpServers = new Core.Mcp.McpConnections(tools, () => instance.McpServers,
|
||||
loggerFactory.CreateLogger("ClawdDotNet.Core.Mcp.Client"));
|
||||
host.McpServers = mcpServers;
|
||||
mcpServers.Start();
|
||||
host._shutdown.Add(mcpServers.DisposeAsync);
|
||||
|
||||
// #725: what comes in from outside through a trigger becomes a task.
|
||||
host.Triggers = new Core.Triggers.InboundTriggers(storage, board, audit, () => instance.Agents);
|
||||
|
||||
|
||||
@@ -45,6 +45,17 @@ public sealed class AgentAdministration(AppHost host)
|
||||
"SocialMediaManager", "AgentSpawn", "AgentEditor", "Memory", "Taskboard"
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// #197: What an agent can be given: the known tools and one per external MCP server — also
|
||||
/// a server's tool an agent still has after the server was removed, so it can be taken away.
|
||||
/// </summary>
|
||||
public IReadOnlyList<string> ToolCatalog()
|
||||
=> KnownTools
|
||||
.Concat(host.Instance.McpServers.Select(s => Core.Mcp.McpServerTool.NameFor(s.Id)))
|
||||
.Concat(host.Instance.Agents.SelectMany(a => a.Tools.Keys).Where(k => k.StartsWith(Core.Mcp.McpServerTool.Prefix, StringComparison.OrdinalIgnoreCase)))
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
|
||||
public IReadOnlyList<AgentConfig> All => host.Instance.Agents;
|
||||
|
||||
public AgentConfig? Find(string agentId)
|
||||
|
||||
Reference in New Issue
Block a user