MCP ExplorerExplorer

Chenreuven Mcp Ts Simple Template

@MCP-Mirroron 9 months ago
1 MIT
FreeCommunity
AI Systems
https://github.com/ChenReuven/mcp-ts-simple-template 的镜像

Overview

What is Chenreuven Mcp Ts Simple Template

ChenReuven_mcp-ts-simple-template is a simple TypeScript template designed for building Model Context Protocol (MCP) servers. It serves as a foundational framework for creating custom MCP tools that can be integrated with AI systems.

Use cases

Use cases include creating custom calculators, data processing tools, or any application that requires interaction with users through an MCP server.

How to use

To use ChenReuven_mcp-ts-simple-template, clone the repository and install the dependencies using npm or yarn. Build and start the server with the command ‘npm start’. You can modify ‘index.ts’ to add your own tools and compile the code using ‘npm run build’.

Key features

Key features include a basic MCP server implementation, input validation using Zod, and the ability to connect the server to standard I/O for communication. The template also provides a sample BMI calculator tool.

Where to use

ChenReuven_mcp-ts-simple-template can be used in various fields where AI systems require custom tools for processing and responding to user inputs, such as healthcare, finance, and education.

Content

MCP TypeScript Simple Template

A simple TypeScript template for building Model Context Protocol (MCP) servers. This project provides a foundation for creating custom MCP tools that can be integrated with AI systems.

Overview

This template implements a basic MCP server with a sample BMI calculator tool. It demonstrates how to:

  • Set up an MCP server in TypeScript
  • Define and implement MCP tools with input validation using Zod
  • Connect the server to standard I/O for communication

Prerequisites

  • Node.js (v20 or higher recommended)
  • npm or yarn

Installation

  1. Clone this repository
  2. Install dependencies:
npm install

Project Structure

  • index.ts - Main server implementation with sample tool
  • package.json - Project dependencies and scripts
  • tsconfig.json - TypeScript configuration

Usage

Building and Running

Build and start the server:

npm start

This will compile the TypeScript code and start the MCP server.

Development

For development, you can:

  1. Modify index.ts to add your own tools
  2. Run the build command to compile:
npm run build

Creating Custom Tools

To create a new tool, follow this pattern in index.ts:

server.tool(
  "your-tool-name",
  {
    // Define input schema using Zod
    paramName: z.string(),
    // Add more parameters as needed
  },
  async ({ paramName }) => ({
    content: [{
      type: "text",
      text: "Your tool's response"
    }]
  })
);

Dependencies

  • @modelcontextprotocol/sdk - Core MCP SDK
  • zod - Schema validation
  • dotenv - Environment variable management
  • typescript - TypeScript compiler

License

ISC

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers