diff --git a/README.md b/README.md index c8a55ea7b..7d2def40e 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" @@ -240,7 +249,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)**. @@ -279,48 +288,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) @@ -330,21 +344,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) @@ -353,6 +371,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) @@ -360,6 +379,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) @@ -371,17 +391,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) @@ -400,6 +423,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) @@ -428,6 +452,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) @@ -445,11 +470,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) @@ -457,6 +484,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) @@ -476,12 +504,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) @@ -500,12 +530,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) @@ -513,11 +545,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) @@ -527,11 +561,13 @@ The following sets of tools are available (all are on by default): - `title`: Issue title (string, required) - **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) @@ -539,6 +575,7 @@ The following sets of tools are available (all are on by default): - `repo`: Repository name (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) @@ -550,6 +587,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) @@ -557,12 +595,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) @@ -571,6 +611,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) @@ -597,13 +638,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) @@ -613,10 +657,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) @@ -646,6 +692,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) @@ -658,6 +705,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) @@ -666,12 +714,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) @@ -682,26 +732,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) @@ -709,16 +764,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) @@ -730,6 +788,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) @@ -738,11 +797,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) @@ -752,6 +813,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) @@ -759,6 +821,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) @@ -783,12 +846,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) @@ -798,12 +863,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) @@ -811,11 +878,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) @@ -823,6 +892,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) @@ -830,17 +900,20 @@ The following sets of tools are available (all are on by default): - `sha`: Accepts optional commit SHA. If specified, it will be used instead of ref (string, optional) - **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) @@ -849,12 +922,14 @@ The following sets of tools are available (all are on by default): - `sha`: Commit SHA, branch or tag name to list commits of. If not provided, uses the default branch of the repository. If a commit SHA is provided, will list commits up to that SHA. (string, optional) - **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) @@ -862,6 +937,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) @@ -880,6 +956,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) @@ -913,12 +990,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)
@@ -1011,7 +1088,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": [ @@ -1075,4 +1153,4 @@ The exported Go API of this module should currently be considered unstable, and ## License -This project is licensed under the terms of the MIT open source license. Please refer to [MIT](./LICENSE) for the full terms. \ No newline at end of file +This project is licensed under the terms of the MIT open source license. Please refer to [MIT](./LICENSE) for the full terms. 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..f8f20c9b9 --- /dev/null +++ b/pkg/github/projects.go @@ -0,0 +1,387 @@ +package github + +import ( + "context" + + "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 + } +} + +// 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 + } +} + +// GetProjectItems lists items for a project. +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 + } + if ownerType == "user" { + var q struct { + User struct { + Project struct { + Items struct { + Nodes []struct { + ID githubv4.ID + } + } `graphql:"items(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 { + Items struct { + Nodes []struct{ ID githubv4.ID } + } `graphql:"items(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 + } +} + +// 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 + } +} + +// 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)) + } + var mut struct { + AddProjectV2DraftIssue struct{ Item struct{ ID githubv4.ID } } `graphql:"addProjectV2DraftIssue(input: $input)"` + } + if err := client.Mutate(ctx, &mut, input, nil); err != nil { + return mcp.NewToolResultError(err.Error()), nil + } + return MarshalledTextResult(mut), 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{ Typename githubv4.String } `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), 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 b41ba9467..1cc56364f 100644 --- a/pkg/github/tools.go +++ b/pkg/github/tools.go @@ -100,6 +100,19 @@ 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(GetProjectFields(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(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)), @@ -180,6 +193,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)