diff --git a/README.md b/README.md index e4543ecf5..e1712fcd7 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ Alternatively, to manually configure VS Code, choose the appropriate JSON block ### Install in other MCP hosts + - **[GitHub Copilot in other IDEs](/docs/installation-guides/install-other-copilot-ides.md)** - Installation for JetBrains, Visual Studio, Eclipse, and Xcode with GitHub Copilot - **[Claude Applications](/docs/installation-guides/install-claude.md)** - Installation guide for Claude Web, Claude Desktop and Claude Code CLI - **[Cursor](/docs/installation-guides/install-cursor.md)** - Installation guide for Cursor IDE @@ -86,11 +87,13 @@ Alternatively, to manually configure VS Code, choose the appropriate JSON block > **Note:** Each MCP host application needs to configure a GitHub App or OAuth App to support remote access via OAuth. Any host application that supports remote MCP servers should support the remote GitHub server with PAT authentication. Configuration details and support levels vary by host. Make sure to refer to the host application's documentation for more info. > ⚠️ **Public Preview Status:** The **remote** GitHub MCP Server is currently in Public Preview. During preview, access may be gated depending on authentication type and surface: +> > - OAuth: Subject to GitHub Copilot Editor Preview Policy until GA > - PAT: Controlled via your organization's PAT policies > - MCP Servers in Copilot policy: Enables/disables access to all MCP servers in VS Code, with other Copilot editors migrating to this policy in the coming months. ### Configuration + See [Remote Server Documentation](/docs/remote-server.md) on how to pass additional configuration settings to the remote GitHub MCP Server. --- @@ -104,33 +107,39 @@ See [Remote Server Documentation](/docs/remote-server.md) on how to pass additio 1. To run the server in a container, you will need to have [Docker](https://www.docker.com/) installed. 2. Once Docker is installed, you will also need to ensure Docker is running. The image is public; if you get errors on pull, you may have an expired token and need to `docker logout ghcr.io`. 3. Lastly you will need to [Create a GitHub Personal Access Token](https://github.com/settings/personal-access-tokens/new). -The MCP server can use many of the GitHub APIs, so enable the permissions that you feel comfortable granting your AI tools (to learn more about access tokens, please check out the [documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)). + The MCP server can use many of the GitHub APIs, so enable the permissions that you feel comfortable granting your AI tools (to learn more about access tokens, please check out the [documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)).
Handling PATs Securely ### Environment Variables (Recommended) + To keep your GitHub PAT secure and reusable across different MCP hosts: 1. **Store your PAT in environment variables** + ```bash export GITHUB_PAT=your_token_here ``` + Or create a `.env` file: + ```env GITHUB_PAT=your_token_here ``` 2. **Protect your `.env` file** + ```bash # Add to .gitignore to prevent accidental commits echo ".env" >> .gitignore ``` 3. **Reference the token in configurations** + ```bash # CLI usage claude mcp update github -e GITHUB_PERSONAL_ACCESS_TOKEN=$GITHUB_PAT - + # In config files (where supported) "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "$GITHUB_PAT" @@ -241,7 +250,7 @@ For other MCP host applications, please refer to our installation guides: - **[GitHub Copilot in other IDEs](/docs/installation-guides/install-other-copilot-ides.md)** - Installation for JetBrains, Visual Studio, Eclipse, and Xcode with GitHub Copilot - **[Claude Code & Claude Desktop](docs/installation-guides/install-claude.md)** - Installation guide for Claude Code and Claude Desktop -- **[Cursor](docs/installation-guides/install-cursor.md)** - Installation guide for Cursor IDE +- **[Cursor](docs/installation-guides/install-cursor.md)** - Installation guide for Cursor IDE - **[Windsurf](docs/installation-guides/install-windsurf.md)** - Installation guide for Windsurf IDE For a complete overview of all installation options, see our **[Installation Guides Index](docs/installation-guides/installation-guides.md)**. @@ -280,48 +289,53 @@ _Toolsets are not limited to Tools. Relevant MCP Resources and Prompts are also The following sets of tools are available (all are on by default): -| Toolset | Description | -| ----------------------- | ------------------------------------------------------------- | -| `context` | **Strongly recommended**: Tools that provide context about the current user and GitHub context you are operating in | -| `actions` | GitHub Actions workflows and CI/CD operations | -| `code_security` | Code security related tools, such as GitHub Code Scanning | -| `dependabot` | Dependabot tools | -| `discussions` | GitHub Discussions related tools | -| `experiments` | Experimental features that are not considered stable yet | -| `gists` | GitHub Gist related tools | -| `issues` | GitHub Issues related tools | -| `notifications` | GitHub Notifications related tools | -| `orgs` | GitHub Organization related tools | -| `pull_requests` | GitHub Pull Request related tools | -| `repos` | GitHub Repository related tools | -| `secret_protection` | Secret protection related tools, such as GitHub Secret Scanning | -| `users` | GitHub User related tools | + +| Toolset | Description | +| ------------------- | ------------------------------------------------------------------------------------------------------------------- | +| `context` | **Strongly recommended**: Tools that provide context about the current user and GitHub context you are operating in | +| `actions` | GitHub Actions workflows and CI/CD operations | +| `code_security` | Code security related tools, such as GitHub Code Scanning | +| `dependabot` | Dependabot tools | +| `discussions` | GitHub Discussions related tools | +| `experiments` | Experimental features that are not considered stable yet | +| `gists` | GitHub Gist related tools | +| `issues` | GitHub Issues related tools | +| `notifications` | GitHub Notifications related tools | +| `orgs` | GitHub Organization related tools | +| `pull_requests` | GitHub Pull Request related tools | +| `repos` | GitHub Repository related tools | +| `secret_protection` | Secret protection related tools, such as GitHub Secret Scanning | +| `users` | GitHub User related tools | + ## Tools -
Actions - **cancel_workflow_run** - Cancel workflow run + - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - `run_id`: The unique identifier of the workflow run (number, required) - **delete_workflow_run_logs** - Delete workflow logs + - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - `run_id`: The unique identifier of the workflow run (number, required) - **download_workflow_run_artifact** - Download workflow artifact + - `artifact_id`: The unique identifier of the artifact (number, required) - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - **get_job_logs** - Get job logs + - `failed_only`: When true, gets logs for all failed jobs in run_id (boolean, optional) - `job_id`: The unique identifier of the workflow job (required for single job logs) (number, optional) - `owner`: Repository owner (string, required) @@ -331,21 +345,25 @@ The following sets of tools are available (all are on by default): - `tail_lines`: Number of lines to return from the end of the log (number, optional) - **get_workflow_run** - Get workflow run + - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - `run_id`: The unique identifier of the workflow run (number, required) - **get_workflow_run_logs** - Get workflow run logs + - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - `run_id`: The unique identifier of the workflow run (number, required) - **get_workflow_run_usage** - Get workflow usage + - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - `run_id`: The unique identifier of the workflow run (number, required) - **list_workflow_jobs** - List workflow jobs + - `filter`: Filters jobs by their completed_at timestamp (string, optional) - `owner`: Repository owner (string, required) - `page`: Page number for pagination (min 1) (number, optional) @@ -354,6 +372,7 @@ The following sets of tools are available (all are on by default): - `run_id`: The unique identifier of the workflow run (number, required) - **list_workflow_run_artifacts** - List workflow artifacts + - `owner`: Repository owner (string, required) - `page`: Page number for pagination (min 1) (number, optional) - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) @@ -361,6 +380,7 @@ The following sets of tools are available (all are on by default): - `run_id`: The unique identifier of the workflow run (number, required) - **list_workflow_runs** - List workflow runs + - `actor`: Returns someone's workflow runs. Use the login for the user who created the workflow run. (string, optional) - `branch`: Returns workflow runs associated with a branch. Use the name of the branch. (string, optional) - `event`: Returns workflow runs for a specific event type (string, optional) @@ -372,17 +392,20 @@ The following sets of tools are available (all are on by default): - `workflow_id`: The workflow ID or workflow file name (string, required) - **list_workflows** - List workflows + - `owner`: Repository owner (string, required) - `page`: Page number for pagination (min 1) (number, optional) - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - `repo`: Repository name (string, required) - **rerun_failed_jobs** - Rerun failed jobs + - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - `run_id`: The unique identifier of the workflow run (number, required) - **rerun_workflow_run** - Rerun workflow run + - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - `run_id`: The unique identifier of the workflow run (number, required) @@ -401,6 +424,7 @@ The following sets of tools are available (all are on by default): Code Security - **get_code_scanning_alert** - Get code scanning alert + - `alertNumber`: The number of the alert. (number, required) - `owner`: The owner of the repository. (string, required) - `repo`: The name of the repository. (string, required) @@ -436,6 +460,7 @@ The following sets of tools are available (all are on by default): Dependabot - **get_dependabot_alert** - Get dependabot alert + - `alertNumber`: The number of the alert. (number, required) - `owner`: The owner of the repository. (string, required) - `repo`: The name of the repository. (string, required) @@ -453,11 +478,13 @@ The following sets of tools are available (all are on by default): Discussions - **get_discussion** - Get discussion + - `discussionNumber`: Discussion Number (number, required) - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - **get_discussion_comments** - Get discussion comments + - `after`: Cursor for pagination. Use the endCursor from the previous page's PageInfo for GraphQL APIs. (string, optional) - `discussionNumber`: Discussion Number (number, required) - `owner`: Repository owner (string, required) @@ -465,6 +492,7 @@ The following sets of tools are available (all are on by default): - `repo`: Repository name (string, required) - **list_discussion_categories** - List discussion categories + - `owner`: Repository owner (string, required) - `repo`: Repository name. If not provided, discussion categories will be queried at the organisation level. (string, optional) @@ -484,12 +512,14 @@ The following sets of tools are available (all are on by default): Gists - **create_gist** - Create Gist + - `content`: Content for simple single-file gist creation (string, required) - `description`: Description of the gist (string, optional) - `filename`: Filename for simple single-file gist creation (string, required) - `public`: Whether the gist is public (boolean, optional) - **list_gists** - List Gists + - `page`: Page number for pagination (min 1) (number, optional) - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - `since`: Only gists updated after this time (ISO 8601 timestamp) (string, optional) @@ -508,12 +538,14 @@ The following sets of tools are available (all are on by default): Issues - **add_issue_comment** - Add comment to issue + - `body`: Comment content (string, required) - `issue_number`: Issue number to comment on (number, required) - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - **add_sub_issue** - Add sub-issue + - `issue_number`: The number of the parent issue (number, required) - `owner`: Repository owner (string, required) - `replace_parent`: When true, replaces the sub-issue's current parent issue (boolean, optional) @@ -521,11 +553,13 @@ The following sets of tools are available (all are on by default): - `sub_issue_id`: The ID of the sub-issue to add. ID is not the same as issue number (number, required) - **assign_copilot_to_issue** - Assign Copilot to issue + - `issueNumber`: Issue number (number, required) - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - **create_issue** - Open new issue + - `assignees`: Usernames to assign to this issue (string[], optional) - `body`: Issue body content (string, optional) - `labels`: Labels to apply to this issue (string[], optional) @@ -536,11 +570,13 @@ The following sets of tools are available (all are on by default): - `type`: Type of this issue (string, optional) - **get_issue** - Get issue details + - `issue_number`: The number of the issue (number, required) - `owner`: The owner of the repository (string, required) - `repo`: The name of the repository (string, required) - **get_issue_comments** - Get issue comments + - `issue_number`: Issue number (number, required) - `owner`: Repository owner (string, required) - `page`: Page number for pagination (min 1) (number, optional) @@ -551,6 +587,7 @@ The following sets of tools are available (all are on by default): - `owner`: The organization owner of the repository (string, required) - **list_issues** - List issues + - `after`: Cursor for pagination. Use the endCursor from the previous page's PageInfo for GraphQL APIs. (string, optional) - `direction`: Order direction. If provided, the 'orderBy' also needs to be provided. (string, optional) - `labels`: Filter by labels (string[], optional) @@ -562,6 +599,7 @@ The following sets of tools are available (all are on by default): - `state`: Filter by state, by default both open and closed issues are returned when not provided (string, optional) - **list_sub_issues** - List sub-issues + - `issue_number`: Issue number (number, required) - `owner`: Repository owner (string, required) - `page`: Page number for pagination (default: 1) (number, optional) @@ -569,12 +607,14 @@ The following sets of tools are available (all are on by default): - `repo`: Repository name (string, required) - **remove_sub_issue** - Remove sub-issue + - `issue_number`: The number of the parent issue (number, required) - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - `sub_issue_id`: The ID of the sub-issue to remove. ID is not the same as issue number (number, required) - **reprioritize_sub_issue** - Reprioritize sub-issue + - `after_id`: The ID of the sub-issue to be prioritized after (either after_id OR before_id should be specified) (number, optional) - `before_id`: The ID of the sub-issue to be prioritized before (either after_id OR before_id should be specified) (number, optional) - `issue_number`: The number of the parent issue (number, required) @@ -583,6 +623,7 @@ The following sets of tools are available (all are on by default): - `sub_issue_id`: The ID of the sub-issue to reprioritize. ID is not the same as issue number (number, required) - **search_issues** - Search issues + - `order`: Sort order (string, optional) - `owner`: Optional repository owner. If provided with repo, only issues for this repository are listed. (string, optional) - `page`: Page number for pagination (min 1) (number, optional) @@ -610,13 +651,16 @@ The following sets of tools are available (all are on by default): Notifications - **dismiss_notification** - Dismiss notification + - `state`: The new state of the notification (read/done) (string, optional) - `threadID`: The ID of the notification thread (string, required) - **get_notification_details** - Get notification details + - `notificationID`: The ID of the notification (string, required) - **list_notifications** - List notifications + - `before`: Only show notifications updated before the given time (ISO 8601 format) (string, optional) - `filter`: Filter notifications to, use default unless specified. Read notifications are ones that have already been acknowledged by the user. Participating notifications are those that the user is directly involved in, such as issues or pull requests they have commented on or created. (string, optional) - `owner`: Optional repository owner. If provided with repo, only notifications for this repository are listed. (string, optional) @@ -626,10 +670,12 @@ The following sets of tools are available (all are on by default): - `since`: Only show notifications updated after the given time (ISO 8601 format) (string, optional) - **manage_notification_subscription** - Manage notification subscription + - `action`: Action to perform: ignore, watch, or delete the notification subscription. (string, required) - `notificationID`: The ID of the notification thread. (string, required) - **manage_repository_notification_subscription** - Manage repository notification subscription + - `action`: Action to perform: ignore, watch, or delete the repository notification subscription. (string, required) - `owner`: The account owner of the repository. (string, required) - `repo`: The name of the repository. (string, required) @@ -659,6 +705,7 @@ The following sets of tools are available (all are on by default): Pull Requests - **add_comment_to_pending_review** - Add review comment to the requester's latest pending pull request review + - `body`: The text of the review comment (string, required) - `line`: The line of the blob in the pull request diff that the comment applies to. For multi-line comments, the last line of the range (number, optional) - `owner`: Repository owner (string, required) @@ -671,6 +718,7 @@ The following sets of tools are available (all are on by default): - `subjectType`: The level at which the comment is targeted (string, required) - **create_and_submit_pull_request_review** - Create and submit a pull request review without comments + - `body`: Review comment text (string, required) - `commitID`: SHA of commit to review (string, optional) - `event`: Review action to perform (string, required) @@ -679,12 +727,14 @@ The following sets of tools are available (all are on by default): - `repo`: Repository name (string, required) - **create_pending_pull_request_review** - Create pending pull request review + - `commitID`: SHA of commit to review (string, optional) - `owner`: Repository owner (string, required) - `pullNumber`: Pull request number (number, required) - `repo`: Repository name (string, required) - **create_pull_request** - Open new pull request + - `base`: Branch to merge into (string, required) - `body`: PR description (string, optional) - `draft`: Create as draft PR (boolean, optional) @@ -695,26 +745,31 @@ The following sets of tools are available (all are on by default): - `title`: PR title (string, required) - **delete_pending_pull_request_review** - Delete the requester's latest pending pull request review + - `owner`: Repository owner (string, required) - `pullNumber`: Pull request number (number, required) - `repo`: Repository name (string, required) - **get_pull_request** - Get pull request details + - `owner`: Repository owner (string, required) - `pullNumber`: Pull request number (number, required) - `repo`: Repository name (string, required) - **get_pull_request_comments** - Get pull request comments + - `owner`: Repository owner (string, required) - `pullNumber`: Pull request number (number, required) - `repo`: Repository name (string, required) - **get_pull_request_diff** - Get pull request diff + - `owner`: Repository owner (string, required) - `pullNumber`: Pull request number (number, required) - `repo`: Repository name (string, required) - **get_pull_request_files** - Get pull request files + - `owner`: Repository owner (string, required) - `page`: Page number for pagination (min 1) (number, optional) - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) @@ -722,16 +777,19 @@ The following sets of tools are available (all are on by default): - `repo`: Repository name (string, required) - **get_pull_request_reviews** - Get pull request reviews + - `owner`: Repository owner (string, required) - `pullNumber`: Pull request number (number, required) - `repo`: Repository name (string, required) - **get_pull_request_status** - Get pull request status checks + - `owner`: Repository owner (string, required) - `pullNumber`: Pull request number (number, required) - `repo`: Repository name (string, required) - **list_pull_requests** - List pull requests + - `base`: Filter by base branch (string, optional) - `direction`: Sort direction (string, optional) - `head`: Filter by head user/org and branch (string, optional) @@ -743,6 +801,7 @@ The following sets of tools are available (all are on by default): - `state`: Filter by state (string, optional) - **merge_pull_request** - Merge pull request + - `commit_message`: Extra detail for merge commit (string, optional) - `commit_title`: Title for merge commit (string, optional) - `merge_method`: Merge method (string, optional) @@ -751,11 +810,13 @@ The following sets of tools are available (all are on by default): - `repo`: Repository name (string, required) - **request_copilot_review** - Request Copilot review + - `owner`: Repository owner (string, required) - `pullNumber`: Pull request number (number, required) - `repo`: Repository name (string, required) - **search_pull_requests** - Search pull requests + - `order`: Sort order (string, optional) - `owner`: Optional repository owner. If provided with repo, only pull requests for this repository are listed. (string, optional) - `page`: Page number for pagination (min 1) (number, optional) @@ -765,6 +826,7 @@ The following sets of tools are available (all are on by default): - `sort`: Sort field by number of matches of categories, defaults to best match (string, optional) - **submit_pending_pull_request_review** - Submit the requester's latest pending pull request review + - `body`: The text of the review comment (string, optional) - `event`: The event to perform (string, required) - `owner`: Repository owner (string, required) @@ -772,6 +834,7 @@ The following sets of tools are available (all are on by default): - `repo`: Repository name (string, required) - **update_pull_request** - Edit pull request + - `base`: New base branch name (string, optional) - `body`: New description (string, optional) - `draft`: Mark pull request as draft (true) or ready for review (false) (boolean, optional) @@ -796,12 +859,14 @@ The following sets of tools are available (all are on by default): Repositories - **create_branch** - Create branch + - `branch`: Name for new branch (string, required) - `from_branch`: Source branch (defaults to repo default) (string, optional) - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - **create_or_update_file** - Create or update file + - `branch`: Branch to create/update the file in (string, required) - `content`: Content of the file (string, required) - `message`: Commit message (string, required) @@ -811,12 +876,14 @@ The following sets of tools are available (all are on by default): - `sha`: Required if updating an existing file. The blob SHA of the file being replaced. (string, optional) - **create_repository** - Create repository + - `autoInit`: Initialize with README (boolean, optional) - `description`: Repository description (string, optional) - `name`: Repository name (string, required) - `private`: Whether repo should be private (boolean, optional) - **delete_file** - Delete file + - `branch`: Branch to delete the file from (string, required) - `message`: Commit message (string, required) - `owner`: Repository owner (username or organization) (string, required) @@ -824,11 +891,13 @@ The following sets of tools are available (all are on by default): - `repo`: Repository name (string, required) - **fork_repository** - Fork repository + - `organization`: Organization to fork to (string, optional) - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - **get_commit** - Get commit details + - `owner`: Repository owner (string, required) - `page`: Page number for pagination (min 1) (number, optional) - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) @@ -836,6 +905,7 @@ The following sets of tools are available (all are on by default): - `sha`: Commit SHA, branch name, or tag name (string, required) - **get_file_contents** - Get file or directory contents + - `owner`: Repository owner (username or organization) (string, required) - `path`: Path to file/directory (directories must end with a slash '/') (string, optional) - `ref`: Accepts optional git refs such as `refs/tags/{tag}`, `refs/heads/{branch}` or `refs/pull/{pr_number}/head` (string, optional) @@ -847,17 +917,20 @@ The following sets of tools are available (all are on by default): - `repo`: Repository name (string, required) - **get_tag** - Get tag details + - `owner`: Repository owner (string, required) - `repo`: Repository name (string, required) - `tag`: Tag name (string, required) - **list_branches** - List branches + - `owner`: Repository owner (string, required) - `page`: Page number for pagination (min 1) (number, optional) - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - `repo`: Repository name (string, required) - **list_commits** - List commits + - `author`: Author username or email address to filter commits by (string, optional) - `owner`: Repository owner (string, required) - `page`: Page number for pagination (min 1) (number, optional) @@ -872,12 +945,14 @@ The following sets of tools are available (all are on by default): - `repo`: Repository name (string, required) - **list_tags** - List tags + - `owner`: Repository owner (string, required) - `page`: Page number for pagination (min 1) (number, optional) - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) - `repo`: Repository name (string, required) - **push_files** - Push files to repository + - `branch`: Branch to push to (string, required) - `files`: Array of file objects to push, each object with path (string) and content (string) (object[], required) - `message`: Commit message (string, required) @@ -885,6 +960,7 @@ The following sets of tools are available (all are on by default): - `repo`: Repository name (string, required) - **search_code** - Search code + - `order`: Sort order for results (string, optional) - `page`: Page number for pagination (min 1) (number, optional) - `perPage`: Results per page for pagination (min 1, max 100) (number, optional) @@ -903,6 +979,7 @@ The following sets of tools are available (all are on by default): Secret Protection - **get_secret_scanning_alert** - Get secret scanning alert + - `alertNumber`: The number of the alert. (number, required) - `owner`: The owner of the repository. (string, required) - `repo`: The name of the repository. (string, required) @@ -936,12 +1013,12 @@ The following sets of tools are available (all are on by default): Copilot coding agent -- **create_pull_request_with_copilot** - Perform task with GitHub Copilot coding agent - - `owner`: Repository owner. You can guess the owner, but confirm it with the user before proceeding. (string, required) - - `repo`: Repository name. You can guess the repository name, but confirm it with the user before proceeding. (string, required) - - `problem_statement`: Detailed description of the task to be performed (e.g., 'Implement a feature that does X', 'Fix bug Y', etc.) (string, required) - - `title`: Title for the pull request that will be created (string, required) - - `base_ref`: Git reference (e.g., branch) that the agent will start its work from. If not specified, defaults to the repository's default branch (string, optional) +- **create_pull_request_with_copilot** - Perform task with GitHub Copilot coding agent + - `owner`: Repository owner. You can guess the owner, but confirm it with the user before proceeding. (string, required) + - `repo`: Repository name. You can guess the repository name, but confirm it with the user before proceeding. (string, required) + - `problem_statement`: Detailed description of the task to be performed (e.g., 'Implement a feature that does X', 'Fix bug Y', etc.) (string, required) + - `title`: Title for the pull request that will be created (string, required) + - `base_ref`: Git reference (e.g., branch) that the agent will start its work from. If not specified, defaults to the repository's default branch (string, optional)
@@ -1034,7 +1111,8 @@ the hostname for GitHub Enterprise Server or GitHub Enterprise Cloud with data r - For GitHub Enterprise Server, prefix the hostname with the `https://` URI scheme, as it otherwise defaults to `http://`, which GitHub Enterprise Server does not support. - For GitHub Enterprise Cloud with data residency, use `https://YOURSUBDOMAIN.ghe.com` as the hostname. -``` json + +```json "github": { "command": "docker", "args": [ diff --git a/docs/remote-server.md b/docs/remote-server.md index 5f57f4961..74b889d2c 100644 --- a/docs/remote-server.md +++ b/docs/remote-server.md @@ -17,22 +17,23 @@ The remote server has [additional tools](#toolsets-only-available-in-the-remote- Below is a table of available toolsets for the remote GitHub MCP Server. Each toolset is provided as a distinct URL so you can mix and match to create the perfect combination of tools for your use-case. Add `/readonly` to the end of any URL to restrict the tools in the toolset to only those that enable read access. We also provide the option to use [headers](#headers) instead. -| Name | Description | API URL | 1-Click Install (VS Code) | Read-only Link | 1-Click Read-only Install (VS Code) | -|----------------|--------------------------------------------------|-------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| all | All available GitHub MCP tools | https://api.githubcopilot.com/mcp/ | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D) | [read-only](https://api.githubcopilot.com/mcp/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Freadonly%22%7D) | -| Actions | GitHub Actions workflows and CI/CD operations | https://api.githubcopilot.com/mcp/x/actions | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-actions&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Factions%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/actions/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-actions&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Factions%2Freadonly%22%7D) | -| Code Security | Code security related tools, such as GitHub Code Scanning | https://api.githubcopilot.com/mcp/x/code_security | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-code_security&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fcode_security%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/code_security/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-code_security&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fcode_security%2Freadonly%22%7D) | -| Dependabot | Dependabot tools | https://api.githubcopilot.com/mcp/x/dependabot | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-dependabot&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fdependabot%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/dependabot/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-dependabot&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fdependabot%2Freadonly%22%7D) | -| Discussions | GitHub Discussions related tools | https://api.githubcopilot.com/mcp/x/discussions | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-discussions&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fdiscussions%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/discussions/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-discussions&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fdiscussions%2Freadonly%22%7D) | -| Experiments | Experimental features that are not considered stable yet | https://api.githubcopilot.com/mcp/x/experiments | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-experiments&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fexperiments%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/experiments/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-experiments&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fexperiments%2Freadonly%22%7D) | -| Gists | GitHub Gist related tools | https://api.githubcopilot.com/mcp/x/gists | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-gists&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fgists%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/gists/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-gists&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fgists%2Freadonly%22%7D) | -| Issues | GitHub Issues related tools | https://api.githubcopilot.com/mcp/x/issues | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-issues&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fissues%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/issues/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-issues&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fissues%2Freadonly%22%7D) | -| Notifications | GitHub Notifications related tools | https://api.githubcopilot.com/mcp/x/notifications | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-notifications&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fnotifications%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/notifications/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-notifications&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fnotifications%2Freadonly%22%7D) | -| Organizations | GitHub Organization related tools | https://api.githubcopilot.com/mcp/x/orgs | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-orgs&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Forgs%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/orgs/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-orgs&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Forgs%2Freadonly%22%7D) | -| Pull Requests | GitHub Pull Request related tools | https://api.githubcopilot.com/mcp/x/pull_requests | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-pull_requests&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fpull_requests%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/pull_requests/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-pull_requests&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fpull_requests%2Freadonly%22%7D) | -| Repositories | GitHub Repository related tools | https://api.githubcopilot.com/mcp/x/repos | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-repos&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Frepos%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/repos/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-repos&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Frepos%2Freadonly%22%7D) | -| Secret Protection | Secret protection related tools, such as GitHub Secret Scanning | https://api.githubcopilot.com/mcp/x/secret_protection | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-secret_protection&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fsecret_protection%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/secret_protection/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-secret_protection&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fsecret_protection%2Freadonly%22%7D) | -| Users | GitHub User related tools | https://api.githubcopilot.com/mcp/x/users | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-users&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fusers%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/users/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-users&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fusers%2Freadonly%22%7D) | + +| Name | Description | API URL | 1-Click Install (VS Code) | Read-only Link | 1-Click Read-only Install (VS Code) | +| ----------------- | --------------------------------------------------------------- | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| all | All available GitHub MCP tools | https://api.githubcopilot.com/mcp/ | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D) | [read-only](https://api.githubcopilot.com/mcp/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Freadonly%22%7D) | +| Actions | GitHub Actions workflows and CI/CD operations | https://api.githubcopilot.com/mcp/x/actions | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-actions&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Factions%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/actions/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-actions&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Factions%2Freadonly%22%7D) | +| Code Security | Code security related tools, such as GitHub Code Scanning | https://api.githubcopilot.com/mcp/x/code_security | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-code_security&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fcode_security%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/code_security/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-code_security&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fcode_security%2Freadonly%22%7D) | +| Dependabot | Dependabot tools | https://api.githubcopilot.com/mcp/x/dependabot | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-dependabot&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fdependabot%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/dependabot/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-dependabot&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fdependabot%2Freadonly%22%7D) | +| Discussions | GitHub Discussions related tools | https://api.githubcopilot.com/mcp/x/discussions | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-discussions&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fdiscussions%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/discussions/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-discussions&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fdiscussions%2Freadonly%22%7D) | +| Experiments | Experimental features that are not considered stable yet | https://api.githubcopilot.com/mcp/x/experiments | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-experiments&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fexperiments%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/experiments/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-experiments&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fexperiments%2Freadonly%22%7D) | +| Gists | GitHub Gist related tools | https://api.githubcopilot.com/mcp/x/gists | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-gists&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fgists%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/gists/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-gists&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fgists%2Freadonly%22%7D) | +| Issues | GitHub Issues related tools | https://api.githubcopilot.com/mcp/x/issues | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-issues&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fissues%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/issues/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-issues&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fissues%2Freadonly%22%7D) | +| Notifications | GitHub Notifications related tools | https://api.githubcopilot.com/mcp/x/notifications | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-notifications&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fnotifications%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/notifications/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-notifications&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fnotifications%2Freadonly%22%7D) | +| Organizations | GitHub Organization related tools | https://api.githubcopilot.com/mcp/x/orgs | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-orgs&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Forgs%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/orgs/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-orgs&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Forgs%2Freadonly%22%7D) | +| Pull Requests | GitHub Pull Request related tools | https://api.githubcopilot.com/mcp/x/pull_requests | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-pull_requests&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fpull_requests%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/pull_requests/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-pull_requests&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fpull_requests%2Freadonly%22%7D) | +| Repositories | GitHub Repository related tools | https://api.githubcopilot.com/mcp/x/repos | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-repos&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Frepos%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/repos/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-repos&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Frepos%2Freadonly%22%7D) | +| Secret Protection | Secret protection related tools, such as GitHub Secret Scanning | https://api.githubcopilot.com/mcp/x/secret_protection | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-secret_protection&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fsecret_protection%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/secret_protection/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-secret_protection&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fsecret_protection%2Freadonly%22%7D) | +| Users | GitHub User related tools | https://api.githubcopilot.com/mcp/x/users | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=gh-users&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fusers%22%7D) | [read-only](https://api.githubcopilot.com/mcp/x/users/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=gh-users&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Fx%2Fusers%2Freadonly%22%7D) | @@ -49,5 +50,6 @@ These toolsets are only available in the remote GitHub MCP Server and are not in You can configure toolsets and readonly mode by providing HTTP headers in your server configuration. The headers are: + - `X-MCP-Toolsets=,...` - `X-MCP-Readonly=true` diff --git a/pkg/github/__toolsnaps__/add_issue_to_project.snap b/pkg/github/__toolsnaps__/add_issue_to_project.snap new file mode 100644 index 000000000..6d0ae86c0 --- /dev/null +++ b/pkg/github/__toolsnaps__/add_issue_to_project.snap @@ -0,0 +1,25 @@ +{ + "annotations": { + "title": "Add issue to project", + "readOnlyHint": false + }, + "description": "Add an issue to a project", + "inputSchema": { + "properties": { + "issue_id": { + "description": "Issue node ID", + "type": "string" + }, + "project_id": { + "description": "Project ID", + "type": "string" + } + }, + "required": [ + "project_id", + "issue_id" + ], + "type": "object" + }, + "name": "add_issue_to_project" +} diff --git a/pkg/github/__toolsnaps__/create_draft_issue.snap b/pkg/github/__toolsnaps__/create_draft_issue.snap new file mode 100644 index 000000000..157d6a3e6 --- /dev/null +++ b/pkg/github/__toolsnaps__/create_draft_issue.snap @@ -0,0 +1,29 @@ +{ + "annotations": { + "title": "Create draft issue", + "readOnlyHint": false + }, + "description": "Create a draft issue in a project", + "inputSchema": { + "properties": { + "body": { + "description": "Issue body", + "type": "string" + }, + "project_id": { + "description": "Project ID", + "type": "string" + }, + "title": { + "description": "Issue title", + "type": "string" + } + }, + "required": [ + "project_id", + "title" + ], + "type": "object" + }, + "name": "create_draft_issue" +} diff --git a/pkg/github/__toolsnaps__/create_project_issue.snap b/pkg/github/__toolsnaps__/create_project_issue.snap new file mode 100644 index 000000000..b9f9071ea --- /dev/null +++ b/pkg/github/__toolsnaps__/create_project_issue.snap @@ -0,0 +1,34 @@ +{ + "annotations": { + "title": "Create issue", + "readOnlyHint": false + }, + "description": "Create a new issue", + "inputSchema": { + "properties": { + "body": { + "description": "Issue body", + "type": "string" + }, + "owner": { + "description": "Repository owner", + "type": "string" + }, + "repo": { + "description": "Repository name", + "type": "string" + }, + "title": { + "description": "Issue title", + "type": "string" + } + }, + "required": [ + "owner", + "repo", + "title" + ], + "type": "object" + }, + "name": "create_project_issue" +} diff --git a/pkg/github/__toolsnaps__/delete_project_item.snap b/pkg/github/__toolsnaps__/delete_project_item.snap new file mode 100644 index 000000000..9edd632aa --- /dev/null +++ b/pkg/github/__toolsnaps__/delete_project_item.snap @@ -0,0 +1,25 @@ +{ + "annotations": { + "title": "Delete project item", + "readOnlyHint": false + }, + "description": "Delete a project item", + "inputSchema": { + "properties": { + "item_id": { + "description": "Item ID", + "type": "string" + }, + "project_id": { + "description": "Project ID", + "type": "string" + } + }, + "required": [ + "project_id", + "item_id" + ], + "type": "object" + }, + "name": "delete_project_item" +} diff --git a/pkg/github/__toolsnaps__/get_project_fields.snap b/pkg/github/__toolsnaps__/get_project_fields.snap new file mode 100644 index 000000000..d43c60e98 --- /dev/null +++ b/pkg/github/__toolsnaps__/get_project_fields.snap @@ -0,0 +1,33 @@ +{ + "annotations": { + "title": "Get project fields", + "readOnlyHint": true + }, + "description": "Get fields for a project", + "inputSchema": { + "properties": { + "number": { + "description": "Project number", + "type": "number" + }, + "owner": { + "description": "Owner login", + "type": "string" + }, + "owner_type": { + "description": "Owner type", + "enum": [ + "user", + "organization" + ], + "type": "string" + } + }, + "required": [ + "owner", + "number" + ], + "type": "object" + }, + "name": "get_project_fields" +} diff --git a/pkg/github/__toolsnaps__/get_project_items.snap b/pkg/github/__toolsnaps__/get_project_items.snap new file mode 100644 index 000000000..577dfbcc6 --- /dev/null +++ b/pkg/github/__toolsnaps__/get_project_items.snap @@ -0,0 +1,33 @@ +{ + "annotations": { + "title": "Get project items", + "readOnlyHint": true + }, + "description": "Get items for a project", + "inputSchema": { + "properties": { + "number": { + "description": "Project number", + "type": "number" + }, + "owner": { + "description": "Owner login", + "type": "string" + }, + "owner_type": { + "description": "Owner type", + "enum": [ + "user", + "organization" + ], + "type": "string" + } + }, + "required": [ + "owner", + "number" + ], + "type": "object" + }, + "name": "get_project_items" +} diff --git a/pkg/github/__toolsnaps__/list_projects.snap b/pkg/github/__toolsnaps__/list_projects.snap new file mode 100644 index 000000000..1ce9ccd98 --- /dev/null +++ b/pkg/github/__toolsnaps__/list_projects.snap @@ -0,0 +1,28 @@ +{ + "annotations": { + "title": "List projects", + "readOnlyHint": true + }, + "description": "List Projects for a user or organization", + "inputSchema": { + "properties": { + "owner": { + "description": "Owner login (user or organization)", + "type": "string" + }, + "owner_type": { + "description": "Owner type", + "enum": [ + "user", + "organization" + ], + "type": "string" + } + }, + "required": [ + "owner" + ], + "type": "object" + }, + "name": "list_projects" +} diff --git a/pkg/github/__toolsnaps__/update_project_item_field.snap b/pkg/github/__toolsnaps__/update_project_item_field.snap new file mode 100644 index 000000000..da201a738 --- /dev/null +++ b/pkg/github/__toolsnaps__/update_project_item_field.snap @@ -0,0 +1,34 @@ +{ + "annotations": { + "title": "Update project item field", + "readOnlyHint": false + }, + "description": "Update a project item field", + "inputSchema": { + "properties": { + "field_id": { + "description": "Field ID", + "type": "string" + }, + "item_id": { + "description": "Item ID", + "type": "string" + }, + "project_id": { + "description": "Project ID", + "type": "string" + }, + "text_value": { + "description": "Text value", + "type": "string" + } + }, + "required": [ + "project_id", + "item_id", + "field_id" + ], + "type": "object" + }, + "name": "update_project_item_field" +} diff --git a/pkg/github/projects.go b/pkg/github/projects.go new file mode 100644 index 000000000..52a828af0 --- /dev/null +++ b/pkg/github/projects.go @@ -0,0 +1,965 @@ +package github + +import ( + "context" + "fmt" + "strings" + + "github.com/github/github-mcp-server/pkg/translations" + "github.com/go-viper/mapstructure/v2" + "github.com/mark3labs/mcp-go/mcp" + "github.com/mark3labs/mcp-go/server" + "github.com/shurcooL/githubv4" +) + +// ListProjects lists projects for a given user or organization. +func ListProjects(getClient GetGQLClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) { + return mcp.NewTool("list_projects", + mcp.WithDescription(t("TOOL_LIST_PROJECTS_DESCRIPTION", "List Projects for a user or organization")), + mcp.WithToolAnnotation(mcp.ToolAnnotation{Title: t("TOOL_LIST_PROJECTS_USER_TITLE", "List projects"), ReadOnlyHint: ToBoolPtr(true)}), + mcp.WithString("owner", mcp.Required(), mcp.Description("Owner login (user or organization)")), + mcp.WithString("owner_type", mcp.Description("Owner type"), mcp.Enum("user", "organization")), + ), func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) { + owner, err := RequiredParam[string](req, "owner") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + ownerType, err := OptionalParam[string](req, "owner_type") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + if ownerType == "" { + ownerType = "organization" + } + client, err := getClient(ctx) + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + if ownerType == "user" { + var q struct { + User struct { + Projects struct { + Nodes []struct { + ID githubv4.ID + Title githubv4.String + Number githubv4.Int + } + } `graphql:"projectsV2(first: 100)"` + } `graphql:"user(login: $login)"` + } + if err := client.Query(ctx, &q, map[string]any{"login": githubv4.String(owner)}); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + return MarshalledTextResult(q), nil + } + var q struct { + Organization struct { + Projects struct { + Nodes []struct { + ID githubv4.ID + Title githubv4.String + Number githubv4.Int + } + } `graphql:"projectsV2(first: 100)"` + } `graphql:"organization(login: $login)"` + } + if err := client.Query(ctx, &q, map[string]any{"login": githubv4.String(owner)}); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + return MarshalledTextResult(q), nil + } +} + +// GetProject defines a tool that retrieves detailed information about a specific GitHub ProjectV2. +// It takes a project number or name and owner as input and works for both organizations and users. +func GetProject(getClient GetGQLClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) { + return mcp.NewTool("get_project", + mcp.WithDescription(t("TOOL_GET_PROJECT_DESCRIPTION", "Get details for a specific project using its number or name")), + mcp.WithToolAnnotation(mcp.ToolAnnotation{Title: t("TOOL_GET_PROJECT_TITLE", "Get project details"), ReadOnlyHint: ToBoolPtr(true)}), + mcp.WithString("owner", mcp.Required(), mcp.Description("Owner login (user or organization)")), + mcp.WithNumber("number", mcp.Description("Project number (either number or name must be provided)")), + mcp.WithString("name", mcp.Description("Project name (either number or name must be provided)")), + mcp.WithString("owner_type", mcp.Description("Owner type"), mcp.Enum("user", "organization")), + ), func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) { + owner, err := RequiredParam[string](req, "owner") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + + // Get optional parameters + number, numberErr := OptionalParam[float64](req, "number") + name, nameErr := OptionalParam[string](req, "name") + + // Check if parameters were actually provided (not just no error) + nameProvided := nameErr == nil && name != "" + numberProvided := numberErr == nil && number != 0 + + // CORRECTED VALIDATION: + // 1. Check if both were provided + if nameProvided && numberProvided { + return mcp.NewToolResultError("Cannot provide both 'number' and 'name' parameters. Please use only one."), nil + } + // 2. Check if neither was provided + if !nameProvided && !numberProvided { + return mcp.NewToolResultError("Either the 'number' or 'name' parameter must be provided."), nil + } + + ownerType, err := OptionalParam[string](req, "owner_type") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + if ownerType == "" { + ownerType = "organization" + } + + client, err := getClient(ctx) + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + + // Route to the correct helper function based on which parameter was provided + if nameProvided { + return getProjectByName(ctx, client, owner, name, ownerType) + } + + // If it wasn't name, it must be number + projectNumber := int(number) + return getProjectByNumber(ctx, client, owner, projectNumber, ownerType) + } +} + +// Helper function to get project by number +func getProjectByNumber(ctx context.Context, client interface{}, owner string, number int, ownerType string) (*mcp.CallToolResult, error) { + type GraphQLClient interface { + Query(ctx context.Context, q interface{}, variables map[string]interface{}) error + } + + gqlClient := client.(GraphQLClient) + + if ownerType == "user" { + var q struct { + User struct { + ProjectV2 struct { + ID githubv4.ID + Title githubv4.String + Number githubv4.Int + Readme githubv4.String + URL githubv4.URI + } `graphql:"projectV2(number: $projectNumber)"` + } `graphql:"user(login: $owner)"` + } + + variables := map[string]any{ + "owner": githubv4.String(owner), + "projectNumber": githubv4.Int(number), + } + + if err := gqlClient.Query(ctx, &q, variables); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + + // Check if the project was found + if q.User.ProjectV2.Title == "" { + return mcp.NewToolResultError(fmt.Sprintf("Could not find project number %d for user '%s'.", number, owner)), nil + } + + return MarshalledTextResult(q.User.ProjectV2), nil + } else { + var q struct { + Organization struct { + ProjectV2 struct { + ID githubv4.ID + Title githubv4.String + Number githubv4.Int + Readme githubv4.String + URL githubv4.URI + } `graphql:"projectV2(number: $projectNumber)"` + } `graphql:"organization(login: $owner)"` + } + + variables := map[string]any{ + "owner": githubv4.String(owner), + "projectNumber": githubv4.Int(number), + } + + if err := gqlClient.Query(ctx, &q, variables); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + + // Check if the project was found + if q.Organization.ProjectV2.Title == "" { + return mcp.NewToolResultError(fmt.Sprintf("Could not find project number %d for organization '%s'.", number, owner)), nil + } + + return MarshalledTextResult(q.Organization.ProjectV2), nil + } +} + +// Helper function to get project by name with pagination support +func getProjectByName(ctx context.Context, client interface{}, owner string, name string, ownerType string) (*mcp.CallToolResult, error) { + type GraphQLClient interface { + Query(ctx context.Context, q interface{}, variables map[string]interface{}) error + } + + gqlClient := client.(GraphQLClient) + + if ownerType == "user" { + var cursor *githubv4.String + + for { + var q struct { + User struct { + Projects struct { + Nodes []struct { + ID githubv4.ID + Title githubv4.String + Number githubv4.Int + Readme githubv4.String + URL githubv4.URI + } + PageInfo struct { + HasNextPage bool + EndCursor githubv4.String + } + } `graphql:"projectsV2(first: 100, after: $cursor)"` + } `graphql:"user(login: $login)"` + } + + variables := map[string]any{ + "login": githubv4.String(owner), + "cursor": cursor, + } + + if err := gqlClient.Query(ctx, &q, variables); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + + // Search for project by name (case-insensitive exact match first) + for _, project := range q.User.Projects.Nodes { + if strings.EqualFold(string(project.Title), name) { + return MarshalledTextResult(project), nil + } + } + + // Check if we should continue to next page + if !q.User.Projects.PageInfo.HasNextPage { + break + } + cursor = &q.User.Projects.PageInfo.EndCursor + } + + // If exact match not found, do a second pass with partial matching + cursor = nil + for { + var q struct { + User struct { + Projects struct { + Nodes []struct { + ID githubv4.ID + Title githubv4.String + Number githubv4.Int + Readme githubv4.String + URL githubv4.URI + } + PageInfo struct { + HasNextPage bool + EndCursor githubv4.String + } + } `graphql:"projectsV2(first: 100, after: $cursor)"` + } `graphql:"user(login: $login)"` + } + + variables := map[string]any{ + "login": githubv4.String(owner), + "cursor": cursor, + } + + if err := gqlClient.Query(ctx, &q, variables); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + + // Search for project by partial name match + for _, project := range q.User.Projects.Nodes { + if strings.Contains(strings.ToLower(string(project.Title)), strings.ToLower(name)) { + return MarshalledTextResult(project), nil + } + } + + // Check if we should continue to next page + if !q.User.Projects.PageInfo.HasNextPage { + break + } + cursor = &q.User.Projects.PageInfo.EndCursor + } + + return mcp.NewToolResultError(fmt.Sprintf("Could not find project with name '%s' for user '%s'.", name, owner)), nil + } else { + var cursor *githubv4.String + + // First pass: exact match + for { + var q struct { + Organization struct { + Projects struct { + Nodes []struct { + ID githubv4.ID + Title githubv4.String + Number githubv4.Int + Readme githubv4.String + URL githubv4.URI + } + PageInfo struct { + HasNextPage bool + EndCursor githubv4.String + } + } `graphql:"projectsV2(first: 100, after: $cursor)"` + } `graphql:"organization(login: $login)"` + } + + variables := map[string]any{ + "login": githubv4.String(owner), + "cursor": cursor, + } + + if err := gqlClient.Query(ctx, &q, variables); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + + // Search for project by name (case-insensitive exact match first) + for _, project := range q.Organization.Projects.Nodes { + if strings.EqualFold(string(project.Title), name) { + return MarshalledTextResult(project), nil + } + } + + // Check if we should continue to next page + if !q.Organization.Projects.PageInfo.HasNextPage { + break + } + cursor = &q.Organization.Projects.PageInfo.EndCursor + } + + // Second pass: partial match + cursor = nil + for { + var q struct { + Organization struct { + Projects struct { + Nodes []struct { + ID githubv4.ID + Title githubv4.String + Number githubv4.Int + Readme githubv4.String + URL githubv4.URI + } + PageInfo struct { + HasNextPage bool + EndCursor githubv4.String + } + } `graphql:"projectsV2(first: 100, after: $cursor)"` + } `graphql:"organization(login: $login)"` + } + + variables := map[string]any{ + "login": githubv4.String(owner), + "cursor": cursor, + } + + if err := gqlClient.Query(ctx, &q, variables); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + + // Search for project by partial name match + for _, project := range q.Organization.Projects.Nodes { + if strings.Contains(strings.ToLower(string(project.Title)), strings.ToLower(name)) { + return MarshalledTextResult(project), nil + } + } + + // Check if we should continue to next page + if !q.Organization.Projects.PageInfo.HasNextPage { + break + } + cursor = &q.Organization.Projects.PageInfo.EndCursor + } + + return mcp.NewToolResultError(fmt.Sprintf("Could not find project with name '%s' for organization '%s'.", name, owner)), nil + } +} + +// GetProjectStatuses retrieves the Status field options for a specific GitHub ProjectV2. +// It returns the status options with their IDs, names, and descriptions. +func GetProjectStatuses(getClient GetGQLClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) { + return mcp.NewTool("get_project_statuses", + mcp.WithDescription(t("TOOL_GET_PROJECT_STATUSES_DESCRIPTION", "Get status field options for a project")), + mcp.WithToolAnnotation(mcp.ToolAnnotation{Title: t("TOOL_GET_PROJECT_STATUSES_TITLE", "Get project statuses"), ReadOnlyHint: ToBoolPtr(true)}), + mcp.WithString("project_id", mcp.Required(), mcp.Description("The global node ID of the project (e.g., 'PVT_kwDOA_dmc84A7u-a')")), + ), func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) { + projectID, err := RequiredParam[string](req, "project_id") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + + client, err := getClient(ctx) + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + + // This struct defines the shape of the GraphQL query. + // It fetches the Status field for a ProjectV2 by ID. + var q struct { + Node struct { + ProjectV2 struct { + Field struct { + ProjectV2SingleSelectField struct { + ID githubv4.ID + Name githubv4.String + Options []struct { + ID githubv4.ID + Name githubv4.String + Description githubv4.String + } + } `graphql:"... on ProjectV2SingleSelectField"` + } `graphql:"field(name: \"Status\")"` + } `graphql:"... on ProjectV2"` + } `graphql:"node(id: $projectId)"` + } + + variables := map[string]any{ + "projectId": githubv4.ID(projectID), + } + + if err := client.Query(ctx, &q, variables); err != nil { + // Provide a more helpful error message if the ID is malformed. + if err.Error() == "Could not resolve to a node with the global id of '"+projectID+"'" { + return mcp.NewToolResultError(fmt.Sprintf("Invalid project_id: '%s'. Please provide a valid global node ID for a project.", projectID)), nil + } + return mcp.NewToolResultError(err.Error()), nil + } + + // Check if the Status field exists and has options + statusField := q.Node.ProjectV2.Field.ProjectV2SingleSelectField + if statusField.Name == "" { + return mcp.NewToolResultError(fmt.Sprintf("Could not find a Status field for project with ID '%s'. The project might not have a Status field configured.", projectID)), nil + } + + return MarshalledTextResult(statusField), nil + } +} + +// GetProjectFields lists fields for a project. +func GetProjectFields(getClient GetGQLClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) { + return mcp.NewTool("get_project_fields", + mcp.WithDescription(t("TOOL_GET_PROJECT_FIELDS_DESCRIPTION", "Get fields for a project")), + mcp.WithToolAnnotation(mcp.ToolAnnotation{Title: t("TOOL_GET_PROJECT_FIELDS_USER_TITLE", "Get project fields"), ReadOnlyHint: ToBoolPtr(true)}), + mcp.WithString("owner", mcp.Required(), mcp.Description("Owner login")), + mcp.WithString("owner_type", mcp.Description("Owner type"), mcp.Enum("user", "organization")), + mcp.WithNumber("number", mcp.Required(), mcp.Description("Project number")), + ), func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) { + owner, err := RequiredParam[string](req, "owner") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + number, err := RequiredInt(req, "number") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + ownerType, err := OptionalParam[string](req, "owner_type") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + if ownerType == "" { + ownerType = "organization" + } + client, err := getClient(ctx) + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + if ownerType == "user" { + var q struct { + User struct { + Project struct { + Fields struct { + Nodes []struct { + ProjectV2Field struct { + ID githubv4.ID + Name githubv4.String + DataType githubv4.String + } `graphql:"... on ProjectV2Field"` + } + } `graphql:"fields(first: 100)"` + } `graphql:"projectV2(number: $number)"` + } `graphql:"user(login: $login)"` + } + if err := client.Query(ctx, &q, map[string]any{"login": githubv4.String(owner), "number": githubv4.Int(number)}); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + return MarshalledTextResult(q), nil + } + var q struct { + Organization struct { + Project struct { + Fields struct { + Nodes []struct { + ProjectV2Field struct { + ID githubv4.ID + Name githubv4.String + DataType githubv4.String + } `graphql:"... on ProjectV2Field"` + } + } `graphql:"fields(first: 100)"` + } `graphql:"projectV2(number: $number)"` + } `graphql:"organization(login: $login)"` + } + if err := client.Query(ctx, &q, map[string]any{"login": githubv4.String(owner), "number": githubv4.Int(number)}); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + return MarshalledTextResult(q), nil + } +} + +// FieldNameFragment defines the fields we want from a ProjectV2FieldCommon interface. +type FieldNameFragment struct { + Name githubv4.String +} + +// Field represents the 'field' interface on a project item's field value. +// It uses an embedded struct with a graphql tag to act as an inline fragment. +type Field struct { + OnProjectV2FieldCommon FieldNameFragment `graphql:"... on ProjectV2FieldCommon"` +} + +// ProjectItem defines the structure of a single item within a project, +// including its field values and content. +type ProjectItem struct { + ID githubv4.ID + FieldValues struct { + Nodes []struct { + TypeName string `graphql:"__typename"` + // Fragment for Text values + OnTextValue struct { + Text githubv4.String + Field Field + } `graphql:"... on ProjectV2ItemFieldTextValue"` + // Fragment for Date values + OnDateValue struct { + Date githubv4.DateTime + Field Field + } `graphql:"... on ProjectV2ItemFieldDateValue"` + // Fragment for Single Select values + OnSingleSelectValue struct { + Name githubv4.String + Field Field + } `graphql:"... on ProjectV2ItemFieldSingleSelectValue"` + } + } `graphql:"fieldValues(first: 8)"` + Content struct { + TypeName string `graphql:"__typename"` + OnDraftIssue struct { + Title githubv4.String + Body githubv4.String + } `graphql:"... on DraftIssue"` + OnIssue struct { + Title githubv4.String + Assignees struct { + Nodes []struct { + Login githubv4.String + } + } `graphql:"assignees(first: 10)"` + } `graphql:"... on Issue"` + OnPullRequest struct { + Title githubv4.String + Assignees struct { + Nodes []struct { + Login githubv4.String + } + } `graphql:"assignees(first: 10)"` + } `graphql:"... on PullRequest"` + } +} + +func GetProjectItems(getClient GetGQLClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) { + return mcp.NewTool("get_project_items", + mcp.WithDescription(t("TOOL_GET_PROJECT_ITEMS_DESCRIPTION", "Get items for a project")), + mcp.WithToolAnnotation(mcp.ToolAnnotation{Title: t("TOOL_GET_PROJECT_ITEMS_USER_TITLE", "Get project items"), ReadOnlyHint: ToBoolPtr(true)}), + mcp.WithString("owner", mcp.Required(), mcp.Description("Owner login")), + mcp.WithString("owner_type", mcp.Description("Owner type"), mcp.Enum("user", "organization")), + mcp.WithNumber("number", mcp.Required(), mcp.Description("Project number")), + ), func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) { + owner, err := RequiredParam[string](req, "owner") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + number, err := RequiredInt(req, "number") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + ownerType, err := OptionalParam[string](req, "owner_type") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + if ownerType == "" { + ownerType = "organization" + } + + client, err := getClient(ctx) + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + + variables := map[string]any{ + "login": githubv4.String(owner), + "number": githubv4.Int(number), + } + + if ownerType == "user" { + var q struct { + User struct { + Project struct { + Items struct { + Nodes []ProjectItem + } `graphql:"items(first: 100)"` + } `graphql:"projectV2(number: $number)"` + } `graphql:"user(login: $login)"` + } + if err := client.Query(ctx, &q, variables); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + return MarshalledTextResult(q.User.Project.Items), nil + } + + // This code is now reachable and syntactically correct. + var q struct { + Organization struct { + Project struct { + Items struct { + Nodes []ProjectItem + } `graphql:"items(first: 100)"` + } `graphql:"projectV2(number: $number)"` + } `graphql:"organization(login: $login)"` + } + if err := client.Query(ctx, &q, variables); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + return MarshalledTextResult(q.Organization.Project.Items), nil + } +} + +// CreateIssue creates an issue in a repository. +func CreateProjectIssue(getClient GetGQLClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) { + return mcp.NewTool("create_project_issue", + mcp.WithDescription(t("TOOL_CREATE_PROJECT_ISSUE_DESCRIPTION", "Create a new issue")), + mcp.WithToolAnnotation(mcp.ToolAnnotation{Title: t("TOOL_CREATE_PROJECT_ISSUE_USER_TITLE", "Create issue"), ReadOnlyHint: ToBoolPtr(false)}), + mcp.WithString("owner", mcp.Required(), mcp.Description("Repository owner")), + mcp.WithString("repo", mcp.Required(), mcp.Description("Repository name")), + mcp.WithString("title", mcp.Required(), mcp.Description("Issue title")), + mcp.WithString("body", mcp.Description("Issue body")), + ), func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) { + var params struct{ Owner, Repo, Title, Body string } + if err := mapstructure.Decode(req.Params.Arguments, ¶ms); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + client, err := getClient(ctx) + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + var repoQ struct { + Repository struct{ ID githubv4.ID } `graphql:"repository(owner: $owner, name: $name)"` + } + if err := client.Query(ctx, &repoQ, map[string]any{"owner": githubv4.String(params.Owner), "name": githubv4.String(params.Repo)}); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + input := githubv4.CreateIssueInput{RepositoryID: repoQ.Repository.ID, Title: githubv4.String(params.Title)} + if params.Body != "" { + input.Body = githubv4.NewString(githubv4.String(params.Body)) + } + var mut struct { + CreateIssue struct{ Issue struct{ ID githubv4.ID } } `graphql:"createIssue(input: $input)"` + } + if err := client.Mutate(ctx, &mut, input, nil); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + return MarshalledTextResult(mut), nil + } +} + +// AddIssueToProject adds an issue to a project by ID. +func AddIssueToProject(getClient GetGQLClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) { + return mcp.NewTool("add_issue_to_project", + mcp.WithDescription(t("TOOL_ADD_ISSUE_TO_PROJECT_DESCRIPTION", "Add an issue to a project")), + mcp.WithToolAnnotation(mcp.ToolAnnotation{Title: t("TOOL_ADD_ISSUE_TO_PROJECT_USER_TITLE", "Add issue to project"), ReadOnlyHint: ToBoolPtr(false)}), + mcp.WithString("project_id", mcp.Required(), mcp.Description("Project ID")), + mcp.WithString("issue_id", mcp.Required(), mcp.Description("Issue node ID")), + ), func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) { + projectID, err := RequiredParam[string](req, "project_id") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + issueID, err := RequiredParam[string](req, "issue_id") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + client, err := getClient(ctx) + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + var mut struct { + AddProjectV2ItemById struct { + Item struct{ ID githubv4.ID } + } `graphql:"addProjectV2ItemById(input: $input)"` + } + input := githubv4.AddProjectV2ItemByIdInput{ProjectID: githubv4.ID(projectID), ContentID: githubv4.ID(issueID)} + if err := client.Mutate(ctx, &mut, input, nil); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + return MarshalledTextResult(mut), nil + } +} + +// UpdateProjectItemStatus updates the status field of a project item, allowing items to be moved between columns. +func UpdateProjectItemStatus(getClient GetGQLClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) { + return mcp.NewTool("update_project_item_status", + mcp.WithDescription(t("TOOL_UPDATE_PROJECT_ITEM_STATUS_DESCRIPTION", "Update a project item's status to move it between columns")), + mcp.WithToolAnnotation(mcp.ToolAnnotation{Title: t("TOOL_UPDATE_PROJECT_ITEM_STATUS_USER_TITLE", "Update project item status"), ReadOnlyHint: ToBoolPtr(false)}), + mcp.WithString("project_id", mcp.Required(), mcp.Description("Project ID")), + mcp.WithString("item_id", mcp.Required(), mcp.Description("Item ID")), + mcp.WithString("status_option_id", mcp.Required(), mcp.Description("Status option ID (use get_project_statuses to find available options)")), + ), func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) { + projectID, err := RequiredParam[string](req, "project_id") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + itemID, err := RequiredParam[string](req, "item_id") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + statusOptionID, err := RequiredParam[string](req, "status_option_id") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + + client, err := getClient(ctx) + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + + var statusFieldQuery struct { + Node struct { + ProjectV2 struct { + Field struct { + ProjectV2SingleSelectField struct { + ID githubv4.ID + Name githubv4.String + Options []struct { + ID githubv4.ID + Name githubv4.String + } + } `graphql:"... on ProjectV2SingleSelectField"` + } `graphql:"field(name: \"Status\")"` + } `graphql:"... on ProjectV2"` + } `graphql:"node(id: $projectId)"` + } + + variables := map[string]any{ + "projectId": githubv4.ID(projectID), + } + + if err := client.Query(ctx, &statusFieldQuery, variables); err != nil { + return mcp.NewToolResultError(fmt.Sprintf("Failed to get Status field for project: %s", err.Error())), nil + } + + statusField := statusFieldQuery.Node.ProjectV2.Field.ProjectV2SingleSelectField + if statusField.ID == "" { + return mcp.NewToolResultError(fmt.Sprintf("Could not find a Status field for project with ID '%s'. The project might not have a Status field configured.", projectID)), nil + } + + // Validate that the provided status option ID exists + var validOption bool + var optionName string + for _, option := range statusField.Options { + if option.ID.(string) == statusOptionID { + validOption = true + optionName = string(option.Name) + break + } + } + + if !validOption { + return mcp.NewToolResultError(fmt.Sprintf("Invalid status_option_id '%s' for project '%s'. Use get_project_statuses to see available options.", statusOptionID, projectID)), nil + } + + val := githubv4.ProjectV2FieldValue{ + SingleSelectOptionID: githubv4.NewString(githubv4.String(statusOptionID)), + } + + var mut struct { + UpdateProjectV2ItemFieldValue struct { + ProjectV2Item struct { + ID githubv4.ID + } `graphql:"projectV2Item"` + } `graphql:"updateProjectV2ItemFieldValue(input: $input)"` + } + + input := githubv4.UpdateProjectV2ItemFieldValueInput{ + ProjectID: githubv4.ID(projectID), + ItemID: githubv4.ID(itemID), + FieldID: statusField.ID, + Value: val, + } + + if err := client.Mutate(ctx, &mut, input, nil); err != nil { + return mcp.NewToolResultError(fmt.Sprintf("Failed to update project item status: %s", err.Error())), nil + } + + result := map[string]interface{}{ + "success": true, + "message": fmt.Sprintf("Successfully updated item status to '%s'", optionName), + "project_id": projectID, + "item_id": itemID, + "new_status": optionName, + "status_option_id": statusOptionID, + } + + return MarshalledTextResult(result), nil + } +} + + +// UpdateProjectItemField updates a field value on a project item. +func UpdateProjectItemField(getClient GetGQLClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) { + return mcp.NewTool("update_project_item_field", + mcp.WithDescription(t("TOOL_UPDATE_PROJECT_ITEM_FIELD_DESCRIPTION", "Update a project item field")), + mcp.WithToolAnnotation(mcp.ToolAnnotation{Title: t("TOOL_UPDATE_PROJECT_ITEM_FIELD_USER_TITLE", "Update project item field"), ReadOnlyHint: ToBoolPtr(false)}), + mcp.WithString("project_id", mcp.Required(), mcp.Description("Project ID")), + mcp.WithString("item_id", mcp.Required(), mcp.Description("Item ID")), + mcp.WithString("field_id", mcp.Required(), mcp.Description("Field ID")), + mcp.WithString("text_value", mcp.Description("Text value")), + ), func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) { + projectID, err := RequiredParam[string](req, "project_id") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + itemID, err := RequiredParam[string](req, "item_id") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + fieldID, err := RequiredParam[string](req, "field_id") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + textValue, err := OptionalParam[string](req, "text_value") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + client, err := getClient(ctx) + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + val := githubv4.ProjectV2FieldValue{} + if textValue != "" { + val.Text = githubv4.NewString(githubv4.String(textValue)) + } + var mut struct { + UpdateProjectV2ItemFieldValue struct{ Typename githubv4.String } `graphql:"updateProjectV2ItemFieldValue(input: $input)"` + } + input := githubv4.UpdateProjectV2ItemFieldValueInput{ProjectID: githubv4.ID(projectID), ItemID: githubv4.ID(itemID), FieldID: githubv4.ID(fieldID), Value: val} + if err := client.Mutate(ctx, &mut, input, nil); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + return MarshalledTextResult(mut), nil + } +} + +// CreateDraftIssue creates a draft issue in a project. +func CreateDraftIssue(getClient GetGQLClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) { + return mcp.NewTool("create_draft_issue", + mcp.WithDescription(t("TOOL_CREATE_DRAFT_ISSUE_DESCRIPTION", "Create a draft issue in a project")), + mcp.WithToolAnnotation(mcp.ToolAnnotation{Title: t("TOOL_CREATE_DRAFT_ISSUE_USER_TITLE", "Create draft issue"), ReadOnlyHint: ToBoolPtr(false)}), + mcp.WithString("project_id", mcp.Required(), mcp.Description("Project ID")), + mcp.WithString("title", mcp.Required(), mcp.Description("Issue title")), + mcp.WithString("body", mcp.Description("Issue body")), + ), func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) { + projectID, err := RequiredParam[string](req, "project_id") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + title, err := RequiredParam[string](req, "title") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + body, err := OptionalParam[string](req, "body") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + + client, err := getClient(ctx) + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + + input := githubv4.AddProjectV2DraftIssueInput{ + ProjectID: githubv4.ID(projectID), + Title: githubv4.String(title), + } + if body != "" { + input.Body = githubv4.NewString(githubv4.String(body)) + } + + // CORRECTED: The payload field is 'projectItem', not 'item'. + var mut struct { + AddProjectV2DraftIssue struct { + ProjectItem struct { + ID githubv4.ID + } + } `graphql:"addProjectV2DraftIssue(input: $input)"` + } + + // The library requires a pointer to the mutation struct, the input, and variables (nil in this case). + if err := client.Mutate(ctx, &mut, input, nil); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + + return MarshalledTextResult(mut.AddProjectV2DraftIssue.ProjectItem), nil + } +} + +// DeleteProjectItem removes an item from a project. +func DeleteProjectItem(getClient GetGQLClientFn, t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) { + return mcp.NewTool("delete_project_item", + mcp.WithDescription(t("TOOL_DELETE_PROJECT_ITEM_DESCRIPTION", "Delete a project item")), + mcp.WithToolAnnotation(mcp.ToolAnnotation{Title: t("TOOL_DELETE_PROJECT_ITEM_USER_TITLE", "Delete project item"), ReadOnlyHint: ToBoolPtr(false)}), + mcp.WithString("project_id", mcp.Required(), mcp.Description("Project ID")), + mcp.WithString("item_id", mcp.Required(), mcp.Description("Item ID")), + ), func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) { + projectID, err := RequiredParam[string](req, "project_id") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + itemID, err := RequiredParam[string](req, "item_id") + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + client, err := getClient(ctx) + if err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + + var mut struct { + DeleteProjectV2Item struct { + DeletedItemID githubv4.ID `graphql:"deletedItemId"` + } `graphql:"deleteProjectV2Item(input: $input)"` + } + + input := githubv4.DeleteProjectV2ItemInput{ + ProjectID: githubv4.ID(projectID), + ItemID: githubv4.ID(itemID), + } + + if err := client.Mutate(ctx, &mut, input, nil); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + + return MarshalledTextResult(mut.DeleteProjectV2Item), nil + } +} + diff --git a/pkg/github/projects_test.go b/pkg/github/projects_test.go new file mode 100644 index 000000000..5212e0e67 --- /dev/null +++ b/pkg/github/projects_test.go @@ -0,0 +1,105 @@ +package github + +import ( + "context" + "testing" + + "github.com/github/github-mcp-server/internal/githubv4mock" + "github.com/github/github-mcp-server/internal/toolsnaps" + "github.com/github/github-mcp-server/pkg/translations" + "github.com/mark3labs/mcp-go/mcp" + "github.com/shurcooL/githubv4" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func Test_ListProjects(t *testing.T) { + mockClient := githubv4mock.NewMockedHTTPClient( + githubv4mock.NewQueryMatcher( + struct { + Organization struct { + Projects struct { + Nodes []struct{ ID githubv4.ID } + } `graphql:"projectsV2(first: 100)"` + } `graphql:"organization(login: $login)"` + }{}, + map[string]any{"login": githubv4.String("acme")}, + githubv4mock.DataResponse(map[string]any{"organization": map[string]any{"projectsV2": map[string]any{"nodes": []any{}}}}), + ), + ) + tool, handler := ListProjects(stubGetGQLClientFn(githubv4.NewClient(mockClient)), translations.NullTranslationHelper) + require.NoError(t, toolsnaps.Test(tool.Name, tool)) + + res, err := handler(context.Background(), createMCPRequest(map[string]any{"owner": "acme"})) + require.NoError(t, err) + assert.NotNil(t, res) +} + +func Test_AddIssueToProject(t *testing.T) { + mockClient := githubv4mock.NewMockedHTTPClient( + githubv4mock.NewMutationMatcher( + struct { + AddProjectV2ItemById struct{ Item struct{ ID githubv4.ID } } `graphql:"addProjectV2ItemById(input: $input)"` + }{}, + githubv4.AddProjectV2ItemByIdInput{ProjectID: "proj", ContentID: "issue"}, + nil, + githubv4mock.DataResponse(map[string]any{"addProjectV2ItemById": map[string]any{"item": map[string]any{"id": "1"}}}), + ), + ) + tool, handler := AddIssueToProject(stubGetGQLClientFn(githubv4.NewClient(mockClient)), translations.NullTranslationHelper) + require.NoError(t, toolsnaps.Test(tool.Name, tool)) + + res, err := handler(context.Background(), createMCPRequest(map[string]any{"project_id": "proj", "issue_id": "issue"})) + require.NoError(t, err) + assert.NotNil(t, res) +} + +func Test_CreateProjectIssue(t *testing.T) { + mockClient := githubv4mock.NewMockedHTTPClient( + githubv4mock.NewQueryMatcher( + struct { + Repository struct{ ID githubv4.ID } `graphql:"repository(owner: $owner, name: $name)"` + }{}, + map[string]any{"owner": githubv4.String("acme"), "name": githubv4.String("demo")}, + githubv4mock.DataResponse(map[string]any{"repository": map[string]any{"id": "123"}}), + ), + githubv4mock.NewMutationMatcher( + struct { + CreateIssue struct{ Issue struct{ ID githubv4.ID } } `graphql:"createIssue(input: $input)"` + }{}, + githubv4.CreateIssueInput{RepositoryID: "123", Title: githubv4.String("hello")}, + nil, + githubv4mock.DataResponse(map[string]any{"createIssue": map[string]any{"issue": map[string]any{"id": "456"}}}), + ), + ) + tool, handler := CreateProjectIssue(stubGetGQLClientFn(githubv4.NewClient(mockClient)), translations.NullTranslationHelper) + require.NoError(t, toolsnaps.Test(tool.Name, tool)) + + res, err := handler(context.Background(), createMCPRequest(map[string]any{"owner": "acme", "repo": "demo", "title": "hello"})) + require.NoError(t, err) + assert.NotNil(t, res) +} + +func Test_ProjectToolSchemas(t *testing.T) { + client := githubv4.NewClient(nil) + tools := []mcp.Tool{} + t1, _ := ListProjects(stubGetGQLClientFn(client), translations.NullTranslationHelper) + tools = append(tools, t1) + t2, _ := GetProjectFields(stubGetGQLClientFn(client), translations.NullTranslationHelper) + tools = append(tools, t2) + t3, _ := GetProjectItems(stubGetGQLClientFn(client), translations.NullTranslationHelper) + tools = append(tools, t3) + t4, _ := CreateProjectIssue(stubGetGQLClientFn(client), translations.NullTranslationHelper) + tools = append(tools, t4) + t5, _ := AddIssueToProject(stubGetGQLClientFn(client), translations.NullTranslationHelper) + tools = append(tools, t5) + t6, _ := UpdateProjectItemField(stubGetGQLClientFn(client), translations.NullTranslationHelper) + tools = append(tools, t6) + t7, _ := CreateDraftIssue(stubGetGQLClientFn(client), translations.NullTranslationHelper) + tools = append(tools, t7) + t8, _ := DeleteProjectItem(stubGetGQLClientFn(client), translations.NullTranslationHelper) + tools = append(tools, t8) + for _, tool := range tools { + require.NoError(t, toolsnaps.Test(tool.Name, tool)) + } +} diff --git a/pkg/github/tools.go b/pkg/github/tools.go index b50499650..9061e9021 100644 --- a/pkg/github/tools.go +++ b/pkg/github/tools.go @@ -103,6 +103,22 @@ func DefaultToolsetGroup(readOnly bool, getClient GetClientFn, getGQLClient GetG toolsets.NewServerTool(SubmitPendingPullRequestReview(getGQLClient, t)), toolsets.NewServerTool(DeletePendingPullRequestReview(getGQLClient, t)), ) + projects := toolsets.NewToolset("projects", "GitHub Projects V2 management tools"). + AddReadTools( + toolsets.NewServerTool(ListProjects(getGQLClient, t)), + toolsets.NewServerTool(GetProject(getGQLClient, t)), + toolsets.NewServerTool(GetProjectFields(getGQLClient, t)), + toolsets.NewServerTool(GetProjectStatuses(getGQLClient, t)), + toolsets.NewServerTool(GetProjectItems(getGQLClient, t)), + ). + AddWriteTools( + toolsets.NewServerTool(CreateProjectIssue(getGQLClient, t)), + toolsets.NewServerTool(AddIssueToProject(getGQLClient, t)), + toolsets.NewServerTool(UpdateProjectItemField(getGQLClient, t)), + toolsets.NewServerTool(UpdateProjectItemStatus(getGQLClient, t)), + toolsets.NewServerTool(CreateDraftIssue(getGQLClient, t)), + toolsets.NewServerTool(DeleteProjectItem(getGQLClient, t)), + ) codeSecurity := toolsets.NewToolset("code_security", "Code security related tools, such as GitHub Code Scanning"). AddReadTools( toolsets.NewServerTool(GetCodeScanningAlert(getClient, t)), @@ -185,6 +201,7 @@ func DefaultToolsetGroup(readOnly bool, getClient GetClientFn, getGQLClient GetG tsg.AddToolset(orgs) tsg.AddToolset(users) tsg.AddToolset(pullRequests) + tsg.AddToolset(projects) tsg.AddToolset(actions) tsg.AddToolset(codeSecurity) tsg.AddToolset(secretProtection) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy