Forge
csharp3407750f
1using AgentForge.Abstractions;
2using AgentForge.Mcp.Core;
3
4namespace AgentForge.Plugin.Issue;
5
6internal static class ForgeIssueMcpTools
7{
8 internal static void Register(ForgeMcpToolRegistry registry)
9 {
10 ForgeMcpHttpTools.Add(registry, IssueCreateDescriptor, (client, args, ct) =>
11 client.CreateIssueAsync(
12 ForgeMcpArgParser.RequireString(args, "repo"),
13 ForgeMcpArgParser.ParseCreateIssue(args),
14 ct));
15 ForgeMcpHttpTools.Add(registry, IssueOpenDescriptor, (client, args, ct) =>
16 client.GetIssueAsync(
17 ForgeMcpArgParser.RequireString(args, "repo"),
18 ForgeMcpArgParser.RequireInt(args, "number"),
19 ct));
20 ForgeMcpHttpTools.Add(registry, IssueListDescriptor, (client, args, ct) =>
21 client.ListIssuesAsync(
22 ForgeMcpArgParser.RequireString(args, "repo"),
23 ForgeMcpArgParser.OptionalString(args, "q"),
24 ct));
25 ForgeMcpHttpTools.Add(registry, IssueSearchDescriptor, (client, args, ct) =>
26 client.ListIssuesAsync(
27 ForgeMcpArgParser.RequireString(args, "repo"),
28 ForgeMcpArgParser.RequireString(args, "query"),
29 ct));
30 ForgeMcpHttpTools.Add(registry, IssueUpdateDescriptor, (client, args, ct) =>
31 client.UpdateIssueAsync(
32 ForgeMcpArgParser.RequireString(args, "repo"),
33 ForgeMcpArgParser.RequireInt(args, "number"),
34 ForgeMcpArgParser.ParseUpdateIssue(args),
35 ct));
36 ForgeMcpHttpTools.Add(registry, IssueCommentDescriptor, (client, args, ct) =>
37 client.AddIssueCommentAsync(
38 ForgeMcpArgParser.RequireString(args, "repo"),
39 ForgeMcpArgParser.RequireInt(args, "number"),
40 ForgeMcpArgParser.ParseAddComment(args),
41 ct));
42 ForgeMcpHttpTools.Add(registry, IssueLinkAnchorsDescriptor, (client, args, ct) =>
43 client.LinkIssueAnchorsAsync(
44 ForgeMcpArgParser.RequireString(args, "repo"),
45 ForgeMcpArgParser.RequireInt(args, "number"),
46 ForgeMcpArgParser.ParseLinkAnchors(args),
47 ct));
48 }
49
50 private static readonly ForgeMcpToolDescriptor IssueCreateDescriptor = new()
51 {
52 Name = ForgeMcpToolNames.IssueCreate,
53 Description = "Создать issue; опционально anchors[] для Forge Lens.",
54 InputSchema = ForgeMcpSchemas.Object(new
55 {
56 type = "object",
57 properties = new
58 {
59 repo = new { type = "string", description = "Slug репозитория." },
60 title = new { type = "string", description = "Заголовок issue." },
61 body = new { type = "string", description = "Описание (markdown)." },
62 anchors = ForgeMcpSchemas.Anchors,
63 author = new { type = "string", description = "oar:LineName; иначе FORGE_ACTOR / X-Forge-Actor." },
64 },
65 required = new[] { "repo", "title" },
66 }),
67 };
68
69 private static readonly ForgeMcpToolDescriptor IssueOpenDescriptor = new()
70 {
71 Name = ForgeMcpToolNames.IssueOpen,
72 Description = "Issue по номеру: body, status, issueUrl, anchors, comments.",
73 InputSchema = ForgeMcpSchemas.Object(new
74 {
75 type = "object",
76 properties = new
77 {
78 repo = new { type = "string" },
79 number = new { type = "integer" },
80 },
81 required = new[] { "repo", "number" },
82 }),
83 };
84
85 private static readonly ForgeMcpToolDescriptor IssueListDescriptor = new()
86 {
87 Name = ForgeMcpToolNames.IssueList,
88 Description = "Список issues; опционально q — поиск по title/body.",
89 InputSchema = ForgeMcpSchemas.Object(new
90 {
91 type = "object",
92 properties = new
93 {
94 repo = new { type = "string" },
95 q = new { type = "string", description = "Поисковый запрос (optional)." },
96 },
97 required = new[] { "repo" },
98 }),
99 };
100
101 private static readonly ForgeMcpToolDescriptor IssueSearchDescriptor = new()
102 {
103 Name = ForgeMcpToolNames.IssueSearch,
104 Description = "Поиск issues по title/body (alias list_issues?q=).",
105 InputSchema = ForgeMcpSchemas.Object(new
106 {
107 type = "object",
108 properties = new
109 {
110 repo = new { type = "string" },
111 query = new { type = "string" },
112 },
113 required = new[] { "repo", "query" },
114 }),
115 };
116
117 private static readonly ForgeMcpToolDescriptor IssueUpdateDescriptor = new()
118 {
119 Name = ForgeMcpToolNames.IssueUpdate,
120 Description = "Обновить issue: title, body, status (open|closed).",
121 InputSchema = ForgeMcpSchemas.Object(new
122 {
123 type = "object",
124 properties = new
125 {
126 repo = new { type = "string" },
127 number = new { type = "integer" },
128 title = new { type = "string" },
129 body = new { type = "string" },
130 status = new { type = "string", description = "open или closed." },
131 },
132 required = new[] { "repo", "number" },
133 }),
134 };
135
136 private static readonly ForgeMcpToolDescriptor IssueCommentDescriptor = new()
137 {
138 Name = ForgeMcpToolNames.IssueComment,
139 Description = "Комментарий к issue (тред расследования).",
140 InputSchema = ForgeMcpSchemas.Object(new
141 {
142 type = "object",
143 properties = new
144 {
145 repo = new { type = "string" },
146 number = new { type = "integer" },
147 body = new { type = "string" },
148 author = new { type = "string", description = "Твоё выбранное имя (oar:…). Или FORGE_ACTOR / oar:{token name}." },
149 },
150 required = new[] { "repo", "number", "body" },
151 }),
152 };
153
154 private static readonly ForgeMcpToolDescriptor IssueLinkAnchorsDescriptor = new()
155 {
156 Name = ForgeMcpToolNames.IssueLinkAnchors,
157 Description = "Привязать anchors[] к существующему issue (merge с уже привязанными).",
158 InputSchema = ForgeMcpSchemas.Object(new
159 {
160 type = "object",
161 properties = new
162 {
163 repo = new { type = "string" },
164 number = new { type = "integer" },
165 anchors = ForgeMcpSchemas.Anchors,
166 },
167 required = new[] { "repo", "number", "anchors" },
168 }),
169 };
170}
171
View only · write via MCP/CIDE