feat: expand MCP tool coverage from 93 to 299 tools
Some checks failed
release-nightly / release-image (push) Failing after 2m17s
Some checks failed
release-nightly / release-image (push) Failing after 2m17s
Fork the official gitea-mcp and massively extend API coverage: - Organization: orgs, members, teams, hooks, blocks, activity (34 tools) - User: profile, followers, keys, emails, repos, blocks (30 tools) - Repository: collaborators, webhooks, branch/tag protection, deploy keys, topics, git refs/trees/notes, commit status, stars/watchers, forks, transfers, mirrors, templates (53 tools) - Issue: reactions, pins, subscriptions, timeline, templates (16 tools) - Notifications: list, check, read, repo-scoped (7 tools) - Settings: API, attachment, repo, UI settings (4 tools) - Packages: list, get, delete, files, latest, link/unlink (7 tools) - Miscellaneous: server version, gitignore/label/license templates, markdown/markup rendering, node info, signing keys (12 tools) - Admin: user/org/repo CRUD, system webhooks, cron tasks, unadopted repos, emails, badges (23 tools) Module path updated to git.lethalbits.com/lethalbits/gitea-mcp.
This commit is contained in:
104
operation/settings/settings.go
Normal file
104
operation/settings/settings.go
Normal file
@@ -0,0 +1,104 @@
|
||||
package settings
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"git.lethalbits.com/lethalbits/gitea-mcp/pkg/gitea"
|
||||
"git.lethalbits.com/lethalbits/gitea-mcp/pkg/log"
|
||||
"git.lethalbits.com/lethalbits/gitea-mcp/pkg/to"
|
||||
"git.lethalbits.com/lethalbits/gitea-mcp/pkg/tool"
|
||||
|
||||
"github.com/mark3labs/mcp-go/mcp"
|
||||
"github.com/mark3labs/mcp-go/server"
|
||||
)
|
||||
|
||||
var Tool = tool.New()
|
||||
|
||||
const (
|
||||
GetAPISettingsToolName = "get_api_settings"
|
||||
GetAttachmentSettingsToolName = "get_attachment_settings"
|
||||
GetRepoSettingsToolName = "get_repo_settings"
|
||||
GetUISettingsToolName = "get_ui_settings"
|
||||
)
|
||||
|
||||
var (
|
||||
GetAPISettingsTool = mcp.NewTool(
|
||||
GetAPISettingsToolName,
|
||||
mcp.WithDescription("Get the global API settings of the Gitea instance"),
|
||||
)
|
||||
|
||||
GetAttachmentSettingsTool = mcp.NewTool(
|
||||
GetAttachmentSettingsToolName,
|
||||
mcp.WithDescription("Get the global attachment settings"),
|
||||
)
|
||||
|
||||
GetRepoSettingsTool = mcp.NewTool(
|
||||
GetRepoSettingsToolName,
|
||||
mcp.WithDescription("Get the global repository settings"),
|
||||
)
|
||||
|
||||
GetUISettingsTool = mcp.NewTool(
|
||||
GetUISettingsToolName,
|
||||
mcp.WithDescription("Get the global UI settings"),
|
||||
)
|
||||
)
|
||||
|
||||
func init() {
|
||||
Tool.RegisterRead(server.ServerTool{Tool: GetAPISettingsTool, Handler: GetAPISettingsFn})
|
||||
Tool.RegisterRead(server.ServerTool{Tool: GetAttachmentSettingsTool, Handler: GetAttachmentSettingsFn})
|
||||
Tool.RegisterRead(server.ServerTool{Tool: GetRepoSettingsTool, Handler: GetRepoSettingsFn})
|
||||
Tool.RegisterRead(server.ServerTool{Tool: GetUISettingsTool, Handler: GetUISettingsFn})
|
||||
}
|
||||
|
||||
func GetAPISettingsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called GetAPISettingsFn")
|
||||
client, err := gitea.ClientFromContext(ctx)
|
||||
if err != nil {
|
||||
return to.ErrorResult(fmt.Errorf("get gitea client err: %v", err))
|
||||
}
|
||||
settings, _, err := client.GetGlobalAPISettings()
|
||||
if err != nil {
|
||||
return to.ErrorResult(fmt.Errorf("get API settings err: %v", err))
|
||||
}
|
||||
return to.TextResult(settings)
|
||||
}
|
||||
|
||||
func GetAttachmentSettingsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called GetAttachmentSettingsFn")
|
||||
client, err := gitea.ClientFromContext(ctx)
|
||||
if err != nil {
|
||||
return to.ErrorResult(fmt.Errorf("get gitea client err: %v", err))
|
||||
}
|
||||
settings, _, err := client.GetGlobalAttachmentSettings()
|
||||
if err != nil {
|
||||
return to.ErrorResult(fmt.Errorf("get attachment settings err: %v", err))
|
||||
}
|
||||
return to.TextResult(settings)
|
||||
}
|
||||
|
||||
func GetRepoSettingsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called GetRepoSettingsFn")
|
||||
client, err := gitea.ClientFromContext(ctx)
|
||||
if err != nil {
|
||||
return to.ErrorResult(fmt.Errorf("get gitea client err: %v", err))
|
||||
}
|
||||
settings, _, err := client.GetGlobalRepoSettings()
|
||||
if err != nil {
|
||||
return to.ErrorResult(fmt.Errorf("get repo settings err: %v", err))
|
||||
}
|
||||
return to.TextResult(settings)
|
||||
}
|
||||
|
||||
func GetUISettingsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called GetUISettingsFn")
|
||||
client, err := gitea.ClientFromContext(ctx)
|
||||
if err != nil {
|
||||
return to.ErrorResult(fmt.Errorf("get gitea client err: %v", err))
|
||||
}
|
||||
settings, _, err := client.GetGlobalUISettings()
|
||||
if err != nil {
|
||||
return to.ErrorResult(fmt.Errorf("get UI settings err: %v", err))
|
||||
}
|
||||
return to.TextResult(settings)
|
||||
}
|
||||
Reference in New Issue
Block a user