GLSL着色器生成服务

通过Model Context Protocol (MCP)连接LLM与ShaderToy,实现复杂GLSL着色器的查询、搜索和生成。

  • by wilsonchenghy
  • Python
  • 本地部署
  • 50 星标
  • 更新于
在 GitHub 查看 wilsonchenghy/ShaderToy-MCP

使用说明

ShaderToy MCP

MCP Server for ShaderBoy,一个用于创建、运行和共享GLSL着色器的网站(https://www.shadertoy.com/).它通过模型上下文协议(MCP)将Claude等LLM与ShaderBoy连接起来,允许LLM查询和读取整个网页,使其能够制作通常无法制作的越来越复杂的着色器。

它生成的复杂着色器示例:


海洋 (https://www.shadertoy.com/view/tXs3Wf)


山脉 (https://www.shadertoy.com/view/W3l3Df)


矩阵数字雨 (https://www.shadertoy.com/view/33l3Df)

特性

  • 在ShaderBoy上检索任何着色器的信息
  • 通过搜索提示搜索ShaderBoy上可用的着色器
  • 通过学习ShaderBoy上的现有着色器生成复杂着色器

MCP工具

  • get_shader_info()
  • search_shader()

安装

在Mac上,请按以下方式安装uv

brew install uv

在Windows上

powershell -c "irm https://astral.sh/uv/install.ps1 | iex" 

然后

set Path=C:\Users\nntra\.local\bin;%Path%

否则,安装说明在他们的网站上: 安装uv

Claude桌面集成

Git克隆项目 git clone https://github.com/wilsonchenghy/ShaderToy-MCP.git

转到Claude>设置>开发人员>编辑配置>Claude_desktop_Config.json,以包含以下内容:

{
    "mcpServers": {
        "ShaderToy_MCP": {
          "command": "uv",
          "args": [
            "run",
            "--with",
            "mcp[cli]",
            "mcp",
            "run",
            "<path_to_project>/ShaderToy-MCP/src/ShaderToy-MCP/server.py"
          ],
          "env": {
            "SHADERTOY_APP_KEY": "your_actual_api_key"  // Replace with your API key
          }
        }
    }
}

在Claude上设置配置文件后,您将看到MCP的锤子图标。使用示例命令进行测试,看看它是否正确使用了MCP工具。

示例命令

Generate shader code of a {object}, if it is based on someone's work on ShaderToy, credit it, make the code follow the ShaderToy format: void mainImage( out vec4 fragColor, in vec2 fragCoord ) {}