@ray0404/zig-audio-mcp 0.1.0
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/AGENTS.md +302 -0
- package/GEMINI.md +266 -0
- package/README.md +444 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1203 -0
- package/dist/index.js.map +1 -0
- package/dist/test.d.ts +2 -0
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +162 -0
- package/dist/test.js.map +1 -0
- package/evaluation.xml +59 -0
- package/mcp-config.json +12 -0
- package/mcp.json +5 -0
- package/package.json +46 -0
- package/src/index.ts +1281 -0
- package/src/test.ts +195 -0
- package/tsconfig.json +20 -0
- package/tsconfig.tsbuildinfo +1 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
# Zig-Audio MCP Server | Project Context and Instructions
|
|
2
|
+
|
|
3
|
+
## Project Goal
|
|
4
|
+
|
|
5
|
+
Build an MCP (Model Context Protocol) server that communicates with either local and/or remote resources in order to aid users, **LLMs/Agents**, etc, in writing high-quality `zig` code, with an emphasis in pro-audio/DSP algorithms.
|
|
6
|
+
|
|
7
|
+
## Project Overview
|
|
8
|
+
|
|
9
|
+
This is a Node.js/TypeScript project that implements an MCP server to help AI systems assist developers in writing Zig audio and DSP code. The server provides tools for:
|
|
10
|
+
|
|
11
|
+
- Discovering and learning about Zig audio/DSP libraries
|
|
12
|
+
- Understanding DSP filter algorithms and their implementations
|
|
13
|
+
- Generating starter code for common audio programming tasks
|
|
14
|
+
- Learning fundamental audio/DSP concepts
|
|
15
|
+
- Finding resources for further learning
|
|
16
|
+
|
|
17
|
+
## Technology Stack
|
|
18
|
+
|
|
19
|
+
- **Language:** TypeScript
|
|
20
|
+
- **MCP SDK:** @modelcontextprotocol/sdk ^1.0.0
|
|
21
|
+
- **Validation:** Zod ^3.22.4
|
|
22
|
+
- **Runtime:** Node.js 18+
|
|
23
|
+
- **Transport:** Stdio (default), supports Streamable HTTP
|
|
24
|
+
|
|
25
|
+
## Project Structure
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
MCP_Zig/
|
|
29
|
+
├── src/
|
|
30
|
+
│ ├── index.ts # Main MCP server implementation
|
|
31
|
+
│ └── test.ts # Evaluation tests
|
|
32
|
+
├── dist/ # Compiled JavaScript
|
|
33
|
+
├── package.json # Dependencies and scripts
|
|
34
|
+
├── tsconfig.json # TypeScript configuration
|
|
35
|
+
├── README.md # Project documentation
|
|
36
|
+
├── AGENTS.md # This file
|
|
37
|
+
├── evaluation.xml # Evaluation Q&A pairs
|
|
38
|
+
└── GEMINI.md # AI/LLM context
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Available Scripts
|
|
42
|
+
|
|
43
|
+
| Command | Description |
|
|
44
|
+
|---------|-------------|
|
|
45
|
+
| `npm install` | Install dependencies |
|
|
46
|
+
| `npm run build` | Compile TypeScript to JavaScript |
|
|
47
|
+
| `npm start` | Run the MCP server |
|
|
48
|
+
| `npm run dev` | Run in development mode with auto-reload |
|
|
49
|
+
| `npx tsx src/test.ts` | Run evaluation tests |
|
|
50
|
+
|
|
51
|
+
## MCP Tools
|
|
52
|
+
|
|
53
|
+
The server exposes 10 tools for AI assistants:
|
|
54
|
+
|
|
55
|
+
### 1. zig_audio_list_libraries
|
|
56
|
+
List available Zig audio/DSP libraries with optional filtering.
|
|
57
|
+
|
|
58
|
+
### 2. zig_audio_library_info
|
|
59
|
+
Get detailed information about a specific library (zang, zaudio, bonk, pcm, zig-liquid-dsp, dalek).
|
|
60
|
+
|
|
61
|
+
### 3. zig_dsp_explain_filter
|
|
62
|
+
Explain DSP filter types (lowpass, highpass, bandpass, notch, biquad, one-pole) with formulas and use cases.
|
|
63
|
+
|
|
64
|
+
### 4. zig_audio_generate_code
|
|
65
|
+
Generate starter code for audio/DSP tasks (oscillator, envelope, filter, delay, mixer, player, recorder, file operations).
|
|
66
|
+
|
|
67
|
+
### 5. zig_audio_list_resources
|
|
68
|
+
List learning resources (tutorials, references, examples, articles).
|
|
69
|
+
|
|
70
|
+
### 6. zig_dsp_get_concepts
|
|
71
|
+
Get explanations of fundamental audio/DSP concepts.
|
|
72
|
+
|
|
73
|
+
### 7. zig_audio_recommend_library
|
|
74
|
+
Get intelligent library recommendations based on use case and requirements.
|
|
75
|
+
|
|
76
|
+
### 8. zig_dsp_design_filter
|
|
77
|
+
Design DSP filters with coefficient calculation and stability verification.
|
|
78
|
+
|
|
79
|
+
### 9. zig_audio_verify_code
|
|
80
|
+
Verify Zig code for syntax issues and missing imports.
|
|
81
|
+
|
|
82
|
+
### 10. zig_audio_project_template
|
|
83
|
+
Generate complete project templates for audio applications.
|
|
84
|
+
|
|
85
|
+
## Development Guidelines
|
|
86
|
+
|
|
87
|
+
### MCP Protocol Compliance
|
|
88
|
+
- Use `@modelcontextprotocol/sdk` for server implementation
|
|
89
|
+
- Implement proper JSON-RPC 2.0 message handling
|
|
90
|
+
- Use StdioServerTransport for local execution
|
|
91
|
+
- Support Streamable HTTP for remote deployment
|
|
92
|
+
|
|
93
|
+
### Code Quality
|
|
94
|
+
- All inputs validated with Zod schemas
|
|
95
|
+
- Clear tool names following `zig_audio_*` or `zig_dsp_*` convention
|
|
96
|
+
- Comprehensive tool descriptions with parameter documentation
|
|
97
|
+
- Proper error handling with actionable messages
|
|
98
|
+
|
|
99
|
+
### Testing
|
|
100
|
+
- Run evaluation tests before submitting changes
|
|
101
|
+
- Ensure all tests pass: `npx tsx src/test.ts`
|
|
102
|
+
- Verify build succeeds: `npm run build`
|
|
103
|
+
|
|
104
|
+
## Extending the Server
|
|
105
|
+
|
|
106
|
+
To add new tools:
|
|
107
|
+
|
|
108
|
+
1. Define Zod input schema in the tool handler section
|
|
109
|
+
2. Add tool definition in the ListToolsRequestSchema handler
|
|
110
|
+
3. Implement the tool logic
|
|
111
|
+
4. Add corresponding test cases
|
|
112
|
+
|
|
113
|
+
## Zig Audio Ecosystem
|
|
114
|
+
|
|
115
|
+
The server maintains knowledge of the Zig audio ecosystem:
|
|
116
|
+
|
|
117
|
+
### Libraries
|
|
118
|
+
- **zang** - Synthesis library (MIT)
|
|
119
|
+
- **zaudio** - miniaudio wrapper (MIT)
|
|
120
|
+
- **bonk** - DSP objects (MPL-2.0)
|
|
121
|
+
- **pcm** - File I/O (MIT)
|
|
122
|
+
- **zig-liquid-dsp** - SDR library (MIT)
|
|
123
|
+
- **dalek** - Experimental engine (MIT)
|
|
124
|
+
|
|
125
|
+
### Filter Types
|
|
126
|
+
- Low pass, high pass, band pass, notch
|
|
127
|
+
- Biquad, one-pole filters
|
|
128
|
+
|
|
129
|
+
### Concepts
|
|
130
|
+
- Sample rate, bit depth, buffer size
|
|
131
|
+
- Nyquist frequency, aliasing
|
|
132
|
+
|
|
133
|
+
## CI/CD and Deployment
|
|
134
|
+
|
|
135
|
+
The project is designed to be deployed as:
|
|
136
|
+
|
|
137
|
+
1. **Local tool** - Run via stdio transport
|
|
138
|
+
2. **HTTP service** - Deploy with Streamable HTTP transport
|
|
139
|
+
3. **Docker container** - Containerize for cloud deployment
|
|
140
|
+
|
|
141
|
+
## Contact and Support
|
|
142
|
+
|
|
143
|
+
For issues, feature requests, or contributions, please refer to the project repository.
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
# GEMINI.md - AI/LLM Context for MCP Zig Audio
|
|
147
|
+
|
|
148
|
+
## Project Purpose
|
|
149
|
+
|
|
150
|
+
This MCP server helps AI assistants provide better assistance for writing Zig code related to audio programming and digital signal processing (DSP).
|
|
151
|
+
|
|
152
|
+
## What This Server Does
|
|
153
|
+
|
|
154
|
+
When an AI assistant needs to help with Zig audio/DSP programming, it can call this MCP server to:
|
|
155
|
+
|
|
156
|
+
1. **Discover Libraries** - Find which Zig libraries are available for specific audio tasks
|
|
157
|
+
2. **Explain Filters** - Understand how different DSP filters work mathematically
|
|
158
|
+
3. **Generate Code** - Create starter implementations for common patterns
|
|
159
|
+
4. **Learn Concepts** - Understand fundamental audio terminology
|
|
160
|
+
5. **Find Resources** - Locate tutorials and documentation
|
|
161
|
+
|
|
162
|
+
## Tool Usage Examples
|
|
163
|
+
|
|
164
|
+
### Finding the Right Library
|
|
165
|
+
|
|
166
|
+
**User Question:** "I want to build a synthesizer in Zig without any dynamic memory allocation. Which library should I use?"
|
|
167
|
+
|
|
168
|
+
**AI Action:** Call `zig_audio_list_libraries` with feature filter or `zig_audio_library_info` for specific libraries.
|
|
169
|
+
|
|
170
|
+
**Response:** The server returns information about zang, which is specifically designed for zero-allocation synthesis.
|
|
171
|
+
|
|
172
|
+
### Understanding DSP Concepts
|
|
173
|
+
|
|
174
|
+
**User Question:** "What is the Nyquist frequency and why does it matter for audio?"
|
|
175
|
+
|
|
176
|
+
**AI Action:** Call `zig_dsp_get_concepts` to get explanations.
|
|
177
|
+
|
|
178
|
+
**Response:** The server returns detailed explanations of Nyquist frequency, sample rate, aliasing, and their relationships.
|
|
179
|
+
|
|
180
|
+
### Generating Code
|
|
181
|
+
|
|
182
|
+
**User Question:** "Help me write a simple oscillator in Zig"
|
|
183
|
+
|
|
184
|
+
**AI Action:** Call `zig_audio_generate_code` with `task: "oscillator"`
|
|
185
|
+
|
|
186
|
+
**Response:** The server returns starter Zig code for implementing an oscillator.
|
|
187
|
+
|
|
188
|
+
### Filter Selection
|
|
189
|
+
|
|
190
|
+
**User Question:** "I need to remove DC offset from an audio signal, which filter should I use?"
|
|
191
|
+
|
|
192
|
+
**AI Action:** Call `zig_dsp_explain_filter` with different filter types to find the right one.
|
|
193
|
+
|
|
194
|
+
**Response:** High-pass filter or one-pole filter are suitable for DC offset removal, with explanations and formulas.
|
|
195
|
+
|
|
196
|
+
### Library Recommendations
|
|
197
|
+
|
|
198
|
+
**User Question:** "I want to build a cross-platform audio player in Zig. What library should I use?"
|
|
199
|
+
|
|
200
|
+
**AI Action:** Call `zig_audio_recommend_library` with use_case "audio player" and requirements ["cross-platform"].
|
|
201
|
+
|
|
202
|
+
**Response:** The server recommends zaudio as the primary choice, explaining it's a miniaudio wrapper perfect for cross-platform playback.
|
|
203
|
+
|
|
204
|
+
### Filter Design
|
|
205
|
+
|
|
206
|
+
**User Question:** "Help me design a low-pass filter at 1000 Hz for 44.1 kHz sample rate"
|
|
207
|
+
|
|
208
|
+
**AI Action:** Call `zig_dsp_design_filter` with filter_type "lowpass", sample_rate 44100, cutoff 1000.
|
|
209
|
+
|
|
210
|
+
**Response:** The server returns biquad coefficients, stability check, and ready-to-use Zig code.
|
|
211
|
+
|
|
212
|
+
### Code Verification
|
|
213
|
+
|
|
214
|
+
**User Question:** "Is this Zig code correct: const zang = @import("zang"); var osc = SineOsc{}"
|
|
215
|
+
|
|
216
|
+
**AI Action:** Call `zig_audio_verify_code` with the code snippet.
|
|
217
|
+
|
|
218
|
+
**Response:** The server identifies missing std import, incorrect struct usage, and suggests corrections.
|
|
219
|
+
|
|
220
|
+
## Key Information for AI Assistants
|
|
221
|
+
|
|
222
|
+
### Library Selection Guide
|
|
223
|
+
|
|
224
|
+
| Task | Recommended Library |
|
|
225
|
+
|------|-------------------|
|
|
226
|
+
| Synthesis without allocations | zang |
|
|
227
|
+
| Audio playback/recording | zaudio |
|
|
228
|
+
| DSP filters and delay lines | bonk |
|
|
229
|
+
| File I/O (WAV/AIFF) | pcm |
|
|
230
|
+
| Software-defined radio | zig-liquid-dsp |
|
|
231
|
+
| High-performance audio engine | dalek |
|
|
232
|
+
|
|
233
|
+
### Filter Selection Guide
|
|
234
|
+
|
|
235
|
+
| Goal | Filter Type |
|
|
236
|
+
|------|-------------|
|
|
237
|
+
| Remove high frequencies | Low Pass |
|
|
238
|
+
| Remove low frequencies (DC offset) | High Pass |
|
|
239
|
+
| Isolate frequency band | Band Pass |
|
|
240
|
+
| Remove specific frequency (hum) | Notch |
|
|
241
|
+
| General EQ/tone control | Biquad |
|
|
242
|
+
| Simple smoothing | One-Pole |
|
|
243
|
+
|
|
244
|
+
### Code Generation Tasks
|
|
245
|
+
|
|
246
|
+
The server can generate starter code for:
|
|
247
|
+
- `oscillator` - Sine, square, saw, triangle waves
|
|
248
|
+
- `envelope` - ADSR envelope implementation
|
|
249
|
+
- `filter` - Biquad filter implementation
|
|
250
|
+
- `delay` - Delay line with feedback
|
|
251
|
+
- `mixer` - Multi-channel audio mixer
|
|
252
|
+
- `player` - Audio playback using zaudio
|
|
253
|
+
- `recorder` - Audio recording using zaudio
|
|
254
|
+
- `file-write` - Write audio to WAV file
|
|
255
|
+
- `file-read` - Read audio from WAV file
|
|
256
|
+
|
|
257
|
+
## Important Notes for AI Assistants
|
|
258
|
+
|
|
259
|
+
1. **Zig Specifics**: Zig is a systems programming language with manual memory management. The server's library information reflects this (e.g., zang's no-allocation design).
|
|
260
|
+
|
|
261
|
+
2. **Version Awareness**: The Zig audio ecosystem is actively developing. Library versions and features may change.
|
|
262
|
+
|
|
263
|
+
3. **License Considerations**: Some libraries have different licenses (MIT vs MPL-2.0). This is included in library information.
|
|
264
|
+
|
|
265
|
+
4. **Transport Options**: The server runs on stdio by default but can be configured for HTTP transport for remote deployment.
|
|
266
|
+
|
|
267
|
+
## Error Handling
|
|
268
|
+
|
|
269
|
+
When tools return errors, they provide actionable messages. Common issues:
|
|
270
|
+
- Invalid library name (check enum values)
|
|
271
|
+
- Missing required parameters
|
|
272
|
+
- Invalid filter type
|
|
273
|
+
|
|
274
|
+
## Testing the Server
|
|
275
|
+
|
|
276
|
+
Before relying on this server for production tasks, AI assistants should verify functionality using the test suite:
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
npx tsx src/test.ts
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
This runs 9 tests covering all tool functionality.
|
|
283
|
+
|
|
284
|
+
## Integration Points
|
|
285
|
+
|
|
286
|
+
This MCP server is designed to work with:
|
|
287
|
+
- Claude Desktop
|
|
288
|
+
- Other MCP clients
|
|
289
|
+
- Custom AI assistants
|
|
290
|
+
- CI/CD pipelines for testing MCP tool functionality
|
|
291
|
+
|
|
292
|
+
## Limitations
|
|
293
|
+
|
|
294
|
+
- Static data: Library information is baked into the server and may become outdated
|
|
295
|
+
- No actual Zig compilation: The server generates example code but doesn't compile it
|
|
296
|
+
- No audio processing: This is a knowledge/reference server, not an audio processor
|
|
297
|
+
|
|
298
|
+
## For Further Reading
|
|
299
|
+
|
|
300
|
+
- [MCP Protocol Documentation](https://modelcontextprotocol.io)
|
|
301
|
+
- [Zig Programming Language](https://ziglang.org)
|
|
302
|
+
- Individual library repositories listed in server responses
|
package/GEMINI.md
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# Zig-Audio MCP Server | Project Context and Instructions
|
|
2
|
+
|
|
3
|
+
## Project Goal
|
|
4
|
+
|
|
5
|
+
Build an MCP (Model Context Protocol) server that communicates with either local and/or remote resources in order to aid users, **LLMs/Agents**, etc, in writing high-quality `zig` code, with an emphasis in pro-audio/DSP algorithms.
|
|
6
|
+
|
|
7
|
+
## Project Overview
|
|
8
|
+
|
|
9
|
+
This is a Node.js/TypeScript project that implements an MCP server to help AI systems assist developers in writing Zig audio and DSP code. The server provides tools for:
|
|
10
|
+
|
|
11
|
+
- Discovering and learning about Zig audio/DSP libraries
|
|
12
|
+
- Understanding DSP filter algorithms and their implementations
|
|
13
|
+
- Generating starter code for common audio programming tasks
|
|
14
|
+
- Learning fundamental audio/DSP concepts
|
|
15
|
+
- Finding resources for further learning
|
|
16
|
+
|
|
17
|
+
## Technology Stack
|
|
18
|
+
|
|
19
|
+
- **Language:** TypeScript
|
|
20
|
+
- **MCP SDK:** @modelcontextprotocol/sdk ^1.0.0
|
|
21
|
+
- **Validation:** Zod ^3.22.4
|
|
22
|
+
- **Runtime:** Node.js 18+
|
|
23
|
+
- **Transport:** Stdio (default), supports Streamable HTTP
|
|
24
|
+
|
|
25
|
+
## Project Structure
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
MCP_Zig/
|
|
29
|
+
├── src/
|
|
30
|
+
│ ├── index.ts # Main MCP server implementation
|
|
31
|
+
│ └── test.ts # Evaluation tests
|
|
32
|
+
├── dist/ # Compiled JavaScript
|
|
33
|
+
├── package.json # Dependencies and scripts
|
|
34
|
+
├── tsconfig.json # TypeScript configuration
|
|
35
|
+
├── README.md # Project documentation
|
|
36
|
+
├── AGENTS.md # This file
|
|
37
|
+
├── evaluation.xml # Evaluation Q&A pairs
|
|
38
|
+
└── GEMINI.md # AI/LLM context
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Available Scripts
|
|
42
|
+
|
|
43
|
+
| Command | Description |
|
|
44
|
+
|---------|-------------|
|
|
45
|
+
| `npm install` | Install dependencies |
|
|
46
|
+
| `npm run build` | Compile TypeScript to JavaScript |
|
|
47
|
+
| `npm start` | Run the MCP server |
|
|
48
|
+
| `npm run dev` | Run in development mode with auto-reload |
|
|
49
|
+
| `npx tsx src/test.ts` | Run evaluation tests |
|
|
50
|
+
|
|
51
|
+
## MCP Tools
|
|
52
|
+
|
|
53
|
+
The server exposes 6 tools for AI assistants:
|
|
54
|
+
|
|
55
|
+
### 1. zig_audio_list_libraries
|
|
56
|
+
List available Zig audio/DSP libraries with optional filtering.
|
|
57
|
+
|
|
58
|
+
### 2. zig_audio_library_info
|
|
59
|
+
Get detailed information about a specific library (zang, zaudio, bonk, pcm, zig-liquid-dsp, dalek).
|
|
60
|
+
|
|
61
|
+
### 3. zig_dsp_explain_filter
|
|
62
|
+
Explain DSP filter types (lowpass, highpass, bandpass, notch, biquad, one-pole) with formulas and use cases.
|
|
63
|
+
|
|
64
|
+
### 4. zig_audio_generate_code
|
|
65
|
+
Generate starter code for audio/DSP tasks (oscillator, envelope, filter, delay, mixer, player, recorder, file operations).
|
|
66
|
+
|
|
67
|
+
### 5. zig_audio_list_resources
|
|
68
|
+
List learning resources (tutorials, references, examples, articles).
|
|
69
|
+
|
|
70
|
+
### 6. zig_dsp_get_concepts
|
|
71
|
+
Get explanations of fundamental audio/DSP concepts.
|
|
72
|
+
|
|
73
|
+
## Development Guidelines
|
|
74
|
+
|
|
75
|
+
### MCP Protocol Compliance
|
|
76
|
+
- Use `@modelcontextprotocol/sdk` for server implementation
|
|
77
|
+
- Implement proper JSON-RPC 2.0 message handling
|
|
78
|
+
- Use StdioServerTransport for local execution
|
|
79
|
+
- Support Streamable HTTP for remote deployment
|
|
80
|
+
|
|
81
|
+
### Code Quality
|
|
82
|
+
- All inputs validated with Zod schemas
|
|
83
|
+
- Clear tool names following `zig_audio_*` or `zig_dsp_*` convention
|
|
84
|
+
- Comprehensive tool descriptions with parameter documentation
|
|
85
|
+
- Proper error handling with actionable messages
|
|
86
|
+
|
|
87
|
+
### Testing
|
|
88
|
+
- Run evaluation tests before submitting changes
|
|
89
|
+
- Ensure all tests pass: `npx tsx src/test.ts`
|
|
90
|
+
- Verify build succeeds: `npm run build`
|
|
91
|
+
|
|
92
|
+
## Extending the Server
|
|
93
|
+
|
|
94
|
+
To add new tools:
|
|
95
|
+
|
|
96
|
+
1. Define Zod input schema in the tool handler section
|
|
97
|
+
2. Add tool definition in the ListToolsRequestSchema handler
|
|
98
|
+
3. Implement the tool logic
|
|
99
|
+
4. Add corresponding test cases
|
|
100
|
+
|
|
101
|
+
## Zig Audio Ecosystem
|
|
102
|
+
|
|
103
|
+
The server maintains knowledge of the Zig audio ecosystem:
|
|
104
|
+
|
|
105
|
+
### Libraries
|
|
106
|
+
- **zang** - Synthesis library (MIT)
|
|
107
|
+
- **zaudio** - miniaudio wrapper (MIT)
|
|
108
|
+
- **bonk** - DSP objects (MPL-2.0)
|
|
109
|
+
- **pcm** - File I/O (MIT)
|
|
110
|
+
- **zig-liquid-dsp** - SDR library (MIT)
|
|
111
|
+
- **dalek** - Experimental engine (MIT)
|
|
112
|
+
|
|
113
|
+
### Filter Types
|
|
114
|
+
- Low pass, high pass, band pass, notch
|
|
115
|
+
- Biquad, one-pole filters
|
|
116
|
+
|
|
117
|
+
### Concepts
|
|
118
|
+
- Sample rate, bit depth, buffer size
|
|
119
|
+
- Nyquist frequency, aliasing
|
|
120
|
+
|
|
121
|
+
## CI/CD and Deployment
|
|
122
|
+
|
|
123
|
+
The project is designed to be deployed as:
|
|
124
|
+
|
|
125
|
+
1. **Local tool** - Run via stdio transport
|
|
126
|
+
2. **HTTP service** - Deploy with Streamable HTTP transport
|
|
127
|
+
3. **Docker container** - Containerize for cloud deployment
|
|
128
|
+
|
|
129
|
+
## Contact and Support
|
|
130
|
+
|
|
131
|
+
For issues, feature requests, or contributions, please refer to the project repository.
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
# GEMINI.md - AI/LLM Context for MCP Zig Audio
|
|
135
|
+
|
|
136
|
+
## Project Purpose
|
|
137
|
+
|
|
138
|
+
This MCP server helps AI assistants provide better assistance for writing Zig code related to audio programming and digital signal processing (DSP).
|
|
139
|
+
|
|
140
|
+
## What This Server Does
|
|
141
|
+
|
|
142
|
+
When an AI assistant needs to help with Zig audio/DSP programming, it can call this MCP server to:
|
|
143
|
+
|
|
144
|
+
1. **Discover Libraries** - Find which Zig libraries are available for specific audio tasks
|
|
145
|
+
2. **Explain Filters** - Understand how different DSP filters work mathematically
|
|
146
|
+
3. **Generate Code** - Create starter implementations for common patterns
|
|
147
|
+
4. **Learn Concepts** - Understand fundamental audio terminology
|
|
148
|
+
5. **Find Resources** - Locate tutorials and documentation
|
|
149
|
+
|
|
150
|
+
## Tool Usage Examples
|
|
151
|
+
|
|
152
|
+
### Finding the Right Library
|
|
153
|
+
|
|
154
|
+
**User Question:** "I want to build a synthesizer in Zig without any dynamic memory allocation. Which library should I use?"
|
|
155
|
+
|
|
156
|
+
**AI Action:** Call `zig_audio_list_libraries` with feature filter or `zig_audio_library_info` for specific libraries.
|
|
157
|
+
|
|
158
|
+
**Response:** The server returns information about zang, which is specifically designed for zero-allocation synthesis.
|
|
159
|
+
|
|
160
|
+
### Understanding DSP Concepts
|
|
161
|
+
|
|
162
|
+
**User Question:** "What is the Nyquist frequency and why does it matter for audio?"
|
|
163
|
+
|
|
164
|
+
**AI Action:** Call `zig_dsp_get_concepts` to get explanations.
|
|
165
|
+
|
|
166
|
+
**Response:** The server returns detailed explanations of Nyquist frequency, sample rate, aliasing, and their relationships.
|
|
167
|
+
|
|
168
|
+
### Generating Code
|
|
169
|
+
|
|
170
|
+
**User Question:** "Help me write a simple oscillator in Zig"
|
|
171
|
+
|
|
172
|
+
**AI Action:** Call `zig_audio_generate_code` with `task: "oscillator"`
|
|
173
|
+
|
|
174
|
+
**Response:** The server returns starter Zig code for implementing an oscillator.
|
|
175
|
+
|
|
176
|
+
### Filter Selection
|
|
177
|
+
|
|
178
|
+
**User Question:** "I need to remove DC offset from an audio signal, which filter should I use?"
|
|
179
|
+
|
|
180
|
+
**AI Action:** Call `zig_dsp_explain_filter` with different filter types to find the right one.
|
|
181
|
+
|
|
182
|
+
**Response:** High-pass filter or one-pole filter are suitable for DC offset removal, with explanations and formulas.
|
|
183
|
+
|
|
184
|
+
## Key Information for AI Assistants
|
|
185
|
+
|
|
186
|
+
### Library Selection Guide
|
|
187
|
+
|
|
188
|
+
| Task | Recommended Library |
|
|
189
|
+
|------|-------------------|
|
|
190
|
+
| Synthesis without allocations | zang |
|
|
191
|
+
| Audio playback/recording | zaudio |
|
|
192
|
+
| DSP filters and delay lines | bonk |
|
|
193
|
+
| File I/O (WAV/AIFF) | pcm |
|
|
194
|
+
| Software-defined radio | zig-liquid-dsp |
|
|
195
|
+
| High-performance audio engine | dalek |
|
|
196
|
+
|
|
197
|
+
### Filter Selection Guide
|
|
198
|
+
|
|
199
|
+
| Goal | Filter Type |
|
|
200
|
+
|------|-------------|
|
|
201
|
+
| Remove high frequencies | Low Pass |
|
|
202
|
+
| Remove low frequencies (DC offset) | High Pass |
|
|
203
|
+
| Isolate frequency band | Band Pass |
|
|
204
|
+
| Remove specific frequency (hum) | Notch |
|
|
205
|
+
| General EQ/tone control | Biquad |
|
|
206
|
+
| Simple smoothing | One-Pole |
|
|
207
|
+
|
|
208
|
+
### Code Generation Tasks
|
|
209
|
+
|
|
210
|
+
The server can generate starter code for:
|
|
211
|
+
- `oscillator` - Sine, square, saw, triangle waves
|
|
212
|
+
- `envelope` - ADSR envelope implementation
|
|
213
|
+
- `filter` - Biquad filter implementation
|
|
214
|
+
- `delay` - Delay line with feedback
|
|
215
|
+
- `mixer` - Multi-channel audio mixer
|
|
216
|
+
- `player` - Audio playback using zaudio
|
|
217
|
+
- `recorder` - Audio recording using zaudio
|
|
218
|
+
- `file-write` - Write audio to WAV file
|
|
219
|
+
- `file-read` - Read audio from WAV file
|
|
220
|
+
|
|
221
|
+
## Important Notes for AI Assistants
|
|
222
|
+
|
|
223
|
+
1. **Zig Specifics**: Zig is a systems programming language with manual memory management. The server's library information reflects this (e.g., zang's no-allocation design).
|
|
224
|
+
|
|
225
|
+
2. **Version Awareness**: The Zig audio ecosystem is actively developing. Library versions and features may change.
|
|
226
|
+
|
|
227
|
+
3. **License Considerations**: Some libraries have different licenses (MIT vs MPL-2.0). This is included in library information.
|
|
228
|
+
|
|
229
|
+
4. **Transport Options**: The server runs on stdio by default but can be configured for HTTP transport for remote deployment.
|
|
230
|
+
|
|
231
|
+
## Error Handling
|
|
232
|
+
|
|
233
|
+
When tools return errors, they provide actionable messages. Common issues:
|
|
234
|
+
- Invalid library name (check enum values)
|
|
235
|
+
- Missing required parameters
|
|
236
|
+
- Invalid filter type
|
|
237
|
+
|
|
238
|
+
## Testing the Server
|
|
239
|
+
|
|
240
|
+
Before relying on this server for production tasks, AI assistants should verify functionality using the test suite:
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
npx tsx src/test.ts
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
This runs 9 tests covering all tool functionality.
|
|
247
|
+
|
|
248
|
+
## Integration Points
|
|
249
|
+
|
|
250
|
+
This MCP server is designed to work with:
|
|
251
|
+
- Claude Desktop
|
|
252
|
+
- Other MCP clients
|
|
253
|
+
- Custom AI assistants
|
|
254
|
+
- CI/CD pipelines for testing MCP tool functionality
|
|
255
|
+
|
|
256
|
+
## Limitations
|
|
257
|
+
|
|
258
|
+
- Static data: Library information is baked into the server and may become outdated
|
|
259
|
+
- No actual Zig compilation: The server generates example code but doesn't compile it
|
|
260
|
+
- No audio processing: This is a knowledge/reference server, not an audio processor
|
|
261
|
+
|
|
262
|
+
## For Further Reading
|
|
263
|
+
|
|
264
|
+
- [MCP Protocol Documentation](https://modelcontextprotocol.io)
|
|
265
|
+
- [Zig Programming Language](https://ziglang.org)
|
|
266
|
+
- Individual library repositories listed in server responses
|