mcp-ts-template
by vidyasagarr7
README.md
# mcp-ts-template
Production-ready **Model Context Protocol (MCP) server** template in TypeScript, built on the official [`@modelcontextprotocol/sdk`](https://github.com/modelcontextprotocol/typescript-sdk). Ships an example **tool**, **resource**, and **prompt**.
## Use this template
```bash
gh repo create my-mcp --template vidyasagarr7/mcp-ts-template
```
## Layout
```
src/
server.ts # stdio entry point (transport wiring only)
index.ts # createServer(): registers tools/resources/prompts
core/tools.ts # pure domain logic (testable, no MCP concerns)
version.ts
tests/ # vitest specs
```
Golden rule: **transport in `server.ts`, registration in `index.ts`, logic in `core/`.**
## Develop
```bash
npm install
npm run dev # run server from source over stdio
npm test # vitest
npm run typecheck
npm run build
npm run inspect # launch MCP Inspector against the built server
```
## Try the server by hand
```bash
npm run build
# Initialize handshake over stdio:
printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"probe","version":"0"}}}' | node dist/server.js
```
## Register a new tool
1. Add pure logic to `src/core/tools.ts`.
2. Add a unit test in `tests/`.
3. Register it in `src/index.ts` via `server.registerTool(...)` with a `zod` input schema.
## Connect from a client
Point any MCP client (Claude Desktop, MCP Inspector, etc.) at the built binary:
```json
{
"mcpServers": {
"my-mcp": { "command": "node", "args": ["/abs/path/dist/server.js"] }
}
}
```
## Make it yours (rename checklist)
- `package.json`: `name`, `description`, `bin` key, `repository`, `keywords`
- `src/index.ts`: `new McpServer({ name: ... })`
- Replace the example `add` tool / `greeting` resource / `summarize` prompt with your own
- Keep transport in `server.ts`, registration in `index.ts`, logic in `core/`
## License
MIT
TDQS
A4.3/5.0
Scored across 1 tool
Disambiguation5/5
Only one tool exists, so there is no possibility of confusion between tools. The tool's purpose is clear and unambiguous.
Naming Consistency5/5
With a single tool, naming is trivially consistent. The name 'add' follows a simple verb pattern appropriate for its function.
Tool Count4/5
As a template server, a single tool is slightly minimal but acceptable. It provides a basic starting point for extension.
Completeness3/5
Within the narrow domain of adding two numbers, the tool is complete. However, for a broader utility server, it lacks other arithmetic operations like subtract, multiply, or divide.
Maintenance
ActivityMaintained
ResponsivenessSyncing