Cover image
Try Now
2025-03-28

A simple TypeScript library for creating MCP servers.

3 years

Works with Finder

1

Github Watches

0

Github Forks

1

Github Stars

Simple MCP

A simple TypeScript library for creating MCP (Model Context Protocol) servers.

Features

  • Simple API: Create MCP servers with minimal code
  • Type Safety: Full TypeScript integration
  • Parameter Validation: Built-in validation with Zod
  • MCP Compatible: Fully implements the Model Context Protocol

Installation

npm install simple-mcp

Quickstart

import { McpServer } from 'simple-mcp';
import { z } from 'zod';

// Create a server instance
const server = new McpServer({ name: 'my-server' });

// Register the tool with the server
server.tool({
  name: 'greet',
  parameters: {
    name: z.string().describe('Person\'s name')
  },
  execute: async ({ name }) => {
    return {
      content: [
        {
          type: 'text',
          text: `Hello, ${name}! Nice to meet you.`
        }
      ]
    };
  }
});

// Start the server
server.start({ transportType: 'stdio' });

Class-based Implementation

You can also implement MCP tools using classes:

import { McpServer, type McpTool } from 'simple-mcp';
import { z, ZodObject } from 'zod';

const parameters = {
  name: z.string().describe('The name is required'),
};

class GreetTool implements McpTool<typeof parameters> {
  public readonly name = 'greet';
  public readonly parameters = parameters;

  public async execute({ name }: z.infer<ZodObject<typeof this.parameters>>) {
    return {
      content: [
        {
          type: 'text',
          text: `Hello, ${name}! Nice to meet you.`,
        },
      ],
    };
  }
}

// Initialize a new MCP server with the name 'greet-server'
const server = new McpServer({ name: 'greet-server' });

// Create an instance of the GreetTool class
const greetTool = new GreetTool();

// Register the tool with the server
server.tool(greetTool);

// Start the server using stdio as the transport method
server.start({ transportType: 'stdio' });

Examples

Check out the examples directory for more complete examples:

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

License

MIT

相关推荐

  • 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.

  • 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!

  • https://appia.in
  • Siri Shortcut Finder – your go-to place for discovering amazing Siri Shortcuts with ease

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Daren White
  • A supportive coach for mastering all Spanish tenses.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • apappascs
  • Discover the most comprehensive and up-to-date collection of MCP servers in the market. This repository serves as a centralized hub, offering an extensive catalog of open-source and proprietary MCP servers, complete with features, documentation links, and contributors.

  • ShrimpingIt
  • Micropython I2C-based manipulation of the MCP series GPIO expander, derived from Adafruit_MCP230xx

  • jae-jae
  • MCP server for fetch web page content using Playwright headless browser.

  • HiveNexus
  • An AI chat bot for small and medium-sized teams, supporting models such as Deepseek, Open AI, Claude, and Gemini. 专为中小团队设计的 AI 聊天应用,支持 Deepseek、Open AI、Claude、Gemini 等模型。

  • ravitemer
  • A powerful Neovim plugin for managing MCP (Model Context Protocol) servers

  • patruff
  • Bridge between Ollama and MCP servers, enabling local LLMs to use Model Context Protocol tools

    Reviews

    4 (1)
    Avatar
    user_YNqDAPLo
    2025-04-17

    I've been using simple-mcp and it's a fantastic tool! It's well-crafted by ribeirogab and simplifies multi-channel processing tasks wonderfully. The project is clearly documented, and the community support is excellent. Highly recommended for anyone in need of a reliable MCP solution. Check it out here: https://github.com/ribeirogab/simple-mcp