Forge
csharp3407750f
1using System.Text.Json;
2using AgentForge.Abstractions;
3using AgentForge.Services;
4using Microsoft.AspNetCore.Builder;
5using Microsoft.Extensions.Configuration;
6using Microsoft.Extensions.DependencyInjection;
7
8namespace AgentForge.Plugin.View;
9
10public sealed class ViewForgePlugin : IForgePlugin
11{
12 public string Id => "view-shell";
13
14 public string DisplayName => "ViewShell (Human-layer chrome)";
15
16 public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
17 {
18 }
19
20 public void MapEndpoints(WebApplication app) => ForgeViewEndpoints.MapForgeViews(app);
21
22 public void RegisterFeatures(ForgeFeatureRegistry registry) => registry.Add("human_view");
23
24 public void RegisterMcpTools(ForgeMcpToolRegistry registry) =>
25 registry.Add(HumanViewUrlTool.Descriptor, HumanViewUrlTool.InvokeAsync);
26
27 public void RegisterCommands(ForgeCommandRegistry registry) =>
28 ForgeViewCommandRegistration.Register(registry);
29}
30
31file static class HumanViewUrlTool
32{
33 internal static readonly ForgeMcpToolDescriptor Descriptor = new()
34 {
35 Name = ForgeMcpToolNames.ViewUrl,
36 Description = "Returns the Human-layer view base URL when the view plugin is loaded (human_view feature).",
37 InputSchema = JsonSerializer.SerializeToElement(new { type = "object", properties = new { } }),
38 };
39
40 internal static Task<ForgeMcpInvokeResponse> InvokeAsync(
41 ForgeMcpToolInvocationContext context,
42 IReadOnlyDictionary<string, JsonElement> arguments,
43 CancellationToken cancellationToken)
44 {
45 var urls = context.RequestServices.GetRequiredService<ForgeUrls>();
46 var body = JsonSerializer.Serialize(new { viewBaseUrl = $"{urls.PublicBaseUrl}/view" });
47 return Task.FromResult(new ForgeMcpInvokeResponse { Success = true, Body = body });
48 }
49}
50
View only · write via MCP/CIDE