Skip to main content
Glama
README.md
# wgpu-mcp

An MCP ([Model Context Protocol](https://modelcontextprotocol.io)) server that gives AI agents
live access to the **[wgpu](https://docs.rs/wgpu/latest/wgpu/)** crate documentation —
the Rust implementation of WebGPU.

Zero dependencies. Runs on Node.js ≥ 18. Always serves the latest wgpu release straight from
[docs.rs](https://docs.rs/wgpu/latest/wgpu/), with in-memory caching.

## Tools

| Tool | Description |
|------|-------------|
| `wgpu_search` | Search wgpu items (structs, enums, traits, functions, …) by name |
| `wgpu_docs` | Full documentation for an item as Markdown: declaration, description, variants/fields, methods |
| `wgpu_member` | Documentation for a single method / variant / field / associated item |
| `wgpu_list` | Enumerate items, filtered by kind or module (`util`, `custom`) |
| `wgpu_info` | Crate version, index statistics, usage cheat-sheet |

Typical flow:

```
wgpu_search("buffer")
  → wgpu_docs("Buffer")
      → wgpu_member("Buffer", "map_async")
```

Item references accept short names (`Buffer`), paths (`util::DeviceExt`, `wgpu::Queue`),
the empty string for the crate root, or full docs.rs URLs.

## Install & run

```bash
node server.mjs
```

It speaks MCP over stdio (newline-delimited JSON-RPC), so any MCP client can launch it.

### opencode

Add to `~/.config/opencode/opencode.json` (adjust the node path to your system):

```json
{
  "mcp": {
    "wgpu": {
      "type": "local",
      "command": ["node", "/absolute/path/to/wgpu-mcp/server.mjs"],
      "enabled": true
    }
  }
}
```

### Claude Desktop / other clients

```json
{
  "mcpServers": {
    "wgpu": {
      "command": "node",
      "args": ["/absolute/path/to/wgpu-mcp/server.mjs"]
    }
  }
}
```

## How it works

- The item index is built by parsing rustdoc's `all.html` (every item in the crate).
- Documentation pages are fetched on demand from docs.rs and converted to Markdown
  (declaration, doc text, variants/fields, inherent methods with docs, compact trait-impl list).
- Trait/synthetic/blanket implementation sections are collapsed to a summary so big
  pages like `Buffer` stay within useful context sizes; `wgpu_member` retrieves the
  details of a single member instead.

## License

MIT