Skip to content

search_model_files

Search file contents in a Bridge Town model for a text or regex pattern — grep-style, so you can answer ‘where does this string appear in this model?’ without reading full files one at a time. pattern is a literal, case-insensitive substring by default; set regex=True to treat it as a Python regular expression, and case_sensitive=True for case-sensitive matching either way.

NameTypeRequiredDefaultDescription
model_nameAnnotated[str, Field(description='Name of the Bridge Town model.')]Yes
patternAnnotated[str, Field(description='Text to search for. A literal, case-insensitive substring by default; set regex=True to treat it as a Python regular expression.')]Yes
pathAnnotated[str, Field(description="Optional subtree path to scope the search to (e.g. 'model' to search only model files). A single harmless trailing slash (e.g. 'model/') is stripped automatically. Omit to search the whole model.")]No''
file_globAnnotated[str, Field(description="Optional glob to filter which files are searched (e.g. '*.py', 'model/**/*.py'), same syntax as list_files' pattern parameter.")]No''
branch`Annotated[strNone, Field(description=“Branch to search. Defaults to the model’s default branch when omitted or null.”)]`NoNone
context_linesAnnotated[int, Field(description=f'Number of lines of context to include before/after each match. Defaults to {_SEARCH_DEFAULT_CONTEXT_LINES}, max {_SEARCH_MAX_CONTEXT_LINES}.')]No2
max_matchesAnnotated[int, Field(description=f'Maximum number of matches to return across all files. Defaults to {_SEARCH_DEFAULT_MAX_MATCHES}, max {_SEARCH_MAX_MATCHES_CAP}.')]No200
max_filesAnnotated[int, Field(description=f'Maximum number of files to scan. Defaults to {_SEARCH_DEFAULT_MAX_FILES}, max {_SEARCH_MAX_FILES_CAP}.')]No200
regexAnnotated[bool, Field(description='Treat pattern as a Python regular expression. Defaults to False.')]NoFalse
case_sensitiveAnnotated[bool, Field(description='Case-sensitive matching. Defaults to False (case-insensitive).')]NoFalse
workspace_id`Annotated[strNone, Field(description=WORKSPACE_ID_FIELD_DESCRIPTION)]`NoNone

Returns a structured object. Top-level fields:

  • model (string)
  • path (string)
  • branch (null)
  • matches (array<object>)
  • count (integer)
  • files_scanned (integer)
  • files_with_matches (integer)
  • skipped_files (array)
  • truncated (boolean)
  • files_truncated (boolean)

See the response example below for the full payload shape.

{
"name": "search_model_files",
"arguments": {
"model_name": "forecasts",
"pattern": "growth_rate",
"file_glob": "*.py"
}
}
{
"model": "forecasts",
"path": "",
"branch": null,
"matches": [
{
"path": "model/revenue.py",
"line_number": 4,
"column_start": 5,
"column_end": 16,
"line_text": " growth_rate = 0.10",
"context_before": [
"def run(inputs):",
" df = load_actuals()"
],
"context_after": [
" return {'revenue': df * (1 + growth_rate)}"
]
}
],
"count": 1,
"files_scanned": 3,
"files_with_matches": 1,
"skipped_files": [],
"truncated": false,
"files_truncated": false
}
  • Module: Files
  • Requires authentication via API token or Auth0 JWT.