@modelcontextprotocol/server-shadertoy 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -19
- package/dist/index.js +3644 -44
- package/dist/mcp-app.html +45 -44
- package/dist/server.js +1747 -1732
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -10,11 +10,33 @@ A demo MCP App that renders [ShaderToy](https://www.shadertoy.com/)-compatible G
|
|
|
10
10
|
</tr>
|
|
11
11
|
</table>
|
|
12
12
|
|
|
13
|
+
## MCP Client Configuration
|
|
14
|
+
|
|
15
|
+
Add to your MCP client configuration (stdio transport):
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"mcpServers": {
|
|
20
|
+
"shadertoy": {
|
|
21
|
+
"command": "npx",
|
|
22
|
+
"args": [
|
|
23
|
+
"-y",
|
|
24
|
+
"--silent",
|
|
25
|
+
"--registry=https://registry.npmjs.org/",
|
|
26
|
+
"@modelcontextprotocol/server-shadertoy",
|
|
27
|
+
"--stdio"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
13
34
|
## Features
|
|
14
35
|
|
|
15
36
|
- **Real-time Rendering**: Renders GLSL shaders using WebGL 2.0
|
|
16
37
|
- **ShaderToy Compatibility**: Uses the standard `mainImage(out vec4 fragColor, in vec2 fragCoord)` entry point
|
|
17
38
|
- **Multi-pass Rendering**: Supports buffers A-D for feedback effects, blur chains, and simulations
|
|
39
|
+
- **Mouse & Touch Interaction**: Full iMouse support with click detection (works on mobile)
|
|
18
40
|
- **Standard Uniforms**: iResolution, iTime, iTimeDelta, iFrame, iMouse, iDate, iChannel0-3
|
|
19
41
|
|
|
20
42
|
## Running
|
|
@@ -101,13 +123,20 @@ _Tool input:_
|
|
|
101
123
|
}
|
|
102
124
|
```
|
|
103
125
|
|
|
104
|
-
**Interactive Julia Set** (
|
|
126
|
+
**Interactive Julia Set** (click and drag to control the fractal's c parameter):
|
|
105
127
|
|
|
106
128
|
```glsl
|
|
107
129
|
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
|
108
130
|
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y * 2.5;
|
|
109
|
-
|
|
110
|
-
vec2 c
|
|
131
|
+
// Use mouse position if clicked, otherwise use animated default
|
|
132
|
+
vec2 c;
|
|
133
|
+
if (iMouse.z > 0.0) {
|
|
134
|
+
// Mouse is pressed - use mouse position
|
|
135
|
+
c = (iMouse.xy / iResolution.xy - 0.5) * 2.0;
|
|
136
|
+
} else {
|
|
137
|
+
// Not pressed - animate around an interesting region
|
|
138
|
+
c = vec2(-0.8 + 0.2 * sin(iTime * 0.5), 0.156 + 0.1 * cos(iTime * 0.7));
|
|
139
|
+
}
|
|
111
140
|
vec2 z = uv;
|
|
112
141
|
float iter = 0.0;
|
|
113
142
|
for (int i = 0; i < 100; i++) {
|
|
@@ -126,25 +155,33 @@ _Tool input:_
|
|
|
126
155
|
|
|
127
156
|
```json
|
|
128
157
|
{
|
|
129
|
-
"fragmentShader": "void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
158
|
+
"fragmentShader": "void mainImage(out vec4 fragColor, in vec2 fragCoord) {\n vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y * 2.5;\n vec2 c;\n if (iMouse.z > 0.0) {\n c = (iMouse.xy / iResolution.xy - 0.5) * 2.0;\n } else {\n c = vec2(-0.8 + 0.2 * sin(iTime * 0.5), 0.156 + 0.1 * cos(iTime * 0.7));\n }\n vec2 z = uv;\n float iter = 0.0;\n for (int i = 0; i < 100; i++) {\n z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c;\n if (dot(z, z) > 4.0) break;\n iter++;\n }\n float t = iter / 100.0;\n vec3 col = 0.5 + 0.5 * cos(3.0 + t * 6.28 * 2.0 + vec3(0.0, 0.6, 1.0));\n if (iter == 100.0) col = vec3(0.0);\n fragColor = vec4(col, 1.0);\n}"
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Mouse & Touch Interaction
|
|
163
|
+
|
|
164
|
+
The `iMouse` uniform provides interactive input, compatible with the official Shadertoy specification:
|
|
165
|
+
|
|
166
|
+
| Component | When Button Down | After Release | Never Clicked |
|
|
167
|
+
| ----------- | ---------------------- | ---------------- | ------------- |
|
|
168
|
+
| `iMouse.xy` | Current position | Last position | `(0, 0)` |
|
|
169
|
+
| `iMouse.zw` | Click start (positive) | Negated (-x, -y) | `(0, 0)` |
|
|
170
|
+
|
|
171
|
+
**Detecting button state:**
|
|
172
|
+
|
|
173
|
+
```glsl
|
|
174
|
+
if (iMouse.z > 0.0) {
|
|
175
|
+
// Button/touch is currently held down
|
|
176
|
+
} else if (iMouse.z < 0.0) {
|
|
177
|
+
// Button was released (can use abs(iMouse.zw) for last click position)
|
|
178
|
+
} else {
|
|
179
|
+
// Never clicked - show default state or animate
|
|
145
180
|
}
|
|
146
181
|
```
|
|
147
182
|
|
|
183
|
+
Touch events are automatically supported for mobile devices.
|
|
184
|
+
|
|
148
185
|
## Architecture
|
|
149
186
|
|
|
150
187
|
### Server (`server.ts`)
|