MCP ExplorerExplorer

Typescript Mcp Demo

@tuoniooooon 10 months ago
1 MIT
FreeCommunity
AI Systems
# Custom Simple MCP Service Based on MCP Protocol

Overview

What is Typescript Mcp Demo

typescript-mcp-demo is a simple MCP server built on the Model Context Protocol (MCP) using TypeScript. It serves as an example project to demonstrate the creation of an MCP server with basic functionalities.

Use cases

Use cases for typescript-mcp-demo include creating educational applications that demonstrate programming concepts, developing tools for quick calculations, and integrating with other services using MCP for enhanced functionality.

How to use

To use typescript-mcp-demo, install the dependencies using ‘pnpm install’, then build the project with ‘pnpm build’. The compiled files will be located in the ‘dist’ directory. You can then run the server and interact with its tools and resources.

Key features

Key features include a simple addition tool, a dynamic greeting resource, development in TypeScript, and support for standard input/output communication.

Where to use

typescript-mcp-demo can be used in various fields such as software development, educational tools, and any application requiring a simple server-client interaction based on the MCP protocol.

Content

Model Context Protocol (MCP) TypeScript Demo

This is a TypeScript example project based on the Model Context Protocol (MCP), demonstrating how to create a simple MCP server with basic tools and resources functionality.

Language

Features

  • Provides a simple addition tool
  • Provides a dynamic greeting resource
  • Developed with TypeScript
  • Supports standard input/output communication

Documentation

Requirements

  • Node.js >= 20.10.0
  • pnpm >= 8.0.0

Installation

  1. Install dependencies:
pnpm install
  1. Build the project:
pnpm  build

The compiled files will be output to the dist directory.

Examples

Developing New Features

To add new tools or resources in src/index.ts:

  1. Use server.tool() to add new tools
  2. Use server.resource() to add new resources
  3. Define input parameter types using Zod
  4. Implement the corresponding processing logic
  5. Create corresponding test case files

Troubleshooting

If you encounter issues:

  1. Ensure all dependencies are correctly installed
  2. Check compilation output for errors
  3. Verify test case JSON format is correct
  4. Check process input/output configuration

Notes

  • Make sure to use compiled JavaScript files (in the dist directory) for testing
  • Use the @modelcontextprotocol/inspector tool for testing
  • Follow JSON-RPC 2.0 specification when writing requests
  • Handle asynchronous operations and error cases properly

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers