create_release
Create a new GitHub release by specifying repository, tag, name, body, and optional settings for draft, prerelease, and release notes.
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. draft (bool, optional): Whether the release is a draft. Defaults to False. prerelease (bool, optional): Whether the release is a prerelease. Defaults to False. generate_release_notes (bool, optional): Whether to generate release notes automatically. Defaults to True. make_latest (Literal['true', 'false', 'legacy'], optional): Whether to mark the release as the latest. Defaults to 'true'. 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 | ||
| draft | No | ||
| prerelease | No | ||
| generate_release_notes | No | ||
| make_latest | No | true |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The create_release method on GitHubIntegration class. It calls the GitHub API to create a release with parameters: repo_owner, repo_name, tag_name, release_name, body, draft, prerelease, generate_release_notes, make_latest.
def create_release( self, repo_owner: str, repo_name: str, tag_name: str, release_name: str, body: str, draft: bool = False, prerelease: bool = False, generate_release_notes: bool = True, make_latest: Literal["true", "false", "legacy"] = "true", ) -> 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. draft (bool, optional): Whether the release is a draft. Defaults to False. prerelease (bool, optional): Whether the release is a prerelease. Defaults to False. generate_release_notes (bool, optional): Whether to generate release notes automatically. Defaults to True. make_latest (Literal['true', 'false', 'legacy'], optional): Whether to mark the release as the latest. Defaults to 'true'. 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. """ logger.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 = httpx.post( releases_url, headers=self._get_headers(), json={ "tag_name": tag_name, "name": release_name, "body": body, "draft": draft, "prerelease": prerelease, "generate_release_notes": generate_release_notes, "make_latest": make_latest, }, timeout=TIMEOUT, ) self._raise_for_status(response, f"create release {release_name}") release_data = response.json() logger.info("Release created successfully") return release_data except GitHubAuthError: raise except Exception as e: logger.error(f"Error creating release: {str(e)}") traceback.print_exc() return {"status": "error", "message": str(e)} - src/mcp_github/issues_pr_analyser.py:137-148 (registration)Registration: _register_tools() calls self.register_tools(self.gi) which iterates over all public methods of GitHubIntegration (including create_release) and adds them as MCP tools via self.mcp.add_tool(method).
def _register_tools(self): self.register_tools(self.gi) self.register_tools(self.ip) self.mcp.add_provider(SkillsDirectoryProvider(Path(__file__).parent / "skills")) def register_tools(self, methods: Any = None) -> None: for name in dir(methods): if name.startswith("_"): continue method = getattr(methods, name) if inspect.isroutine(method): self.mcp.add_tool(method) - The register_tools method dynamically discovers all non-underscore-prefixed methods on the GitHubIntegration instance and registers them as MCP tools.
def register_tools(self, methods: Any = None) -> None: for name in dir(methods): if name.startswith("_"): continue method = getattr(methods, name) if inspect.isroutine(method): self.mcp.add_tool(method)