emcp
A framework for building simple MCP servers with custom middleware
claude mcp add --transport stdio joeymeere-emcp npx -y emcp
How to use
eMCP is a TypeScript-based MCP server library designed to be a near drop-in replacement for LiteMCP, with optional built-in authentication handling and support for custom middleware. It lets you define tools (prompts or actions) that can be invoked by clients, and you can attach an authentication handler to gate access to any resource. The server also supports custom layered middleware, so you can measure or modify requests and responses, enforce policies, or log telemetry around the request lifecycle. A typical workflow is to install the package, instantiate the server with an authentication handler, and register tools with a name, description, input schema, and an execute function. You can also add middleware that runs before and after the main handler, enabling things like timing, logging, or metric collection.
To use it, install the package (emcp) and follow the quickstart examples: create a server instance, pass an authentication handler function that returns a boolean indicating access, and call server.addTool with a name, description, input parameters (for example using zod objects), and an execute function that implements the tool’s logic. You can also configure and register middleware to run around the request lifecycle, including pre-processing, timing, and post-processing steps. Examples in the README demonstrate basic usage, authentication-aware tooling, and middleware integration, so you can tailor the server behavior to your needs.
How to install
Prerequisites:
- Node.js (recommended v14+ or latest LTS) and npm or Bun
- Basic familiarity with TypeScript or JavaScript development
Install the package from npm (or bun):
Code block: npm install emcp
Or using Bun:
Code block: bun add emcp
Basic usage after installation:
Code block: // Basic usage example (pseudo-setup; adapt to your project structure) import { eMCP } from "emcp";
const server = new eMCP("mcp-server", "1.0.0", { authenticationHandler: async (request) => { // implement your auth logic here return true; }, });
server.addTool({ name: "add", description: "Add two numbers", parameters: z.object({ a: z.number(), b: z.number() }), execute: async (args) => { server.logger.debug("Adding two numbers", args); return args.a + args.b; }, });
// Start your MCP server according to the library's guidance
Follow the package documentation for your preferred runtime (Node.js/ Bun) to run the server, typically by importing the library and invoking its start/run methods. The README indicates basic examples and an authentication/middleware workflow to tailor the server behavior to your needs.
Additional notes
Notes and tips:
- The package emcp includes built-in authentication support and a hook-based middleware system; use them to enforce access control and to observe request lifecycles.
- When defining tools, you can specify input parameters using a schema (e.g., zod) to validate arguments before execution.
- If you plan to distribute or reuse the server in multiple environments, consider bundling or compiling the TypeScript source and ensuring the Node version compatibility.
- If you encounter issues with installation or running examples, ensure your environment can resolve and install npm packages, and verify that your runtime (Node/Bun) is properly configured.
- The MCP server name in the config is flexible; choose a meaningful identifier for your deployment (e.g., your app or project name).
- The README indicates availability of example usage (basic, auth, middleware, advanced); these can serve as starting templates for your own tools and middleware.
- Since the server is a library, you’ll typically integrate it within your application bootstrap rather than running a standalone CLI.
Related MCP Servers
obsidian -tools
Add Obsidian integrations like semantic search and custom Templater prompts to Claude or any MCP client.
ironcurtain
A secure* runtime for autonomous AI agents. Policy from plain-English constitutions. (*https://ironcurtain.dev)
CanvasMCPClient
Canvas MCP Client is an open-source, self-hostable dashboard application built around an infinite, zoomable, and pannable canvas. It provides a unified interface for interacting with multiple MCP (Model Context Protocol) servers through a flexible, widget-based system.
vikunja
Model Context Protocol server for Vikunja task management. Enables AI assistants to interact with Vikunja instances via MCP.
grok-faf
First MCP server for Grok | FAST⚡️AF • URL-based AI context • Vercel-deployed
mcp-turso
MCP server for interacting with Turso-hosted LibSQL databases