@@ -28,6 +28,11 @@ class McpServerError(WebRunnerException):
2828
2929
3030_MCP_PROTOCOL_VERSION = "2024-11-05"
31+
32+ # Reused error messages — extracted so SonarCloud S1192 stays quiet and
33+ # downstream tooling can grep for them.
34+ _ERR_ACTIONS_LIST = "'actions' must be a list"
35+ _ERR_TEXT_STRING = "'text' must be a string"
3136_SERVER_NAME = "webrunner-mcp"
3237_SERVER_VERSION = "0.1.0"
3338
@@ -144,7 +149,7 @@ def _tool_lint_action(arguments: Dict[str, Any]) -> Any:
144149 from je_web_runner .utils .linter .action_linter import lint_action
145150 actions = arguments .get ("actions" )
146151 if not isinstance (actions , list ):
147- raise McpServerError ("'actions' must be a list" )
152+ raise McpServerError (_ERR_ACTIONS_LIST )
148153 # ``lint_action`` returns ``List[Dict[str, Any]]`` with ``rule`` /
149154 # ``severity`` / ``message`` / ``location`` keys; pass through verbatim
150155 # so MCP clients see the same shape the Python API exposes.
@@ -238,23 +243,23 @@ def _tool_format_actions(arguments: Dict[str, Any]) -> Any:
238243 from je_web_runner .utils .action_formatter .formatter import format_actions
239244 actions = arguments .get ("actions" )
240245 if not isinstance (actions , list ):
241- raise McpServerError ("'actions' must be a list" )
246+ raise McpServerError (_ERR_ACTIONS_LIST )
242247 return format_actions (actions , indent = int (arguments .get ("indent" , 2 )))
243248
244249
245250def _tool_parse_markdown (arguments : Dict [str , Any ]) -> Any :
246251 from je_web_runner .utils .md_authoring .markdown_to_actions import parse_markdown
247252 text = arguments .get ("text" )
248253 if not isinstance (text , str ):
249- raise McpServerError ("'text' must be a string" )
254+ raise McpServerError (_ERR_TEXT_STRING )
250255 return parse_markdown (text )
251256
252257
253258def _tool_translate_actions_to_playwright (arguments : Dict [str , Any ]) -> Any :
254259 from je_web_runner .utils .sel_to_pw .translator import translate_action_list
255260 actions = arguments .get ("actions" )
256261 if not isinstance (actions , list ):
257- raise McpServerError ("'actions' must be a list" )
262+ raise McpServerError (_ERR_ACTIONS_LIST )
258263 return translate_action_list (actions )
259264
260265
@@ -295,7 +300,7 @@ def _tool_scan_pii(arguments: Dict[str, Any]) -> Any:
295300 from je_web_runner .utils .pii_scanner .scanner import scan_text
296301 text = arguments .get ("text" )
297302 if not isinstance (text , str ):
298- raise McpServerError ("'text' must be a string" )
303+ raise McpServerError (_ERR_TEXT_STRING )
299304 categories = arguments .get ("categories" )
300305 findings = scan_text (text , categories = categories )
301306 return [
@@ -309,7 +314,7 @@ def _tool_redact_pii(arguments: Dict[str, Any]) -> Any:
309314 from je_web_runner .utils .pii_scanner .scanner import redact_text
310315 text = arguments .get ("text" )
311316 if not isinstance (text , str ):
312- raise McpServerError ("'text' must be a string" )
317+ raise McpServerError (_ERR_TEXT_STRING )
313318 return redact_text (
314319 text ,
315320 replacement = str (arguments .get ("replacement" , "[REDACTED]" )),
@@ -351,7 +356,7 @@ def _tool_score_action_locators(arguments: Dict[str, Any]) -> Any:
351356 from je_web_runner .utils .linter .locator_strength import score_action_locators
352357 actions = arguments .get ("actions" )
353358 if not isinstance (actions , list ):
354- raise McpServerError ("'actions' must be a list" )
359+ raise McpServerError (_ERR_ACTIONS_LIST )
355360 return list (score_action_locators (actions ))
356361
357362
0 commit comments