使用说明
@氟化氢/mcp-geo
MCP(模型上下文协议)服务器,用于使用渐近线生成精确的几何图像。 该服务器允许与MCP兼容的AI模型通过提供Asymptote代码来请求图像生成。
先决条件
在使用此服务器之前,请确保已安装以下内容:
- Node.js:建议使用16.x或更高版本。您可以从以下网址下载 nodejs.org.
- 渐行渐远:这是一个关键的依赖关系。这
asy命令行工具必须在系统的PATH中安装并可访问。- 访问 Asymptote官方网站 下载和详细的安装说明。
- 常见安装方法:
- macOS(通过Homebrew):
brew install asymptote - Debian/Ubuntu Linux:
sudo apt-get install asymptote - 窗户: 通常作为MiKTeX或TeX Live等TeX发行版的一部分安装。确保渐近线
bin目录已添加到您的PATH中。
- macOS(通过Homebrew):
- 服务器将尝试检查
asy -version启动时,如果找不到错误,请打印错误。
安装
全局安装此软件包(如果您打算运行 connect 直接命令)或作为另一个项目中的依赖项:
npm install @luorivergoddess/mcp-geo
如果您已经克隆了存储库,并希望在本地运行它进行开发:
- 克隆存储库。
- 安装依赖项:
npm install - 构建项目:
npm run build
用法
启动服务器
安装包后(例如,全局或本地链接),您可以使用启动MCP服务器 connect 此包提供的命令。此命令旨在由MCP客户端调用。
npx @luorivergoddess/mcp-geo connect
或者,如果您已经克隆并构建了存储库:
node dist/cli.js
服务器将启动并监听stdin/stdout上的JSON-RPC消息,使用 @modelcontextprotocol/sdk.
MCP客户端集成
配置您的MCP兼容客户端(例如,具有复制代理模式的VS Code、Claude Desktop)以使用此服务器。这通常涉及告诉客户端如何启动服务器,这将是 npx @luorivergoddess/mcp-geo connect 命令。
可用工具: renderGeometricImage
服务器公开了一个主要工具:
- 姓名:
renderGeometricImage - 说明: 从Asymptote代码渲染图像。
- 输入架构:
{ "type": "object", "properties": { "asyCode": { "type": "string", "description": "A string containing complete and valid Asymptote code to be compiled. The server executes this code directly. Ensure necessary `import` statements (e.g., `import graph;`) and settings (e.g., `unitsize(1cm);`) are included within this code block if needed." }, "outputParams": { "type": "object", "description": "Optional parameters to control the output image.", "properties": { "format": { "type": "string", "enum": ["svg", "png"], "description": "The desired output image format. \"svg\" for scalable vector graphics (recommended for diagrams and plots), \"png\" for raster graphics. Defaults to \"svg\" if not specified." }, "renderLevel": { "type": "number", "description": "For PNG output only. Specifies the rendering quality (supersampling level for antialiasing). Higher values (e.g., 4 or 8) produce smoother images but take longer to render and result in larger files. Asymptote default is 2. This server defaults to 4 if not specified and format is \"png\". Ignored for SVG output." } } } }, "required": ["asyCode"] } - 输出:
工具返回a
CallToolResult包含一系列内容部分。- 如果成功,它包括
ImageContent部分内容如下:type: "image"mimeType: "image/svg+xml"或"image/png"data: "<base64_encoded_image_data>"
- 它也可能包括
TextContent使用Asymptote的日志。 - 如果发生错误,它会抛出
McpError.
- 如果成功,它包括
示例 renderGeometricImage 调用(JSON arguments 字段):
{
"asyCode": "draw(unitsquare); fill(unitsquare, lightblue);",
"outputParams": {
"format": "png",
"renderLevel": 4
}
}
客户端兼容性说明:
- 某些MCP客户端可能对支持的图像MIME类型有限制。
- 例如,如果您将此服务器与不支持的客户端一起使用
image/svg+xml(例如,所报告的“Cherry Studio”的某些版本或配置),请确保您要求png格式包括"outputParams": { "format": "png" }在您的工具调用参数中。服务器默认为svg如果没有指定格式。
作者
氟化物
许可证
国际协调委员会