Cover image
Try Now
2025-03-28

一个用于创建模型上下文协议(MCP)服务器的模板存储库中的node.js/tyspript中的存储库。该模板演示了如何使用MCP协议构建简单的笔记管理系统,该协议可以与LLM驱动的应用程序一起使用。

3 years

Works with Finder

1

Github Watches

0

Github Forks

0

Github Stars

MCP Template Node

A template repository for creating Model Context Protocol (MCP) servers in Node.js/TypeScript. This template demonstrates a simple notes management system using the MCP protocol.

What is MCP?

The Model Context Protocol (MCP) is a standardized way for applications to provide context to Large Language Models (LLMs). Learn more at the Model Context Protocol Website.

Features

  • TypeScript implementation with strict type checking
  • Simple notes management system with basic CRUD operations
  • Complete examples of MCP concepts (Tools, Resources, Prompts)
  • In-memory storage for notes
  • Comprehensive error handling and validation
  • Unit tests with Vitest
  • VS Code debugging configuration
  • GitHub Actions CI workflow for testing and building

Prerequisites

  • Node.js 18 or later
  • npm or yarn

Project Structure

mcp-template-node/
├── build/                # Compiled JavaScript files
├── src/
│   ├── __tests__/        # Integration tests and test utilities
│   ├── errors/           # Custom error classes
│   ├── tools/            # MCP tool implementations
│   │   └── __tests__/    # Tool unit tests
│   ├── types/            # TypeScript type definitions
│   │   └── __tests__/    # Type tests
│   └── index.ts          # Main server entry point with MCP examples
├── package.json          # Project configuration
├── tsconfig.json         # TypeScript configuration
├── eslint.config.mjs     # ESLint flat configuration
└── README.md             # Project documentation

Getting Started

  1. Clone the repository:

    git clone https://github.com/Rethunk-Tech/mcp-template-node.git
    cd mcp-template-node
    
  2. Install dependencies:

    yarn install
    
  3. Build and run the server:

    yarn build
    yarn start
    

Development

  • Start TypeScript compiler in watch mode: yarn dev
  • Lint your code: yarn lint
  • Fix linting issues: yarn lint:fix
  • Run tests: yarn test

Testing

This project includes comprehensive tests to verify the functionality of the MCP server and its tools.

Running Tests

Run all tests:

yarn test

Run tests in watch mode (rerun tests when files change):

yarn test:watch

Run tests with coverage:

yarn test:coverage

Test Structure

  • Unit Tests: Located in __tests__ directories near the code they test
  • Integration Tests: Located in src/__tests__/
  • Test Utilities: Common test helpers in src/__tests__/test-utils.ts

Writing Tests

The project includes a MockMcpServer for testing tools without real MCP dependencies:

import { MockMcpServer } from '../__tests__/test-utils.js';

describe('My Tool Tests', () => {
  let server: MockMcpServer;

  beforeEach(() => {
    server = new MockMcpServer();
    // Register tools
    registerMyTools(server as any);
  });

  it('should perform some action', async () => {
    const result = await server.callTool('my_tool', { param: 'value' });
    expect(result.content[0].text).toContain('Expected text');
  });
});

Testing with MCP Inspector

For standalone testing, use the MCP Inspector tool:

yarn inspector

This will open an interactive session where you can test your MCP tools.

Available Tools

Create Note

Creates a new note with title and content.

List Notes

Lists all available notes with their IDs and titles.

Get Note

Retrieves a specific note by ID.

Update Note

Updates an existing note's title, content, or tags.

Delete Note

Deletes a note by ID.

Extending the Template

To extend this template:

  1. Add new types in src/types/
  2. Implement new tools in src/tools/
  3. Add new resources in src/index.ts
  4. Create new prompt templates as needed
  5. Add tests for your new functionality

Contributing

See CONTRIBUTING.md for guidelines on how to contribute to this project.

License

MIT

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Bora Yalcin
  • Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Lists Tailwind CSS classes in monospaced font

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • Yasir Eryilmaz
  • AI scriptwriting assistant for short, engaging video content.

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • huahuayu
  • 统一的API网关,用于将多个Etherscan样区块链Explorer API与对AI助手的模型上下文协议(MCP)支持。

  • deemkeen
  • 用电源组合控制您的MBOT2:MQTT+MCP+LLM

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

    Reviews

    1 (1)
    Avatar
    user_6gqTXCP3
    2025-04-16

    I've been using MCP Tools by ZbigniewTomanek, and it's truly a game-changer for my projects. The interface is user-friendly, and the functionality is top-notch. I appreciate the seamless integration and the efficient performance it provides. Highly recommended for anyone in need of reliable tools. Check it out here: https://mcp.so/server/my-mcp-server/ZbigniewTomanek.