Tools
Base Class
The base class of the Smarter Project MCP server’s tools, the scope that they work on, and the limits of their results.
Each tool is a SmarterProjectTool: a name, a description, a Pydantic model of its
arguments, from which its MCP inputSchema is generated, and SmarterProjectTool.run(),
which returns its result as Markdown text for the LLM. SmarterProjectTool.call()
validates the arguments, and caches a read-only tool’s result.
A tool works on the repositories of its SmarterProjectScope. The MCP server of
one repository serves the tools without a repository argument, and the MCP server of
all of the repositories adds one, whose values are the repositories’ names.
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.
- smarter.apps.mcpserver.protocol.tools.DEFAULT_SEARCH_LIMIT = 8
The number of results that a search tool returns when the LLM does not give a
limit.
- smarter.apps.mcpserver.protocol.tools.MAX_READ_CHARACTERS = 16000
The maximum length of a tool’s result that reads a file or a schema, below the MCPClient’s limit for a tool result.
- smarter.apps.mcpserver.protocol.tools.MAX_SEARCH_LIMIT = 20
The most results that a search tool returns, which keeps a result within the LLM’s context.
- class smarter.apps.mcpserver.protocol.tools.SmarterProjectScope(**data)[source]
Bases:
BaseModelThe repositories that one Smarter Project MCP server serves.
The server creates its scope once, and gives it to each of its tools, which call
resolve()to turn a call’srepositoryargument into a repository. It is frozen, because the tools share it.- Parameters:
repository – The one repository of the server, or None for all of them.
repositories – The repositories that the server serves:
(repository,), or every repository of The Smarter Project.
- model_config = {'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- repositories: tuple[ProjectRepository, ...]
The repositories that the server serves, in their configured order.
- repository: ProjectRepository | None
The one repository of the server, or None for the server of all of them.
- resolve(name, required)[source]
Return the repository that a tool call names.
- Parameters:
- Return type:
- Returns:
The server’s one repository, the named repository, or None for all of them.
- Raises:
SmarterMCPServerToolError – If the name is not one of the scope’s repositories, or a required name is missing.
- class smarter.apps.mcpserver.protocol.tools.SmarterProjectTool(scope, github_token=None)[source]
Bases:
MCPToolBaseA tool of the Smarter Project MCP server.
A subclass sets
name,title,descriptionandarguments_model, the class attributes that say which servers serve it and how it takes a repository, and implementsrun().call()validates the arguments and caches a read-only tool’s result, sorun()only does the work.- Parameters:
scope (
SmarterProjectScope) – The repositories of the MCP server.github_token (
SecretStr|None) – The caller’s GitHub token, from the request’sAuthorization: Bearerheader, or None. Only a tool thatrequires_github_tokenuses it.
- __init__(scope, github_token=None)[source]
Keep the server’s scope, and the caller’s GitHub token.
- Parameters:
scope (
SmarterProjectScope) – The repositories of the MCP server.github_token (
SecretStr|None) – The caller’s GitHub token, or None.
- arguments_model
The Pydantic model of the tool’s arguments, a subclass of
ToolArguments.alias of
ToolArguments
- cache_ttl: ClassVar[int | None] = None
Seconds that a read-only tool’s result is cached, or None for
TOOL_RESULT_CACHE_TTL.
- call(arguments)[source]
Validate a tool call’s arguments, and run the tool.
The server of one repository, and a tool that does not
uses_repository, drop arepositoryargument, which their schema does not offer, rather than refuse it.A read-only tool’s result is cached for an hour, or its
cache_ttl, until an index changes. Seesmarter.apps.mcpserver.caching. The cache key is the platform’s version, the index generation, the server’s repository (*for all of them), the tool’s name and its validated arguments, so a new release or a new index never serves a stale result. An error is not cached. A tool that writes runs on every call.Side effects: reads, and on a miss writes, the Django cache, with
cached_tool_call().
- description: ClassVar[str]
What the tool does, and when to call it.
The LLM reads it to decide which tool to call.
- project_wide: ClassVar[bool] = False
Whether only the MCP server of all of the repositories serves the tool.
- requires_github_token: ClassVar[bool] = False
Whether the tool is served only to a request that carries the caller’s GitHub token.
- requires_repository: ClassVar[bool] = False
Whether a call to the MCP server of all of the repositories must name one.
- abstractmethod run(arguments)[source]
Run the tool.
call()has already validated the arguments, and checked the cache.- Parameters:
arguments (
ToolArguments) – The validated arguments, an instance ofarguments_model.- Return type:
- Returns:
The result, as Markdown.
- Raises:
SmarterMCPServerToolError – If the tool fails in a way that the LLM should be told about, e.g. a file that does not exist.
- classmethod serves(scope, has_github_token=False)[source]
Whether the MCP server of a scope serves the tool.
A tool that
requires_github_tokenis served only to a request that carries one, and aproject_widetool only by the MCP server of all of the repositories.- Parameters:
scope (
SmarterProjectScope) – The server’s repositories.has_github_token (
bool) – Whether the request carries the caller’s GitHub token.
- Return type:
- Returns:
True if the server lists the tool, and lets the LLM call it.
- class smarter.apps.mcpserver.protocol.tools.ToolArguments(**data)[source]
Bases:
BaseModelThe arguments of every tool:
repository, which only the MCP server of all of the repositories offers.A tool’s own arguments model subclasses it. Arguments that the model does not define are refused (
extra="forbid"), so that a misspelled argument is reported to the LLM rather than ignored.- model_config = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- repository: str | None
The name of the repository to work on, e.g.
smarter-cli.SmarterProjectTool.input_schema()replaces its schema with anenumof the scope’s repositories, or removes it from the server of one repository.
- smarter.apps.mcpserver.protocol.tools.simplify_schema(schema)[source]
Simplify a Pydantic JSON schema for an LLM.
Pydantic’s schema carries what helps a form, not an LLM: a title for the model and for each field, the model’s docstring as its description, and
"default": nullfor each optional field. They cost tokens in everytools/listresult, and the docstring is written for developers, so they are removed. An optional field’sanyOf: [<type>, {"type": "null"}]becomes its type, which every MCP client understands.
Registry
The tools of the Smarter Project MCP server: TOOL_CLASSES, in the order that tools/list lists them.
Each feature’s tools are in its own package, beside the code that they call:
smarter.apps.mcpserver.index.tools: the repositories and the blog, from the index.smarter.apps.mcpserver.manifests.tools: the platform’s manifests.smarter.apps.mcpserver.github.tools: the GitHub issues and pull requests.
Their base class is smarter.apps.mcpserver.protocol.tools.SmarterProjectTool.
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.
- smarter.apps.mcpserver.protocol.registry.TOOL_CLASSES: tuple[type[SmarterProjectTool], ...] = (<class 'smarter.apps.mcpserver.index.tools.GetRepositoryOverviewTool'>, <class 'smarter.apps.mcpserver.index.tools.SearchDocumentationTool'>, <class 'smarter.apps.mcpserver.index.tools.SearchCodeTool'>, <class 'smarter.apps.mcpserver.index.tools.ReadFileTool'>, <class 'smarter.apps.mcpserver.index.tools.ListFilesTool'>, <class 'smarter.apps.mcpserver.manifests.tools.GetManifestSchemaTool'>, <class 'smarter.apps.mcpserver.manifests.tools.ValidateManifestTool'>, <class 'smarter.apps.mcpserver.index.tools.SearchBlogTool'>, <class 'smarter.apps.mcpserver.index.tools.ReadBlogPostTool'>, <class 'smarter.apps.mcpserver.github.tools.SearchIssuesTool'>, <class 'smarter.apps.mcpserver.github.tools.ReadIssueTool'>, <class 'smarter.apps.mcpserver.github.tools.CreateIssueTool'>, <class 'smarter.apps.mcpserver.github.tools.CommentOnIssueTool'>, <class 'smarter.apps.mcpserver.github.tools.CloseIssueTool'>, <class 'smarter.apps.mcpserver.github.tools.CreatePullRequestTool'>)
Every tool of the Smarter Project MCP server, in the order that tools/list lists them.
SmarterProjectMCPServercreates one of each that its scope serves (seeserves()). The order puts the tools that an LLM should try first, the overview and the searches, before the tools that read one item, and the tools that write to GitHub last.( <class 'smarter.apps.mcpserver.index.tools.GetRepositoryOverviewTool'>, <class 'smarter.apps.mcpserver.index.tools.SearchDocumentationTool'>, <class 'smarter.apps.mcpserver.index.tools.SearchCodeTool'>, <class 'smarter.apps.mcpserver.index.tools.ReadFileTool'>, <class 'smarter.apps.mcpserver.index.tools.ListFilesTool'>, <class 'smarter.apps.mcpserver.manifests.tools.GetManifestSchemaTool'>, <class 'smarter.apps.mcpserver.manifests.tools.ValidateManifestTool'>, <class 'smarter.apps.mcpserver.index.tools.SearchBlogTool'>, <class 'smarter.apps.mcpserver.index.tools.ReadBlogPostTool'>, <class 'smarter.apps.mcpserver.github.tools.SearchIssuesTool'>, <class 'smarter.apps.mcpserver.github.tools.ReadIssueTool'>, <class 'smarter.apps.mcpserver.github.tools.CreateIssueTool'>, <class 'smarter.apps.mcpserver.github.tools.CommentOnIssueTool'>, <class 'smarter.apps.mcpserver.github.tools.CloseIssueTool'>, <class 'smarter.apps.mcpserver.github.tools.CreatePullRequestTool'>, )