mcpField
M
mcp-server-template

mcp-server-template

Local
github.com/qmmughalDeveloper Tools4Updated 14w ago

About mcp-server-template

mcp-server-template is a TypeScript and Node.js template for developers building custom MCP servers. It includes type checking, input validation, a modular layout, and build and test setup.

Key features

  1. 01Strict TypeScript type checking
  2. 02Validate inputs and environment variables with Zod
  3. 03Bundle into one file with esbuild
  4. 04Separate tools, resources, prompts, and services
  5. 05Vitest testing setup
  6. 06Publish to npm and MCP Registry

Use cases

  1. 01Scaffold a custom MCP server
  2. 02Add runtime validation for tool inputs
  3. 03Build and test a Node.js server
  4. 04Publish a server from version tags

MCP support

The template scaffolds MCP servers, with stdio setup and structures for registering tools, resources, and prompts. It includes connection examples for Claude Desktop and Cursor and automates publishing to the MCP Registry.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"qmmughal-mcp-server-template": {
"command": "npx",
"args": [
"-y",
"@qmmughal/mcp-server-template"
]
}
}
}
Run commandnpx -y @qmmughal/mcp-server-template

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npm@qmmughal/mcp-server-template1.0.0

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

Enterprise MCP Server Template 🚀

TypeScript Node.js Model Context Protocol License: MIT

A production-ready, enterprise-grade template for building Model Context Protocol (MCP) servers in TypeScript and Node.js. Designed for scalability, type safety, and seamless integration with AI agents like Claude Desktop and Cursor.

📖 About

The Model Context Protocol (MCP) standardizes how AI models interact with local and remote resources. This template provides a robust foundation for building your own custom MCP servers, eliminating boilerplate and enforcing best practices.

Key Features
  • Strict TypeScript: Modern ECMAScript targets with rigorous type safety.
  • Zod Validation: Runtime schema validation for tool inputs and environment variables, ensuring your server never crashes from malformed AI payloads.
  • Fast Bundling (esbuild): Compiles the entire server into a single, optimized executable (dist/index.js), eliminating the need to deploy node_modules.
  • Safe Structured Logging: Pre-configured pino logger writing safely to stderr, preserving the integrity of the stdout JSON-RPC transport required by MCP.
  • Modular Architecture: Clean separation of Tools, Resources, Prompts, and Services.
  • Vitest Integration: Blazing fast unit testing out of the box.

🚀 Getting Started

1. Installation

Clone the repository and install dependencies:

git clone https://github.com/qmmughal/mcp-server-template.git
cd mcp-server-template
npm install
2. Configuration

Copy the example environment file and configure your variables:

cp .env.example .env
3. Development Workflow

Start the server in watch mode for local development:

npm run dev

Run the test suite:

npm test

Verify typings:

npm run typecheck
4. Production Build

Bundle the server into a single, optimized executable:

npm run build

The output will be generated at dist/index.js.

🔌 Connecting to an MCP Client

Claude Desktop

To connect this server to the Claude Desktop app, edit your Claude configuration file (usually found at %APPDATA%\Claude\claude_desktop_config.json on Windows or ~/Library/Application Support/Claude/claude_desktop_config.json on Mac):

{
  "mcpServers": {
    "enterprise-template-server": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-server-template/dist/index.js"],
      "env": {
        "LOG_LEVEL": "info",
        "EXAMPLE_API_KEY": "your_api_key_here"
      }
    }
  }
}
Cursor

In Cursor, navigate to Settings -> Features -> MCP and add a new MCP server:

  • Type: command
  • Command: node /absolute/path/to/mcp-server-template/dist/index.js

🏗️ Architecture Overview

  • src/index.ts: Application entrypoint, capability registration, and stdio connection setup.
  • src/tools/: Definitions and JSON schemas for MCP Tools (actions the AI can take).
  • src/resources/: Dynamic resources via URI templating (data the AI can read).
  • src/prompts/: Reusable agent prompt templates.
  • src/services/: Core business logic, keeping protocol handlers thin and testable.
  • src/utils/errors.ts: Standardized error handling aligned with MCP error codes.

📦 Publishing & Registry

package.json is publish-ready (scoped name @qmmughal/mcp-server-template, license, repository, keywords), and server.json + .github/workflows/publish-mcp.yml are wired up to publish to both npm and the MCP Registry automatically whenever a v* tag is pushed:

git tag v1.0.0
git push origin v1.0.0

The workflow needs one repo secret before it can run: NPM_TOKEN (an npm automation token with publish rights to the @qmmughal scope). MCP Registry auth uses GitHub OIDC, so no extra secret is needed there.

🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

📝 License

This project is MIT licensed.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.