Skip to main content
Glama
duke0317

Image Processing MCP Server

by duke0317

apply_smooth

Reduce image noise and soften details by applying a smoothing filter to images. This tool processes image files or base64 data to create cleaner visual outputs.

Instructions

应用平滑滤镜

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
image_sourceYes图片源,可以是文件路径或base64编码的图片数据

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core implementation of the apply_smooth tool handler. Loads the image from base64 data, applies PIL's ImageFilter.SMOOTH filter, generates output info using ImageProcessor, and returns JSON result.
    async def apply_smooth(image_data: str) -> list[TextContent]:
        """
        应用平滑滤镜
        
        Args:
            image_data: 图片数据(base64编码)
            
        Returns:
            应用滤镜后的图片数据
        """
        try:
            # 验证参数
            if not image_data:
                raise ValidationError("图片数据不能为空")
            
            # 加载图片
            image = processor.load_image(image_data)
            
            # 应用平滑滤镜
            smooth_image = image.filter(ImageFilter.SMOOTH)
            
            # 输出处理后的图片
            output_info = processor.output_image(smooth_image, "smooth")
            
            result = {
                "success": True,
                "message": "平滑滤镜应用成功",
                "data": {
                    **output_info,
                    "filter_type": "smooth",
                    "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:327-338 (registration)
    MCP tool registration for apply_smooth using @mcp.tool() decorator. Wraps the filters.apply_smooth handler with safe_run_async and error handling, defining input schema via Annotated Field.
    def apply_smooth(
        image_source: Annotated[str, Field(description="图片源,可以是文件路径或base64编码的图片数据")]
    ) -> str:
        """应用平滑滤镜"""
        try:
            result = safe_run_async(filters_apply_smooth(image_source))
            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 for apply_smooth in get_filter_tools(), specifying inputSchema requiring 'image_data' string.
    Tool(
        name="apply_smooth",
        description="应用平滑滤镜",
        inputSchema={
            "type": "object",
            "properties": {
                "image_data": {
                    "type": "string",
                    "description": "图片数据(base64编码)"
                }
            },
            "required": ["image_data"]
        }
    ),
  • main.py:40-51 (registration)
    Import of the apply_smooth handler from tools.filters as filters_apply_smooth for use in main.py tool registration.
    from tools.filters import (
        apply_blur as filters_apply_blur,
        apply_gaussian_blur as filters_apply_gaussian_blur,
        apply_sharpen as filters_apply_sharpen,
        apply_edge_enhance as filters_apply_edge_enhance,
        apply_emboss as filters_apply_emboss,
        apply_find_edges as filters_apply_find_edges,
        apply_smooth as filters_apply_smooth,
        apply_contour as filters_apply_contour,
        apply_sepia as filters_apply_sepia,
        apply_invert as filters_apply_invert
    )
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states the action ('apply smooth filter') without detailing effects (e.g., how much smoothing, whether it's reversible, performance implications, or output format). For an image processing tool with no annotation coverage, this is a significant gap in transparency about its behavior and constraints.

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 phrase '应用平滑滤镜', which is extremely concise and front-loaded with the core action. There is no wasted text, and it directly communicates the tool's function without unnecessary elaboration, making it efficient for quick understanding.

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 complexity (simple image filter), 100% schema coverage, and the presence of an output schema (implied by 'Has output schema: true'), the description is minimally adequate. It states what the tool does but lacks details on effects, usage context, or behavioral traits. With output schema handling return values, the description meets a basic threshold but leaves gaps in guidance and transparency.

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?

The description adds no parameter information beyond what the schema provides. The input schema has 100% description coverage, clearly documenting the 'image_source' parameter as accepting file paths or base64 data. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't enhance parameter understanding but doesn't detract either.

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 smooth filter) clearly states the verb 'apply' and the resource 'smooth filter', making the purpose understandable. It distinguishes from siblings like apply_blur or apply_sharpen by specifying 'smooth' as the filter type. However, it doesn't explicitly differentiate from similar tools like apply_gaussian_blur, which might also smooth images, leaving some ambiguity.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when smooth filtering is appropriate (e.g., for noise reduction or softening edges) or when not to use it (e.g., for sharp details). With many sibling tools like apply_blur and apply_sharpen, this lack of context makes it hard for an agent to choose correctly without additional information.

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