Skip to main content
Glama
duke0317

Image Processing MCP Server

by duke0317

apply_contour

Apply contour filters to images to detect and highlight edges and boundaries for enhanced visual analysis.

Instructions

应用轮廓滤镜

Input Schema

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core handler function that loads the image, applies PIL's ImageFilter.CONTOUR filter, processes output via ImageProcessor, and returns JSON result with processed image data.
    async def apply_contour(image_data: str) -> list[TextContent]:
        """
        应用轮廓滤镜
        
        Args:
            image_data: 图片数据(base64编码)
            
        Returns:
            应用滤镜后的图片数据
        """
        try:
            # 验证参数
            if not image_data:
                raise ValidationError("图片数据不能为空")
            
            # 加载图片
            image = processor.load_image(image_data)
            
            # 应用轮廓滤镜
            contour_image = image.filter(ImageFilter.CONTOUR)
            
            # 输出处理后的图片
            output_info = processor.output_image(contour_image, "contour")
            
            result = {
                "success": True,
                "message": "轮廓滤镜应用成功",
                "data": {
                    **output_info,
                    "filter_type": "contour",
                    "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:340-352 (registration)
    MCP server tool registration using @mcp.tool() decorator. Wraps the filters.apply_contour handler with safe_run_async and error handling.
    @mcp.tool()
    def apply_contour(
        image_source: Annotated[str, Field(description="图片源,可以是文件路径或base64编码的图片数据")]
    ) -> str:
        """应用轮廓滤镜"""
        try:
            result = safe_run_async(filters_apply_contour(image_source))
            return result[0].text
        except Exception as e:
            return json.dumps({
                "success": False,
                "error": f"应用轮廓效果失败: {str(e)}"
            }, ensure_ascii=False, indent=2)
  • Input schema definition for the apply_contour tool in the get_filter_tools() function (possibly auxiliary or legacy).
    Tool(
        name="apply_contour",
        description="应用轮廓滤镜",
        inputSchema={
            "type": "object",
            "properties": {
                "image_data": {
                    "type": "string",
                    "description": "图片数据(base64编码)"
                }
            },
            "required": ["image_data"]
        }
    ),
Behavior1/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 contour filter') without any details on effects (e.g., visual outcome, whether it modifies the image in place or creates a new version), performance implications, error conditions, or output format. This is inadequate for a tool that performs image processing with potential side effects.

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

Conciseness4/5

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

The description is a single phrase ('应用轮廓滤镜'), which is very concise and front-loaded with the core action. There is no wasted verbiage, making it efficient in terms of length. However, it may be overly terse given the lack of additional context needed for clarity and usage.

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

Completeness2/5

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

Given the complexity of image processing and the lack of annotations, the description is incomplete. It doesn't explain what a 'contour filter' does, how it differs from similar tools, or what the output entails. While an output schema exists (which might define the return structure), the description fails to provide sufficient context for an agent to understand the tool's behavior and appropriate use cases, especially among many siblings.

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 input schema has 100% description coverage, with the single parameter 'image_source' well-documented as accepting file paths or base64-encoded image data. The description adds no additional meaning beyond this, as it doesn't elaborate on parameter usage or constraints. With high schema coverage, the baseline score of 3 is appropriate, as the schema handles the parameter semantics effectively.

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

Purpose3/5

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

The description '应用轮廓滤镜' (apply contour filter) states a clear verb+resource combination, indicating it applies a contour filter to an image. However, it doesn't distinguish this tool from its many sibling image processing tools (like apply_edge_enhance, apply_find_edges, etc.), leaving the specific nature of 'contour' ambiguous compared to similar edge-related filters.

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. With numerous sibling tools for image effects (e.g., apply_edge_enhance, apply_emboss, apply_find_edges), there is no indication of what makes 'contour' unique or when it's preferred over other edge or filter operations, nor any mention of prerequisites or context for its application.

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