kodegen_github
GitHub API operations via Octocrab with MCP tool wrappers for AI agents.
Features
- Async-first: Built on tokio for efficient async operations
- Clean API: Wraps octocrab with ergonomic interfaces
- MCP Tools: 12 GitHub tools for AI agent integration (7 issue + 5 pull request tools)
- Type-safe: Full Rust type safety throughout
- Streaming: Efficient streaming for large result sets
MCP Tools
Issue Operations
create_issue
Create a new issue in a GitHub repository.
Arguments:
owner(string): Repository owner (user or organization)repo(string): Repository nametitle(string): Issue titlebody(string, optional): Issue description (Markdown supported)labels(array, optional): Labels to applyassignees(array, optional): Users to assign
Example:
Requirements:
- GITHUB_TOKEN environment variable must be set
- Token needs 'repo' scope for private repos, 'public_repo' for public
- User must have write access to the repository
- Labels must already exist in the repository
- Assignees must be collaborators on the repository
get_issue
Fetch a single issue by number.
Arguments:
owner(string): Repository ownerrepo(string): Repository nameissue_number(number): Issue number
Example:
Returns:
number: Issue numbertitle: Issue titlebody: Issue descriptionstate: "open" or "closed"labels: Array of label objectsassignees: Array of assigned userscreated_at: Creation timestampupdated_at: Last update timestampcomments: Number of commentshtml_url: Link to issue on GitHub
Note: issue_number is the issue number (e.g., #42), NOT the internal ID. Works for both issues and pull requests.
list_issues
List and filter repository issues.
Arguments:
owner(string): Repository ownerrepo(string): Repository namestate(string, optional): "open" (default), "closed", or "all"labels(array, optional): Filter by labels (AND logic)assignee(string, optional): Filter by assignee usernamepage(number, optional): Page number for paginationper_page(number, optional): Results per page (max 100, default 30)
Example:
Filter behavior:
- Multiple labels match issues with ALL labels (AND logic, not OR)
- State defaults to "open" if not specified
- Returns issues in most recent order
update_issue
Update an existing issue.
Arguments:
owner(string): Repository ownerrepo(string): Repository nameissue_number(number): Issue numbertitle(string, optional): New titlebody(string, optional): New bodystate(string, optional): "open" or "closed"labels(array, optional): Replace labelsassignees(array, optional): Replace assignees
Example:
Important notes:
- All fields are optional - only specified fields are updated
labelsandassigneesREPLACE existing values (not additive)- To clear labels or assignees, pass empty array: []
- Set
stateto "closed" to close an issue, "open" to reopen
search_issues
Search issues across GitHub using GitHub's search syntax.
Arguments:
query(string): GitHub search query (supports complex syntax)sort(string, optional): "comments", "reactions", "created", "updated"order(string, optional): "asc" or "desc"page(number, optional): Page numberper_page(number, optional): Results per page (max 100)
Search Query Syntax:
repo:owner/repo- Search in specific repositoryis:open/is:closed- Filter by statelabel:bug- Filter by labelassignee:username- Filter by assigneeauthor:username- Filter by authorinvolves:username- User is author, assignee, or mentionedcreated:>=2024-01-01- Created after datecreated:2024-01-01..2024-12-31- Date range- Text without prefix searches title and body
Example:
Combined filters example:
repo:octocat/hello-world is:open label:bug assignee:alice created:>=2024-01-01
Important notes:
- Search API has stricter rate limits (30 requests/minute authenticated)
- Results are relevance-ranked by default
- Use quotes for multi-word searches: "bug report"
- Date format: YYYY-MM-DD
add_issue_comment
Add a comment to an existing issue.
Arguments:
owner(string): Repository ownerrepo(string): Repository nameissue_number(number): Issue numberbody(string): Comment text (Markdown supported)
Example:
Markdown features:
- Full Markdown support (headings, code blocks, lists, etc.)
- @mention users to notify them
- Reference other issues/PRs with #number
- Link commits with SHA hashes
- Add emojis with :emoji_name:
Important notes:
- This tool CREATES a new comment each time (not idempotent)
- Cannot edit existing comments (separate tool needed)
- Works for both issues and pull requests
get_issue_comments
Fetch all comments for an issue.
Arguments:
owner(string): Repository ownerrepo(string): Repository nameissue_number(number): Issue number
Example:
Returns: Array of comment objects with:
id: Comment IDbody: Comment text (Markdown)user: Author information (login, avatar_url, etc.)created_at: When comment was createdupdated_at: When comment was last editedhtml_url: Link to comment on GitHubauthor_association: Relationship to repo (OWNER, CONTRIBUTOR, etc.)
Comment ordering:
- Comments are returned in chronological order (oldest first)
- Use
created_attimestamp to determine comment age - Check
author_associationto see if author is repo owner/maintainer updated_atdiffers fromcreated_atif comment was edited
Pull Request Operations
create_pull_request
Create a new pull request in a GitHub repository.
Arguments:
owner(string): Repository owner (user or organization)repo(string): Repository nametitle(string): Pull request titlebody(string, optional): Pull request description (Markdown supported)head(string): Name of the branch where changes are implemented (head branch)base(string): Name of the branch to merge into (base branch)draft(boolean, optional): Create as draft PR (default: false)maintainer_can_modify(boolean, optional): Allow maintainer edits (default: true)
Example:
Cross-fork PRs:
For PRs from a fork, use format: fork-owner:branch-name for head:
Requirements:
- GITHUB_TOKEN with appropriate permissions
- Head branch must exist
- Base branch must exist
- User must have push access to head repository
- User needs write access for non-fork PRs
update_pull_request
Update an existing pull request.
Arguments:
owner(string): Repository ownerrepo(string): Repository namepr_number(number): Pull request numbertitle(string, optional): New titlebody(string, optional): New descriptionstate(string, optional): "open" or "closed"base(string, optional): New base branchmaintainer_can_modify(boolean, optional): Allow maintainer edits
Example:
Important notes:
- All fields are optional except owner, repo, and pr_number
- Only specified fields are updated
- Changing base branch retargets the PR
- Set state to "closed" to close without merging
merge_pull_request
Merge a pull request in a GitHub repository.
Arguments:
owner(string): Repository ownerrepo(string): Repository namepr_number(number): Pull request numbercommit_title(string, optional): Merge commit titlecommit_message(string, optional): Merge commit messagemerge_method(string, optional): "merge", "squash", or "rebase"sha(string, optional): SHA of PR head for safety check
Example:
Merge methods:
merge: Creates merge commit, preserves all commitssquash: Combines all commits into onerebase: Rebases commits onto base branch
Safety:
Use sha parameter to ensure PR hasn't changed:
Requirements:
- PR must be in mergeable state
- All required checks must pass
- Sufficient review approvals
- No merge conflicts
- User must have write access
Warning: This is a destructive operation that modifies the base branch.
get_pull_request_status
Get detailed status information about a pull request.
Arguments:
owner(string): Repository ownerrepo(string): Repository namepr_number(number): Pull request number
Example:
Returns comprehensive status:
- Basic info: number, title, state, author
- Merge status: mergeable, merge conflicts
- Base/head branches and SHAs
- CI/CD check status and results
- Review state (approved, changes requested, pending)
- Labels and assignees
- Draft status
- Mergeable state (clean, dirty, blocked, unstable, etc.)
Use cases:
- Pre-merge validation
- CI/CD monitoring
- Review requirement checks
- Conflict detection
- Workflow automation
- Status dashboards
Important fields:
mergeable: true/false/null (null = still calculating)mergeable_state: "clean", "dirty", "blocked", "unstable"draft: true if still in draft modemerged: true if already merged
get_pull_request_files
Get all files changed in a pull request with diff stats.
Arguments:
owner(string): Repository ownerrepo(string): Repository namepr_number(number): Pull request number
Example:
Returns for each file:
filename: Path to the filestatus: "added", "modified", "removed", "renamed", "copied"additions: Lines addeddeletions: Lines deletedchanges: Total changes (additions + deletions)patch: Actual diff contentblob_url: URL to view fileraw_url: URL to download raw fileprevious_filename: Original name (for renamed files)
Response format:
Use cases:
- Code review preparation
- Impact analysis and scope assessment
- Automated PR checks
- Test coverage verification
- Documentation update checks
- File type filtering
- Change size metrics
Pull Request Review Operations
get_pull_request_reviews
Get all reviews for a pull request.
Arguments:
owner(string): Repository ownerrepo(string): Repository namepull_number(number): PR number
Example:
Returns: Array of reviews with:
id: Review IDuser: Reviewer username and profilebody: Review comment textstate: "APPROVED", "CHANGES_REQUESTED", "COMMENTED", "DISMISSED", "PENDING"submitted_at: When review was submittedcommit_id: SHA the review is associated with
Use cases:
- Check approval status before merging
- See who has reviewed and their feedback
- Understand what changes were requested
- Track review history over time
create_pull_request_review
Create a review on a pull request (approve, request changes, or comment).
Arguments:
owner(string): Repository ownerrepo(string): Repository namepull_number(number): PR numberevent(string): "APPROVE", "REQUEST_CHANGES", or "COMMENT"body(string, optional): Review commentcommit_id(string, optional): Specific commit to review
Example (approve):
Example (request changes):
Event types:
APPROVE: Approve the PR (allows merging if required reviews are met)REQUEST_CHANGES: Block PR until changes are madeCOMMENT: Leave review comments without approval/blocking
Note: This creates a REVIEW, not individual line comments. Use add_pull_request_review_comment for inline comments.
add_pull_request_review_comment
Add an inline review comment to a PR (comment on specific lines of code).
Arguments:
owner(string): Repository ownerrepo(string): Repository namepull_number(number): PR numberbody(string): Comment textcommit_id(string, optional): Commit SHApath(string, optional): File pathline(number, optional): Line number in diffside(string, optional): "LEFT" or "RIGHT"start_line(number, optional): For multi-line commentsstart_side(string, optional): Side of start linesubject_type(string, optional): Subject typein_reply_to(number, optional): Comment ID to reply to
Example (inline comment):
Example (multi-line comment):
Example (reply to comment):
Comment types:
- New inline comment: Requires commit_id, path, line, and optionally side
- Multi-line comment: Requires commit_id, path, start_line, line, and optionally sides
- Threaded reply: Only requires in_reply_to (inherits position from parent)
Tips:
- Use RIGHT side for commenting on new/changed code (most common)
- Use LEFT side for commenting on old code being removed
- Multi-line comments span from start_line to line (inclusive)
- Thread replies create conversations on specific code sections
request_copilot_review
Request GitHub Copilot to review a pull request (experimental).
Arguments:
owner(string): Repository ownerrepo(string): Repository namepull_number(number): PR number
Example:
What Copilot reviews:
- Code quality and best practices
- Potential bugs and issues
- Security vulnerabilities
- Performance improvements
- Code style and conventions
Important notes:
- This is an EXPERIMENTAL feature that may change
- Requires GitHub Copilot access on the repository
- The request triggers the review but doesn't return the review content
- Check PR comments after a short delay to see Copilot's feedback
- Not all repositories have Copilot review enabled
Example workflow:
- Create or update a pull request
- Request Copilot review:
request_copilot_review({...}) - Wait a few moments for Copilot to analyze
- Check PR comments:
get_pull_request_reviews({...}) - Review Copilot's suggestions and feedback
Repository Operations
create_repository
Create a new repository under the authenticated user's account.
Arguments:
name(string): Repository namedescription(string, optional): Repository descriptionprivate(boolean, optional): Make privateauto_init(boolean, optional): Initialize with README
Example:
fork_repository
Fork a repository.
Arguments:
owner(string): Repository owner to fork fromrepo(string): Repository nameorganization(string, optional): Fork to organization
Example:
list_branches
List branches in a repository.
Arguments:
owner(string): Repository ownerrepo(string): Repository namepage(number, optional): Page numberper_page(number, optional): Results per page
Example:
create_branch
Create a new branch from a commit SHA.
Arguments:
owner(string): Repository ownerrepo(string): Repository namebranch_name(string): New branch namesha(string): Commit SHA to branch from
Example:
list_commits
List commits in a repository with filtering options.
Arguments:
owner(string): Repository ownerrepo(string): Repository namesha(string, optional): Branch or SHA to start frompath(string, optional): Only commits affecting this pathauthor(string, optional): Filter by authorsince(string, optional): Only after this date (ISO 8601)until(string, optional): Only before this date (ISO 8601)page(number, optional): Page numberper_page(number, optional): Results per page
Example:
get_commit
Get detailed information about a specific commit.
Arguments:
owner(string): Repository ownerrepo(string): Repository namecommit_sha(string): Commit SHApage(number, optional): Page for files listper_page(number, optional): Results per page
Example:
Search Operations
search_code
Search code across GitHub repositories.
Arguments:
query(string): Search query (GitHub code search syntax)sort(string, optional): Sort by "indexed"order(string, optional): "asc" or "desc"page(number, optional): Page numberper_page(number, optional): Results per page
Query Syntax:
repo:owner/repo- Search in repositorylanguage:rust- Filter by languagepath:src/- Search in pathextension:rs- Filter by extension- Text without prefix searches code content
Example:
search_repositories
Search GitHub repositories.
Arguments:
query(string): Search query (GitHub repository search syntax)sort(string, optional): "stars", "forks", or "updated"order(string, optional): "asc" or "desc"page(number, optional): Page numberper_page(number, optional): Results per page
Query Syntax:
language:rust- Filter by languagestars:>1000- Star count filterforks:>100- Fork count filtertopic:async- Filter by topicuser:octocat- By userorg:github- By organization
Example:
search_users
Search GitHub users.
Arguments:
query(string): Search querysort(string, optional): "followers", "repositories", or "joined"order(string, optional): "asc" or "desc"page(number, optional): Page numberper_page(number, optional): Results per page
Example:
Environment Variables
All tools require:
GITHUB_TOKEN: Personal access token or app token
Token scopes:
- Public repos:
public_reposcope - Private repos:
reposcope
Usage in Rust
use GitHubClient;
async
MCP Integration
These tools are automatically available when the github feature is enabled in the kodegen server:
# Enable GitHub tools
# List available categories
License
MIT