# Rivet Docs MCP Server

This package exposes a fully static Model Context Protocol (MCP) server that serves Rivet documentation
using the metadata generated by the Astro site. It provides:

- `createDocsMcpServer` — registers the docs/search/get/list tools, prompts, and resources.
- `createSseResponse` — helper for Fetch/Request handlers (Astro, Workers, Next.js, etc.).
- `cli` entry point (`pnpm --filter @rivetkit/mcp-hub run build && node dist/cli.js`) for a quick local server.

## Updating metadata

The MCP server reads `website/dist/_metadata/docs.json`, which is produced by the `_metadata/docs.json`
endpoint during the normal Astro build. Run a full site build whenever docs change:

```bash
pnpm --filter rivet-website run build
```

This writes the fresh metadata to `website/dist/_metadata/docs.json`, which `@rivetkit/mcp-hub`
automatically loads at runtime.

## Building / running

```bash
# Emit JS + type definitions for the MCP package (prebuild runs the Astro build)
pnpm --filter @rivetkit/mcp-hub run build

# Run the bundled CLI (HTTP SSE endpoint on http://localhost:7332/mcp by default)
node rivetkit-typescript/packages/mcp-hub/dist/cli.js
```

## Embedding in an HTTP handler

```ts
import { createDocsMcpServer, createSseResponse } from "@rivetkit/mcp-hub";

const { server } = createDocsMcpServer();

export default {
	async fetch(request: Request) {
		// Reuse a single transport internally; returns a web-standard Response.
		return createSseResponse(server, request);
	},
};
```

See `src/index.ts` for more examples (tools, prompts, resources) if you want to compose custom transports.
