searchBrain
Search inside a brain
Search the documents of one brain (case-insensitive text match), and with includeParents its readable parent brains too. Returns the brain, document title, path, line and snippet for each match. Read the full document with readDoc and that path.
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
brain | string | required | Brain id from listBrains, in the form "<project>/<folder>" |
query | string | required | Text to search for |
includeParents | boolean | optional | Also search the parent brains this connection can read (default false) |
Scopes
knowledge:read
Annotations
- Read only: yes
- Destructive: no
When to use
Use searchBrain when the question is about one subject that has a brain, for example "what does the website say about discounts?". Then read the full document with readDoc.
The tool needs the knowledge:read scope.
brainis a brain id fromlistBrains:<project>/<folder>.- The search covers the files in the brain's folder and its sub-folders. A sub-folder that holds its own
brain.mdis another brain and is not searched. - With
includeParents: true, it also searches the parent brain, and that brain's parent, up to 3 levels, but only the ones this person can read.searchedlists the brains it covered, in order. - The matching is the same as
searchKnowledge: a plain, case-insensitive text match, not a semantic search.querymust have at least 2 characters. It returns one result for each file (the first line that matches), at most 40 results in all, and skips files larger than 2 MB. - Each result has the
brainit came from, thedocumenttitle (the title in the brain's list, for a listed document), thepath, thelineand asnippet. PasspathtoreadDocas it is, with noproject.
Example
{ "brain": "northwind-advisory/brains/website", "query": "discount", "includeParents": true }
{
"brain": "northwind-advisory/brains/website",
"query": "discount",
"searched": [
"northwind-advisory/brains/website",
"northwind-advisory/brains/business"
],
"results": [
{
"brain": "northwind-advisory/brains/website",
"path": "northwind-advisory/brains/website/offer.md",
"document": "Offer",
"line": 4,
"snippet": "Strategy review: from 4,500 GBP. A discount above 5 per cent needs a partner's approval."
},
{
"brain": "northwind-advisory/brains/business",
"path": "northwind-advisory/brains/business/commercial-logic.md",
"document": "Commercial logic",
"line": 2,
"snippet": "summary: Day rates, the 10 per cent maximum discount and walk-away terms."
}
],
"truncated": false
}
When truncated is true, the search stopped at 40 results. Make the query narrower, or leave out includeParents.
Refusals and what to do
Error in searchBrain: Not found: there is no brain with this id that this person can read. The answer is the same whether the brain is hidden or does not exist. CalllistBrainsand use an id from that list.- A
queryshorter than 2 characters is refused as invalid arguments. - If the connection does not hold
knowledge:read, the tool is not in your tool list, and a call to it returnsMCP error -32602: Tool searchBrain not found. Read thepermissionssection ofgetDocs. A scope is never added to an existing connection: the person must reconnect, or mint a new token, withknowledge:read. - An empty
resultslist is not an error. Try other words, or usesearchKnowledgeto search every project.
Related
getBrainshows the brain's contents page.listBrainsgives the brain ids.readDocreads a document that the search found.searchKnowledgesearches every visible project, not one brain.getDocshas alimitssection with the search limits.