Skip to main content
Glama
duke0317

Image Processing MCP Server

by duke0317

adjust_saturation

Adjust image saturation levels to enhance or reduce color intensity. Modify saturation factor to create vibrant visuals or grayscale effects for image processing workflows.

Instructions

调整图片饱和度

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
image_sourceYes图片源,可以是文件路径或base64编码的图片数据
factorYes饱和度调整因子,1.0为原始饱和度,>1.0增强,<1.0减弱,0为灰度

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core handler function that validates input, loads the image using ImageProcessor, applies saturation adjustment with PIL's ImageEnhance.Color.enhance(factor), generates output image data, and returns JSON result.
    async def adjust_saturation(image_source: str, factor: float) -> list[TextContent]:
        """
        调整图片饱和度
        
        Args:
            image_source: 图片数据(base64编码)或文件路径
            factor: 饱和度调整因子(0.0-2.0)
            
        Returns:
            调整后的图片数据
        """
        try:
            # 验证参数
            if not image_source:
                raise ValidationError("图片数据不能为空")
            
            if not validate_numeric_range(factor, 0.0, 2.0):
                raise ValidationError(f"饱和度因子必须在0.0-2.0范围内: {factor}")
            
            # 加载图片
            image = processor.load_image(image_source)
            
            # 调整饱和度
            enhancer = ImageEnhance.Color(image)
            enhanced_image = enhancer.enhance(factor)
            
            # 输出处理后的图片
            output_info = processor.output_image(enhanced_image, "saturation")
            
            result = {
                "success": True,
                "message": f"饱和度调整成功: 因子 {factor}",
                "data": {
                    **output_info,
                    "saturation_factor": factor,
                    "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:414-428 (registration)
    MCP server tool registration using FastMCP's @mcp.tool() decorator. This synchronous wrapper calls the async handler from tools.color_adjust via safe_run_async and handles errors.
    @mcp.tool()
    def adjust_saturation(
        image_source: Annotated[str, Field(description="图片源,可以是文件路径或base64编码的图片数据")],
        factor: Annotated[float, Field(description="饱和度调整因子,1.0为原始饱和度,>1.0增强,<1.0减弱,0为灰度", ge=0)]
    ) -> str:
        """调整图片饱和度"""
        try:
            result = safe_run_async(color_adjust_saturation(image_source, factor))
            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 adjust_saturation tool in the get_color_adjust_tools() function (possibly legacy or internal). Defines JSON schema with image_source (string) and factor (number 0.0-2.0).
    Tool(
        name="adjust_saturation",
        description="调整图片饱和度",
        inputSchema={
            "type": "object",
            "properties": {
                "image_source": {
                    "type": "string",
                    "description": "图片数据(base64编码)或文件路径"
                },
                "factor": {
                    "type": "number",
                    "description": "饱和度调整因子(0.0-2.0,1.0为原始饱和度,0.0为灰度)",
                    "minimum": 0.0,
                    "maximum": 2.0
                }
            },
            "required": ["image_source", "factor"]
        }
    ),
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 '调整' (adjust) implies a mutation operation, the description doesn't specify whether this modifies the original image or creates a new one, what permissions are needed, or any side effects like performance impacts. It lacks details on output format or error conditions, leaving significant gaps.

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 purpose without any wasted words. It's front-loaded and appropriately sized for a simple image adjustment tool, making it easy to parse quickly.

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), the lack of annotations, and the presence of an output schema (which reduces the need to describe return values), the description is minimally adequate. It states what the tool does but misses behavioral details and usage context, leaving room for improvement without being completely inadequate.

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's in the input schema, which has 100% coverage with clear descriptions for both parameters (image_source and factor). Since the schema fully documents the parameters, the baseline score of 3 is appropriate—the description doesn't compensate but doesn't need to given the schema's completeness.

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 '调整图片饱和度' (adjust image saturation) clearly states the verb ('adjust') and resource ('image saturation'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'adjust_brightness' or 'adjust_contrast' that perform similar adjustment operations on images, which prevents a perfect score.

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 many sibling tools for image adjustments (e.g., adjust_brightness, adjust_contrast, convert_to_grayscale), there's no indication of appropriate contexts, prerequisites, or exclusions for saturation adjustment specifically.

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