You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/mcp/local/mcp_tools_registry.json
-26Lines changed: 0 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -456,32 +456,6 @@
456
456
"usage_count": 2,
457
457
"last_used": "2025-08-01T17:01:50.743059"
458
458
},
459
-
{
460
-
"name": "extract_colored_numbers_from_image",
461
-
"description": "Extracts numbers from an image and categorizes them into two lists based on their color: red or green.",
462
-
"function": null,
463
-
"metadata": {
464
-
"name": "extract_colored_numbers_from_image",
465
-
"description": "Extracts numbers from an image and categorizes them into two lists based on their color: red or green.",
466
-
"requires": "cv2, pytesseract, numpy, typing",
467
-
"args": [
468
-
"image_path (str): Path to the input image file.",
469
-
"red_color_lower_bound (tuple): Lower bound for red color in HSV format (H, S, V).",
470
-
"red_color_upper_bound (tuple): Upper bound for red color in HSV format (H, S, V).",
471
-
"green_color_lower_bound (tuple): Lower bound for green color in HSV format (H, S, V).",
472
-
"green_color_upper_bound (tuple): Upper bound for green color in HSV format (H, S, V).",
473
-
"ocr_config (str): Configuration string for Tesseract OCR.",
474
-
"min_contour_area (int): The minimum area (in pixels) for a contour to be considered a number."
475
-
],
476
-
"returns": [
477
-
"result (dict): A dictionary with 'red_numbers' and 'green_numbers' as keys, containing their respective lists of extracted integers."
478
-
]
479
-
},
480
-
"script_content": "```python\n# MCP Name: extract_colored_numbers_from_image\n# Description: Extracts numbers from an image and categorizes them into two lists based on their color: red or green.\n# Arguments:\n# image_path (str): Path to the input image file.\n# red_color_lower_bound (tuple): Lower bound for red color in HSV format (H, S, V).\n# red_color_upper_bound (tuple): Upper bound for red color in HSV format (H, S, V).\n# green_color_lower_bound (tuple): Lower bound for green color in HSV format (H, S, V).\n# green_color_upper_bound (tuple): Upper bound for green color in HSV format (H, S, V).\n# ocr_config (str): Configuration string for Tesseract OCR.\n# min_contour_area (int): The minimum area (in pixels) for a contour to be considered a number.\n# Returns:\n# result (dict): A dictionary with 'red_numbers' and 'green_numbers' as keys, containing their respective lists of extracted integers.\n# Requires: cv2, pytesseract, numpy, typing\n\nimport cv2\nimport pytesseract\nimport numpy as np\nfrom typing import Tuple, List, Dict\n\ndef extract_colored_numbers_from_image(\n image_path: str,\n red_color_lower_bound: Tuple[int, int, int],\n red_color_upper_bound: Tuple[int, int, int],\n green_color_lower_bound: Tuple[int, int, int],\n green_color_upper_bound: Tuple[int, int, int],\n ocr_config: str,\n min_contour_area: int\n) -> Dict[str, List[int]]:\n \"\"\"\n Extracts numbers from an image and categorizes them into two lists based on their color: red or green.\n\n This function reads an image, converts it to the HSV color space, and then creates binary masks\n for the specified red and green color ranges. It finds contours in these masks, filters them by area,\n and then performs Optical Character Recognition (OCR) on each valid contour to extract the numbers.\n\n Args:\n image_path (str): Path to the input image file.\n red_color_lower_bound (Tuple[int, int, int]): Lower bound for red color in HSV format (H, S, V).\n red_color_upper_bound (Tuple[int, int, int]): Upper bound for red color in HSV format (H, S, V).\n green_color_lower_bound (Tuple[int, int, int]): Lower bound for green color in HSV format (H, S, V).\n green_color_upper_bound (Tuple[int, int, int]): Upper bound for green color in HSV format (H, S, V).\n ocr_config (str): Configuration string for Tesseract OCR (e.g., '--psm 10 -c tessedit_char_whitelist=0123456789').\n min_contour_area (int): The minimum area (in pixels) for a contour to be considered a number, used to filter out noise.\n\n Returns:\n Dict[str, List[int]]: A dictionary with two keys, 'red_numbers' and 'green_numbers', each containing a list of the integers extracted for that color.\n \"\"\"\n try:\n image = cv2.imread(image_path)\n if image is None:\n raise FileNotFoundError(f\"Image not found at path: {image_path}\")\n\n hsv_image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)\n\n # Create masks for red and green colors\n red_mask = cv2.inRange(hsv_image, red_color_lower_bound, red_color_upper_bound)\n green_mask = cv2.inRange(hsv_image, green_color_lower_bound, green_color_upper_bound)\n\n def _extract_from_mask(mask: np.ndarray) -> List[int]:\n \"\"\"Helper function to extract numbers from a given color mask.\"\"\"\n numbers = []\n contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)\n\n # Sort contours top-to-bottom, then left-to-right for consistent order\n if contours:\n bounding_boxes = [cv2.boundingRect(c) for c in contours]\n (contours, _) = zip(*sorted(zip(contours, bounding_boxes),\n key=lambda b: (b[1][1], b[1][0])))\n\n for contour in contours:\n if cv2.contourArea(contour) < min_contour_area:\n continue\n\n x, y, w, h = cv2.boundingRect(contour)\n \n # Add padding to ROI to prevent cropping number edges\n padding = 5\n roi = image[max(0, y - padding):min(image.shape[0], y + h + padding), \n max(0, x - padding):min(image.shape[1], x + w + padding)]\n\n if roi.size == 0:\n continue\n \n # Pre-process ROI for better OCR accuracy\n gray_roi = cv2.cvtColor(roi, cv2.COLOR_BGR2GRAY)\n # Apply thresholding to get a clear black and white image\n _, thresh_roi = cv2.threshold(gray_roi, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)\n\n text = pytesseract.image_to_string(thresh_roi, config=ocr_config).strip()\n \n cleaned_text = ''.join(filter(str.isdigit, text))\n if cleaned_text:\n numbers.append(int(cleaned_text))\n return numbers\n\n red_numbers = _extract_from_mask(red_mask)\n green_numbers = _extract_from_mask(green_mask)\n\n return {\n \"red_numbers\": red_numbers,\n \"green_numbers\": green_numbers\n }\n except Exception as e:\n # In a real application, you might want to log the error.\n # For this tool, returning a descriptive error string is sufficient.\n return {\"error\": f\"An error occurred: {str(e)}\"}\n```",
481
-
"created_at": "2025-08-01T18:06:32.493499",
482
-
"usage_count": 4,
483
-
"last_used": "2025-08-02T06:49:08.127031"
484
-
},
485
459
{
486
460
"name": "calculate_deviation_average",
487
461
"description": "Takes two lists of numbers (red and green). It calculates the population standard deviation for the red numbers and the sample standard deviation for the green numbers using Python's 'statistics' module. It then returns the average of these two deviation values, rounded to three decimal points.",
0 commit comments