MCP-Server
README.md
# MCP-Server
A minimal [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server built with TypeScript. It exposes a single tool, `get_weather`, over a stdio transport so that MCP-compatible clients (Claude Desktop, Claude Code, the MCP Inspector, etc.) can call it.
## Features
- Built on `@modelcontextprotocol/sdk`
- Input validation via `zod`
- Communicates over stdio (JSON-RPC)
- One example tool: `get_weather`
## Prerequisites
- Node.js (v18+ recommended)
- Yarn (v1 classic or Berry)
## Installation
```bash
yarn install
```
## Build
Compiles the TypeScript source in `src/` to JavaScript in `build/`:
```bash
yarn build
```
This runs `tsc` and marks `build/index.js` as executable.
## Running
**Start the server directly** (for a quick smoke test — it will sit silently listening on stdio, which is expected):
```bash
yarn start
```
**Start with the MCP Inspector** (recommended for interactive testing/debugging):
```bash
yarn start:local
```
This launches a local web UI (usually at `http://localhost:6274`) where you can view the registered tools, call them with test inputs, and inspect the raw JSON-RPC traffic.
> If running the Inspector through a Yarn script causes connection issues, run it directly instead:
> ```bash
> npx @modelcontextprotocol/inspector node build/index.js
> ```
## Available Tools
### `get_weather`
Returns a (currently mocked) weather reading for a given city.
**Input:**
| Parameter | Type | Description |
|-----------|--------|--------------------|
| `city` | string | Name of the city |
**Example output:**
```
The weather in Chandigarh is 24°C and sunny.
```
> Note: this is a stub implementation returning a random temperature. Replace the logic inside `registerTool("get_weather", ...)` in `src/index.ts` with a real weather API call as needed.
## Connecting to an MCP Client
To use this server with Claude Desktop or another MCP client, add it to the client's config (e.g. `claude_desktop_config.json`):
```json
{
"mcpServers": {
"MCP-Server": {
"command": "node",
"args": ["/absolute/path/to/MCP-Server/build/index.js"]
}
}
}
```
Restart the client afterward — the `get_weather` tool should appear as available.
## Project Structure
```
.
├── src/
│ └── index.ts # Server entry point + tool definitions
├── build/ # Compiled output (generated by `yarn build`)
├── package.json
├── tsconfig.json
└── README.md
```
## Extending
To add more tools, call `server.registerTool(...)` again inside `src/index.ts` with a new name, schema, and handler. For larger projects, consider splitting each tool into its own file under `src/tools/` and importing them into `index.ts`.
## License
MIT
TDQS
C2.7/5.0
Scored across 2 tools
Disambiguation5/5
The two tools serve completely distinct purposes (age vs. weather), so there is no ambiguity or overlap. An agent can easily tell them apart.
Naming Consistency5/5
Both tool names follow a consistent verb_noun pattern ('get_age', 'get_weather'), making the naming predictable and clear.
Tool Count2/5
Only two tools exist, covering two unrelated domains. This feels insufficient for any meaningful workflow, as each domain likely requires more operations (e.g., for weather: location support, forecast; for age: input variations).
Completeness1/5
Each tool is a single isolated operation with no supporting tools (e.g., no set_age, no get_forecast). The surface is severely incomplete for any realistic use case.
Maintenance
ActivityStale
ResponsivenessNo issues