Implements 12 new MCP tools for full CRUD on issue and comment attachments via a new raw-HTTP helper, bypassing the SDK gap. New packages: - pkg/forgejo/rawhttp.go: DoJSON, DoJSONList, DoMultipart, DoRaw with 1 MiB inline cap (ErrPayloadTooLarge sentinel), auth-header propagation, and 401/403/404 error sentinels - operation/attachment/attachment.go: 12 tools registered under the new "attachment" CLI domain Key design decisions (see docs/plans/issue-attachments.md): - Files < 1 MiB: inline as BlobResourceContents + metadata JSON - Files >= 1 MiB: metadata + browser_download_url only; caller fetches with Authorization: token (verified live against Codeberg API) - Always includes browser_download_url regardless of size - 404 on list endpoints treated as empty array, not error Also: - operation/params/params.go: attachment param descriptions - operation/operation.go + cmd/cli.go: registration wired - README.md: tool table updated - demos/issue-attachments.md + demos/comment-attachments.md added
95 lines
3.3 KiB
Go
95 lines
3.3 KiB
Go
package params
|
|
|
|
// Shared parameter descriptions for MCP tools
|
|
// Following Anthropic's guideline: "be frugal with their use of tokens"
|
|
// Patterns follow official MCP server conventions (GitHub, MCP spec examples)
|
|
const (
|
|
// Common repository parameters
|
|
Owner = "Repository owner"
|
|
Repo = "Repository name"
|
|
|
|
// Issue/PR parameters
|
|
Index = "Issue/PR index"
|
|
IssueIndex = "Issue index"
|
|
PRIndex = "PR index"
|
|
CommentID = "Comment ID"
|
|
Body = "Content body"
|
|
Title = "Title"
|
|
State = "State"
|
|
Labels = "Label IDs"
|
|
Milestone = "Milestone ID"
|
|
|
|
// Branch parameters
|
|
Branch = "Branch name"
|
|
OldBranch = "Source branch"
|
|
Head = "Head branch"
|
|
Base = "Base branch"
|
|
|
|
// File parameters
|
|
FilePath = "File path"
|
|
Content = "Content (plain text, will be base64-encoded automatically)"
|
|
Message = "Commit message"
|
|
BranchName = "Branch name"
|
|
NewBranchName = "New branch name"
|
|
Ref = "Ref (branch/tag/commit)"
|
|
SHA = "SHA"
|
|
|
|
// Pagination parameters
|
|
Page = "Page number (1-based)"
|
|
Limit = "Page size"
|
|
|
|
// Time parameters
|
|
Since = "After time (RFC3339)"
|
|
Before = "Before time (RFC3339)"
|
|
|
|
// Sort/filter parameters
|
|
Sort = "Sort order"
|
|
Order = "Order direction"
|
|
Keyword = "Search keyword"
|
|
|
|
// User/org parameters
|
|
User = "Username"
|
|
Org = "Organization name"
|
|
|
|
// Wiki parameters
|
|
WikiTitle = "Wiki page title"
|
|
WikiContent = "Wiki page content"
|
|
WikiPage = "Wiki page name"
|
|
|
|
// Review parameters
|
|
ReviewID = "Review ID"
|
|
ReviewState = "Review state (APPROVED, REQUEST_CHANGES, COMMENT)"
|
|
ReviewBody = "Review body/message"
|
|
Reviewers = "Reviewer usernames (comma-separated)"
|
|
TeamReviewers = "Team reviewer names (comma-separated)"
|
|
DismissMessage = "Dismissal message"
|
|
ReviewComments = `Inline comments as JSON array, e.g. [{"path":"file.go","body":"Fix this","new_position":10}]`
|
|
|
|
// Actions parameters
|
|
Workflow = "Workflow file or ID (e.g. main.yml)"
|
|
Inputs = `Workflow inputs as JSON object (e.g. {"key": "value"})`
|
|
Event = "Filter by event type (e.g. push, pull_request, workflow_dispatch)"
|
|
RunNumber = "Filter by run number"
|
|
HeadSHA = "Filter by HEAD SHA"
|
|
RunID = "Run ID"
|
|
Status = "Filter by status (e.g. waiting, running, success, failure, cancelled)"
|
|
|
|
// Misc parameters
|
|
Description = "Description"
|
|
Private = "Private repo"
|
|
|
|
// Attachment parameters
|
|
AttachmentID = "Attachment ID"
|
|
AttachmentName = "New name for the attachment"
|
|
AttachmentContent = "Base64-encoded file bytes to upload"
|
|
AttachmentFilename = `Filename to associate with the uploaded attachment (e.g. "requirements.pdf")`
|
|
AttachmentMIME = "MIME type hint for uploaded file (optional; inferred from filename if omitted)"
|
|
|
|
// Time tracking parameters
|
|
TimeID = "Tracked time entry ID"
|
|
TimeSeconds = "Time in seconds to log (positive integer). Provide exactly one of seconds or duration."
|
|
TimeDuration = `Time as a duration string, e.g. "15m", "1h30m", "45s". Provide exactly one of seconds or duration.`
|
|
TimeCreatedAt = "Optional RFC3339 timestamp for when the work happened (defaults to server time)"
|
|
TimeUserName = "Optional username to log time on behalf of (requires admin; omit for self)"
|
|
TimeUserFilter = "Filter results to this username"
|
|
)
|