MCP Tools Reference¶
tools ¶
Defines MCP tools for interacting with the Lean Explore search engine.
These tools provide functionalities such as searching for statement groups, retrieving specific groups by ID, and getting their dependencies. They utilize a backend service (either an API client or a local service) made available through the MCP application context.
Classes¶
Functions¶
get_by_id
async
¶
Retrieves specific statement groups by their unique identifier(s).
The display_statement_text field is omitted from the response. This tool
always returns a list of results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The MCP context, providing access to the backend service. |
required |
group_id
|
Union[int, List[int]]
|
A single unique integer identifier or a list of identifiers
of the statement group(s) to retrieve. For example, |
required |
Returns:
| Type | Description |
|---|---|
List[Optional[Dict[str, Any]]]
|
A list of dictionaries, where each dictionary corresponds to the |
List[Optional[Dict[str, Any]]]
|
APISearchResultItem model. If an ID is not found, its corresponding |
List[Optional[Dict[str, Any]]]
|
entry in the list will be None (serialized as JSON null by MCP). |
Source code in src/lean_explore/mcp/tools.py
get_dependencies
async
¶
Retrieves direct dependencies (citations) for specific statement group(s).
The display_statement_text field within each cited item is omitted
from the response. This tool always returns a list of results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The MCP context, providing access to the backend service. |
required |
group_id
|
Union[int, List[int]]
|
A single unique integer identifier or a list of identifiers for
the statement group(s) for which to fetch direct dependencies.
For example, |
required |
Returns:
| Type | Description |
|---|---|
List[Optional[Dict[str, Any]]]
|
A list of dictionaries, where each dictionary corresponds to the |
List[Optional[Dict[str, Any]]]
|
APICitationsResponse model. If a source group ID is not found or has |
List[Optional[Dict[str, Any]]]
|
no dependencies, its corresponding entry will be None. |
Source code in src/lean_explore/mcp/tools.py
search
async
¶
Searches Lean statement groups by a query string or list of strings.
This tool allows for filtering by package names and limits the number of results returned per query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The MCP context, providing access to shared resources like the backend service. |
required |
query
|
Union[str, List[str]]
|
A single search query string or a list of query strings. For example, "continuous function" or ["prime number theorem", "fundamental theorem of arithmetic"]. |
required |
package_filters
|
Optional[List[str]]
|
An optional list of package names to filter the search
results by. For example, |
None
|
limit
|
int
|
The maximum number of search results to return per query. Defaults to 10. Must be a positive integer. |
10
|
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
A list of dictionaries, where each dictionary corresponds to the |
List[Dict[str, Any]]
|
APISearchResponse model. Each response contains the search results |
List[Dict[str, Any]]
|
for a single query. The |
List[Dict[str, Any]]
|
result item is omitted. |
Source code in src/lean_explore/mcp/tools.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |