handler

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuditLog

func AuditLog(toolName, walletAddress string, success bool, duration time.Duration, detail string)

AuditLog emits a structured log entry for chain-write operations. Non-blocking, uses existing logrus infrastructure.

func CheckTrust

func CheckTrust(currentLevel TrustLevel, toolName string) error

CheckTrust returns an error if the current trust level is insufficient for the tool.

func DryRunResult

func DryRunResult(toolName string, params any) (*mcp.CallToolResult, any, error)

DryRunResult returns a JSON preview of the operation that would be performed without actually signing or broadcasting it.

func IsToolEnabled

func IsToolEnabled(toolName string, activeToolsets map[Toolset]bool) bool

IsToolEnabled checks if a tool should be registered given the active toolsets.

func ParseToolsets

func ParseToolsets(s string) map[Toolset]bool

ParseToolsets parses a comma-separated toolset string. Empty string or "all" enables all toolsets.

func RegisterAll

func RegisterAll(srv *mcp.Server, h *ToolHandler)

RegisterAll registers all tools, prompts, and resource templates on the given MCP server using handlers from h and the provided gitopia client. This is extracted from cmd/server/main.go so that both the production binary and integration tests share the exact same registration.

Types

type BatchExecuteParams

type BatchExecuteParams struct {
	Operations []BatchOperation `json:"operations" jsonschema:"List of operations to execute in a single transaction (max 10)"`
}

BatchExecuteParams holds parameters for the batch_execute tool.

type BatchOperation

type BatchOperation struct {
	Tool   string         `json:"tool" jsonschema:"The tool name to execute"`
	Params map[string]any `json:"params" jsonschema:"Parameters for the tool as a JSON object"`
}

BatchOperation represents a single operation in a batch transaction.

type BootstrapRepoParams

type BootstrapRepoParams struct {
	OwnerId           string `json:"owner_id"`
	Name              string `json:"name"`
	LocalPath         string `json:"local_path,omitempty"`
	Description       string `json:"description,omitempty"`
	CreateReadme      bool   `json:"create_readme"`
	CreateGitignore   bool   `json:"create_gitignore"`
	InitialBranch     string `json:"initial_branch,omitempty"`
	GitignoreTemplate string `json:"gitignore_template,omitempty"`
}

type ClaimFeeGrantParams

type ClaimFeeGrantParams struct {
	Address string `json:"address,omitempty" jsonschema:"If empty, uses current wallet address"`
}

ClaimFeeGrantParams holds parameters for the claim_fee_grant tool.

type CloseBountyParams

type CloseBountyParams struct {
	BountyID uint64 `json:"bounty_id"`
}

type CoinParam

type CoinParam struct {
	Denom  string `json:"denom" jsonschema:"Token denomination (e.g. ulore)"`
	Amount string `json:"amount" jsonschema:"Token amount as string (e.g. 1000)"`
}

CoinParam is a JSON-schema-friendly representation of a coin amount. sdk.Coin uses math.Int which produces "type":"object" in JSON schema; this struct produces correct "type":"string" for the amount field.

type CommentOnIssueParams

type CommentOnIssueParams struct {
	Owner    string `json:"owner" jsonschema:"Repository owner (username or DAO name)"`
	Name     string `json:"name" jsonschema:"Repository name"`
	IssueIid uint64 `json:"issue_iid" jsonschema:"Issue number (IID)"`
	Body     string `json:"body" jsonschema:"Comment body text"`
}

type CommentOnPullRequestParams

type CommentOnPullRequestParams struct {
	Owner    string `json:"owner" jsonschema:"Repository owner (username or DAO name)"`
	Name     string `json:"name" jsonschema:"Repository name"`
	PullIid  uint64 `json:"pull_iid" jsonschema:"Pull request number (IID)"`
	Body     string `json:"body" jsonschema:"Comment body text"`
	DiffHunk string `json:"diff_hunk,omitempty" jsonschema:"Diff hunk for inline comment"`
	Path     string `json:"path,omitempty" jsonschema:"File path for inline comment"`
	Position uint64 `json:"position,omitempty" jsonschema:"Line position for inline comment"`
}

type CommitAndPushChangesParams

type CommitAndPushChangesParams struct {
	RepoPath      string   `json:"repo_path" jsonschema:"Repository path relative to workspace"`
	CommitMessage string   `json:"commit_message" jsonschema:"Commit message"`
	Files         []string `json:"files,omitempty" jsonschema:"Specific files to stage (empty for all)"`
	Branch        string   `json:"branch,omitempty" jsonschema:"Target branch (current if empty)"`
	CreateBranch  bool     `json:"create_branch,omitempty" jsonschema:"Create branch if it does not exist"`
}

type ConfirmTransactionParams

type ConfirmTransactionParams struct {
	PendingID string `json:"pending_id" jsonschema:"The ID of the pending transaction to confirm"`
}

type CreateBountyParams

type CreateBountyParams struct {
	Owner    string      `json:"owner"`
	Name     string      `json:"name"`
	IssueIID uint64      `json:"issue_iid"`
	Amount   []CoinParam `json:"amount"`
	Expiry   int64       `json:"expiry,omitempty"`
}

type CreateDaoParams

type CreateDaoParams struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	AvatarURL   string `json:"avatar_url,omitempty"`
	Location    string `json:"location,omitempty"`
	Website     string `json:"website,omitempty"`
	Members     []struct {
		Address  string `json:"address"`
		Weight   string `json:"weight"`
		Metadata string `json:"metadata,omitempty"`
	} `json:"members,omitempty"`
	VotingPeriod string                  `json:"voting_period,omitempty"`
	Percentage   string                  `json:"percentage,omitempty"`
	Config       *gitopiatypes.DaoConfig `json:"config,omitempty"`
}

type CreateFeatureBranchPRParams

type CreateFeatureBranchPRParams struct {
	RepoPath      string          `json:"repo_path" jsonschema:"Repository path relative to workspace (e.g. 'myrepo')"`
	Owner         string          `json:"owner"`
	Name          string          `json:"name"`
	BranchName    string          `json:"branch_name"`
	BaseBranch    string          `json:"base_branch,omitempty"`
	Files         []fs.FileChange `json:"files"`
	CommitMessage string          `json:"commit_message"`
	PRTitle       string          `json:"pr_title"`
	PRDescription string          `json:"pr_description"`
	Assignees     []string        `json:"assignees,omitempty"`
	Labels        []uint64        `json:"labels,omitempty"`
}

type CreateFeatureBranchParams

type CreateFeatureBranchParams struct {
	RepoPath   string `json:"repo_path"`
	BranchName string `json:"branch_name"`
	BaseBranch string `json:"base_branch,omitempty"`
}

type CreateIssueParams

type CreateIssueParams struct {
	Owner       string `json:"owner"`
	Name        string `json:"name"`
	Title       string `json:"title"`
	Description string `json:"description"`
}

type CreateLabelParams

type CreateLabelParams struct {
	Owner       string `json:"owner" jsonschema:"Repository owner (username or DAO name)"`
	Name        string `json:"name" jsonschema:"Repository name"`
	LabelName   string `json:"label_name" jsonschema:"Label name (3-63 characters)"`
	Color       string `json:"color" jsonschema:"Label color as hex code (e.g. FF0000)"`
	Description string `json:"description,omitempty" jsonschema:"Label description (max 255 characters)"`
}

type CreatePullRequestParams

type CreatePullRequestParams struct {
	Owner       string   `json:"owner"`
	Name        string   `json:"name"`
	Title       string   `json:"title"`
	Description string   `json:"description"`
	HeadBranch  string   `json:"head_branch"`
	BaseBranch  string   `json:"base_branch"`
	Assignees   []string `json:"assignees,omitempty"`
	Labels      []uint64 `json:"labels,omitempty"`
	IssueIids   []uint64 `json:"issue_iids,omitempty"`
}

type CreateReleaseParams

type CreateReleaseParams struct {
	Owner       string `json:"owner" jsonschema:"Repository owner (username or DAO name)"`
	Name        string `json:"name" jsonschema:"Repository name"`
	TagName     string `json:"tag_name" jsonschema:"Tag name for the release (e.g. v1.0.0)"`
	Target      string `json:"target,omitempty" jsonschema:"Branch or commit SHA to tag (defaults to default branch HEAD)"`
	ReleaseName string `json:"release_name" jsonschema:"Human-readable release title"`
	Description string `json:"description,omitempty" jsonschema:"Release notes / description"`
	Draft       bool   `json:"draft,omitempty" jsonschema:"Mark as draft release"`
	PreRelease  bool   `json:"pre_release,omitempty" jsonschema:"Mark as pre-release"`
	Provider    string `` /* 127-byte string literal not displayed */
}

type CreateRepoParams

type CreateRepoParams struct {
	OwnerId     string `json:"owner_id,omitempty"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

type CreateUserParams

type CreateUserParams struct {
	Username string `json:"username" jsonschema:"Gitopia username (3-39 chars, alphanumeric and hyphens)"`
}

CreateUserParams holds parameters for the create_user tool.

type DeleteBountyParams

type DeleteBountyParams struct {
	BountyID uint64 `json:"bounty_id"`
}

type DeleteLabelParams

type DeleteLabelParams struct {
	Owner   string `json:"owner" jsonschema:"Repository owner (username or DAO name)"`
	Name    string `json:"name" jsonschema:"Repository name"`
	LabelID uint64 `json:"label_id" jsonschema:"Label ID to delete (from list_labels)"`
}

type ErrorCode

type ErrorCode string

ErrorCode represents a machine-readable error classification.

const (
	ErrClientUnavailable ErrorCode = "CLIENT_UNAVAILABLE"
	ErrAuthFailed        ErrorCode = "AUTH_FAILED"
	ErrRateLimited       ErrorCode = "RATE_LIMITED"
	ErrValidation        ErrorCode = "VALIDATION_ERROR"
	ErrNotFound          ErrorCode = "NOT_FOUND"
	ErrConflict          ErrorCode = "CONFLICT"
	ErrNotRepository     ErrorCode = "NOT_REPOSITORY"
	ErrPathTraversal     ErrorCode = "PATH_TRAVERSAL"
	ErrChainTx           ErrorCode = "CHAIN_TX_FAILED"
	ErrGitOperation      ErrorCode = "GIT_OPERATION_FAILED"
	ErrFileSystem        ErrorCode = "FS_ERROR"
	ErrApproval          ErrorCode = "APPROVAL_ERROR"
	ErrInternal          ErrorCode = "INTERNAL_ERROR"
)

type ExecDaoProposalParams

type ExecDaoProposalParams struct {
	ProposalID uint64 `json:"proposal_id" jsonschema:"The unique ID of the proposal to execute"`
}

type ForkRepositoryParams

type ForkRepositoryParams struct {
	Owner           string `json:"owner" jsonschema:"Source repository owner (username or DAO name)"`
	Name            string `json:"name" jsonschema:"Source repository name"`
	ForkName        string `json:"fork_name,omitempty" jsonschema:"Name for the forked repository (defaults to source name)"`
	ForkDescription string `json:"fork_description,omitempty" jsonschema:"Description for the fork"`
	Branch          string `json:"branch,omitempty" jsonschema:"Branch to fork (defaults to all branches)"`
	ForkOwner       string `json:"fork_owner,omitempty" jsonschema:"Owner of the fork (defaults to authenticated user)"`
}

type GetBountyParams

type GetBountyParams struct {
	BountyID uint64 `json:"bounty_id" jsonschema:"The ID of the bounty to retrieve"`
}

type GetDaoParams

type GetDaoParams struct {
	ID string `json:"id" jsonschema:"DAO name or address"`
}

type GetDaoProposalParams

type GetDaoProposalParams struct {
	ProposalID uint64 `json:"proposal_id" jsonschema:"The unique ID of the proposal"`
}

type GetFileParams

type GetFileParams struct {
	Owner  string `json:"owner"`
	Name   string `json:"name"`
	Branch string `json:"branch"`
	Path   string `json:"path"`
}

type GetIssueParams

type GetIssueParams struct {
	Owner    string `json:"owner" jsonschema:"Repository owner (username or DAO name)"`
	Name     string `json:"name" jsonschema:"Repository name"`
	IssueIid uint64 `json:"issue_iid" jsonschema:"Issue number (IID)"`
}

type GetPullRequestDiffParams

type GetPullRequestDiffParams struct {
	Owner   string `json:"owner" jsonschema:"Repository owner (username or DAO name)"`
	Name    string `json:"name" jsonschema:"Repository name"`
	PullIid uint64 `json:"pull_iid" jsonschema:"Pull request number (IID)"`
	Limit   int    `json:"limit,omitempty" jsonschema:"Maximum number of file diffs to return (default 50)"`
}

type GetPullRequestParams

type GetPullRequestParams struct {
	Owner   string `json:"owner" jsonschema:"Repository owner (username or DAO name)"`
	Name    string `json:"name" jsonschema:"Repository name"`
	PullIid uint64 `json:"pull_iid" jsonschema:"Pull request number (IID)"`
}

type GetRepoParams

type GetRepoParams struct {
	Owner string `json:"owner"`
	Name  string `json:"name"`
}

type GitAddParams

type GitAddParams struct {
	RepoPath string   `json:"repo_path" jsonschema:"Repository path relative to workspace"`
	Files    []string `json:"files" jsonschema:"Files to stage. Use '.' to stage all changes."`
}

type GitCloneParams

type GitCloneParams struct {
	RepoURL   string `json:"repo_url" jsonschema:"gitopia:// URL or owner/name format"`
	LocalPath string `json:"local_path" jsonschema:"Path relative to workspace root"`
	Branch    string `json:"branch,omitempty" jsonschema:"Specific branch to clone"`
	Depth     int    `json:"depth,omitempty" jsonschema:"Shallow clone depth"`
}

type GitCommitParams

type GitCommitParams struct {
	RepoPath    string `json:"repo_path" jsonschema:"Repository path relative to workspace"`
	Message     string `json:"message" jsonschema:"The commit message"`
	AuthorName  string `json:"author_name,omitempty" jsonschema:"Optional author name"`
	AuthorEmail string `json:"author_email,omitempty" jsonschema:"Optional author email"`
}

type GitInitParams

type GitInitParams struct {
	Path      string `json:"path" jsonschema:"Repository path relative to workspace root"`
	RemoteURL string `json:"remote_url,omitempty" jsonschema:"The gitopia URL to set as origin remote"`
}

type GitPushParams

type GitPushParams struct {
	RepoPath    string `json:"repo_path" jsonschema:"Repository path relative to workspace"`
	Remote      string `json:"remote,omitempty" jsonschema:"Remote name (default: origin)"`
	Branch      string `json:"branch,omitempty" jsonschema:"Branch to push"`
	Force       bool   `json:"force,omitempty" jsonschema:"Force push"`
	SetUpstream bool   `json:"set_upstream,omitempty" jsonschema:"Set upstream tracking"`
	DryRun      bool   `json:"dry_run,omitempty" jsonschema:"Dry run"`
}

type GitStatusParams

type GitStatusParams struct {
	RepoPath string `json:"repo_path" jsonschema:"Repository path relative to workspace"`
}

type ListBountiesParams

type ListBountiesParams struct {
	Limit uint64 `json:"limit,omitempty" jsonschema:"Maximum number of bounties to return (default 50)"`
}

type ListBranchesParams

type ListBranchesParams struct {
	Owner string `json:"owner"`
	Name  string `json:"name"`
}

type ListCommitsParams

type ListCommitsParams struct {
	Owner  string `json:"owner" jsonschema:"Repository owner (username or DAO name)"`
	Name   string `json:"name" jsonschema:"Repository name"`
	Branch string `json:"branch,omitempty" jsonschema:"Branch name (defaults to repo's default branch)"`
	Limit  int    `json:"limit,omitempty" jsonschema:"Maximum number of commits to return (default 50)"`
}

type ListDaoMembersParams

type ListDaoMembersParams struct {
	DAO     string `json:"dao,omitempty" jsonschema:"DAO name or address (alternative to group_id)"`
	GroupID uint64 `json:"group_id,omitempty" jsonschema:"The cosmos group ID of the DAO"`
	Limit   uint64 `json:"limit,omitempty" jsonschema:"Maximum number of members to return (default 100)"`
}

type ListDaoProposalsParams

type ListDaoProposalsParams struct {
	DAO                string `json:"dao,omitempty" jsonschema:"DAO name or address (alternative to group_policy_address)"`
	GroupPolicyAddress string `json:"group_policy_address,omitempty" jsonschema:"The group policy account address"`
	Limit              uint64 `json:"limit,omitempty" jsonschema:"Maximum number of proposals to return (default 50)"`
}

type ListIssuesParams

type ListIssuesParams struct {
	Owner string `json:"owner"`
	Name  string `json:"name"`
}

type ListLabelsParams

type ListLabelsParams struct {
	Owner string `json:"owner" jsonschema:"Repository owner (username or DAO name)"`
	Name  string `json:"name" jsonschema:"Repository name"`
}

type ListPullRequestsParams

type ListPullRequestsParams struct {
	Owner string `json:"owner"`
	Name  string `json:"name"`
	Limit uint64 `json:"limit,omitempty"`
}

type ListReleasesParams

type ListReleasesParams struct {
	Owner string `json:"owner" jsonschema:"Repository owner (username or DAO name)"`
	Name  string `json:"name" jsonschema:"Repository name"`
	Limit uint64 `json:"limit,omitempty" jsonschema:"Maximum number of releases to return (default 50)"`
}

type ListReposParams

type ListReposParams struct {
	Owner string `json:"owner" jsonschema:"Gitopia account name"`
}

type ListTagsParams

type ListTagsParams struct {
	Owner string `json:"owner" jsonschema:"Repository owner (username or DAO name)"`
	Name  string `json:"name" jsonschema:"Repository name"`
	Limit uint64 `json:"limit,omitempty" jsonschema:"Maximum number of tags to return (default 100)"`
}

type MergePullRequestParams

type MergePullRequestParams struct {
	Owner    string `json:"owner" jsonschema:"Repository owner (username or DAO name)"`
	Name     string `json:"name" jsonschema:"Repository name"`
	PullIid  uint64 `json:"pull_iid" jsonschema:"Pull request number (IID)"`
	Provider string `` /* 127-byte string literal not displayed */
}

type PendingTx

type PendingTx struct {
	ID            string    `json:"id"`
	ToolName      string    `json:"tool_name"`
	Detail        string    `json:"detail"`
	WalletAddress string    `json:"wallet_address"`
	SessionID     string    `json:"session_id"`
	CreatedAt     time.Time `json:"created_at"`
	ExpiresAt     time.Time `json:"expires_at"`
	// contains filtered or unexported fields
}

PendingTx represents a chain transaction awaiting user confirmation.

type PendingTxStore

type PendingTxStore struct {
	// contains filtered or unexported fields
}

PendingTxStore is a thread-safe store for pending transactions.

func NewPendingTxStore

func NewPendingTxStore(ttl time.Duration) *PendingTxStore

NewPendingTxStore creates a new store with the given TTL.

func (*PendingTxStore) Add

func (s *PendingTxStore) Add(tx *PendingTx) string

Add stores a pending transaction and returns its ID.

func (*PendingTxStore) Cleanup

func (s *PendingTxStore) Cleanup()

Cleanup removes all expired transactions.

func (*PendingTxStore) Get

func (s *PendingTxStore) Get(id string) *PendingTx

Get returns a pending transaction by ID, or nil if missing or expired.

func (*PendingTxStore) ListForSession

func (s *PendingTxStore) ListForSession(sessionID string) []*PendingTx

ListForSession returns all non-expired pending transactions for a session.

func (*PendingTxStore) Remove

func (s *PendingTxStore) Remove(id string)

Remove deletes a pending transaction by ID.

type PromptHandler

type PromptHandler struct{}

PromptHandler holds dependencies for MCP prompt handlers.

func (*PromptHandler) FixIssuePrompt

func (ph *PromptHandler) FixIssuePrompt(_ context.Context, req *mcp.GetPromptRequest) (*mcp.GetPromptResult, error)

FixIssuePrompt returns a multi-step workflow to fix an issue.

func (*PromptHandler) HuntBountyPrompt

func (ph *PromptHandler) HuntBountyPrompt(_ context.Context, req *mcp.GetPromptRequest) (*mcp.GetPromptResult, error)

HuntBountyPrompt returns a multi-step workflow to find and work on bounties.

func (*PromptHandler) ReviewPRPrompt

func (ph *PromptHandler) ReviewPRPrompt(_ context.Context, req *mcp.GetPromptRequest) (*mcp.GetPromptResult, error)

ReviewPRPrompt returns a multi-step workflow to review a pull request.

type RateLimiter

type RateLimiter struct {
	// contains filtered or unexported fields
}

RateLimiter implements a sliding-window rate limiter for chain transactions.

func NewRateLimiter

func NewRateLimiter(perMinute, perHour int) *RateLimiter

NewRateLimiter creates a new RateLimiter with the given per-minute and per-hour limits.

func (*RateLimiter) Allow

func (r *RateLimiter) Allow() error

Allow checks if a new request is allowed. If allowed, it records the request and returns nil. Otherwise it returns an error describing the limit hit.

type ReadFileParams

type ReadFileParams struct {
	Path string `json:"path" jsonschema:"File path relative to workspace root (e.g. 'myrepo/src/main.go')"`
}

type RejectTransactionParams

type RejectTransactionParams struct {
	PendingID string `json:"pending_id" jsonschema:"The ID of the pending transaction to reject"`
}

type ResourceHandler

type ResourceHandler struct {
	GClient *gitopia.Client
}

ResourceHandler holds dependencies for MCP resource handlers.

func (*ResourceHandler) HandleBountyResource

func (rh *ResourceHandler) HandleBountyResource(_ context.Context, req *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error)

HandleBountyResource reads a bounty resource by URI.

func (*ResourceHandler) HandleIssueResource

func (rh *ResourceHandler) HandleIssueResource(_ context.Context, req *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error)

HandleIssueResource reads an issue resource by URI.

func (*ResourceHandler) HandlePullRequestResource

func (rh *ResourceHandler) HandlePullRequestResource(_ context.Context, req *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error)

HandlePullRequestResource reads a pull request resource by URI.

func (*ResourceHandler) HandleRepoResource

func (rh *ResourceHandler) HandleRepoResource(_ context.Context, req *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error)

HandleRepoResource reads a repository resource by URI.

type SearchCodeParams

type SearchCodeParams struct {
	RepoPath      string `json:"repo_path" jsonschema:"Repository path relative to workspace"`
	Query         string `json:"query" jsonschema:"Search query string or regex pattern"`
	CaseSensitive bool   `json:"case_sensitive,omitempty" jsonschema:"Whether search should be case-sensitive"`
}

type SetActiveDAOParams

type SetActiveDAOParams struct {
	DaoName string `json:"dao_name,omitempty"` // Empty to use personal account
}

type SubmitDaoProposalParams

type SubmitDaoProposalParams struct {
	DAO                string `json:"dao,omitempty" jsonschema:"DAO name or address (alternative to group_policy_address)"`
	GroupPolicyAddress string `json:"group_policy_address,omitempty" jsonschema:"The group policy account address"`
	Title              string `json:"title" jsonschema:"Title of the proposal"`
	Summary            string `json:"summary,omitempty" jsonschema:"Summary of the proposal"`
	Metadata           string `json:"metadata,omitempty" jsonschema:"Arbitrary metadata for the proposal"`
	ExecTry            bool   `json:"exec_try,omitempty" jsonschema:"If true, try to execute immediately after submission"`
}

type SyncWithRemoteParams

type SyncWithRemoteParams struct {
	RepoPath string `json:"repo_path"`
	Branch   string `json:"branch,omitempty"`
	Remote   string `json:"remote,omitempty"`
	Strategy string `json:"strategy,omitempty"`
}

type ToggleRepositoryForkingParams

type ToggleRepositoryForkingParams struct {
	Owner string `json:"owner" jsonschema:"Repository owner (username or DAO name)"`
	Name  string `json:"name" jsonschema:"Repository name"`
}

type ToolHandler

type ToolHandler struct {
	GClient        *gitopia.Client
	GitClient      *git.Client
	AuthMgr        *git.AuthManager
	WorkspaceMgr   *workspace.Manager
	TrustLvl       TrustLevel
	ChainLimiter   *RateLimiter
	DryRunMode     bool
	ApprovalMode   bool
	PendingTxs     *PendingTxStore
	ActiveToolsets map[Toolset]bool
	// contains filtered or unexported fields
}

ToolHandler holds shared dependencies for all tool handlers. By making handlers methods on this struct, we can easily share state and dependencies like clients and managers without using globals.

func New

func New(g *gitopia.Client, git *git.Client, auth *git.AuthManager, ws *workspace.Manager) *ToolHandler

New creates a new ToolHandler.

func (*ToolHandler) BatchExecute

BatchExecute executes multiple operations in a single on-chain transaction.

func (*ToolHandler) BootstrapRepo

func (*ToolHandler) ClaimFeeGrant

ClaimFeeGrant claims a fee grant from the Gitopia faucet.

func (*ToolHandler) CloseBounty

func (*ToolHandler) CommentOnIssue

func (*ToolHandler) CommentOnPullRequest

func (h *ToolHandler) CommentOnPullRequest(
	ctx context.Context,
	req *mcp.CallToolRequest,
	p CommentOnPullRequestParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) CommitAndPushChanges

func (h *ToolHandler) CommitAndPushChanges(
	ctx context.Context,
	req *mcp.CallToolRequest,
	p CommitAndPushChangesParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) ConfirmTransaction

func (h *ToolHandler) ConfirmTransaction(
	ctx context.Context,
	req *mcp.CallToolRequest,
	p ConfirmTransactionParams,
) (*mcp.CallToolResult, any, error)

ConfirmTransaction broadcasts a previously held pending transaction.

func (*ToolHandler) CreateBounty

func (*ToolHandler) CreateDao

func (*ToolHandler) CreateFeatureBranch

func (h *ToolHandler) CreateFeatureBranch(
	ctx context.Context,
	req *mcp.CallToolRequest,
	p CreateFeatureBranchParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) CreateFeatureBranchPR

func (h *ToolHandler) CreateFeatureBranchPR(
	ctx context.Context,
	req *mcp.CallToolRequest,
	p CreateFeatureBranchPRParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) CreateIssue

func (*ToolHandler) CreateLabel

func (*ToolHandler) CreatePullRequest

func (h *ToolHandler) CreatePullRequest(
	ctx context.Context,
	req *mcp.CallToolRequest,
	p CreatePullRequestParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) CreateRelease

func (*ToolHandler) CreateRepository

func (h *ToolHandler) CreateRepository(
	ctx context.Context,
	req *mcp.CallToolRequest,
	p CreateRepoParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) CreateUser

CreateUser creates an on-chain Gitopia user for the current wallet.

func (*ToolHandler) DeleteBounty

func (*ToolHandler) DeleteLabel

func (*ToolHandler) ExecDaoProposal

func (*ToolHandler) ForkRepository

func (*ToolHandler) GetBounty

func (*ToolHandler) GetDao

func (h *ToolHandler) GetDao(
	ctx context.Context,
	req *mcp.CallToolRequest,
	params GetDaoParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) GetDaoProposal

func (*ToolHandler) GetFile

func (h *ToolHandler) GetFile(
	ctx context.Context,
	req *mcp.CallToolRequest,
	params GetFileParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) GetIssue

func (h *ToolHandler) GetIssue(
	ctx context.Context,
	req *mcp.CallToolRequest,
	params GetIssueParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) GetPullRequest

func (h *ToolHandler) GetPullRequest(
	ctx context.Context,
	req *mcp.CallToolRequest,
	params GetPullRequestParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) GetPullRequestDiff

func (h *ToolHandler) GetPullRequestDiff(
	ctx context.Context,
	req *mcp.CallToolRequest,
	params GetPullRequestDiffParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) GetRepo

func (h *ToolHandler) GetRepo(
	ctx context.Context,
	req *mcp.CallToolRequest,
	params GetRepoParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) GetUserContext

func (h *ToolHandler) GetUserContext(
	ctx context.Context,
	req *mcp.CallToolRequest,
	_ struct{},
) (*mcp.CallToolResult, any, error)

GetUserContext returns the current user context information

func (*ToolHandler) GitAdd

func (*ToolHandler) GitClone

func (*ToolHandler) GitCommit

func (*ToolHandler) GitInit

func (*ToolHandler) GitPush

func (*ToolHandler) GitStatus

func (*ToolHandler) ListBounties

func (*ToolHandler) ListBranches

func (h *ToolHandler) ListBranches(
	ctx context.Context,
	req *mcp.CallToolRequest,
	params ListBranchesParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) ListCommits

func (h *ToolHandler) ListCommits(
	ctx context.Context,
	req *mcp.CallToolRequest,
	params ListCommitsParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) ListDaoMembers

func (*ToolHandler) ListDaoProposals

func (h *ToolHandler) ListDaoProposals(
	ctx context.Context,
	req *mcp.CallToolRequest,
	p ListDaoProposalsParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) ListIssues

func (h *ToolHandler) ListIssues(
	ctx context.Context,
	req *mcp.CallToolRequest,
	params ListIssuesParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) ListLabels

func (h *ToolHandler) ListLabels(
	ctx context.Context,
	req *mcp.CallToolRequest,
	params ListLabelsParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) ListPendingTransactions

func (h *ToolHandler) ListPendingTransactions(
	ctx context.Context,
	req *mcp.CallToolRequest,
	_ struct{},
) (*mcp.CallToolResult, any, error)

ListPendingTransactions lists all non-expired pending transactions for the current session.

func (*ToolHandler) ListPullRequests

func (h *ToolHandler) ListPullRequests(
	ctx context.Context,
	req *mcp.CallToolRequest,
	p ListPullRequestsParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) ListReleases

func (h *ToolHandler) ListReleases(
	ctx context.Context,
	req *mcp.CallToolRequest,
	params ListReleasesParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) ListRepos

func (h *ToolHandler) ListRepos(
	ctx context.Context,
	req *mcp.CallToolRequest,
	params ListReposParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) ListTags

func (h *ToolHandler) ListTags(
	ctx context.Context,
	req *mcp.CallToolRequest,
	params ListTagsParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) MergePullRequest

func (h *ToolHandler) MergePullRequest(
	ctx context.Context,
	req *mcp.CallToolRequest,
	p MergePullRequestParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) ReadFile

func (*ToolHandler) RefreshUserContext

func (h *ToolHandler) RefreshUserContext(
	ctx context.Context,
	req *mcp.CallToolRequest,
	_ struct{},
) (*mcp.CallToolResult, any, error)

RefreshUserContext refreshes the user context from Gitopia

func (*ToolHandler) RejectTransaction

func (h *ToolHandler) RejectTransaction(
	ctx context.Context,
	req *mcp.CallToolRequest,
	p RejectTransactionParams,
) (*mcp.CallToolResult, any, error)

RejectTransaction cancels a previously held pending transaction.

func (*ToolHandler) ResolvePath

func (h *ToolHandler) ResolvePath(relativePath string) (string, error)

ResolvePath resolves a relative path to an absolute workspace path

func (*ToolHandler) SearchCode

func (*ToolHandler) SetActiveDAO

SetActiveDAO sets the active DAO for operations

func (*ToolHandler) SubmitDaoProposal

func (h *ToolHandler) SubmitDaoProposal(
	ctx context.Context,
	req *mcp.CallToolRequest,
	p SubmitDaoProposalParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) SyncWithRemote

func (*ToolHandler) ToggleRepositoryForking

func (h *ToolHandler) ToggleRepositoryForking(
	ctx context.Context,
	req *mcp.CallToolRequest,
	p ToggleRepositoryForkingParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) UpdateBounty

func (*ToolHandler) UpdateDaoMembers

func (h *ToolHandler) UpdateDaoMembers(
	ctx context.Context,
	req *mcp.CallToolRequest,
	p UpdateDaoMembersParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) UpdateFeatureBranch

func (h *ToolHandler) UpdateFeatureBranch(
	ctx context.Context,
	req *mcp.CallToolRequest,
	p UpdateFeatureBranchParams,
) (*mcp.CallToolResult, any, error)

func (*ToolHandler) UpdateIssue

func (*ToolHandler) VoteDaoProposal

func (*ToolHandler) WriteFile

type Toolset

type Toolset string

Toolset groups tools by functional area. Tools in the "core" set are always registered. Other sets can be enabled via TOOLSETS env var.

const (
	ToolsetCore     Toolset = "core"
	ToolsetWorkflow Toolset = "workflow"
)

type TrustLevel

type TrustLevel int

TrustLevel represents the permission tier for tool access.

const (
	TrustReadOnly   TrustLevel = 1
	TrustLocalWrite TrustLevel = 2
	TrustChainWrite TrustLevel = 3
)

func ParseTrustLevel

func ParseTrustLevel(s string) TrustLevel

ParseTrustLevel converts a string to a TrustLevel. Defaults to TrustChainWrite for backward compatibility.

func (TrustLevel) String

func (t TrustLevel) String() string

String returns the human-readable name of the trust level.

type UpdateBountyParams

type UpdateBountyParams struct {
	BountyID uint64 `json:"bounty_id"`
	Expiry   int64  `json:"expiry,omitempty"`
}

type UpdateDaoMembersParams

type UpdateDaoMembersParams struct {
	DAO           string `json:"dao,omitempty" jsonschema:"DAO name or address (alternative to group_id)"`
	GroupID       uint64 `json:"group_id,omitempty" jsonschema:"The cosmos group ID of the DAO"`
	MemberUpdates []struct {
		Address  string `json:"address"`
		Weight   string `json:"weight"`
		Metadata string `json:"metadata,omitempty"`
	} `json:"member_updates" jsonschema:"List of member updates. Set weight to 0 to remove a member."`
}

type UpdateFeatureBranchParams

type UpdateFeatureBranchParams struct {
	RepoPath      string          `json:"repo_path" jsonschema:"Repository path relative to workspace (e.g. 'myrepo')"`
	BranchName    string          `json:"branch_name"`
	Files         []fs.FileChange `json:"files"`
	CommitMessage string          `json:"commit_message"`
}

type UpdateIssueParams

type UpdateIssueParams struct {
	Owner           string   `json:"owner" jsonschema:"Repository owner (username or DAO name)"`
	Name            string   `json:"name" jsonschema:"Repository name"`
	IssueIid        uint64   `json:"issue_iid" jsonschema:"Issue number (IID)"`
	ToggleState     bool     `json:"toggle_state,omitempty" jsonschema:"Toggle issue open/closed state"`
	StateComment    string   `json:"state_comment,omitempty" jsonschema:"Comment to add when toggling state"`
	AddLabels       []uint64 `json:"add_labels,omitempty" jsonschema:"Label IDs to add"`
	RemoveLabels    []uint64 `json:"remove_labels,omitempty" jsonschema:"Label IDs to remove"`
	AddAssignees    []string `json:"add_assignees,omitempty" jsonschema:"Usernames to assign"`
	RemoveAssignees []string `json:"remove_assignees,omitempty" jsonschema:"Usernames to unassign"`
}

type VoteDaoProposalParams

type VoteDaoProposalParams struct {
	ProposalID uint64 `json:"proposal_id" jsonschema:"The unique ID of the proposal to vote on"`
	Option     string `json:"option" jsonschema:"Vote option: yes, no, abstain, or no_with_veto"`
	Metadata   string `json:"metadata,omitempty" jsonschema:"Arbitrary metadata for the vote"`
	ExecTry    bool   `json:"exec_try,omitempty" jsonschema:"If true, try to execute proposal after voting"`
}

type WriteFileParams

type WriteFileParams struct {
	Path    string `json:"path" jsonschema:"File path relative to workspace root (e.g. 'myrepo/src/main.go')"`
	Content string `json:"content" jsonschema:"The content to write to the file."`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL