- Notifications
You must be signed in to change notification settings - Fork3.1k
Add create_discussion tool to discussions toolset#1519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Add create_discussion tool to discussions toolset#1519
Conversation
Implements GraphQL mutation for creating discussions programmatically.Enables AI agents to create discussions in repositories and organizations.Closesgithub#1517
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull request overview
This PR adds a newcreate_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 theCreateDiscussion function with GraphQL mutation, parameter validation, and error handling. Supports both repository-level and organization-level discussions (via.github repo). |
| pkg/github/tools.go | RegistersCreateDiscussion 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 newcreate_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" | ||
| }, |
CopilotAIDec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The toolsnap is missing thereadOnlyHint field that should be set tofalse for write operations. This needs to be regenerated after addingReadOnlyHint: false to the tool annotations indiscussions.go. RunUPDATE_TOOLSNAPS=true go test ./... to update the snapshot after fixing the code.
| }, | |
| }, | |
| "readOnlyHint":false, |
| | 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)| |
CopilotAIDec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This change from "Default" to "all" appears to be unrelated to adding thecreate_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"), |
CopilotAIDec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
MissingReadOnlyHint: false annotation. Write operations likecreate_discussion should explicitly setReadOnlyHint: false to indicate they perform mutations. This is consistent with other write tools in the codebase (seecreate_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), |
| 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"}) |
CopilotAIDec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The test should verify thatReadOnlyHint isfalse 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")
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.