simonlee2/mcp-server-ts
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.
add
Adds two numbers together.
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
-
Install dependencies:
pnpm install
-
Build the server:
pnpm build
-
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 greetinggreeting://Alice
Development
Available Scripts
pnpm dev
- Watch mode development (auto-rebuilds on changes)pnpm build
- Build the projectpnpm start
- Run the built serverpnpm clean
- Clean build directorypnpm lint
- Check code for linting issuespnpm lint:fix
- Auto-fix linting issuespnpm format
- Format code with Prettierpnpm type-check
- Check TypeScript types without building
Development Workflow
-
Start development:
pnpm dev
This starts TypeScript in watch mode - your code will auto-rebuild on changes.
-
Code quality (run before committing):
pnpm lint:fix pnpm format pnpm type-check
-
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 implementationbuild/
- Compiled outputtsconfig.json
- TypeScript configuration.eslintrc.js
- ESLint configuration (create as needed).prettierrc
- Prettier configuration (create as needed)
Extending
To add your own tools and resources:
- Use
server.registerTool()
for new tools - Use
server.registerResource()
for new resources - Follow the existing patterns in
src/index.ts
- Run
pnpm lint:fix
andpnpm format
to maintain code quality
License
MIT