Skip to main content
Glama
vidyasagarr7

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

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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vidyasagarr7/mcp-ts-template'

If you have feedback or need assistance with the MCP directory API, please join our Discord server