mcpField
E
eMCP

eMCP

本地服务
github.com/joeymeere开发工具1186 周前更新

关于 eMCP

eMCP 是用于构建 MCP 服务的 TypeScript 框架,面向需要 LiteMCP 风格接口并可选使用身份验证和分层中间件的开发者。

主要功能

  1. 01LiteMCP 的功能
  2. 02内置身份验证处理器
  3. 03分层自定义中间件

适用场景

  1. 01为 MCP 服务添加请求身份验证
  2. 02在服务处理器前后运行中间件

MCP 相关

eMCP 是用于构建 MCP 服务的框架,可在处理 MCP 请求时使用身份验证处理器和自定义中间件。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

暂未收录安装方式

我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。

代码仓库

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

eMCP


这是 LiteMCP TS 库的分支,扩展了内置身份验证处理和自定义中间件等功能。

功能

本项目旨在成为 LiteMCP 等工具的近乎即插即用的替代品。因此,目前所有新增功能都是可选的。

  • LiteMCP 的所有现有功能
  • 内置身份验证处理程序
  • 支持自定义分层中间件

快速入门

通过 Bun 或 NPM 安装:

npm i emcp
# or use Bun (preferred)
bun add emcp
基本用法

(可选)运行示例:

bun run example:basic
bun run example:auth
bun run example:middleware
bun run example:advanced
const server = new eMCP("mcp-server-with-auth", "1.0.0", {
  authenticationHandler: async (request) => {
    // implement your custom auth logic here
    return true;
  },
});

// Request to this tool, or any other resource or prompt will
// require authentication governed by the handler
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;
  },
});
自定义中间件
const server = new eMCP("mcp-server-with-middleware", "1.0.0", {
  authenticationHandler: async (request) => {
    // implement your custom auth logic here
    return true;
  },
});

// This will time entire req -> res cycle, including middlewares
server.use(async (request, next) => {
  const startTime = Date.now();
  server.logger.debug("Request started", { method: request.method });

  // Wait for all inner middleware and the handler to complete
  const response = await next();

  const endTime = Date.now();
  server.logger.debug("Request completed", {
    method: request.method,
    duration: `${endTime - startTime}ms`,
  });

  return response;
});

中间件的工作方式

eMCP 中的中间件按注册顺序运行。所有中间件处理程序都执行到 next() 代码块后,才会执行标准 MCP 流程。服务器处理完毕后,对于 next() 代码块之后还有代码的中间件处理程序,将按相反顺序执行。

简单来说,它的运行方式大致如下:

<---- Request received ----
1. Middleware 1
2. Middleware 2
<---- Pre-processing done ---->
4. Server handler
<---- Post-processing start ---->
5. Middleware 2
6. Middleware 1
---- Response sent ---->

如果你熟悉 Hono 之类的框架,那么这套机制对你来说应该很熟悉。

路线图

  • 便捷的 MCP<->MCP 通信
  • 集成到框架中

为什么?

因为我想这么做

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。