OM

onamfc/mcp-starter-template-ts

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

10 stars 3 forks 质量 57 趋势 18MIT

TypeScript starter template for building Model Context Protocol (MCP) servers, designed to help developers create secure and robust AI-agent-compatible services.

概览

A comprehensive starter template for building Model Context Protocol (MCP) servers with TypeScript. This template provides a solid foundation for developers of all skill levels to quickly bootstrap production-ready MCP projects. - : Complete type safety with comprehensive type definitions - : Robust error handling, logging, and validation - : Clean separation of concerns following SOLID principles - : Unit tests with Jest and high coverage standards - : Containerization for easy deployment - : GitHub Actions workflows included - : Extensive documentation and debugging tools - : Input validation and secure file operations - : Built-in health checks and metrics - Node.js 18.0.0 or higher - npm 8.0.0 or higher (or yarn/pnpm equivalent) This will start the server with automatic restarts when you modify source files. The server can be configured through environment variables. Create a .

README

以下为原文 README 节选,完整内容请查看原文。

MCP Starter Template

A comprehensive starter template for building Model Context Protocol (MCP) servers with TypeScript. This template provides a solid foundation for developers of all skill levels to quickly bootstrap production-ready MCP projects.

Features

  • TypeScript First: Complete type safety with comprehensive type definitions
  • Production Ready: Robust error handling, logging, and validation
  • Modular Architecture: Clean separation of concerns following SOLID principles
  • Comprehensive Testing: Unit tests with Jest and high coverage standards
  • Docker Support: Containerization for easy deployment
  • CI/CD Ready: GitHub Actions workflows included
  • Developer Friendly: Extensive documentation and debugging tools
  • Security Focused: Input validation and secure file operations
  • Health Monitoring: Built-in health checks and metrics

Quick Start

Prerequisites

  • Node.js 18.0.0 or higher
  • npm 8.0.0 or higher (or yarn/pnpm equivalent)

Installation

Choose your preferred package manager:

Using npm:

git clone https://github.com/onamfc/mcp-starter-template-ts.git
cd mcp-starter-template-ts
npm install
npm run build
npm start

Using yarn:

git clone https://github.com/onamfc/mcp-starter-template-ts.git
cd mcp-starter-template-ts
yarn install
yarn build
yarn start

Using pnpm:

git clone https://github.com/onamfc/mcp-starter-template-ts.git
cd mcp-starter-template-ts
pnpm install
pnpm build
pnpm start

Development Mode

For development with hot reloading:

npm run dev

This will start the server with automatic restarts when you modify source files.

Project Structure

src/
├── server.ts              # Main MCP server implementation
├── types/                 # TypeScript type definitions
│   └── index.ts
├── tools/                 # MCP tools implementation
│   ├── setup.ts           # Tool registration and management
│   ├── calculator.ts      # Mathematical calculations
│   ├── filesystem.ts      # File system operations
│   ├── text-processing.ts # Text manipulation and analysis
│   └── weather.ts         # Weather information (mock)
├── resources/             # MCP resources implementation
│   ├── setup.ts           # Resource registration and management
│   ├── config.ts          # Configuration access
│   ├── docs.ts            # Documentation resource
│   └── logs.ts            # Logs access
├── utils/                 # Utility functions
│   ├── config.ts          # Configuration management
│   ├── logger.ts          # Structured logging
│   ├── validation.ts      # Input validation
│   ├── errors.ts          # Error handling
│   └── health.ts          # Health check utilities
└── __tests__/             # Test files
    ├── server.test.ts
    ├── tools/
    └── utils/

Configuration

The server can be configured through environment variables. Create a .env file in the project root:

在 GitHub 查看完整 README

安装

docker run -p 3000:3000 mcp-server
新手?先看 mcpskill.org 教程 →