Uh oh!
There was an error while loading. Please reload this page.
feat: add a framework for translations - #25
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements a new translation framework that enables overriding tool and resource descriptions through environment variables and JSON configuration. The key changes include updating all GitHub tool and resource functions to accept a translation function parameter, modifying tests to pass a default translation function, and adding preliminary translation support in the server initialization.
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/github/server.go | Updated NewServer to retrieve and pass the translation helper. |
| pkg/github/repositories.go | Updated tool functions to accept the translation function. |
| pkg/github/search.go | Updated search tool functions to use the translation function. |
| pkg/github/issues.go | Updated issue tool functions to use the translation function. |
| pkg/github/pullrequests.go | Updated pull request tool functions to accept the translation function. |
| pkg/github/code_scanning.go | Updated code scanning tool functions to use the translation function. |
| Various test files | Modified test cases to pass the default translation function. |
Tip: Leave feedback on Copilot's review comments with the 👎 and 👍 buttons to help improve review quality. Learn more
Uh oh!
There was an error while loading. Please reload this page.
26f918e to
ee78b9aCompare
Closes#24
i18n / Overriding descriptions
The descriptions of the tools can be overridden by creating a github-mcp-server.json file in the same directory as the binary.
The file should contain a JSON object with the tool names as keys and the new descriptions as values.
For example:
{ "TOOL_ADD_ISSUE_COMMENT_DESCRIPTION": "an alternative description", "TOOL_CREATE_BRANCH_DESCRIPTION": "Create a new branch in a GitHub repository" }You can create an export of the current translations by running the binary with the
--export-translationsflag.This flag will preserve any translations/overrides you have made, while adding any new translations that have been added to the binary since the last time you exported.
You can also use ENV vars to override the descriptions. The environment variable names are the same as the keys in the JSON file,
prefixed with
GITHUB_MCP_and all uppercase.For example, to override the
TOOL_ADD_ISSUE_COMMENT_DESCRIPTIONtool, you can set the following environment variable:The JSON Dump
So far, I have drawn the line at descriptions, but parameters can easily be added, I just didn't want this PR to touch any more parts. This is the whole shebang:
{ "RESOURCE_REPOSITORY_CONTENT_BRANCH_DESCRIPTION": "Repository Content for specific branch", "RESOURCE_REPOSITORY_CONTENT_COMMIT_DESCRIPTION": "Repository Content for specific commit", "RESOURCE_REPOSITORY_CONTENT_DESCRIPTION": "Repository Content", "RESOURCE_REPOSITORY_CONTENT_PR_DESCRIPTION": "Repository Content for specific pull request", "RESOURCE_REPOSITORY_CONTENT_TAG_DESCRIPTION": "Repository Content for specific tag", "TOOL_ADD_ISSUE_COMMENT_DESCRIPTION": "Add a comment to an existing issue", "TOOL_CREATE_BRANCH_DESCRIPTION": "Create a new branch in a GitHub repository", "TOOL_CREATE_OR_UPDATE_FILE_DESCRIPTION": "Create or update a single file in a GitHub repository", "TOOL_CREATE_REPOSITORY_DESCRIPTION": "Create a new GitHub repository in your account", "TOOL_FORK_REPOSITORY_DESCRIPTION": "Fork a GitHub repository to your account or specified organization", "TOOL_GET_CODE_SCANNING_ALERT_DESCRIPTION": "Get details of a specific code scanning alert in a GitHub repository.", "TOOL_GET_FILE_CONTENTS_DESCRIPTION": "Get the contents of a file or directory from a GitHub repository", "TOOL_GET_ISSUE_DESCRIPTION": "Get details of a specific issue in a GitHub repository.", "TOOL_GET_ME_DESCRIPTION": "Get details of the authenticated GitHub user", "TOOL_GET_PULL_REQUEST_COMMENTS_DESCRIPTION": "Get the review comments on a pull request", "TOOL_GET_PULL_REQUEST_DESCRIPTION": "Get details of a specific pull request", "TOOL_GET_PULL_REQUEST_FILES_DESCRIPTION": "Get the list of files changed in a pull request", "TOOL_GET_PULL_REQUEST_REVIEWS_DESCRIPTION": "Get the reviews on a pull request", "TOOL_GET_PULL_REQUEST_STATUS_DESCRIPTION": "Get the combined status of all status checks for a pull request", "TOOL_LIST_CODE_SCANNING_ALERTS_DESCRIPTION": "List code scanning alerts in a GitHub repository.", "TOOL_LIST_COMMITS_DESCRIPTION": "Get list of commits of a branch in a GitHub repository", "TOOL_LIST_PULL_REQUESTS_DESCRIPTION": "List and filter repository pull requests", "TOOL_MERGE_PULL_REQUEST_DESCRIPTION": "Merge a pull request", "TOOL_SEARCH_CODE_DESCRIPTION": "Search for code across GitHub repositories", "TOOL_SEARCH_ISSUES_DESCRIPTION": "Search for issues and pull requests across GitHub repositories", "TOOL_SEARCH_REPOSITORIES_DESCRIPTION": "Search for GitHub repositories", "TOOL_SEARCH_USERS_DESCRIPTION": "Search for GitHub users", "TOOL_UPDATE_PULL_REQUEST_BRANCH_DESCRIPTION": "Update a pull request branch with the latest changes from the base branch" }Live example
tools/listAn example running with a file, and an env var:
{ "jsonrpc": "2.0", "id": 3, "result": { "tools": [ { "description": "an alternative description", "inputSchema": { "type": "object", "properties": { "body": { "description": "Comment text", "type": "string" }, "issue_number": { "description": "Issue number to comment on", "type": "number" }, "owner": { "description": "Repository owner", "type": "string" }, "repo": { "description": "Repository name", "type": "string" } }, "required": [ "owner", "repo", "issue_number", "body" ] }, "name": "add_issue_comment" }, { "description": "OVERRIDE DESCRIPTION", "inputSchema": { "type": "object", "properties": { "branch": { "description": "Name for new branch", "type": "string" }, "from_branch": { "description": "Source branch (defaults to repo default)", "type": "string" }, "owner": { "description": "Repository owner", "type": "string" }, "repo": { "description": "Repository name", "type": "string" } }, "required": [ "owner", "repo", "branch" ] }, "name": "create_branch" }, ... ] } }