Skip to main content
Glama
duke0317

Image Processing MCP Server

by duke0317

apply_gaussian_blur

Apply Gaussian blur to images by specifying a radius value to reduce detail or noise in visual content.

Instructions

应用高斯模糊滤镜

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
image_sourceYes图片源,可以是文件路径或base64编码的图片数据
radiusYes高斯模糊半径,值越大模糊效果越强

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core handler function implementing the Gaussian blur effect: validates inputs, loads image from base64 data, applies PIL's ImageFilter.GaussianBlur(radius), processes output via ImageProcessor, returns JSON result as TextContent list.
    async def apply_gaussian_blur(image_data: str, radius: float) -> list[TextContent]:
        """
        应用高斯模糊滤镜
        
        Args:
            image_data: 图片数据(base64编码)
            radius: 高斯模糊半径
            
        Returns:
            应用滤镜后的图片数据
        """
        try:
            # 验证参数
            if not image_data:
                raise ValidationError("图片数据不能为空")
            
            if not validate_numeric_range(radius, 0.1, 10.0):
                raise ValidationError(f"高斯模糊半径必须在0.1-10.0范围内: {radius}")
            
            # 加载图片
            image = processor.load_image(image_data)
            
            # 应用高斯模糊滤镜
            blurred_image = image.filter(ImageFilter.GaussianBlur(radius))
            
            # 输出处理后的图片
            output_info = processor.output_image(blurred_image, "gaussian_blur")
            
            result = {
                "success": True,
                "message": f"高斯模糊滤镜应用成功: 半径 {radius}",
                "data": {
                    **output_info,
                    "filter_type": "gaussian_blur",
                    "radius": radius,
                    "size": image.size
                }
            }
            
            return [TextContent(type="text", text=json.dumps(result, ensure_ascii=False))]
            
        except ValidationError as e:
            error_result = {
                "success": False,
                "error": f"参数验证失败: {str(e)}"
            }
            return [TextContent(type="text", text=json.dumps(error_result, ensure_ascii=False))]
            
        except Exception as e:
            error_result = {
                "success": False,
                "error": f"高斯模糊滤镜应用失败: {str(e)}"
            }
            return [TextContent(type="text", text=json.dumps(error_result, ensure_ascii=False))]
  • main.py:255-269 (registration)
    MCP tool registration using @mcp.tool() decorator. Defines input schema via Annotated[Field] for image_source and radius parameters. Delegates execution to the filters.py handler via safe_run_async with error handling and JSON response formatting.
    @mcp.tool()
    def apply_gaussian_blur(
        image_source: Annotated[str, Field(description="图片源,可以是文件路径或base64编码的图片数据")],
        radius: Annotated[float, Field(description="高斯模糊半径,值越大模糊效果越强", ge=0.1)]
    ) -> str:
        """应用高斯模糊滤镜"""
        try:
            result = safe_run_async(filters_apply_gaussian_blur(image_source, radius))
            return result[0].text
        except Exception as e:
            return json.dumps({
                "success": False,
                "error": f"应用高斯模糊失败: {str(e)}"
            }, ensure_ascii=False, indent=2)
  • Tool schema definition within get_filter_tools(), specifying JSON schema for inputs: image_data (base64 string) and radius (number 0.1-10.0). Note: This appears unused in the main registration flow.
    Tool(
        name="apply_gaussian_blur",
        description="应用高斯模糊滤镜",
        inputSchema={
            "type": "object",
            "properties": {
                "image_data": {
                    "type": "string",
                    "description": "图片数据(base64编码)"
                },
                "radius": {
                    "type": "number",
                    "description": "高斯模糊半径(0.1-10.0)",
                    "minimum": 0.1,
                    "maximum": 10.0
                }
            },
            "required": ["image_data", "radius"]
        }
    ),
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but lacks behavioral details. It doesn't disclose whether this is a read-only or destructive operation, how it handles errors (e.g., invalid image sources), performance implications, or output characteristics beyond what the output schema might cover.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence in Chinese ('应用高斯模糊滤镜') that directly states the tool's purpose without unnecessary words. It is appropriately sized and front-loaded, with zero waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (image processing with two parameters), no annotations, and the presence of an output schema, the description is minimally adequate. It states what the tool does but lacks context on usage, behavioral traits, or integration with siblings, leaving gaps that could hinder agent selection.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so parameters are fully documented in the schema. The description adds no additional meaning beyond the schema's details for 'image_source' and 'radius', meeting the baseline for high coverage without extra value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '应用高斯模糊滤镜' (Apply Gaussian blur filter) clearly states the action (apply) and the specific effect (Gaussian blur filter). It distinguishes from siblings like 'apply_blur' (generic blur) by specifying the Gaussian type, though it doesn't explicitly contrast with all similar tools like 'apply_smooth' or 'apply_sharpen'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention scenarios where Gaussian blur is preferred over other blur types (e.g., 'apply_blur') or other image effects, nor does it specify prerequisites or exclusions for usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/duke0317/ps-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server