learn-typescript-mcp
A monorepo for learning the Model Context Protocol with TypeScript, featuring example MCP servers for weather data and tax calculation.
README
learn TypeScript MCP
Learning monorepo for the Model Context Protocol TypeScript SDK, built on Bun workspaces. Each learning topic lives in its own app under apps/ — new topics get a new apps/<topic> workspace.
| App | What it is |
|---|---|
| apps/weather/ | The MCP weather tutorial, restructured as a NestJS application (running on the Bun runtime) |
| apps/tax-assistant/ | A minimal plain-TypeScript stdio MCP server (VAT calculator) |
To install dependencies for all workspaces:
bun install
Weather app (apps/weather/) — NestJS + MCP
Follows the official MCP TypeScript SDK "Build your first server" / "Build your first client" tutorials, using the real NWS weather API — hosted inside a NestJS app.
- apps/weather/src/main.ts — Nest HTTP bootstrap (port 3000,
bodyParser: false) - apps/weather/src/stdio.ts — stdio entry point (Nest application context, logger disabled so stdout stays protocol-only)
- apps/weather/src/weather/weather.service.ts — NWS API calls (
getActiveAlertHeadlines,getForecastPeriods) - apps/weather/src/weather/weather-mcp.service.ts — builds the
McpServer, registersget-alerts/get-forecast, owns the shared HTTP transport - apps/weather/src/weather/mcp.controller.ts — routes every method on
/mcpinto the MCP transport - apps/weather/src/weather/express-web-bridge.ts — converts Express req/res ↔ web-standard Request/Response (the SDK's v2 transport is web-standard only)
- apps/weather/client.ts — example client (spawns the stdio server itself)
- apps/weather/test/mcp-http.test.ts —
bun testboots the Nest app on an ephemeral port and connects a real streamable-HTTP MCP client - tutorial/weather-server.ts — compatibility shim for clients still pointing at the old pre-monorepo path (e.g. a saved MCP Inspector connection); safe to delete once nothing references it
Both tools declare default values in their input schemas for development convenience — Inspector pre-fills its form with them (state: CA, latitude/longitude: San Francisco), so you can hit "Run Tool" without typing. Callers that pass their own arguments override them; the defaults only apply when an argument is omitted.
Run the stdio server
Each client that connects (Claude Code, Inspector, client.ts) spawns its own private copy of this process — it's not a shared server.
bun run weather:stdio
Run the HTTP server
One shared process that clients connect to over the network. Kill this terminal and every connected client loses the connection immediately.
bun run weather:http
Run the example client
bun run weather:client
Run the tests / typecheck
bun test # from apps/weather/ (or the repo root)
bun run typecheck # from the repo root — tsc over both apps
Tax assistant (apps/tax-assistant/)
Minimal stdio MCP server with a single calculate-vat tool (Thai VAT 7%):
bun run tax:stdio
Inspect/test with MCP Inspector
bunx @modelcontextprotocol/inspector
Opens a browser UI (proxy on port 6277, UI on port 6274). In the sidebar, connect it either way:
- stdio: Transport Type
STDIO, Commandbun, Argsapps/weather/src/stdio.ts - HTTP: Transport Type
Streamable HTTP, URLhttp://localhost:3000/mcp— requires the HTTP server (bun run weather:http) to already be running
Inspector remembers your last-used connection in the browser and auto-reconnects with it on load/refresh — always check the sidebar's Transport Type/URL before assuming what it's actually connected to.
If you get PORT IS IN USE on 6274/6277, a previous Inspector instance didn't shut down cleanly (it can leave its proxy process orphaned even after reporting failure). Find and kill it before retrying:
lsof -nP -iTCP:6274,6277 -sTCP:LISTEN
kill <PID>
Connect to Claude Code
.mcp.json registers the weather server, pointed at the HTTP transport — start the Nest server (bun run weather:http) yourself before opening a Claude Code session here, or /mcp will show it disconnected.
NestJS-on-Bun notes
- No
nest-cli/webpack build step — Bun runs the TypeScript entrypoints directly (bun src/main.ts). - tsconfig.json enables
experimentalDecorators+emitDecoratorMetadata; Bun's transpiler honors both, which is what makes Nest constructor injection work. - Nest still uses its Express adapter internally; only the runtime and package manager are Bun.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。