Skip to main content
Glama
mcp-ts-template

mcp-ts-template

by vidyasagarr7

mcp-ts-template

Production-ready Model Context Protocol (MCP) server template in TypeScript, built on the official @modelcontextprotocol/sdk. Ships an example tool, resource, and prompt.

Use this template

gh repo create my-mcp --template vidyasagarr7/mcp-ts-template

Related MCP server: MCP Server Starter

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

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

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:

{
  "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

Available Tools

1 tool
addAddA

Add two numbers

Inputs: a (required), b (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    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.

    Related MCP Connectors

    Related MCP Servers