Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 13 additions & 83 deletions cmd/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,95 +8,25 @@ package cmd

import (
"github.com/raohwork/forgejo-mcp/tools"
"github.com/raohwork/forgejo-mcp/tools/action"
"github.com/raohwork/forgejo-mcp/tools/issue"
"github.com/raohwork/forgejo-mcp/tools/label"
"github.com/raohwork/forgejo-mcp/tools/milestone"
"github.com/raohwork/forgejo-mcp/tools/pullreq"
"github.com/raohwork/forgejo-mcp/tools/release"
"github.com/raohwork/forgejo-mcp/tools/repo"
"github.com/raohwork/forgejo-mcp/tools/wiki"
"github.com/raohwork/forgejo-mcp/tools/unified"
"github.com/raohwork/forgejo-mcp/types"

"github.com/modelcontextprotocol/go-sdk/mcp"
)

func registerCommands(s *mcp.Server, cl *tools.Client) {
// Issue tools
tools.Register(s, &issue.ListRepoIssuesImpl{Client: cl})
tools.Register(s, &issue.GetIssueImpl{Client: cl})
tools.Register(s, &issue.CreateIssueImpl{Client: cl})
tools.Register(s, &issue.EditIssueImpl{Client: cl})

// Issue label tools
tools.Register(s, &issue.AddIssueLabelsImpl{Client: cl})
tools.Register(s, &issue.RemoveIssueLabelImpl{Client: cl})
tools.Register(s, &issue.ReplaceIssueLabelsImpl{Client: cl})

// Issue comment tools
tools.Register(s, &issue.ListIssueCommentsImpl{Client: cl})
tools.Register(s, &issue.CreateIssueCommentImpl{Client: cl})
tools.Register(s, &issue.EditIssueCommentImpl{Client: cl})
tools.Register(s, &issue.DeleteIssueCommentImpl{Client: cl})

// Issue attachment tools
tools.Register(s, &issue.ListIssueAttachmentsImpl{Client: cl})
tools.Register(s, &issue.DeleteIssueAttachmentImpl{Client: cl})
tools.Register(s, &issue.EditIssueAttachmentImpl{Client: cl})

// Issue dependency tools
tools.Register(s, &issue.ListIssueDependenciesImpl{Client: cl})
tools.Register(s, &issue.AddIssueDependencyImpl{Client: cl})
tools.Register(s, &issue.RemoveIssueDependencyImpl{Client: cl})

// Issue blocking tools
tools.Register(s, &issue.ListIssueBlockingImpl{Client: cl})
tools.Register(s, &issue.AddIssueBlockingImpl{Client: cl})
tools.Register(s, &issue.RemoveIssueBlockingImpl{Client: cl})

// Label tools
tools.Register(s, &label.ListRepoLabelsImpl{Client: cl})
tools.Register(s, &label.CreateLabelImpl{Client: cl})
tools.Register(s, &label.EditLabelImpl{Client: cl})
tools.Register(s, &label.DeleteLabelImpl{Client: cl})

// Milestone tools
tools.Register(s, &milestone.ListRepoMilestonesImpl{Client: cl})
tools.Register(s, &milestone.CreateMilestoneImpl{Client: cl})
tools.Register(s, &milestone.EditMilestoneImpl{Client: cl})
tools.Register(s, &milestone.DeleteMilestoneImpl{Client: cl})

// Release tools
tools.Register(s, &release.ListReleasesImpl{Client: cl})
tools.Register(s, &release.CreateReleaseImpl{Client: cl})
tools.Register(s, &release.EditReleaseImpl{Client: cl})
tools.Register(s, &release.DeleteReleaseImpl{Client: cl})

// Release attachment tools
tools.Register(s, &release.ListReleaseAttachmentsImpl{Client: cl})
tools.Register(s, &release.EditReleaseAttachmentImpl{Client: cl})
tools.Register(s, &release.DeleteReleaseAttachmentImpl{Client: cl})

// Pull request tools
tools.Register(s, &pullreq.ListPullRequestsImpl{Client: cl})
tools.Register(s, &pullreq.GetPullRequestImpl{Client: cl})
tools.Register(s, &pullreq.CreatePullRequestImpl{Client: cl})

// Repository tools
tools.Register(s, &repo.SearchRepositoriesImpl{Client: cl})
tools.Register(s, &repo.ListMyRepositoriesImpl{Client: cl})
tools.Register(s, &repo.ListOrgRepositoriesImpl{Client: cl})
tools.Register(s, &repo.GetRepositoryImpl{Client: cl})

// Wiki tools
tools.Register(s, &wiki.GetWikiPageImpl{Client: cl})
tools.Register(s, &wiki.CreateWikiPageImpl{Client: cl})
tools.Register(s, &wiki.EditWikiPageImpl{Client: cl})
tools.Register(s, &wiki.DeleteWikiPageImpl{Client: cl})
tools.Register(s, &wiki.ListWikiPagesImpl{Client: cl})

// Action tools
tools.Register(s, &action.ListActionTasksImpl{Client: cl})
// Use unified tools (8 tools instead of 47)
// This reduces token consumption by ~80% while maintaining full functionality.
// The unified tools use action-based organization:
// - gitea_manual: On-demand documentation lookup
// - create_gitea: Create resources (issue, label, milestone, release, wiki_page, pull_request, issue_comment)
// - get_gitea: Get single resources (issue, wiki_page, pull_request, repository)
// - list_gitea: List resources (issues, labels, milestones, releases, wiki_pages, pull_requests, repositories, etc.)
// - edit_gitea: Edit resources (issue, label, milestone, release, wiki_page, etc.)
// - delete_gitea: Delete resources (label, milestone, release, wiki_page, issue_comment, etc.)
// - link_gitea: Create relationships (issue↔label, issue dependencies, issue blocking)
// - unlink_gitea: Remove relationships
unified.RegisterAll(s, cl)
}

func createServer(cl *tools.Client) *mcp.Server {
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIx
github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/jsonschema-go v0.2.0 h1:Uh19091iHC56//WOsAd1oRg6yy1P9BpSvpjOL6RcjLQ=
github.com/google/jsonschema-go v0.2.0/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
github.com/google/jsonschema-go v0.2.1-0.20250825175020-748c325cec76 h1:mBlBwtDebdDYr+zdop8N62a44g+Nbv7o2KjWyS1deR4=
github.com/google/jsonschema-go v0.2.1-0.20250825175020-748c325cec76/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
Expand All @@ -30,8 +28,6 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/modelcontextprotocol/go-sdk v0.2.1-0.20250812214950-6e03217c831b h1:UY+mamH9fcvW4D7X2DcNnTUNSFagNNr85evEF1xAdqs=
github.com/modelcontextprotocol/go-sdk v0.2.1-0.20250812214950-6e03217c831b/go.mod h1:71VUZVa8LL6WARvSgLJ7DMpDWSeomT4uBv8g97mGBvo=
github.com/modelcontextprotocol/go-sdk v0.4.0 h1:RJ6kFlneHqzTKPzlQqiunrz9nbudSZcYLmLHLsokfoU=
github.com/modelcontextprotocol/go-sdk v0.4.0/go.mod h1:whv0wHnsTphwq7CTiKYHkLtwLC06WMoY2KpO+RB9yXQ=
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
Expand Down
Loading