Files
gitea-mcp/Tools/OrgTools.cs
T
zhengchen.tao 71600adba9
Build Docker Image / build (push) Failing after 1m40s
Initial public release
MCP (Model Context Protocol) server providing read-only access to a Gitea
instance, gated by OAuth-issued JWT bearer tokens. See README.md for setup.
2026-05-17 23:54:59 +08:00

57 lines
1.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using GiteaMcp.Services;
using ModelContextProtocol.Server;
using System.ComponentModel;
namespace GiteaMcp.Tools;
/// <summary>Organization Toollist_orgs / read_org</summary>
[McpServerToolType]
public class OrgTools(GiteaApiClient gitea)
{
[McpServerTool]
[Description(
"List all Gitea organizations visible to the admin token. " +
"Returns: org name, full name, description, visibility, and website. " +
"Use read_org to get repo/member counts for a specific org. " +
"Tip: after listing orgs, call list_repos with owner=<org_name> to see that org's repos.")]
public async Task<object> list_orgs(
[Description("Max orgs to return. Default 50.")] int? limit = null,
CancellationToken ct = default)
{
var lim = Math.Min(limit ?? 50, 50);
var orgs = await gitea.GetOrgsAsync(lim, ct);
return orgs.Select(o => new
{
name = o.Name,
full_name = o.FullName,
description = o.Description,
website = o.Website,
location = o.Location,
visibility = o.Visibility,
}).ToList();
}
[McpServerTool]
[Description(
"Get detailed information about a specific Gitea organization: " +
"description, website, location, and visibility setting. " +
"Use list_repos with owner=<name> to see the org's repositories.")]
public async Task<object> read_org(
[Description("Organization name (login).")] string name,
CancellationToken ct = default)
{
var org = await gitea.GetOrgAsync(name, ct);
return new
{
name = org.Name,
full_name = org.FullName,
description = org.Description,
website = org.Website,
location = org.Location,
visibility = org.Visibility,
};
}
}