mcp-server-ts
# mcp-server-ts
[](https://github.com/lditzel94/mcp-server-ts/actions/workflows/ci.yml)
A lab where I learn the Model Context Protocol by building an MCP server in TypeScript with the official SDK, one milestone at a time.
## What this lab teaches
- How MCP works on the wire: the initialize handshake, capabilities and JSON-RPC messages.
- The three server primitives: tools, resources and prompts.
- Transports: stdio for local clients, Streamable HTTP with sessions for remote ones.
- Securing a remote server with bearer tokens and OAuth.
- Designing a set of tools that work together, applied to exploring Kafka topics.
- Testing the protocol contract and consuming the server from a TypeScript client.
## Architecture
// milestone 1: one process, one tool, stdio.
```mermaid
flowchart LR
host["MCP host<br/>(Inspector, Claude Desktop, IDE)"] -- "JSON-RPC over stdin/stdout" --> entry["serveStdio<br/>src/index.ts"]
entry -- "one instance per connection" --> server["createServer()<br/>src/server.ts"]
server --> tool["convert_epoch<br/>src/tools/convert-epoch.ts"]
entry -. "logs" .-> stderr[(stderr)]
style entry fill:#0a0a0b,stroke:#f4b740,color:#f4b740
```
- `serveStdio` answers both the 2026-07-28 protocol (per-request version, `server/discover`) and legacy clients that open with `initialize`.
- `convert_epoch` turns a Unix timestamp in milliseconds into UTC and local time. Bad input comes back as `isError: true` with a message written for the model.
- stdout only carries MCP messages; logs go to stderr.
## Run it
Requires Node 24.22.1+ and pnpm through Corepack (`corepack enable`, or prefix commands with `corepack`).
```sh
pnpm install
pnpm test # vitest, an in-memory MCP client against the real server
pnpm inspect # build and open MCP Inspector against dist/index.js
```
To use it from an MCP host, point the host at `node /path/to/mcp-server-ts/dist/index.js` after `pnpm build`.
## Milestones
See [ROADMAP.md](ROADMAP.md).
## Decisions
Architecture decision records live in [docs/adr/](docs/adr/).
## License
[MIT](LICENSE)
TDQS
Scored across 1 tool
With only one tool, there is no possibility of confusing it with another; convert_epoch has a single, unambiguous purpose (epoch milliseconds to ISO-8601 UTC and zoned local time). An agent cannot misselect here.
The lone name follows a clean verb_noun snake_case convention (convert_epoch) that would scale predictably if more tools were added. There are no competing conventions to clash.
A single tool is thin even for a narrow time-conversion server; the surface is barely scoped rather than well-scoped. It earns its place but leaves the server feeling like a one-off utility rather than a coherent toolkit.
The obvious inverse operation (ISO-8601 or local time back to epoch milliseconds) is missing, as is any batch or multi-timezone conversion, creating a dead end for round-trip workflows. Agents needing two-way conversion will have to fall back to other means.