ts-mcp-starter
A weather simulation MCP server that provides deterministic mock weather data for any city, including current conditions and forecasts.
README
ts-mcp-starter
A minimal Bun + TypeScript + Biome starter that ships a working MCP (Model Context Protocol) server simulating weather queries. No external API calls — responses are deterministic mock data seeded by city + date.
Stack
- Runtime: Bun 1.x (TypeScript natively, no build step required)
- Language: TypeScript (strict)
- Lint/format: Biome
- MCP:
@modelcontextprotocol/sdkover stdio
Setup
bun install
Tools exposed by the server
| Tool | Description |
|---|---|
get_current_weather |
Simulated current conditions for any city. Args: city, units (metric / imperial). |
get_forecast |
1–7 day simulated forecast. Args: city, days, units. |
list_supported_cities |
Cities with curated baseline climate (others fall back to a default profile). |
All output is JSON text. Values are deterministic per (city, hour) for current weather and per (city, date) for forecasts.
Run locally
The same server supports two MCP transports simultaneously:
| Transport | When to use | How to start |
|---|---|---|
| stdio | Local MCP clients that launch the process (Cursor, Claude Desktop, etc.) | bun run start |
| Streamable HTTP | Remote use — any MCP client that speaks the Streamable HTTP transport | bun run start:http |
| Both at once | Single process exposes stdio and HTTP | bun run start:both |
Useful scripts:
bun run start # stdio only
bun run start:http # Streamable HTTP on http://127.0.0.1:3000/mcp
bun run start:both # stdio + HTTP in one process
bun run dev # stdio, watch mode
bun run dev:http # HTTP, watch mode
bun run test # bun test (stdio + HTTP + unit)
bun run typecheck # tsc --noEmit
bun run check # biome lint + format
CLI flags (also work in any combination): --stdio, --http, --both, --port=4000, --host=0.0.0.0.
Env vars: MCP_HTTP=1, MCP_STDIO=1, PORT / MCP_PORT, MCP_HOST.
Streamable HTTP details
- Endpoint:
POST/GET/DELETE /mcpon the configured port (default3000). - Health check:
GET /health→ok. - Stateful sessions: the server issues an
Mcp-Session-Idheader oninitialize; clients must echo it on every subsequent request. Each session gets its ownMcpServerinstance. - Supports both SSE streaming responses and JSON responses (negotiated by the client's
Acceptheader). - DELETE
/mcpwith a validMcp-Session-Idterminates that session.
Quick smoke test (no client needed)
{
printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"smoke","version":"0"}}}'
printf '%s\n' '{"jsonrpc":"2.0","method":"notifications/initialized"}'
printf '%s\n' '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'
printf '%s\n' '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"get_current_weather","arguments":{"city":"Tokyo"}}}'
} | bun run src/index.ts
Wire it into an MCP client
Local (stdio) — Cursor / Claude Desktop mcp.json:
{
"mcpServers": {
"weather-demo": {
"command": "bun",
"args": ["run", "/absolute/path/to/ts-mcp-starter/src/index.ts"]
}
}
}
Remote (Streamable HTTP) — run bun run start:http on the host, then point a Streamable-HTTP-capable MCP client at:
http://your-host:3000/mcp
Project layout
src/
index.ts CLI dispatcher (--stdio / --http / --both)
server.ts createServer() factory: McpServer with the three weather tools
stdio.ts stdio transport bootstrap
http.ts Streamable HTTP transport on Bun.serve (stateful sessions)
weather.ts Pure functions that generate simulated weather data
tests/
weather.test.ts unit tests for the simulation functions
mcp-server.test.ts end-to-end JSON-RPC over stdio (hand-written client)
mcp-http.test.ts end-to-end JSON-RPC over Streamable HTTP (hand-written client)
mcp-client-sdk.test.ts end-to-end tests via the official MCP Client SDK (stdio + HTTP)
biome.json Lint + format config
bunfig.toml Bun config
tsconfig.json Strict TS for editor / typecheck
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
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 模型以安全和受控的方式获取实时的网络信息。