Skip to main content
Glama
README.md
# mcp-tasks-demo

A tiny MCP server in TypeScript, built for the Code With Stan video "MCP explained".

It keeps tasks in a local JSON file and shows all three MCP primitives:

| Primitive | Name | What it does |
|---|---|---|
| Tool | `add_task` | Adds a task |
| Resource | `tasks://open` | Returns open tasks as JSON |
| Prompt | `standup` | Drafts a standup from open tasks |

Built on the MCP spec revision `2026-07-28` with the TypeScript SDK v2 (`@modelcontextprotocol/server` 2.4.0).

## Run it

```bash
npm install
npm run client          # 2026-07-28 client: no handshake, _meta on every request
npm run client:legacy   # 2025-era client: initialize handshake
```

Both clients print every message on the wire (`>>` sent, `<<` received). The same server answers both.

## Connect to Claude Code

```bash
claude mcp add tasks -- npx tsx "/absolute/path/to/mcp-tasks-demo/src/server.ts"
```

Then run `/mcp` in Claude Code to check the connection. Type `@` to attach `tasks://open`, and `/` to find the `standup` prompt.

Tasks are stored in `./tasks.json` by default. Set `TASKS_FILE` to change the location.

## Two things worth knowing

- **stdio and the new spec.** Wiring `StdioServerTransport` by hand serves the 2025 protocol. `serveStdio(createServer)` serves `2026-07-28` and still answers older clients.
- **stdout is for MCP messages only.** Log to stderr (`console.error`), never stdout.

## Links

- MCP specification: https://modelcontextprotocol.io/specification/2026-07-28
- TypeScript SDK: https://github.com/modelcontextprotocol/typescript-sdk
- Claude Code MCP docs: https://code.claude.com/docs/en/mcp

## License

MIT