Porcus Lardum MCP服务器
一种MCP(模型上下文协议)服务器,使用Porcus Lardum API的ImageOpsTransformParamsIn模型提供图像转换功能。
特性
- ImageOps转换:仅使用ImageOpsTransformParamsIn模型
- 裁剪:按坐标、纵横比或边框裁剪
- 遏制:缩放图像以适应边界
- 填充:将画布扩展到目标尺寸
- 旋转:按度数旋转图像或自动旋转为横向/纵向
- DPI控制:设置图像DPI元数据
- 灰度:将图像转换为灰度
- PDF转换:将图像转换为PDF格式
- 预构建提示:已准备好使用的常见转换场景
安装
- 克隆此存储库:
git clone
cd porcus-lardum-mcp-server- 使用uv安装依赖项:
uv pip install -e .或者使用pip:
pip install -e .- 配置环境变量:
cp .env.example .env
# Edit .env and add your Porcus Lardum API key配置
在您的 .env 文件:
PORCUS_LARDUM_API_KEY:您的Porcus Lardum API密钥(必需)PORCUS_LARDUM_BASE_URL:API基本URL(可选,默认为https://porcus-lardum-func-dev.azurewebsites.net)
用法
运行服务器
发展:
uv run mcp dev server.py在Claude Desktop中安装
uv run mcp install server.py或者手动添加到Claude Desktop配置:
{
"mcpServers": {
"porcus-lardum": {
"command": "uv",
"args": ["run", "python", "/path/to/server.py"],
"env": {
"PORCUS_LARDUM_API_KEY": "your_api_key_here"
}
}
}
}可用工具
transform_image
使用ImageOpsTransformParamsIn模型转换图像:
- 百万像素:从边框中删除像素\[上、右、下、左\]
- crop_box_像素:提取矩形\[x1,y1,x2,y2\](像素)
- 作物性状比率:作物与宽度/高度比(例如,16:9为1.77)
- pad_像素:以像素为单位展开画布\[宽度、高度\]
- 包含像素:缩放以适应\[宽度,高度\]像素
- override_dpi:设置DPI元数据
- 旋转:旋转角度(度)
- rotate_to:自动旋转到“横向”或“纵向”
- 灰度:转换为灰度
- PDF:将输出转换为PDF
可用提示
服务器包括常见用例的预配置提示:
crop_image_prompt:裁剪到特定像素坐标crop_aspect_ratio_prompt:裁剪到特定的纵横比contain_image_prompt:缩放图像以适应尺寸rotate_image_prompt:按度旋转图像convert_to_grayscale_prompt:转换为灰度set_dpi_prompt:设置图像DPI元数据pad_image_prompt:添加填充以展开画布
Claude中的示例用法
User: "Please contain this image within 800x600 pixels"
Assistant: [Uses contain_image_prompt to scale the image]
User: "Crop this image to 16:9 aspect ratio"
Assistant: [Uses crop_aspect_ratio_prompt with aspect_ratio=1.77]
User: "Convert this image to grayscale and rotate 90 degrees"
Assistant: [Uses transform_image with grayscale=true and rotate=90]发展
运行测试
# Test the server locally
uv run python server.py添加新转换
要添加新的转换功能,请修改 ImageOpsTransformParamsIn 类在 server.py 并更新相应的刀具参数。
许可证
\[您的许可证在这里\]
支持
有关MCP服务器的问题或疑问,请在此存储库中打开问题。 有关Porcus Lardum API文档,请参阅OpenAPI规范。
