Documentation
¶
Index ¶
- Constants
- func BranchExists(directory, branch string) (bool, error)
- func FormatCommentCreateSuccess(comment *remote.Comment) string
- func FormatCommentDetails(comment *remote.Comment) string
- func FormatCommentEditSuccess(comment *remote.Comment) string
- func FormatCommentList(comments []remote.Comment) string
- func FormatIssueCreateSuccess(issue *remote.Issue) string
- func FormatIssueDetails(issue *remote.Issue) string
- func FormatIssueEditSuccess(issue *remote.Issue) string
- func FormatIssueList(issues []remote.Issue) string
- func FormatPullRequestCreateSuccess(pr *remote.PullRequest) string
- func FormatPullRequestDetails(pr *remote.PullRequestDetails) string
- func FormatPullRequestEditSuccess(pr *remote.PullRequest) string
- func FormatPullRequestList(pullRequests []remote.PullRequest) string
- func GetCommitCount(directory, base, head string) (int, error)
- func GetCurrentBranch(directory string) (string, error)
- func HasConflicts(directory, base, head string) (bool, []string, error)
- func IsBranchBehind(directory, base, head string) (bool, error)
- func LoadPRTemplate(ctx context.Context, client remote.FileContentFetcher, ...) (string, error)
- func MergeTemplateContent(template, userContent string) string
- func NewDirectoryNotFoundError(path string) error
- func NewInvalidRemoteURLError(url string) error
- func NewNoRemotesConfiguredError(path string) error
- func NewNotGitRepositoryError(path, reason string) error
- func TextError(msg string) *mcp.CallToolResult
- func TextErrorf(format string, args ...any) *mcp.CallToolResult
- func TextResult(msg string) *mcp.CallToolResult
- func TextResultf(format string, args ...any) *mcp.CallToolResult
- func ValidateAttachment(data []byte, filename string, maxSize int64, allowedTypes []string) error
- type CommentEditResult
- type CommentListResult
- type CommentResult
- type ConflictDetail
- type ConflictReport
- type DirectoryNotFoundError
- type ForkInfo
- type HelloArgs
- type HelloResult
- type InvalidRemoteURLError
- type IssueCommentArgs
- type IssueCommentEditArgs
- type IssueCommentListArgs
- type IssueCreateArgs
- type IssueCreateResult
- type IssueEditArgs
- type IssueEditResult
- type IssueList
- type IssueListArgs
- type NoRemotesConfiguredError
- type NotGitRepositoryError
- type PullRequestCommentCreateArgs
- type PullRequestCommentCreateResult
- type PullRequestCommentEditArgs
- type PullRequestCommentEditResult
- type PullRequestCommentList
- type PullRequestCommentListArgs
- type PullRequestCreateArgs
- type PullRequestCreateResult
- type PullRequestEditArgs
- type PullRequestEditResult
- type PullRequestFetchArgs
- type PullRequestFetchResult
- type PullRequestList
- type PullRequestListArgs
- type RepositoryError
- type RepositoryResolution
- type RepositoryResolver
- func (r *RepositoryResolver) DetectForkRelationship(remotes map[string]string, targetRepo string) (*ForkInfo, error)
- func (r *RepositoryResolver) ExtractAllRemotes(directory string) (map[string]string, error)
- func (r *RepositoryResolver) ExtractRemoteInfo(directory string) (string, error)
- func (r *RepositoryResolver) ResolveRepository(directory string) (*RepositoryResolution, error)
- func (r *RepositoryResolver) ResolveWithForkInfo(directory string) (*RepositoryResolution, *ForkInfo, error)
- func (r *RepositoryResolver) ValidateDirectory(directory string) error
- type Server
- func New() (*Server, error)
- func NewFromConfig(cfg *config.Config) (*Server, error)
- func NewFromConfigWithDebug(cfg *config.Config, debug bool) (*Server, error)
- func NewFromConfigWithDebugAndCompat(cfg *config.Config, debug, compat bool) (*Server, error)
- func NewFromService(service remote.ClientInterface, cfg *config.Config) (*Server, error)
- func NewFromServiceWithDebug(service remote.ClientInterface, cfg *config.Config, debug bool) (*Server, error)
- func NewFromServiceWithDebugAndCompat(service remote.ClientInterface, cfg *config.Config, debug, compat bool) (*Server, error)
- func NewWithDebug(debug bool) (*Server, error)
- func NewWithDebugAndCompat(debug, compat bool) (*Server, error)
Constants ¶
const GitCommandTimeout = 30 * time.Second
GitCommandTimeout is the timeout for git command execution
Variables ¶
This section is empty.
Functions ¶
func BranchExists ¶
BranchExists checks if a branch exists locally
func FormatCommentCreateSuccess ¶ added in v0.2.0
FormatCommentCreateSuccess creates success message for comment creation
func FormatCommentDetails ¶ added in v0.2.0
FormatCommentDetails creates detailed comment information
func FormatCommentEditSuccess ¶ added in v0.2.0
FormatCommentEditSuccess creates success message for comment editing
func FormatCommentList ¶ added in v0.2.0
FormatCommentList creates a human-readable summary of comments
func FormatIssueCreateSuccess ¶ added in v0.2.0
FormatIssueCreateSuccess creates success message for issue creation
func FormatIssueDetails ¶ added in v0.2.0
FormatIssueDetails creates detailed issue information
func FormatIssueEditSuccess ¶ added in v0.2.0
FormatIssueEditSuccess creates success message for issue editing
func FormatIssueList ¶ added in v0.2.0
FormatIssueList creates a human-readable summary of issues
func FormatPullRequestCreateSuccess ¶ added in v0.2.0
func FormatPullRequestCreateSuccess(pr *remote.PullRequest) string
FormatPullRequestCreateSuccess creates success message for PR creation
func FormatPullRequestDetails ¶ added in v0.2.0
func FormatPullRequestDetails(pr *remote.PullRequestDetails) string
FormatPullRequestDetails creates detailed PR information
func FormatPullRequestEditSuccess ¶ added in v0.2.0
func FormatPullRequestEditSuccess(pr *remote.PullRequest) string
FormatPullRequestEditSuccess creates success message for PR editing
func FormatPullRequestList ¶ added in v0.2.0
func FormatPullRequestList(pullRequests []remote.PullRequest) string
FormatPullRequestList creates a human-readable summary of pull requests
func GetCommitCount ¶
GetCommitCount returns number of commits between base and head
func GetCurrentBranch ¶
GetCurrentBranch returns the current git branch name
func HasConflicts ¶
HasConflicts detects if merging base into head would cause conflicts
func IsBranchBehind ¶
IsBranchBehind checks if head branch is behind base branch
func LoadPRTemplate ¶
func LoadPRTemplate(ctx context.Context, client remote.FileContentFetcher, owner, repo, branch string) (string, error)
LoadPRTemplate attempts to load PR template from repository
func MergeTemplateContent ¶
MergeTemplateContent merges template with user-provided content
func TextError ¶
func TextError(msg string) *mcp.CallToolResult
func TextErrorf ¶
func TextErrorf(format string, args ...any) *mcp.CallToolResult
func TextResult ¶
func TextResult(msg string) *mcp.CallToolResult
func TextResultf ¶
func TextResultf(format string, args ...any) *mcp.CallToolResult
Types ¶
type CommentEditResult ¶
CommentEditResult represents the result data for the issue_comment_edit tool.
type CommentListResult ¶
type CommentListResult struct {
Comments []remote.Comment `json:"comments,omitempty"`
Total int `json:"total,omitempty"`
Limit int `json:"limit,omitzero"`
Offset int `json:"offset,omitzero"`
}
CommentListResult represents the result data for the list_issue_comments tool.
type CommentResult ¶
CommentResult represents the result data for the create_issue_comment tool.
type ConflictDetail ¶
type ConflictDetail struct {
File string `json:"file"` // Path to the conflicting file
Type string `json:"type"` // Type of conflict: "content", "add_add", "delete_modify"
Lines []int `json:"lines"` // Line numbers where conflicts occur (if available)
Markers []string `json:"markers"` // Conflict markers found
Severity string `json:"severity"` // "low", "medium", "high" based on conflict complexity
}
ConflictDetail represents detailed information about a conflict
type ConflictReport ¶
type ConflictReport struct {
HasConflicts bool `json:"has_conflicts"`
ConflictFiles []string `json:"conflict_files"` // Simple list of conflicting files
ConflictDetails []ConflictDetail `json:"conflict_details"` // Detailed conflict information
TotalConflicts int `json:"total_conflicts"` // Total number of conflict regions
SuggestedActions []string `json:"suggested_actions"` // Suggested resolution steps
}
ConflictReport represents a comprehensive conflict analysis
func GetConflictReport ¶
func GetConflictReport(directory, base, head string) (*ConflictReport, error)
GetConflictReport provides detailed conflict analysis
type DirectoryNotFoundError ¶
type DirectoryNotFoundError struct {
RepositoryError
}
DirectoryNotFoundError indicates that a directory does not exist
func (*DirectoryNotFoundError) Is ¶
func (e *DirectoryNotFoundError) Is(target error) bool
type ForkInfo ¶
type ForkInfo struct {
IsFork bool `json:"is_fork"`
ForkOwner string `json:"fork_owner,omitempty"`
OriginalOwner string `json:"original_owner,omitempty"`
ForkRemote string `json:"fork_remote,omitempty"`
}
ForkInfo contains information about fork relationships
type HelloArgs ¶ added in v0.1.2
type HelloArgs struct {
}
HelloArgs represents the arguments for the hello tool
type HelloResult ¶ added in v0.1.2
type HelloResult struct {
Message string `json:"message,omitempty"`
}
HelloResult represents the result data for the hello tool
type InvalidRemoteURLError ¶
type InvalidRemoteURLError struct {
RepositoryError
URL string
}
InvalidRemoteURLError indicates that a remote URL cannot be parsed
func (*InvalidRemoteURLError) Error ¶
func (e *InvalidRemoteURLError) Error() string
func (*InvalidRemoteURLError) Is ¶
func (e *InvalidRemoteURLError) Is(target error) bool
type IssueCommentArgs ¶
type IssueCommentArgs struct {
Repository string `json:"repository,omitzero"` // Repository path in "owner/repo" format
Directory string `json:"directory,omitzero"` // Local directory path containing a git repository for automatic resolution
IssueNumber int `json:"issue_number"`
Comment string `json:"comment"`
}
type IssueCommentEditArgs ¶
type IssueCommentEditArgs struct {
Repository string `json:"repository,omitzero"` // Repository path in "owner/repo" format
Directory string `json:"directory,omitzero"` // Local directory path containing a git repository for automatic resolution
IssueNumber int `json:"issue_number"`
CommentID int `json:"comment_id"`
NewContent string `json:"new_content"`
}
type IssueCommentListArgs ¶
type IssueCommentListArgs struct {
Repository string `json:"repository,omitzero"` // Repository path in "owner/repo" format
Directory string `json:"directory,omitzero"` // Local directory path containing a git repository for automatic resolution
IssueNumber int `json:"issue_number"`
Limit int `json:"limit,omitzero"`
Offset int `json:"offset,omitzero"`
}
type IssueCreateArgs ¶
type IssueCreateResult ¶
type IssueEditArgs ¶
type IssueEditArgs struct {
Repository string `json:"repository,omitzero"` // Repository path in "owner/repo" format
Directory string `json:"directory,omitzero"` // Local directory path containing a git repository for automatic resolution
IssueNumber int `json:"issue_number" validate:"required,min=1"`
Title string `json:"title,omitzero"` // New title for the issue
Body string `json:"body,omitzero"` // New description/body for the issue
State string `json:"state,omitzero"` // New state ("open" or "closed")
}
IssueEditArgs represents the arguments for editing an issue with validation tags
type IssueEditResult ¶
IssueEditResult represents the result data for the issue_edit tool
type IssueList ¶
IssueList represents a collection of repository issues. This struct is used as the result data for the list_issues tool.
type IssueListArgs ¶
type IssueListArgs struct {
Repository string `json:"repository,omitzero"` // Repository path in "owner/repo" format
Directory string `json:"directory,omitzero"` // Local directory path containing a git repository for automatic resolution
Limit int `json:"limit,omitzero"`
Offset int `json:"offset,omitzero"`
}
type NoRemotesConfiguredError ¶
type NoRemotesConfiguredError struct {
RepositoryError
}
NoRemotesConfiguredError indicates that no git remotes are configured
func (*NoRemotesConfiguredError) Is ¶
func (e *NoRemotesConfiguredError) Is(target error) bool
type NotGitRepositoryError ¶
type NotGitRepositoryError struct {
RepositoryError
Reason string
}
NotGitRepositoryError indicates that a directory is not a git repository
func (*NotGitRepositoryError) Error ¶
func (e *NotGitRepositoryError) Error() string
func (*NotGitRepositoryError) Is ¶
func (e *NotGitRepositoryError) Is(target error) bool
type PullRequestCommentCreateArgs ¶
type PullRequestCommentCreateArgs struct {
Repository string `json:"repository,omitzero"` // Repository path in "owner/repo" format
Directory string `json:"directory,omitzero"` // Local directory path containing a git repository for automatic resolution
PullRequestNumber int `json:"pull_request_number" validate:"required,min=1"`
Comment string `json:"comment" validate:"required,min=1"`
}
PullRequestCommentCreateArgs represents the arguments for creating a pull request comment with validation tags
type PullRequestCommentCreateResult ¶
PullRequestCommentCreateResult represents the result data for the pr_comment_create tool
type PullRequestCommentEditArgs ¶
type PullRequestCommentEditArgs struct {
Repository string `json:"repository,omitzero"` // Repository path in "owner/repo" format
Directory string `json:"directory,omitzero"` // Local directory path containing a git repository for automatic resolution
PullRequestNumber int `json:"pull_request_number" validate:"required,min=1"`
CommentID int `json:"comment_id" validate:"required,min=1"`
NewContent string `json:"new_content" validate:"required,min=1"`
}
PullRequestCommentEditArgs represents the arguments for editing a pull request comment with validation tags
type PullRequestCommentEditResult ¶
PullRequestCommentEditResult represents the result data for the pr_comment_edit tool
type PullRequestCommentList ¶
type PullRequestCommentList struct {
PullRequestComments []remote.Comment `json:"pull_request_comments,omitempty"`
}
PullRequestCommentList represents a collection of pull request comments. This struct is used as the result data for the pr_comment_list tool.
type PullRequestCommentListArgs ¶
type PullRequestCommentListArgs struct {
Repository string `json:"repository,omitzero"` // Repository path in "owner/repo" format
Directory string `json:"directory,omitzero"` // Local directory path containing a git repository for automatic resolution
PullRequestNumber int `json:"pull_request_number" validate:"required,min=1"`
Limit int `json:"limit,omitzero" validate:"min=1,max=100"`
Offset int `json:"offset,omitzero" validate:"min=0"`
}
PullRequestCommentListArgs represents the arguments for listing pull request comments with validation tags
type PullRequestCreateArgs ¶
type PullRequestCreateArgs struct {
Repository string `json:"repository,omitzero"` // Repository path in "owner/repo" format
Directory string `json:"directory,omitzero"` // Local directory path containing a git repository for automatic resolution
Head string `json:"head,omitzero"` // Source branch (auto-detected if not provided)
Base string `json:"base,omitzero"` // Target branch (default if not provided)
Title string `json:"title" validate:"required"` // PR title
Body string `json:"body,omitzero"` // PR description
Draft bool `json:"draft,omitzero"` // Create as draft PR
Assignee string `json:"assignee,omitzero"` // Single reviewer
}
PullRequestCreateArgs represents the arguments for creating a pull request with validation tags
type PullRequestCreateResult ¶
type PullRequestCreateResult struct {
PullRequest *remote.PullRequest `json:"pull_request,omitempty"`
}
PullRequestCreateResult represents the result data for the pr_create tool
type PullRequestEditArgs ¶
type PullRequestEditArgs struct {
Repository string `json:"repository,omitzero"` // Repository path in "owner/repo" format
Directory string `json:"directory,omitzero"` // Local directory path containing a git repository for automatic resolution
PullRequestNumber int `json:"pull_request_number" validate:"required,min=1"`
Title string `json:"title,omitzero"` // New title for the pull request
Body string `json:"body,omitzero"` // New description/body for the pull request
State string `json:"state,omitzero"` // New state ("open" or "closed")
BaseBranch string `json:"base_branch,omitzero"` // New base branch for the pull request
}
PullRequestEditArgs represents the arguments for editing a pull request with validation tags
type PullRequestEditResult ¶
type PullRequestEditResult struct {
PullRequest *remote.PullRequest `json:"pull_request,omitempty"`
}
PullRequestEditResult represents the result data for the pr_edit tool
type PullRequestFetchArgs ¶ added in v0.1.1
type PullRequestFetchArgs struct {
Repository string `json:"repository,omitzero"` // Repository path in "owner/repo" format
Directory string `json:"directory,omitzero"` // Local directory path for automatic resolution
PullRequestNumber int `json:"pull_request_number" validate:"required,min=1"`
}
PullRequestFetchArgs represents the arguments for fetching a pull request
type PullRequestFetchResult ¶ added in v0.1.1
type PullRequestFetchResult struct {
PullRequest *remote.PullRequestDetails `json:"pull_request,omitempty"`
}
PullRequestFetchResult represents the result data for the pr_fetch tool
type PullRequestList ¶
type PullRequestList struct {
PullRequests []remote.PullRequest `json:"pull_requests,omitempty"`
}
PullRequestList represents a collection of repository pull requests. This struct is used as the result data for the pr_list tool.
type PullRequestListArgs ¶
type PullRequestListArgs struct {
Repository string `json:"repository,omitzero"` // Repository path in "owner/repo" format
Directory string `json:"directory,omitzero"` // Local directory path containing a git repository for automatic resolution
Limit int `json:"limit,omitzero"`
Offset int `json:"offset,omitzero"`
State string `json:"state"`
}
PullRequestListArgs represents the arguments for listing pull requests with validation tags
type RepositoryError ¶
type RepositoryError struct {
Op string // Operation that failed
Path string // Path involved in the error
Err error // Underlying error
}
RepositoryError represents a base error type for repository resolution operations
func (*RepositoryError) Error ¶
func (e *RepositoryError) Error() string
func (*RepositoryError) Unwrap ¶
func (e *RepositoryError) Unwrap() error
type RepositoryResolution ¶
type RepositoryResolution struct {
Directory string `json:"directory,omitzero"` // The original directory path
Repository string `json:"repository,omitzero"` // The resolved repository in "owner/repo" format
RemoteURL string `json:"remote_url"` // The full remote URL
RemoteName string `json:"remote_name"` // The name of the remote (e.g., "origin", "upstream")
}
RepositoryResolution represents the result of resolving a directory to repository information
type RepositoryResolver ¶
type RepositoryResolver struct {
}
RepositoryResolver handles directory-to-repository resolution
func NewRepositoryResolver ¶
func NewRepositoryResolver() *RepositoryResolver
NewRepositoryResolver creates a new RepositoryResolver instance
func (*RepositoryResolver) DetectForkRelationship ¶
func (r *RepositoryResolver) DetectForkRelationship(remotes map[string]string, targetRepo string) (*ForkInfo, error)
DetectForkRelationship analyzes remotes to detect fork relationships
func (*RepositoryResolver) ExtractAllRemotes ¶
func (r *RepositoryResolver) ExtractAllRemotes(directory string) (map[string]string, error)
ExtractAllRemotes extracts all remote configurations from git config
func (*RepositoryResolver) ExtractRemoteInfo ¶
func (r *RepositoryResolver) ExtractRemoteInfo(directory string) (string, error)
ExtractRemoteInfo extracts repository information from git remote configuration
func (*RepositoryResolver) ResolveRepository ¶
func (r *RepositoryResolver) ResolveRepository(directory string) (*RepositoryResolution, error)
ResolveRepository performs the complete directory to repository resolution
func (*RepositoryResolver) ResolveWithForkInfo ¶
func (r *RepositoryResolver) ResolveWithForkInfo(directory string) (*RepositoryResolution, *ForkInfo, error)
ResolveWithForkInfo performs repository resolution with fork detection
func (*RepositoryResolver) ValidateDirectory ¶
func (r *RepositoryResolver) ValidateDirectory(directory string) error
ValidateDirectory validates that the directory exists and is a git repository
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the MCP server instance using the official MCP SDK. This server provides tools for interacting with Forgejo/Gitea repositories through the Model Context Protocol.
Migration Note: Updated from mark3labs/mcp-go to github.com/modelcontextprotocol/go-sdk/mcp v0.4.0 for official protocol compliance and long-term stability.
func New ¶
New creates a new MCP server instance with default configuration. It initializes the server with the official MCP SDK and registers all available tools.
Migration Note: Constructor updated to use the official MCP SDK's server initialization pattern instead of the third-party library's approach.
func NewFromConfig ¶
NewFromConfig creates a new MCP server instance with the provided configuration. This allows for custom server setup while maintaining the official SDK integration.
Migration Note: Tool registration updated to use mcp.AddTool() instead of the previous SDK's tool registration methods.
func NewFromConfigWithDebug ¶
NewFromConfigWithDebug creates a new MCP server instance with the provided configuration and debug mode. When debug is true, the hello tool will be registered for debugging purposes.
func NewFromConfigWithDebugAndCompat ¶ added in v0.2.0
NewFromConfigWithDebugAndCompat creates a new MCP server instance with the provided configuration, debug mode, and compatibility mode. When debug is true, the hello tool will be registered for debugging purposes. When compat is true, tools return detailed text responses alongside structured data.
func NewFromService ¶
NewFromService creates a new MCP server instance with the provided service. This allows for dependency injection, particularly useful for testing with mock services.
func NewFromServiceWithDebug ¶
func NewFromServiceWithDebug(service remote.ClientInterface, cfg *config.Config, debug bool) (*Server, error)
NewFromServiceWithDebug creates a new MCP server instance with the provided service and debug mode. When debug is true, the hello tool will be registered for debugging purposes.
func NewFromServiceWithDebugAndCompat ¶ added in v0.2.0
func NewFromServiceWithDebugAndCompat(service remote.ClientInterface, cfg *config.Config, debug, compat bool) (*Server, error)
NewFromServiceWithDebugAndCompat creates a new MCP server instance with the provided service, debug mode, and compatibility mode. When debug is true, the hello tool will be registered for debugging purposes. When compat is true, tools return detailed text responses alongside structured data.
func NewWithDebug ¶
NewWithDebug creates a new MCP server instance with debug mode support. When debug is true, the hello tool will be registered for debugging purposes.
func NewWithDebugAndCompat ¶ added in v0.2.0
NewWithDebugAndCompat creates a new MCP server instance with debug mode and compatibility mode support. When debug is true, the hello tool will be registered for debugging purposes. When compat is true, tools return detailed text responses alongside structured data.
func (*Server) Config ¶
Config returns the server configuration. This provides access to the configuration used by the server.
func (*Server) MCPServer ¶
MCPServer returns the underlying MCP server instance. This provides access to the official SDK server for advanced use cases.
Migration Note: Returns the official SDK's *mcp.Server instead of the previous third-party library's server type.
func (*Server) Start ¶
Start starts the MCP server using stdio transport. The server will listen for MCP protocol messages on stdin/stdout.
Migration Note: Updated to use the official SDK's Run method with StdioTransport instead of the previous SDK's server start pattern.
func (*Server) Stop ¶
Stop stops the MCP server gracefully. Note: For stdio transport, the server runs until the process ends, so this method primarily handles cleanup of resources.
Migration Note: The official SDK handles server lifecycle differently; stdio servers run until process termination rather than explicit stopping.