https://github.com/ribeirogab/simple-mcp
A simple TypeScript library for creating MCP servers.
https://github.com/ribeirogab/simple-mcp
ai mcp model-context-protocol
Last synced: 2 months ago
JSON representation
A simple TypeScript library for creating MCP servers.
- Host: GitHub
- URL: https://github.com/ribeirogab/simple-mcp
- Owner: ribeirogab
- License: mit
- Created: 2025-03-27T06:25:51.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-28T14:52:46.000Z (over 1 year ago)
- Last Synced: 2025-09-19T00:02:30.271Z (10 months ago)
- Topics: ai, mcp, model-context-protocol
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/simple-mcp
- Size: 22.5 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-mcp-servers - simple-mcp - simple-mcp is a lightweight TypeScript library for creating MCP servers with minimal configuration and straightforward implementation. ([Read more](/details/simple-mcp.md)) `mcp` `typescript` `library` `framework` `development` (Development Tools MCP Servers)
- awesome-mcp-servers - **simple-mcp** - A simple TypeScript library for creating MCP servers. `typescript` `ai` `mcp` `model-context-protocol` `server` `npm install ribeirogab/simple-mcp` (🤖 AI/ML)
- metorial-index - Simple MCP - This server enables the creation of MCP servers using a straightforward API with full TypeScript support. It includes parameter validation and facilitates the implementation of tools for dynamic interactions by adhering to the Model Context Protocol. (APIs and HTTP Requests)
- awesome-mcp-devtools - ribeirogab/simple-mcp - A simple TypeScript library for creating MCP servers (SDKs / JavaScript/TypeScript)
- awesome-mcp-devtools - ribeirogab/simple-mcp - A simple TypeScript library for creating MCP servers (SDKs / JavaScript/TypeScript)
- awesome-mcp-servers - SimpleMCP - A simple TypeScript library for creating MCP servers. (Table of Contents / Gaming)
README
# Simple MCP
A simple TypeScript library for creating [MCP](https://modelcontextprotocol.io/) (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](https://github.com/ribeirogab/simple-mcp/tree/main/examples) for more complete examples:
- [Greeting Tool](https://github.com/ribeirogab/simple-mcp/tree/main/examples/greet.ts) - Simple greeting example
- [Calculator Tool](https://github.com/ribeirogab/simple-mcp/tree/main/examples/calculator.ts) - Mathematical operations example
## Contributing
Contributions are welcome! Feel free to open issues or submit pull requests.
## License
[MIT](LICENSE)