Skip to main content
Glama

简单 MCP

用于创建MCP (模型上下文协议)服务器的简单 TypeScript 库。

特征

  • 简单的 API :使用最少的代码创建 MCP 服务器

  • 类型安全:完全 TypeScript 集成

  • 参数验证:使用 Zod 内置验证

  • MCP 兼容:完全实现模型上下文协议

Related MCP server: easy-mcp

安装

npm install simple-mcp

快速入门

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' });

基于类的实现

您还可以使用类来实现 MCP 工具:

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' });

示例

查看示例目录以获取更完整的示例:

贡献

欢迎贡献代码!欢迎随时提交 issue 或 PR。

执照

麻省理工学院

Install Server
A
license - permissive license
D
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Tools

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A TypeScript wrapper library for the Model Context Protocol SDK that provides a simplified interface for creating MCP servers with tools, resources, and prompts without needing to work directly with the protocol.
    94
    AGPL 3.0
  • A
    license
    Not graded
    quality
    D
    maintenance
    Simplifies creating MCP servers in TypeScript with an Express-like API and experimental decorators, enabling quick definition of tools, resources, and prompts.
    57
    196
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    A lightweight SDK for building Model Context Protocol (MCP) servers with zero-config setup, automatic TypeScript type inference, and Zod runtime validation.
    14
    2
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Turn your typed TypeScript functions into an MCP server — tool, resource, and prompt schemas inferred from your types and JSDoc. No schema library, no decorators, no boilerplate.
    12
    MIT

View all related MCP servers

Related MCP Connectors

  • A TypeScript MCP server for Home Assistant, enabling programmatic management of entities, automati…

  • A Model Context Protocol server for Wix AI tools

  • MCP Spec Compliance MCP — audits any MCP server.json against the official Model Context Protocol

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ribeirogab/simple-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server