Skip to content

Commit 2db1c06

Browse files
committed
feat: Add GitHub label retrieval functionality in DoCommandHandler
1 parent 946f6bd commit 2db1c06

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/Cli/src/Commands/DoCommandHandler.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using ModelContextProtocol.Client;
1313
using ModelContextProtocol.Protocol.Transport;
1414
using ModelContextProtocol.Protocol.Types;
15+
using Octokit;
1516
using Tool = LangChain.Cli.Models.Tool;
1617

1718
namespace LangChain.Cli.Commands;
@@ -188,6 +189,12 @@ .. tools.Contains(Tool.Filesystem)
188189
name: "FindFilePathsByContent",
189190
description: "Finds file paths by content.") }
190191
: [],
192+
.. tools.Contains(Tool.GitHub)
193+
? new [] { AIFunctionFactory.Create(
194+
GetAvailableLabels,
195+
name: "GetAvailableLabelsForRepository",
196+
description: "Retrieves all available labels for a GitHub repository.") }
197+
: [],
191198
],
192199
ResponseFormat = format switch
193200
{
@@ -271,6 +278,17 @@ static async Task<IList<string>> FindFilePathsByContent(
271278

272279
return paths;
273280
}
281+
282+
[Description("Retrieves all available labels for a GitHub repository.")]
283+
static async Task<IReadOnlyList<Label>> GetAvailableLabels(
284+
[Description("The owner of the repository")] string owner,
285+
[Description("The name of the repository")] string name)
286+
{
287+
var github = new GitHubClient(new ProductHeaderValue("LangChain DO MCP extension"));
288+
var labels = await github.Issue.Labels.GetAllForRepository(owner, name).ConfigureAwait(false);
289+
290+
return labels;
291+
}
274292
}
275293

276294
public static ChatResponseFormatJson ChatResponseFormatForType<T>(

src/Cli/src/LangChain.Cli.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<PackageReference Include="Microsoft.Extensions.Logging.Console"/>
2424
<PackageReference Include="Microsoft.Extensions.Logging.Debug"/>
2525
<PackageReference Include="ModelContextProtocol"/>
26+
<PackageReference Include="Octokit" />
2627
<PackageReference Include="OpenAI"/>
2728
<PackageReference Include="System.CommandLine"/>
2829
<PackageReference Include="System.Text.Json"/>

src/Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
4242
<PackageVersion Include="ModelContextProtocol" Version="0.1.0-preview.4" />
4343
<PackageVersion Include="Moq" Version="4.20.72" />
44+
<PackageVersion Include="Octokit" Version="14.0.0" />
4445
<PackageVersion Include="OpenAI" Version="2.2.0-beta.4" />
4546
<PackageVersion Include="Testcontainers" Version="4.4.0" />
4647
<PackageVersion Include="tryAGI.OpenAI" Version="4.2.0" />

0 commit comments

Comments
 (0)