create_release
Create a new release in a GitHub repository by specifying tag name, release name, and description to organize and distribute software versions.
Instructions
Creates a new release in the specified GitHub repository. Args: repo_owner (str): The owner of the repository. repo_name (str): The name of the repository. tag_name (str): The tag name for the release. release_name (str): The name of the release. body (str): The description or body content of the release. Returns: Dict[str, Any]: The JSON response from the GitHub API containing release information if successful. None: If an error occurs during the release creation process. Error Handling: Logs errors and prints the traceback if the release creation fails, returning None.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_owner | Yes | ||
| repo_name | Yes | ||
| tag_name | Yes | ||
| release_name | Yes | ||
| body | Yes |
Implementation Reference
- The handler function implementing the 'create_release' tool. It creates a new GitHub release by posting to the GitHub API with the provided repository details, tag, name, and body.def create_release(self, repo_owner: str, repo_name: str, tag_name: str, release_name: str, body: str) -> Dict[str, Any]: """ Creates a new release in the specified GitHub repository. Args: repo_owner (str): The owner of the repository. repo_name (str): The name of the repository. tag_name (str): The tag name for the release. release_name (str): The name of the release. body (str): The description or body content of the release. Returns: Dict[str, Any]: The JSON response from the GitHub API containing release information if successful. None: If an error occurs during the release creation process. Error Handling: Logs errors and prints the traceback if the release creation fails, returning None. """ logging.info(f"Creating release {release_name} in {repo_owner}/{repo_name}") # Construct the releases URL releases_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/releases" try: # Create the release response = requests.post(releases_url, headers=self._get_headers(), json={ 'tag_name': tag_name, 'name': release_name, 'body': body, 'draft': False, 'prerelease': False, 'generate_release_notes': True }, timeout=TIMEOUT) response.raise_for_status() release_data = response.json() logging.info("Release created successfully") return release_data except Exception as e: logging.error(f"Error creating release: {str(e)}") traceback.print_exc() return {"status": "error", "message": str(e)}
- src/mcp_github/issues_pr_analyser.py:106-113 (registration)The registration code that dynamically registers all public methods of the GitHubIntegration instance (including create_release) as MCP tools via FastMCP.add_tool.self.register_tools(self.gi) self.register_tools(self.ip) def register_tools(self, methods: Any = None) -> None: for name, method in inspect.getmembers(methods): if (inspect.isfunction(method) or inspect.ismethod(method)) and not name.startswith("_"): self.mcp.add_tool(method)
- Documentation in the MCP server instructions mentioning the create_release tool.- Use create_tag and create_release for release management
- src/mcp_github/issues_pr_analyser.py:67-67 (registration)Instantiation of the GitHubIntegration class whose methods are registered as tools.self.gi = GI()
- src/mcp_github/issues_pr_analyser.py:27-27 (registration)Import of the GitHubIntegration class containing the create_release handler.from .github_integration import GitHubIntegration as GI