Skip to main content
Glama
duke0317

Image Processing MCP Server

by duke0317

apply_sepia

Apply a vintage sepia filter to images to create a warm, antique look by converting colors to brownish tones. Use this tool to transform digital photos into nostalgic, classic-style images.

Instructions

应用复古棕褐色滤镜

Input Schema

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core handler function implementing the sepia filter. Loads image, applies pixel-by-pixel color transformation using sepia tone matrix (coefficients for R,G,B channels), clamps values to 0-255, and returns processed image data via ImageProcessor.
    async def apply_sepia(image_data: str) -> list[TextContent]:
        """
        应用复古棕褐色滤镜
        
        Args:
            image_data: 图片数据(base64编码)
            
        Returns:
            应用滤镜后的图片数据
        """
        try:
            # 验证参数
            if not image_data:
                raise ValidationError("图片数据不能为空")
            
            # 加载图片
            image = processor.load_image(image_data)
            
            # 转换为RGB模式
            if image.mode != 'RGB':
                image = image.convert('RGB')
            
            # 应用棕褐色滤镜
            pixels = image.load()
            width, height = image.size
            
            for y in range(height):
                for x in range(width):
                    r, g, b = pixels[x, y]
                    
                    # 棕褐色变换公式
                    tr = int(0.393 * r + 0.769 * g + 0.189 * b)
                    tg = int(0.349 * r + 0.686 * g + 0.168 * b)
                    tb = int(0.272 * r + 0.534 * g + 0.131 * b)
                    
                    # 确保值在0-255范围内
                    tr = min(255, tr)
                    tg = min(255, tg)
                    tb = min(255, tb)
                    
                    pixels[x, y] = (tr, tg, tb)
            
            # 输出处理后的图片
            output_info = processor.output_image(image, "sepia")
            
            result = {
                "success": True,
                "message": "复古棕褐色滤镜应用成功",
                "data": {
                    **output_info,
                    "filter_type": "sepia",
                    "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:354-367 (registration)
    MCP tool registration using @mcp.tool() decorator. Defines tool schema via Annotated Field (image_source: str), description, and wraps the execution of the core handler from filters.py using safe_run_async.
    @mcp.tool()
    def apply_sepia(
        image_source: Annotated[str, Field(description="图片源,可以是文件路径或base64编码的图片数据")]
    ) -> str:
        """应用复古棕褐色滤镜"""
        try:
            result = safe_run_async(filters_apply_sepia(image_source))
            return result[0].text
        except Exception as e:
            return json.dumps({
                "success": False,
                "error": f"应用复古滤镜失败: {str(e)}"
            }, ensure_ascii=False, indent=2)
  • Explicit JSON schema definition for the apply_sepia tool input, specifying required 'image_data' string parameter. Matches the MCP tool signature.
    Tool(
        name="apply_sepia",
        description="应用复古棕褐色滤镜",
        inputSchema={
            "type": "object",
            "properties": {
                "image_data": {
                    "type": "string",
                    "description": "图片数据(base64编码)"
                }
            },
            "required": ["image_data"]
        }
    ),
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. While 'apply' implies a transformation operation, the description doesn't reveal whether this is destructive to the original image, what permissions are needed, whether it has rate limits, or what the output format will be. For a mutation tool with zero annotation coverage, this is a significant gap.

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 phrase that directly states the tool's function without any wasted words. It's appropriately sized for a straightforward image filter operation and is front-loaded with the essential information.

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 transformation), the presence of an output schema (which handles return values), and 100% schema coverage for the single parameter, the description is minimally adequate. However, the lack of annotations and behavioral context means it doesn't fully prepare the agent for safe and effective use.

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%, with the single parameter 'image_source' well-documented in the schema as accepting file paths or base64 data. The description adds no additional parameter semantics beyond what the schema already provides, so it meets the baseline score of 3 for high schema coverage.

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 retro sepia filter) clearly states the verb 'apply' and the resource 'sepia filter', making the purpose immediately understandable. It distinguishes from siblings like 'apply_invert' or 'apply_blur' by specifying the particular filter type. However, it doesn't explicitly mention this operates on images, though that's implied by context.

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 sepia filtering is appropriate compared to other color adjustments like 'adjust_brightness' or 'convert_to_grayscale', nor does it specify prerequisites or exclusions. The agent must infer usage from the tool name alone.

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