0t2/mcp-typescript-starter
If you are the rightful owner of mcp-typescript-starter 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.
A simple MCP (Model Context Protocol) server demo built with Node.js and TypeScript.
sum
A tool to calculate the sum of two numbers.
mcp-typescript-starter
How to use this template
To fully utilize this template for your own project:
- Use
git clone
to copy this repo locally. - Rename the project folder and update the
name
field inpackage.json
to your new project name. - Run
pnpm install
to install all dependencies. - Start developing your MCP server by modifying the source code in the
src/
directory. - Use the built-in scripts (e.g.,
pnpm dev
,pnpm test
) for development and testing. - (Optional) Remove the existing git history by deleting the
.git
folder and re-initialize withgit init
for a fresh start.
This approach ensures your new project is independent and clean, without any fork or commit history from the template.
A simple MCP (Model Context Protocol) server demo built with Node.js and TypeScript. This project demonstrates how to create an MCP server using the official SDK, featuring a sum
tool for adding two numbers.
Features
- TypeScript for type safety
- Standard MCP server implementation via the official SDK
- Built-in
sum
tool to calculate a + b - CLI executable (
mcp-typescript-starter
) - Comprehensive test suite with Vitest
- Test coverage reporting
- GitHub Actions CI/CD
Scripts
Script | Description |
---|---|
pnpm dev | Compile TypeScript in watch mode |
pnpm build | Compile TypeScript and generate executable |
pnpm format | Format all files using Prettier |
pnpm format:check | Check code formatting with Prettier |
pnpm format:src | Format only source files in src directory |
pnpm test | Run tests in watch mode |
pnpm test:run | Run tests once |
pnpm test:watch | Run tests in watch mode |
pnpm test:coverage | Run tests with coverage report |
Testing
This project uses Vitest for testing. The test suite includes:
- Unit tests for individual functions (
src/tools.test.ts
) - Integration tests for MCP server functionality (
tests/integration.test.ts
) - Coverage reporting with threshold enforcement
Running Tests
# Run tests once
pnpm test:run
# Run tests in watch mode
pnpm test:watch
# Generate coverage report
pnpm test:coverage
Test Coverage
The project maintains high test coverage with the following thresholds:
- Statements: 80%
- Branches: 80%
- Functions: 80%
- Lines: 80%
Coverage reports are generated in HTML format in the coverage/
directory.
Usage
-
Build the project:
pnpm build
-
Integrate with Claude for Desktop
To use this MCP server with Claude for Desktop, add your server to the Claude configuration file:
- Open (or create)
~/Library/Application Support/Claude/claude_desktop_config.json
on macOS/Linux. - Add the following configuration (replace
/ABSOLUTE/PATH/TO/PROJECT
with your project path):
{ "mcpServers": { "mcp-typescript-starter": { "command": "node", "args": [ "/ABSOLUTE/PATH/TO/PROJECT/dist/index.js" ] } } }
- Save the file and restart Claude for Desktop.
- The MCP server and its tools (e.g.,
sum
) will now be available in Claude for Desktop's tool menu.
- Open (or create)
-
Tool details
- Tool name:
sum
- Parameters:
a
: The first numberb
: The second number
- Returns:
a + b = result
- Tool name:
Global Linking (npm link)
Run the following command in the project root to create a symbolic link, which makes the command specified in the bin
field of package.json
available globally:
npm link
After running this, you can use mcp-typescript-starter
(or the name specified in the bin
field) directly in your terminal to start the MCP server.
Project Structure
.
āāā src/ # Source code
ā āāā index.ts # MCP server entry point
ā āāā tools.ts # Tool implementations
āāā tests/ # Test files (separated from source)
ā āāā unit/ # Unit tests
ā ā āāā tools.test.ts # Unit tests for tools.ts
ā āāā integration/ # Integration tests
ā āāā integration.test.ts # MCP server integration tests
āāā .github/ # GitHub Actions workflows
ā āāā workflows/
ā āāā test.yml # CI/CD pipeline
āāā dist/ # Compiled output (gitignored)
āāā coverage/ # Test coverage reports (gitignored)
āāā package.json # Project config and dependencies
āāā tsconfig.json # TypeScript config
āāā vitest.config.ts # Vitest configuration
āāā TESTING.md # Detailed testing documentation
āāā .prettierrc # Prettier config
āāā .gitignore # Git ignore list
Development Environment
- Node.js 22.17.0 (recommended: use Volta)
- TypeScript 5.8.x
- MCP SDK 1.13.x
- Prettier 3.6.x
- Vitest 2.1.x
Continuous Integration
This project uses GitHub Actions for CI/CD:
- Runs tests on Node.js 18.x, 20.x, and 22.x
- Generates coverage reports
- Runs on push to
main
anddevelop
branches - Runs on pull requests to
main
Formatting
This project uses Prettier for code formatting. To format all files, run:
pnpm format
License
ISC License