Token导航 LogoToken导航TokenDH.com
Create MCP Express logo
AI代理stdio官方级别未说明来源级核验

Create MCP Express

MCP Server

create-mcp-express

一个快速搭建基于Express.js的Model Context Protocol(MCP)服务器的模板,提供TypeScript支持、测试框架和模块化架构。

工具数

0

提示词数

0

GitHub Stars

1

资源数

0
服务器模板测试框架TypeScriptJavaScript

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

ahnafyy

提供方

ahnafyy

最后核验

2026/5/17 20:20

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx create-mcp-express my-mcp-server

详细介绍

MCP Express服务器模板

使用Express.js快速构建新的模型上下文协议(MCP)服务器。

🎯 使用此存储库的两种方法

1.️⃣ 使用脚手架工具(推荐)

快速创建新的MCP服务器项目:

npx create-mcp-express my-mcp-server

这将:

  • ✅ 使用所有模板文件创建新项目
  • ✅ 设置TypeScript、Jest和所有依赖项
  • ✅ 使用交互式提示配置您的项目
  • ✅ 自动安装依赖项

2.️⃣ 克隆为模板

直接将此存储库用作起点:

git clone https://github.com/ahnafyy/mcp-poc.git my-mcp-server
cd my-mcp-server
rm -rf .git
git init
npm install

🏗️ 建筑

src/
├── config/          # Configuration management
├── constants/       # Application constants
├── registry/        # Tool & resource registration (Strategy Pattern)
├── resources/       # Resource handlers (functional)
├── server/          # Server creation and HTTP setup
├── tools/           # Tool handlers (functional)
├── types/           # TypeScript type definitions
├── utils/           # Utility functions (logger, etc.)
└── index.ts         # Application entry point
└── __tests__        # Tests for the app

🚀 入门指南

安装

npm install

发展

# Run in development mode
npm run dev

# Run with MCP inspector
npm run inspect

# Run both concurrently
npm run dev:inspect

生产

# Build
npm run build

# Start
npm start

🧪 测试

包含单元和集成测试的全面测试套件。

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run with coverage report
npm run test:coverage

# Run with verbose output
npm run test:verbose

测试覆盖范围:

  • 工具、资源、注册表和实用程序的单元测试
  • HTTP和MCP服务器的集成测试
  • 目标覆盖率:70%(语句、分支、函数、行)

测试.md 详细的测试策略。

🔍 检查员

抬头看 http://localhost:6274/ 与MCP服务器交互

📝 配置

通过环境变量进行配置:

SERVER_NAME=my-mcp-server
SERVER_VERSION=1.0.0
PORT=3000
NODE_ENV=development
LOG_LEVEL=info
LOG_COLORS=true
MCP_JSON_RESPONSE=true

🛠️ 添加新工具

工具使用具有明确类型定义的函数式方法:

// src/tools/my-custom.tools.ts
import { z } from 'zod';
import { Tool } from '../types/index.js';
import { logger } from '../utils/logger.js';

interface MyInput {
  value: string;
}

interface MyOutput {
  result: string;
}

const myHandler = async (input: MyInput) => {
  logger.debug('Executing my tool', { input });
  const result = { result: input.value.toUpperCase() };
  
  return {
    content: [{ type: 'text' as const, text: JSON.stringify(result) }],
    structuredContent: result,
  };
};

export const myTool: Tool = {
  name: 'my-tool',
  definition: {
    title: 'My Custom Tool',
    description: 'Does something useful',
    inputSchema: {
      value: z.string().describe('Input value'),
    },
  },
  handler: myHandler,
};

export const myTools = [myTool];

然后添加到 src/tools/index.ts:

export * from './my-custom.tools.js';

import { mathTools } from './math/math.tools.js';
import { myTools } from './my-custom.tools.js';

export const allTools = [...mathTools, ...myTools];

🗂️ 添加新资源

资源遵循相同的功能模式:

// src/resources/my-custom.resources.ts
import { Resource } from '../types/index.js';
import { logger } from '../utils/logger.js';

const myHandler = async (uri: URL, variables?: any) => {
  logger.debug('Fetching resource', { uri: uri.href });
  
  return {
    contents: [{
      uri: uri.href,
      mimeType: 'text/plain',
      text: 'My resource content',
    }],
  };
};

export const myResource: Resource = {
  name: 'my-resource',
  uri: 'custom://my-resource',
  definition: {
    title: 'My Custom Resource',
    description: 'Provides custom data',
  },
  handler: myHandler,
  isTemplate: false,
};

export const myResources = [myResource];

然后添加到 src/resources/index.ts:

export * from './my-custom.resources.js';

import { greetingResources } from './greeting/greeting.resources.js';
import { testResources } from './test/test.resources.js';
import { myResources } from './my-custom.resources.js';

export const allResources = [...testResources, ...greetingResources, ...myResources];

目录标签

目录标签

服务器模板测试框架TypeScriptJavaScript本地部署Express.jsMCP协议

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Node.js

来源包(packageName,安装包名)

create-mcp-express

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP