Skip to main content
Glama
shricodev

updated mcp spec tut

by shricodev
README.md
# updated mcp spec tut

![node](https://img.shields.io/badge/node-%3E%3D20-339933?logo=node.js&logoColor=white)
![typescript](https://img.shields.io/badge/typescript-strict-3178C6?logo=typescript&logoColor=white)
![cloudflare workers](https://img.shields.io/badge/cloudflare-workers-F38020?logo=cloudflare&logoColor=white)

Small MCP server that plays with the newer bits of the spec: elicitation
(interactive confirm dialogs), signed request state, and cache hints on
`tools/list`. Ships as a plain Node server and as a Cloudflare Worker, same
handler underneath.

## What it does

The `deploy` tool needs confirmation before it does anything. If the
connecting client supports elicitation, the server pops a real confirm
dialog and mints a signed, short lived state token to track that flow. If
the client doesn't support elicitation, it falls back to a
`confirm: true` argument instead. `legacy-client-test.ts` exercises that
fallback path directly.

Every request builds a fresh `McpServer` instance, so `server_stats`
shows you the process is stateless per request while `list_deployments`
proves you can still keep real state around (in memory here, for the demo).

## Run it

```bash
npm install
npm run server   # starts on http://127.0.0.1:3000/mcp
npm run client   # connects, deploys, reads it back
```

## Cloudflare Worker

Same MCP handler, just wired through `worker.ts` and `wrangler.jsonc`.

```bash
npx wrangler dev
npx wrangler deploy
```

Set `STATE_KEY` in production so every instance verifies request state
with the same secret.

## Files

- `bot.ts`: the actual MCP server and tools
- `server.ts`: Node entrypoint (Hono + `@hono/node-server`)
- `worker.ts`: Cloudflare Worker entrypoint
- `client.ts`: demo client with elicitation support
- `legacy-client-test.ts`: demo client without it, uses the fallback

enjoy!! :)