trackmcp
Back to directory
ribeirogab

simple-mcp

View on GitHub

A simple TypeScript library for creating MCP servers.

1 stars TypeScriptAI & Machine Learning Updated Mar 28, 2025
aimcpmodel-context-protocol

Documentation

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

bash
npm install simple-mcp

Quickstart

typescript
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:

typescript
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 {
  public readonly name = 'greet';
  public readonly parameters = parameters;

  public async execute({ name }: z.infer>) {
    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

Frequently asked questions

What is simple-mcp?

simple-mcp is A simple TypeScript library for creating MCP servers.

How do I install simple-mcp?

Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.

Is simple-mcp open source?

Yes — it is hosted on GitHub at https://github.com/ribeirogab/simple-mcp and has 1 stars.

Related MCP tools

Run your own MCP server? See who uses it and what to fix.

Measure it with TrackMCP