Add create_discussion tool to discussions toolset#1519
Add create_discussion tool to discussions toolset#1519furkankoykiran wants to merge 1 commit intogithub:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new create_discussion tool to enable programmatic creation of GitHub Discussions through the MCP server. The implementation uses GraphQL mutations and follows existing patterns in the codebase for write operations.
Key changes:
- New
CreateDiscussionfunction using GraphQL mutation API - Registration of the tool in the discussions toolset as a write tool
- Comprehensive unit tests covering various scenarios
- Generated toolsnap for API schema validation
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/github/discussions.go | Implements the CreateDiscussion function with GraphQL mutation, parameter validation, and error handling. Supports both repository-level and organization-level discussions (via .github repo). |
| pkg/github/tools.go | Registers CreateDiscussion as a write tool in the discussions toolset. |
| pkg/github/discussions_test.go | Adds comprehensive unit tests covering successful creation, organization-level discussions, missing parameters, and error scenarios (repository/category not found). |
| pkg/github/toolsnaps/create_discussion.snap | Tool schema snapshot for API validation (needs regeneration after fixing ReadOnlyHint issue). |
| README.md | Updates tool documentation with the new create_discussion tool and its parameters. |
| docs/remote-server.md | Changes "Default" to "all" in the toolset table (appears unrelated to this PR). |
| { | ||
| "annotations": { | ||
| "title": "Create discussion" | ||
| }, |
There was a problem hiding this comment.
The toolsnap is missing the readOnlyHint field that should be set to false for write operations. This needs to be regenerated after adding ReadOnlyHint: false to the tool annotations in discussions.go. Run UPDATE_TOOLSNAPS=true go test ./... to update the snapshot after fixing the code.
| }, | |
| }, | |
| "readOnlyHint": false, |
docs/remote-server.md
Outdated
| | Name | Description | API URL | 1-Click Install (VS Code) | Read-only Link | 1-Click Read-only Install (VS Code) | | ||
| |----------------|--------------------------------------------------|-------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| | Default | ["Default" toolset](../README.md#default-toolset) | 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) | | ||
| | 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) | |
There was a problem hiding this comment.
This change from "Default" to "all" appears to be unrelated to adding the create_discussion tool. If this is an intentional update to the remote server documentation, it should be in a separate commit or PR. Otherwise, this line should remain as "Default" to match line 91 which still references "Default toolset".
| | 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) | | |
| | Default | 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) | |
| Name: "create_discussion", | ||
| Description: t("TOOL_CREATE_DISCUSSION_DESCRIPTION", "Create a new discussion in a repository or organisation."), | ||
| Annotations: &mcp.ToolAnnotations{ | ||
| Title: t("TOOL_CREATE_DISCUSSION_USER_TITLE", "Create discussion"), |
There was a problem hiding this comment.
Missing ReadOnlyHint: false annotation. Write operations like create_discussion should explicitly set ReadOnlyHint: false to indicate they perform mutations. This is consistent with other write tools in the codebase (see create_gist, label_write, create_issue, etc.).
| Title: t("TOOL_CREATE_DISCUSSION_USER_TITLE", "Create discussion"), | |
| Title: t("TOOL_CREATE_DISCUSSION_USER_TITLE", "Create discussion"), | |
| ReadOnlyHint: mcp.BoolPtr(false), |
pkg/github/discussions_test.go
Outdated
| require.NoError(t, toolsnaps.Test(toolDef.Name, toolDef)) | ||
|
|
||
| assert.Equal(t, "create_discussion", toolDef.Name) | ||
| assert.NotEmpty(t, toolDef.Description) | ||
| schema, ok := toolDef.InputSchema.(*jsonschema.Schema) | ||
| require.True(t, ok, "InputSchema should be *jsonschema.Schema") | ||
| assert.Contains(t, schema.Properties, "owner") | ||
| assert.Contains(t, schema.Properties, "repo") | ||
| assert.Contains(t, schema.Properties, "categoryId") | ||
| assert.Contains(t, schema.Properties, "title") | ||
| assert.Contains(t, schema.Properties, "body") | ||
| assert.ElementsMatch(t, schema.Required, []string{"owner", "categoryId", "title", "body"}) |
There was a problem hiding this comment.
The test should verify that ReadOnlyHint is false for the write tool, similar to how other write tool tests do (e.g., create_gist, label_write). Add:
assert.False(t, toolDef.Annotations.ReadOnlyHint, "create_discussion tool should not be read-only")This PR adds a new CreateDiscussion tool that allows users to create discussions in a GitHub repository or at the organisation level. Changes: - Add CreateDiscussion function with new NewTool() pattern in discussions.go - Add getDiscussionRepositoryID helper function - Add comprehensive unit tests in discussions_test.go - Add toolsnap for create_discussion tool
e02cd14 to
e854a95
Compare
|
Hey @SamMorrowDrums 👋 Just wanted to give a heads up - I've rebased this PR on latest main to fix the conflicts that came up after all the recent refactoring. Had to reimplement the whole thing using the new Would appreciate a review when you get a chance! Let me know if anything needs adjustment. |
Closes #1517
This PR adds a new
create_discussiontool to the discussions toolset, enabling programmatic creation of GitHub Discussions through the MCP server.Changes
CreateDiscussionfunction inpkg/github/discussions.gousing GraphQL mutationTesting
script/generate-docsThe tool follows existing patterns in the codebase and integrates cleanly with the current discussions toolset structure.