Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zcaceres/easy-mcp
Absurdly easy Model Context Protocol Servers in Typescript
https://github.com/zcaceres/easy-mcp
ai bun claude claude-ai framework mcp mcp-server mcp-servers model-context-protocol node nodejs open-source typescript
Last synced: 2 days ago
JSON representation
Absurdly easy Model Context Protocol Servers in Typescript
- Host: GitHub
- URL: https://github.com/zcaceres/easy-mcp
- Owner: zcaceres
- License: mit
- Created: 2024-12-26T18:36:14.000Z (12 days ago)
- Default Branch: main
- Last Pushed: 2025-01-04T17:59:35.000Z (3 days ago)
- Last Synced: 2025-01-04T18:19:48.586Z (3 days ago)
- Topics: ai, bun, claude, claude-ai, framework, mcp, mcp-server, mcp-servers, model-context-protocol, node, nodejs, open-source, typescript
- Language: TypeScript
- Homepage:
- Size: 119 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# easy-mcp
> EasyMCP is in beta, with a first release coming in January 2025. Please report any issues you encounter.
Easy MCP is the simplest way to create Model Context Protocol (MCP) servers in TypeScript.
It hides the plumbing and definitions behind simple, easy-to-use functions, allowing you to focus on building your server. Easy MCP strives to mimic the syntax of popular server frameworks like Express, making it easy to get started.
Easy MCP allows you to define the bare minimum of what you need to get started, or you can define more complex resources, templates, tools, and prompts.
## Installation
To install easy-mcp, run the following command in your project directory:
```bash
pnpm install easy-mcp
```Or if you're using bun:
```bash
bun add easy-mcp
```## Limitations
- No support for sampling
- No support for SSE## Usage
Here's a basic example of how to use easy-mcp:
```typescript
import EasyMCP from "easy-mcp";const mcp = EasyMCP.create("my-mcp-server", {
version: "0.1.0",
});// Define a resource
mcp.resource({
uri: "dir://desktop",
name: "Desktop Directory", // Optional
description: "Lists files on the desktop", // Optional
mimeType: "text/plain", // Optional
fn: async () => {
return "file://desktop/file1.txt\nfile://desktop/file2.txt";
},
});// Define a resource template
mcp.template({
uriTemplate: "file://{filename}",
name: "File Template", // Optional
description: "Template for accessing files", // Optional
mimeType: "text/plain", // Optional
fn: async ({ filename }) => {
return `Contents of ${filename}`;
},
});// Define a tool
mcp.tool({
name: "greet",
description: "Greets a person", // Optional
inputs: [ // Optional
{
name: "name",
type: "string",
description: "The name to greet",
required: true,
},
],
fn: async ({ name }) => {
return `Hello, ${name}!`;
},
});// Define a prompt
mcp.prompt({
name: "introduction",
description: "Generates an introduction", // Optional
args: [ // Optional
{
name: "name",
type: "string",
description: "Your name",
required: true,
},
],
fn: async ({ name }) => {
return `Hi there! My name is ${name}. It's nice to meet you!`;
},
});// Start the server
mcp.serve().catch(console.error);
```## API
### `EasyMCP.create(name: string, options: ServerOptions)`
Creates a new EasyMCP instance.
- `name`: The name of your MCP server.
- `options`: Server options, including the version.### `mcp.resource(config: ResourceConfig)`
Defines a resource.
### `mcp.template(config: ResourceTemplateConfig)`
Defines a resource template.
### `mcp.tool(config: ToolConfig)`
Defines a tool.
### `mcp.prompt(config: PromptConfig)`
Defines a prompt.
### `mcp.root(config: Root)`
Defines a root.
### `mcp.serve()`
Starts the MCP server.
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
This project is licensed under the MIT License.
## Credits
Easy MCP was created by Zach Caceres but inspired by [FastMCP by kjlowin](https://github.com/jlowin/fastmcp), a library for Python MCP servers.