This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
- Build:
pnpm build- Compiles TypeScript to JavaScript - Start:
pnpm start- Runs the compiled server (HTTP on PORT, default 3000) - Dev mode:
pnpm dev- Builds and runs in one command - Test:
pnpm test- Currently runs build as test
AUDIUS_API_KEY- API key for Audius REST APIPORT- HTTP server port (default: 3000)
This is a Code Mode MCP server built with Effect-TS. It provides LLM access to the Audius music platform via two tools (search + execute) over Streamable HTTP transport.
Instead of exposing 100+ individual tools (which bloats LLM context), this server uses the Cloudflare Code Mode approach:
- search — Discover API endpoints by querying the OpenAPI spec
- execute — Run JavaScript code in a QuickJS WASM sandbox with an authenticated
audius.request()client
src/
├── index.ts # Entry point — Effect program, HTTP server
├── AppConfig.ts # Effect Config service (env vars)
├── mcp/
│ ├── McpSchema.ts # MCP 2025-11-25 spec (Effect-TS port)
│ ├── McpSerialization.ts # JSON-RPC ↔ Effect RPC bridge
│ ├── McpNotifications.ts # Notification channels
│ ├── McpServerTransport.ts # Server-side Streamable HTTP transport
│ └── McpServer.ts # RPC handler wiring
├── api/
│ ├── SpecLoader.ts # Fetch + parse Audius swagger.yaml
│ ├── SpecIndex.ts # Searchable index over parsed spec
│ └── AudiusClient.ts # HTTP client for Audius REST API
├── tools/
│ ├── SearchTool.ts # search() tool
│ └── ExecuteTool.ts # execute() tool
└── sandbox/
├── Sandbox.ts # QuickJS WASM sandbox
└── TypeGenerator.ts # TS declarations from swagger spec
-
Effect-TS Services: Every component is an Effect service (
Context.Tag) composed viaLayer. The entry point provides all layers and starts the HTTP server. -
MCP Schema: Full MCP 2025-11-25 protocol spec ported to Effect-TS using
@effect/rpcandeffect/Schema. Located insrc/mcp/McpSchema.ts. -
McpSerialization Bridge: Translates between Effect RPC's internal message format (
_tag: "Request"/"Exit") and MCP's JSON-RPC wire format (jsonrpc: "2.0"). Two variants:mcpJson(HTTP) andmcpNdJson(STDIO). -
QuickJS Sandbox: LLM-generated code runs in a WASM-isolated QuickJS context with:
audius.request(method, path, options?)host functionconsole.log()capture- Memory and execution time limits
- Fresh context per execution (no state leakage)
-
API Spec Layer: At startup, fetches the Audius OpenAPI spec, resolves all
$refreferences, and builds a searchable index. The search tool queries this index.
Streamable HTTP on a single /mcp endpoint:
POST /mcp— JSON-RPC requestsDELETE /mcp— terminate session- Session ID via
MCP-Session-Idheader - Protocol version:
2025-11-25
-
Effect service pattern: Access services via
yield* ServiceTaginEffect.gen. All handlers returnEffect.Effect<T, E, R>. -
Tool handlers: Return
CallToolResultfromMcpSchema.ts. Errors go incontentwithisError: true(tool-level), not protocol-level. -
No old SDK: Direct REST API calls via
AudiusClient.request(method, path, options). No@audius/sdk.