GitHub Issues
GitHub issues of The Smarter Project’s repositories: searched, opened and commented on.
search_issues()asks GitHub’s issue search,GET /search/issues, live, rather than the index: issues change by the minute, and an LLM that is about to open an issue must see one that was opened a minute ago. It searches one repository withrepo:, or all of them withorg:, and drops the results of the organization’s other repositories. Issues are public, so the result does not depend on who asks. Without the caller’s classic token the search is anonymous, and GitHub allows anonymous clients 10 searches a minute for each IP address, which the platform’s users share. A token raises that to 30 for its owner.read_issue()reads an issue and its latest comments, withGET /repos/{owner}/{repo}/issues/{number}and its/comments, so that an LLM can see what an issue already says before it adds to it.create_issue()opens an issue, optionally with labels, withPOST /repos/{owner}/{repo}/issues.close_issue()closes an issue that a merged pull request resolved, with a comment that says why, after GitHub confirms that the pull request was merged.comment_on_issue()adds a comment to an existing issue, withPOST /repos/{owner}/{repo}/issues/{number}/comments.
create_issue(), comment_on_issue() and close_issue() write as the caller, with
the caller’s own classic personal access token, so the issue or comment is the caller’s, and
GitHub decides what the caller may do. Each appends a footer that says where the text came from.
Never cache them: every call writes. None of them writes a credential: see
refuse_secrets(). See
smarter.apps.mcpserver.services.github.client for how the token is checked and kept secret, and how
GitHub’s errors are explained.
Note
Experimental. The MCPServer was designed and coded by Claude Code (Anthropic’s Claude Opus 5.5), with Lawrence McDaniel as co-author. It is experimental, and will be documented.
- class smarter.apps.mcpserver.services.github.issues.GitHubComment(**data)[source]
Bases:
BaseModelA comment that GitHub created, with the fields of its response that the
comment_on_issuetool reports.comment_on_issue()builds it from GitHub’s201 Createdresponse, plus theauthorthatcreated()adds. GitHub’s response has many more fields, which are ignored.- model_config = {'extra': 'ignore', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.mcpserver.services.github.issues.GitHubIssue(**data)[source]
Bases:
BaseModelAn issue that GitHub created, with the fields of its response that the
create_issuetool reports.create_issue()builds it from GitHub’s201 Createdresponse, plus theauthorthatcreated()adds. GitHub’s response has many more fields, which are ignored.- model_config = {'extra': 'ignore', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.mcpserver.services.github.issues.GitHubIssueClosed(**data)[source]
Bases:
BaseModelAn issue that
close_issue()closed, with the comment that says why.The
close_issuetool reports it. It is built from the comment thatcomment_on_issue()added and the pull request that GitHub confirmed was merged, rather than from GitHub’s response to the closing, which the tool does not need.- model_config = {'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.mcpserver.services.github.issues.GitHubIssueComment(**data)[source]
Bases:
BaseModelA comment on an issue, with the fields that
read_issuereports.read_issue()builds it from an item of GitHub’sGET /repos/{owner}/{repo}/issues/{number}/commentsresponse. GitHub’s response has many more fields, which are ignored.- model_config = {'extra': 'ignore', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.mcpserver.services.github.issues.GitHubIssueDetail(**data)[source]
Bases:
BaseModelOne issue, as
GET /repos/{owner}/{repo}/issues/{number}returns it, with the fields thatread_issuereports.GitHub’s response has many more fields, which are ignored. GitHub returns a pull request from this endpoint too, with a
pull_requestfield, soread_issuecan also read a pull request’s description and conversation, e.g. beforeclose_issue.- model_config = {'extra': 'ignore', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.mcpserver.services.github.issues.GitHubIssueHit(**data)[source]
Bases:
BaseModelOne issue that GitHub’s search found, with the fields that the
search_issuestool reports.search_issues()builds it from an item of GitHub’sGET /search/issuesresponse. GitHub’s response has many more fields, which are ignored. It is frozen, because it is a snapshot of GitHub’s answer.- property excerpt: str
The start of the issue’s body, on one line, at most
MAX_EXCERPT_LENGTHcharacters.Runs of whitespace, including line breaks, become one space, so that the excerpt fits on one line of the tool’s result. A longer body is cut, and ends with
.... An issue without a body has an empty excerpt.
- model_config = {'extra': 'ignore', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.mcpserver.services.github.issues.GitHubIssueThread(**data)[source]
Bases:
BaseModelAn issue and its latest comments, oldest first, as
read_issue()returns them.The
read_issuetool formats it as Markdown.- comments: list[GitHubIssueComment]
The issue’s latest comments, at most
COMMENTS_PER_PAGE, oldest first.The issue’s
commentscount says how many it has in all.
- issue: GitHubIssueDetail
The issue.
- model_config = {'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.mcpserver.services.github.issues.GitHubPullRequestState(**data)[source]
Bases:
BaseModelA pull request, as
GET /repos/{owner}/{repo}/pulls/{number}returns it, with the fields thatclose_issuereads.close_issue()closes an issue only ifmergedis true. GitHub’s response has many more fields, which are ignored.- model_config = {'extra': 'ignore', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- smarter.apps.mcpserver.services.github.issues.IssueState
open,closed, orall, which leaves the state out of the query.- Type:
Which issues a search asks for
alias of
Literal[‘open’, ‘closed’, ‘all’]
- smarter.apps.mcpserver.services.github.issues.close_issue(repository, number, pull_request_number, comment, token)[source]
Close an issue that a merged pull request resolved, with a comment that says why, as the owner of a GitHub token.
The issue is closed only if GitHub says that the pull request was merged, so that an LLM cannot close an issue on its own judgment alone, nor because a log or an issue told it to. The comment is added first, and the issue is then closed as
completed, so that an issue is never closed without saying why.Side effects, in order: a
GETrequest for the pull request; aPOSTthat adds the comment (seecomment_on_issue()); and aPATCHthat closes the issue, which notifies its participants. If the closing fails after the comment was added, the error says so, so that the LLM does not add the comment again. Nothing is cached.- Parameters:
repository (
ProjectRepository) – The repository of the issue and the pull request.number (
int) – The issue’s number.pull_request_number (
int) – The number of the merged pull request that resolved the issue.comment (
str) – Why the issue is resolved, in Markdown.COMMENT_FOOTERis appended.token (
SecretStr|None) – The caller’s classic personal access token.
- Return type:
- Returns:
The closed issue.
- Raises:
SmarterMCPServerServiceError – If the token is not a classic personal access token, the comment holds a credential, the pull request was not found or not merged, or GitHub could not be reached, or refused the comment or the closing.
- smarter.apps.mcpserver.services.github.issues.comment_on_issue(repository, number, body, token)[source]
Add a comment to an issue of a repository of The Smarter Project, as the owner of a GitHub token.
Like
create_issue(), it writes with the caller’s own token, after checking the token and the body for credentials. It also comments on a pull request, whose number GitHub shares with issues.close_issue()calls it to say why an issue is closed.Side effects: one
POST /repos/{owner}/{repo}/issues/{number}/commentsrequest, which creates a public comment and notifies the issue’s participants. The result is never cached: every call writes. The new comment’s url is logged.- Parameters:
repository (
ProjectRepository) – The repository.number (
int) – The issue’s number.body (
str) – The comment, in Markdown.COMMENT_FOOTERis appended.token (
SecretStr|None) – The caller’s classic personal access token.
- Return type:
- Returns:
The new comment.
- Raises:
SmarterMCPServerServiceError – If the token is not a classic personal access token, the body holds a credential, or GitHub could not be reached, or did not create the comment, e.g. the issue is locked.
- smarter.apps.mcpserver.services.github.issues.create_issue(repository, title, body, token, labels=())[source]
Open an issue in a repository of The Smarter Project, as the owner of a GitHub token.
The issue is written with the caller’s own token, so it is theirs on GitHub, and GitHub decides what they may do, e.g. whether their labels are kept. Before anything is sent, the token is checked (
validate_token()), and the title, body and labels are checked for credentials (refuse_secrets()), because the issue is public.Side effects: one
POST /repos/{owner}/{repo}/issuesrequest, which creates a public issue and notifies the repository’s watchers. The result is never cached: every call writes. The new issue’s url is logged.- Parameters:
repository (
ProjectRepository) – The repository.title (
str) – The issue’s title.body (
str) – The issue’s body, in Markdown.ISSUE_FOOTERis appended.token (
SecretStr|None) – The caller’s classic personal access token.labels (
tuple[str,...]) – The issue’s labels, e.g.bug. GitHub creates a label that the repository does not have, and silently drops the labels of a caller who cannot push to the repository.
- Return type:
- Returns:
The new issue.
- Raises:
SmarterMCPServerServiceError – If the token is not a classic personal access token, the title or body holds a credential, or GitHub could not be reached, or did not create the issue.
- smarter.apps.mcpserver.services.github.issues.read_issue(repository, number, token)[source]
Read an issue of a repository, and its latest
COMMENTS_PER_PAGEcomments.Issues are public, so the result does not depend on who asks. Without the caller’s classic token the request is anonymous, at GitHub’s anonymous rate limit.
Side effects: one
GETrequest to GitHub for the issue, and, if it has comments, a second one for the last page of its comments, which holds the latest. A failure is logged.- Parameters:
repository (
ProjectRepository) – The repository.number (
int) – The issue’s number.token (
SecretStr|None) – The caller’s GitHub token, or None. Only a classic personal access token is sent.
- Return type:
- Returns:
The issue and its latest comments, oldest first.
- Raises:
SmarterMCPServerServiceError – If GitHub could not be reached, the issue was not found, or GitHub’s response could not be read.
- smarter.apps.mcpserver.services.github.issues.search_issues(repositories, query, one, state, limit, token)[source]
Search the issues of the repositories, best match first.
GitHub’s issue search is asked live, rather than an index, because issues change by the minute (see the module’s docstring). Side effects: one
GET /search/issuesrequest to GitHub, which counts against the caller’s, or the platform’s anonymous, search rate limit. A failure is logged.- Parameters:
repositories (
tuple[ProjectRepository,...]) – The repositories to search. They have the same owner.query (
str) – The keywords.one (
bool) – Whether to search only the first repository, rather than all of them.state (
Literal['open','closed','all']) –open,closedorall.limit (
int) – The maximum number of issues.token (
SecretStr|None) – The caller’s GitHub token, or None. Only a classic personal access token is sent: otherwise the search is anonymous.
- Return type:
- Returns:
The issues of the repositories.
- Raises:
SmarterMCPServerServiceError – If GitHub could not be reached, or refused the search, e.g. its rate limit was reached.