Skip to content

Commit d5675c5

Browse files
committed
housekeeping move stargazer tools
1 parent c1f47eb commit d5675c5

File tree

5 files changed

+586
-556
lines changed

5 files changed

+586
-556
lines changed

docs/remote-server.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ Below is a table of available toolsets for the remote GitHub MCP Server. Each to
1919
<!-- START AUTOMATED TOOLSETS -->
2020
| Name | Description | API URL | 1-Click Install (VS Code) | Read-only Link | 1-Click Read-only Install (VS Code) |
2121
|----------------|--------------------------------------------------|-------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
22-
| default | Default GitHub MCP toolset (see [default toolset](../README.md#default-toolset)) | https://api.githubcopilot.com/mcp/ | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D) | [read-only](https://api.githubcopilot.com/mcp/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Freadonly%22%7D) |
23-
| all | All available GitHub MCP tools | https://api.githubcopilot.com/mcp/x/all | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=github-all&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fall%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/all/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=github-all&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fall%2Freadonly%22%7D) |
22+
| all | All available GitHub MCP tools | https://api.githubcopilot.com/mcp/ | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D) | [read-only](https://api.githubcopilot.com/mcp/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Freadonly%22%7D) |
2423
| Actions | GitHub Actions workflows and CI/CD operations | https://api.githubcopilot.com/mcp/x/actions | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-actions&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Factions%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/actions/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-actions&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Factions%2Freadonly%22%7D) |
2524
| Code Security | Code security related tools, such as GitHub Code Scanning | https://api.githubcopilot.com/mcp/x/code_security | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-code_security&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fcode_security%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/code_security/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-code_security&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fcode_security%2Freadonly%22%7D) |
2625
| Dependabot | Dependabot tools | https://api.githubcopilot.com/mcp/x/dependabot | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-dependabot&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fdependabot%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/dependabot/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-dependabot&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fdependabot%2Freadonly%22%7D) |

pkg/github/repositories.go

Lines changed: 0 additions & 228 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,231 +1564,3 @@ func PushFilesMethod(ctx context.Context, client *github.Client, owner, repo, br
15641564

15651565
return mcp.NewToolResultText(string(r)), nil
15661566
}
1567-
1568-
// ListStarredRepositories creates a tool to list starred repositories for the authenticated user or a specified user.
1569-
func ListStarredRepositories(getClient GetClientFn, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
1570-
return mcp.NewTool("list_starred_repositories",
1571-
mcp.WithDescription(t("TOOL_LIST_STARRED_REPOSITORIES_DESCRIPTION", "List starred repositories")),
1572-
mcp.WithToolAnnotation(mcp.ToolAnnotation{
1573-
Title: t("TOOL_LIST_STARRED_REPOSITORIES_USER_TITLE", "List starred repositories"),
1574-
ReadOnlyHint: ToBoolPtr(true),
1575-
}),
1576-
mcp.WithString("username",
1577-
mcp.Description("Username to list starred repositories for. Defaults to the authenticated user."),
1578-
),
1579-
mcp.WithString("sort",
1580-
mcp.Description("How to sort the results. Can be either 'created' (when the repository was starred) or 'updated' (when the repository was last pushed to)."),
1581-
mcp.Enum("created", "updated"),
1582-
),
1583-
mcp.WithString("direction",
1584-
mcp.Description("The direction to sort the results by."),
1585-
mcp.Enum("asc", "desc"),
1586-
),
1587-
WithPagination(),
1588-
),
1589-
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
1590-
username, err := OptionalParam[string](request, "username")
1591-
if err != nil {
1592-
return mcp.NewToolResultError(err.Error()), nil
1593-
}
1594-
sort, err := OptionalParam[string](request, "sort")
1595-
if err != nil {
1596-
return mcp.NewToolResultError(err.Error()), nil
1597-
}
1598-
direction, err := OptionalParam[string](request, "direction")
1599-
if err != nil {
1600-
return mcp.NewToolResultError(err.Error()), nil
1601-
}
1602-
pagination, err := OptionalPaginationParams(request)
1603-
if err != nil {
1604-
return mcp.NewToolResultError(err.Error()), nil
1605-
}
1606-
1607-
opts := &github.ActivityListStarredOptions{
1608-
ListOptions: github.ListOptions{
1609-
Page: pagination.Page,
1610-
PerPage: pagination.PerPage,
1611-
},
1612-
}
1613-
if sort != "" {
1614-
opts.Sort = sort
1615-
}
1616-
if direction != "" {
1617-
opts.Direction = direction
1618-
}
1619-
1620-
client, err := getClient(ctx)
1621-
if err != nil {
1622-
return nil, fmt.Errorf("failed to get GitHub client: %w", err)
1623-
}
1624-
1625-
var repos []*github.StarredRepository
1626-
var resp *github.Response
1627-
if username == "" {
1628-
// List starred repositories for the authenticated user
1629-
repos, resp, err = client.Activity.ListStarred(ctx, "", opts)
1630-
} else {
1631-
// List starred repositories for a specific user
1632-
repos, resp, err = client.Activity.ListStarred(ctx, username, opts)
1633-
}
1634-
1635-
if err != nil {
1636-
return ghErrors.NewGitHubAPIErrorResponse(ctx,
1637-
fmt.Sprintf("failed to list starred repositories for user '%s'", username),
1638-
resp,
1639-
err,
1640-
), nil
1641-
}
1642-
defer func() { _ = resp.Body.Close() }()
1643-
1644-
if resp.StatusCode != 200 {
1645-
body, err := io.ReadAll(resp.Body)
1646-
if err != nil {
1647-
return nil, fmt.Errorf("failed to read response body: %w", err)
1648-
}
1649-
return mcp.NewToolResultError(fmt.Sprintf("failed to list starred repositories: %s", string(body))), nil
1650-
}
1651-
1652-
// Convert to minimal format
1653-
minimalRepos := make([]MinimalRepository, 0, len(repos))
1654-
for _, starredRepo := range repos {
1655-
repo := starredRepo.Repository
1656-
minimalRepo := MinimalRepository{
1657-
ID: repo.GetID(),
1658-
Name: repo.GetName(),
1659-
FullName: repo.GetFullName(),
1660-
Description: repo.GetDescription(),
1661-
HTMLURL: repo.GetHTMLURL(),
1662-
Language: repo.GetLanguage(),
1663-
Stars: repo.GetStargazersCount(),
1664-
Forks: repo.GetForksCount(),
1665-
OpenIssues: repo.GetOpenIssuesCount(),
1666-
Private: repo.GetPrivate(),
1667-
Fork: repo.GetFork(),
1668-
Archived: repo.GetArchived(),
1669-
DefaultBranch: repo.GetDefaultBranch(),
1670-
}
1671-
1672-
if repo.UpdatedAt != nil {
1673-
minimalRepo.UpdatedAt = repo.UpdatedAt.Format("2006-01-02T15:04:05Z")
1674-
}
1675-
1676-
minimalRepos = append(minimalRepos, minimalRepo)
1677-
}
1678-
1679-
r, err := json.Marshal(minimalRepos)
1680-
if err != nil {
1681-
return nil, fmt.Errorf("failed to marshal starred repositories: %w", err)
1682-
}
1683-
1684-
return mcp.NewToolResultText(string(r)), nil
1685-
}
1686-
}
1687-
1688-
// StarRepository creates a tool to star a repository.
1689-
func StarRepository(getClient GetClientFn, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
1690-
return mcp.NewTool("star_repository",
1691-
mcp.WithDescription(t("TOOL_STAR_REPOSITORY_DESCRIPTION", "Star a GitHub repository")),
1692-
mcp.WithToolAnnotation(mcp.ToolAnnotation{
1693-
Title: t("TOOL_STAR_REPOSITORY_USER_TITLE", "Star repository"),
1694-
ReadOnlyHint: ToBoolPtr(false),
1695-
}),
1696-
mcp.WithString("owner",
1697-
mcp.Required(),
1698-
mcp.Description("Repository owner"),
1699-
),
1700-
mcp.WithString("repo",
1701-
mcp.Required(),
1702-
mcp.Description("Repository name"),
1703-
),
1704-
),
1705-
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
1706-
owner, err := RequiredParam[string](request, "owner")
1707-
if err != nil {
1708-
return mcp.NewToolResultError(err.Error()), nil
1709-
}
1710-
repo, err := RequiredParam[string](request, "repo")
1711-
if err != nil {
1712-
return mcp.NewToolResultError(err.Error()), nil
1713-
}
1714-
1715-
client, err := getClient(ctx)
1716-
if err != nil {
1717-
return nil, fmt.Errorf("failed to get GitHub client: %w", err)
1718-
}
1719-
1720-
resp, err := client.Activity.Star(ctx, owner, repo)
1721-
if err != nil {
1722-
return ghErrors.NewGitHubAPIErrorResponse(ctx,
1723-
fmt.Sprintf("failed to star repository %s/%s", owner, repo),
1724-
resp,
1725-
err,
1726-
), nil
1727-
}
1728-
defer func() { _ = resp.Body.Close() }()
1729-
1730-
if resp.StatusCode != 204 {
1731-
body, err := io.ReadAll(resp.Body)
1732-
if err != nil {
1733-
return nil, fmt.Errorf("failed to read response body: %w", err)
1734-
}
1735-
return mcp.NewToolResultError(fmt.Sprintf("failed to star repository: %s", string(body))), nil
1736-
}
1737-
1738-
return mcp.NewToolResultText(fmt.Sprintf("Successfully starred repository %s/%s", owner, repo)), nil
1739-
}
1740-
}
1741-
1742-
// UnstarRepository creates a tool to unstar a repository.
1743-
func UnstarRepository(getClient GetClientFn, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
1744-
return mcp.NewTool("unstar_repository",
1745-
mcp.WithDescription(t("TOOL_UNSTAR_REPOSITORY_DESCRIPTION", "Unstar a GitHub repository")),
1746-
mcp.WithToolAnnotation(mcp.ToolAnnotation{
1747-
Title: t("TOOL_UNSTAR_REPOSITORY_USER_TITLE", "Unstar repository"),
1748-
ReadOnlyHint: ToBoolPtr(false),
1749-
}),
1750-
mcp.WithString("owner",
1751-
mcp.Required(),
1752-
mcp.Description("Repository owner"),
1753-
),
1754-
mcp.WithString("repo",
1755-
mcp.Required(),
1756-
mcp.Description("Repository name"),
1757-
),
1758-
),
1759-
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
1760-
owner, err := RequiredParam[string](request, "owner")
1761-
if err != nil {
1762-
return mcp.NewToolResultError(err.Error()), nil
1763-
}
1764-
repo, err := RequiredParam[string](request, "repo")
1765-
if err != nil {
1766-
return mcp.NewToolResultError(err.Error()), nil
1767-
}
1768-
1769-
client, err := getClient(ctx)
1770-
if err != nil {
1771-
return nil, fmt.Errorf("failed to get GitHub client: %w", err)
1772-
}
1773-
1774-
resp, err := client.Activity.Unstar(ctx, owner, repo)
1775-
if err != nil {
1776-
return ghErrors.NewGitHubAPIErrorResponse(ctx,
1777-
fmt.Sprintf("failed to unstar repository %s/%s", owner, repo),
1778-
resp,
1779-
err,
1780-
), nil
1781-
}
1782-
defer func() { _ = resp.Body.Close() }()
1783-
1784-
if resp.StatusCode != 204 {
1785-
body, err := io.ReadAll(resp.Body)
1786-
if err != nil {
1787-
return nil, fmt.Errorf("failed to read response body: %w", err)
1788-
}
1789-
return mcp.NewToolResultError(fmt.Sprintf("failed to unstar repository: %s", string(body))), nil
1790-
}
1791-
1792-
return mcp.NewToolResultText(fmt.Sprintf("Successfully unstarred repository %s/%s", owner, repo)), nil
1793-
}
1794-
}

0 commit comments

Comments
 (0)