Skip to content

feat: provide tool annotations #308

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025
Merged

feat: provide tool annotations #308

merged 1 commit into from
Apr 23, 2025

Conversation

SamMorrowDrums
Copy link
Collaborator

@SamMorrowDrums SamMorrowDrums commented Apr 18, 2025

Closes: #306

We can provide tool annotations as part of the tool specification. This PR sets the descriptions (with ability to override translations), and the ReadOnlyHint.

I tried to make the descriptions more human readable as intended also. These are the translation file entries:

  "TOOL_ADD_ISSUE_COMMENT_USER_TITLE": "Add comment to issue",
  "TOOL_ADD_PULL_REQUEST_REVIEW_COMMENT_USER_TITLE": "Add review comment to pull request",
  "TOOL_CREATE_BRANCH_USER_TITLE": "Create branch",
  "TOOL_CREATE_ISSUE_USER_TITLE": "Open new issue",
  "TOOL_CREATE_OR_UPDATE_FILE_USER_TITLE": "Create or update file",
  "TOOL_CREATE_PULL_REQUEST_REVIEW_USER_TITLE": "Submit pull request review",
  "TOOL_CREATE_PULL_REQUEST_USER_TITLE": "Open new pull request",
  "TOOL_CREATE_REPOSITORY_USER_TITLE": "Create repository",
  "TOOL_FORK_REPOSITORY_USER_TITLE": "Fork repository",
  "TOOL_GET_CODE_SCANNING_ALERT_USER_TITLE": "Get Code Scanning alert",
  "TOOL_GET_COMMITS_USER_TITLE": "Get commit details",
  "TOOL_GET_FILE_CONTENTS_USER_TITLE": "Get file or directory contents",
  "TOOL_GET_ISSUE_COMMENTS_USER_TITLE": "Get issue comments",
  "TOOL_GET_ISSUE_USER_TITLE": "Get issue details",
  "TOOL_GET_ME_USER_TITLE": "Fetch my user profile",
  "TOOL_GET_PULL_REQUEST_COMMENTS_USER_TITLE": "Get pull request comments",
  "TOOL_GET_PULL_REQUEST_FILES_USER_TITLE": "Get pull request changed files",
  "TOOL_GET_PULL_REQUEST_REVIEWS_USER_TITLE": "Get pull request reviews",
  "TOOL_GET_PULL_REQUEST_STATUS_USER_TITLE": "Get pull request status",
  "TOOL_GET_PULL_REQUEST_USER_TITLE": "Get pull request details",
  "TOOL_GET_SECRET_SCANNING_ALERT_USER_TITLE": "Get Secret Scanning alert",
  "TOOL_LIST_BRANCHES_USER_TITLE": "List branches",
  "TOOL_LIST_CODE_SCANNING_ALERTS_USER_TITLE": "List code scanning alerts",
  "TOOL_LIST_COMMITS_USER_TITLE": "List commits",
  "TOOL_LIST_ISSUES_USER_TITLE": "List issues",
  "TOOL_LIST_PULL_REQUESTS_USER_TITLE": "List pull requests",
  "TOOL_LIST_SECRET_SCANNING_ALERTS_USER_TITLE": "List secret scanning alerts",
  "TOOL_MERGE_PULL_REQUEST_USER_TITLE": "Merge a pull request",
  "TOOL_PUSH_FILES_USER_TITLE": "Push files to repository",
  "TOOL_SEARCH_CODE_USER_TITLE": "Search code",
  "TOOL_SEARCH_ISSUES_USER_TITLE": "Search issues",
  "TOOL_SEARCH_REPOSITORIES_USER_TITLE": "Search repositories",
  "TOOL_SEARCH_USERS_USER_TITLE": "Search users",
  "TOOL_UPDATE_ISSUE_USER_TITLE": "Edit issue",
  "TOOL_UPDATE_PULL_REQUEST_BRANCH_USER_TITLE": "Update pull request branch",
  "TOOL_UPDATE_PULL_REQUEST_USER_TITLE": "Update pull request"

@Copilot Copilot AI review requested due to automatic review settings April 18, 2025 04:15
@SamMorrowDrums SamMorrowDrums requested a review from a team as a code owner April 18, 2025 04:15
Copy link
Contributor

@Copilot Copilot AI left a 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 implements tool annotations to enhance the human-readable titles and descriptions for each tool in the GitHub MCP Server. Key changes include updating the mcp-go version in third-party licenses, adding the mcp.WithToolAnnotation field in multiple tool definitions, and refining tool descriptions for clarity.

Reviewed Changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 1 comment.

File Description
third-party-licenses.*.md Updated mcp-go license version to v0.21.1
pkg/toolsets/toolsets.go Added explicit annotation settings for write/read tools
pkg/github/*.go Added mcp.WithToolAnnotation to enhance tool specifications
pkg/github/context_tools.go Added tool annotation for GetMe with a typo in the title
Files not reviewed (1)
  • go.mod: Language not supported

@SamMorrowDrums SamMorrowDrums force-pushed the tool-annotations branch 3 times, most recently from 145357a to 4e1bd11 Compare April 18, 2025 04:52
Copy link
Collaborator

@williammartin williammartin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, the only thing that jumps out to me is that the logic for whether something is read-only now lives in two places. It would be my preference to have the toolset registration use the hints here, so that the state is declarative; this will make it easier to use for docs generation.

Comment on lines +61 to +65
for _, tool := range tools {
if tool.Tool.Annotations.ReadOnlyHint {
panic(fmt.Sprintf("tool (%s) is incorrectly annotated as read-only", tool.Tool.Name))
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should probably be tested, but if you're open to it I'd like to flip this and see if we can use the ReadOnlyHint declaratively to build the toolsets?

@williammartin
Copy link
Collaborator

Bypassing the "Merging is blocked" since I pushed last because the only thing I did was fix merge conflicts on the go.mod and third party licenses.

@williammartin williammartin merged commit a58937c into main Apr 23, 2025
16 checks passed
@williammartin williammartin deleted the tool-annotations branch April 23, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adopt tool annotations for title and readOnlyHint
2 participants