mcp-server-ts

simonlee2/mcp-server-ts

3.1

If you are the rightful owner of mcp-server-ts and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

This document provides a structured overview of a Model Context Protocol (MCP) server template implemented in TypeScript, designed for creating and managing tools and resources with modern JavaScript features.

Tools
1
Resources
0
Prompts
0

MCP Server TypeScript Template

A simple template for creating MCP (Model Context Protocol) servers in TypeScript.

Features

  • Addition Tool: Demonstrates a basic tool that adds two numbers
  • Greeting Resource: Shows dynamic resource generation with URL parameters
  • TypeScript: Full TypeScript support with strict mode
  • Modern ES Modules: Uses the latest JavaScript module system

Quick Start

  1. Install dependencies:

    pnpm install
    
  2. Build the server:

    pnpm build
    
  3. Run the server:

    pnpm start
    

Usage

This template provides two examples:

Tools

  • add: Adds two numbers together
    { "a": 5, "b": 3 }
    

Resources

  • greeting://{name}: Generates a personalized greeting
    greeting://Alice
    

Development

Available Scripts

  • pnpm dev - Watch mode development (auto-rebuilds on changes)
  • pnpm build - Build the project
  • pnpm start - Run the built server
  • pnpm clean - Clean build directory
  • pnpm lint - Check code for linting issues
  • pnpm lint:fix - Auto-fix linting issues
  • pnpm format - Format code with Prettier
  • pnpm type-check - Check TypeScript types without building

Development Workflow

  1. Start development:

    pnpm dev
    

    This starts TypeScript in watch mode - your code will auto-rebuild on changes.

  2. Code quality (run before committing):

    pnpm lint:fix
    pnpm format
    pnpm type-check
    
  3. Test your server:

    pnpm build
    pnpm start
    

Code Quality

This template includes:

  • ESLint - TypeScript linting with recommended rules
  • Prettier - Code formatting
  • TypeScript - Strict type checking

Project Structure

  • src/index.ts - Main server implementation
  • build/ - Compiled output
  • tsconfig.json - TypeScript configuration
  • .eslintrc.js - ESLint configuration (create as needed)
  • .prettierrc - Prettier configuration (create as needed)

Extending

To add your own tools and resources:

  1. Use server.registerTool() for new tools
  2. Use server.registerResource() for new resources
  3. Follow the existing patterns in src/index.ts
  4. Run pnpm lint:fix and pnpm format to maintain code quality

License

MIT