SkyH34D/basic-MCP
If you are the rightful owner of basic-MCP and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This repository contains a minimal MCP server written in TypeScript, designed for quick local testing with Model Context Protocol clients.
basic-mcp · Minimal MCP Server in TypeScript
Status: Proof of concept â designed for quick local testing with Model Context Protocol clients.
This repository contains a tiny MCP server written in TypeScript.
It publishes a single tool â fetch-weather
 â that returns a mock weather report for any city.
Use it to learn how transports, tools and schemas work with @modelcontextprotocol/sdk
.
âš Features
Feature | Description |
---|---|
Lightweight | Oneâfile implementation (main.ts ). |
Stdio transport | Communicates over standard I/O (perfect for piping into LLMs). |
Zod validation | Stronglyâtyped parameters with runtime validation. |
Mock weather | Demonstrates content blocks without external APIs. |
đ Requirements
- Node.js â„ 18 (ESM & topâlevelÂ
await
support) - pnpm / npm / yarn to install dependencies
- ts-node (optional) for dev mode
đ Quick start
# 1 â Clone
git clone https://github.com/SkyH34D/basic-mcp.git
cd first-mcp
# 2 â Install
pnpm install # or: npm install / yarn install
# 3 â Run (non-sense, it's LLM's job)
npx -y tsx main.ts
# The server now listens on STDIN/STDOUT for MCP messages
Send a tool call such as:
{
"tool": "fetch-weather",
"params": { "city": "Madrid" }
}
and youâll get:
{
"content": [
{ "type": "text", "text": "The weather in Madrid is sunny." }
]
}
đ Project layout
basic-mcp/
ââ main.ts # Main MCP server
ââ package.json
ââ pnpm-lock.yaml
đ§© How it works
- Instantiate
McpServer
with aname
andversion
. - Register the
fetch-weather
tool viaserver.tool()
, providing:- A unique ID and description
- A Zod schema for
city
- An async handler that returns a
content
array
- Create
StdioServerTransport
to use standard I/O. - Connect with
await server.connect(transport)
and start listening.
đŠ NPM scripts
Script | Runs | Description |
---|---|---|
dev | ts-node | Hotâreload style development. |
build | tsc | Compiles TypeScript into dist/ . |
start | node | Executes the compiled build. |
(Edit package.json
to fit your tooling.)
đ TODO / ideas
- Replace the mock weather with a real API (e.g. OpenWeatherMap).
- Add more tools â currency rates, timezone lookup, etc.
- Switch to WebSocket/HTTP transport for remote use.
- Write tests for tool handlers.
đ License
MIT License. See for more information.