Token导航 LogoToken导航

MCP Server · AI代理

Cortexflow AI MCP

一个用于构建具有HTTP流功能的MCP(模型上下文协议)服务器的基础模板,提供生产就绪的实现、全面的测试覆盖和清晰的文档。

stdio官方级别未说明来源级核验工具 1vitest
服务器模板生产就绪TypeScriptJavaScript

快速开始

作者 / 组织
CortexFlow-AI
提供方
CortexFlow-AI
运行时
Node.js

工具数量

1

来源目录标注

资源数量

0

来源目录标注

提示词数量

0

来源目录标注

GitHub Star

0

仓库热度

收录来源

1 个

MCP World

选型结论

Cortexflow AI MCP 属于AI代理类 MCP Server,公开资料标注 1 个工具,通过stdio 本地进程接入,客户端适配情况以官方文档为准,有可以直接复制的安装命令;接入前要先准备 访问 Token。

分类

AI代理

传输方式

stdio

认证方式

访问 Token

部署方式

公开资料未说明

安装与配置

安装命令

npx vitest run tests/unit/tools/hello-tool.test.ts

客户端配置示例

{
  "mcpServers": {
    "http-stream-mcp-template": {
      "command": "npx",
      "args": [
        "vitest",
        "run",
        "tests/unit/tools/hello-tool.test.ts"
      ]
    }
  }
}

按公开安装命令拼出来的示例,字段名和参数以仓库 README 为准;带 YOUR_API_KEY 这类占位符的位置记得换成自己的值。

上手步骤

  1. 1

    准备运行环境

    stdio 服务在本地起进程,需要先装好 Node.js,再按安装命令拉取依赖。

  2. 2

    安装服务

    复制下面的安装命令执行;命令里带占位符的位置换成自己的密钥或路径。

  3. 3

    写入客户端配置

    在客户端的 MCP 配置里填启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4

    验证是否可用

    连接成功后客户端会列出 1 个工具,随便调一个只读工具确认能返回结果。

接入前确认

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

详细介绍

HTTP流MCP模板

用于构建具有HTTP流功能的MCP(模型上下文协议)服务器的基础结构。

概述

此模板使用Streamable HTTP传输协议提供了一个完整的、生产就绪的MCP服务器实现。它包括Hello world功能、全面的测试覆盖率和清晰的文档,可作为开发人员构建自己的MCP服务器的起点。

该模板实现了MCP协议版本2025-06-18,并遵循所有安全最佳实践,使其适用于开发和生产使用。

特性

  • ✅ MCP协议2025-06-18合规性 -全面实施最新的MCP规范
  • ✅ HTTP流式传输 -POST/GET支持,可选服务器发送事件(SSE)
  • ✅ Hello world工具实现 -带有参数处理的完整示例工具
  • ✅ 全面的测试覆盖率 -通过单元和集成测试,线路覆盖率达到95%以上
  • ✅ 具有严格模式的TypeScript -完全类型安全和现代JavaScript功能
  • ✅ 安全最佳实践 -源验证、本地主机绑定、输入净化
  • ✅ 可扩展架构 -易于添加新工具和自定义行为
  • ✅ 生产就绪 -错误处理、日志记录、正常关机和配置

快速开始

先决条件

  • Node.js 18+(推荐:Node.js 20 LTS)
  • npm 9+或纱1.22+

安装

  1. 克隆或下载模板:
   git clone  my-mcp-server
   cd my-mcp-server
  1. 安装依赖项:
   npm install
  1. 启动开发服务器:
   npm run dev

服务器将于启动 http://127.0.0.1:3000 默认情况下。

验证安装

用一个简单的HTTP请求测试服务器:

# Test server health
curl http://127.0.0.1:3000/mcp

# Test MCP initialization (requires proper MCP client)
curl -X POST http://127.0.0.1:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "initialize",
    "params": {
      "protocolVersion": "2025-06-18",
      "capabilities": {},
      "clientInfo": {"name": "test-client", "version": "1.0.0"}
    }
  }'

配置

环境变量

可以使用环境变量配置服务器:

# Server configuration
export MCP_PORT=3000              # Server port (default: 3000)
export MCP_HOST=127.0.0.1         # Server host (default: 127.0.0.1)

# Start server with custom configuration
npm start

程序化配置

import { MCPServer, createDefaultConfig } from './src/index.js';

const config = {
  ...createDefaultConfig(),
  port: 8080,
  host: '0.0.0.0',  // WARNING: Only use in secure environments
  allowedOrigins: ['localhost', '127.0.0.1', 'myapp.com'],
  serverInfo: {
    name: 'my-custom-mcp-server',
    version: '2.0.0'
  }
};

const server = new MCPServer(config);
await server.start();

配置选项

选项类型默认值描述
portnumber3000HTTP服务器端口
hoststring'127.0.0.1'服务器绑定地址
allowedOriginsstring\[\]\['localhost','127.0.0.1'\]允许的Origin标头
protocolVersionstring'2025-06-18'MCP协议版本
serverInfo.namestring“http流mcp模板”服务器名称
serverInfo.versionstring“1.0.0”服务器版本

用法

使用Hello工具

该模板包括一个Hello工具,用于演示基本的MCP功能:

# List available tools
curl -X POST http://127.0.0.1:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/list"
  }'

# Call Hello tool without parameters
curl -X POST http://127.0.0.1:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "tools/call",
    "params": {
      "name": "hello",
      "arguments": {}
    }
  }'

# Call Hello tool with name parameter
curl -X POST http://127.0.0.1:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 4,
    "method": "tools/call",
    "params": {
      "name": "hello",
      "arguments": {"name": "Alice"}
    }
  }'

添加自定义工具

  1. 创建新的工具类:
   // src/tools/my-tool.ts
   import { ToolImplementation, ToolResult } from '../types/index.js';

   export class MyTool implements ToolImplementation {
     name = 'my-tool';
     description = 'My custom tool';
     inputSchema = {
       type: 'object',
       properties: {
         input: { type: 'string' }
       }
     };

     async execute(args: any): Promise {
       return {
         content: [{ type: 'text', text: `Processed: ${args.input}` }],
         isError: false
       };
     }
   }
  1. 注册工具:
   // In your server setup
   import { MyTool } from './tools/my-tool.js';

   const server = new MCPServer(config);
   server.registerTool(new MyTool());
   await server.start();

发展

可用脚本

脚本描述
npm run dev使用热重新加载启动开发服务器
npm run build将TypeScript构建为JavaScript
npm start启动生产服务器
npm test运行所有测试
npm run test:watch在监视模式下运行测试
npm run test:coverage使用覆盖率报告运行测试
npm run lint检查代码样式
npm run lint:fix修复代码风格问题
npm run format使用Prettier格式化代码

项目结构

├── src/
│   ├── types/              # TypeScript type definitions
│   │   ├── index.ts        # Main type exports
│   │   ├── mcp.ts          # MCP protocol types
│   │   └── server.ts       # Server configuration types
│   ├── protocol/           # MCP protocol implementation
│   │   ├── errors.ts       # Error handling and standard error codes
│   │   ├── initialization.ts # MCP initialization handshake
│   │   └── jsonrpc.ts      # JSON-RPC message handling
│   ├── transport/          # HTTP transport layer
│   │   ├── http-server.ts  # Main HTTP server implementation
│   │   ├── content-negotiation.ts # Accept header handling
│   │   └── security-middleware.ts # Origin validation & security
│   ├── server/             # MCP server orchestration
│   │   ├── mcp-server.ts   # Main server class
│   │   └── tools-handler.ts # Tool request routing
│   ├── tools/              # Tool implementations
│   │   ├── hello-tool.ts   # Hello world tool example
│   │   ├── registry.ts     # Tool registration and management
│   │   └── index.ts        # Tool exports
│   └── index.ts            # Main entry point and exports
├── tests/
│   ├── unit/               # Unit tests
│   └── integration/        # Integration tests
├── examples/               # Usage examples
├── dist/                   # Compiled JavaScript (generated)
└── coverage/               # Test coverage reports (generated)

测试

该模板包括全面的测试覆盖率:

# Run all tests
npm test

# Run tests with coverage
npm run test:coverage

# Run tests in watch mode during development
npm run test:watch

# Run specific test file
npx vitest run tests/unit/tools/hello-tool.test.ts

代码质量

该项目使用ESLint和Prettier来提高代码质量:

# Check for linting issues
npm run lint

# Automatically fix linting issues
npm run lint:fix

# Format code
npm run format

生产部署

生产大楼

# Build the project
npm run build

# Start production server
npm start

Docker部署

创建一个 Dockerfile:

FROM node:20-alpine

WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production

COPY dist/ ./dist/
EXPOSE 3000

CMD ["npm", "start"]

构建并运行:

docker build -t my-mcp-server .
docker run -p 3000:3000 my-mcp-server

流程管理

对于生产部署,使用PM2这样的流程管理器:

# Install PM2
npm install -g pm2

# Start with PM2
pm2 start dist/index.js --name mcp-server

# Monitor
pm2 status
pm2 logs mcp-server

安全考虑

默认安全功能

  • 本地主机绑定:默认情况下,服务器绑定到127.0.0.1
  • 原产地验证:验证Origin标头以防止DNS重新绑定攻击
  • 输入净化:所有工具输入都经过验证和消毒
  • 错误处理:防止通过错误消息泄露信息

生产安全

对于生产部署:

  1. 使用HTTPS:在生产环境中始终使用TLS
  2. 防火墙:限制对MCP端口的访问
  3. 认证:添加身份验证中间件(参见示例)
  4. 速率限制:对工具调用实施速率限制
  5. 监控:添加日志记录和监控

添加身份验证

// Example authentication middleware
import { MCPServer } from './src/index.js';

const server = new MCPServer(config);

// Add authentication hook (implement based on your needs)
server.addAuthenticationHook(async (request) => {
  const token = request.headers.authorization;
  if (!isValidToken(token)) {
    throw new Error('Unauthorized');
  }
});

故障排除

常见问题

服务器无法启动

问题: Error: listen EADDRINUSE :::3000 解决方案:端口3000已在使用中。要么:

  • 使用端口3000停止进程: lsof -ti:3000 | xargs kill
  • 使用其他端口: MCP_PORT=3001 npm start

问题: Error: listen EACCES :::80 解决方案:1024以下的端口需要root权限。使用端口3000+或使用sudo运行(不推荐)。

连接被拒绝

问题: curl: (7) Failed to connect to 127.0.0.1 port 3000: Connection refused 解决方案:

  • 确保服务器正在运行: npm run dev
  • 检查服务器日志中的启动错误
  • 验证端口配置
原产地验证错误

问题: Error: Invalid Origin header 解决方案:将您的域名添加到 allowedOrigins 在配置中:

const config = {
  ...createDefaultConfig(),
  allowedOrigins: ['localhost', '127.0.0.1', 'yourdomain.com']
};
未找到工具

问题: Method not found: tools/call 解决方案:

  • 在调用工具之前,确保服务器已初始化
  • 检查工具是否正确登记
  • 验证请求中的工具名称
JSON-RPC错误

问题: Parse error 或 Invalid Request 解决方案:

  • 确保内容类型为 application/json
  • 验证JSON语法
  • 包含必需的JSON-RPC字段(jsonrpc, method, id)

调试模式

启用调试日志记录:

# Set debug environment variable
DEBUG=mcp:* npm run dev

# Or in code
process.env.DEBUG = 'mcp:*';

健康检查

服务器提供健康检查端点:

# Basic health check
curl http://127.0.0.1:3000/mcp

# Server statistics
curl -X POST http://127.0.0.1:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"server/stats"}'

性能问题

如果遇到性能问题:

  1. 检查测试覆盖率: npm run test:coverage
  2. 配置文件内存使用情况:使用Node.js --inspect 旗帜
  3. 监控工具执行时间:检查服务器日志
  4. 验证输入模式:确保有效验证

获取帮助

  1. 检查日志:服务器日志包含详细的错误信息
  2. 审查测试用例:测试证明了预期的行为
  3. 参考MCP规范: MCP协议文件
  4. 查看示例:参见 examples/ 使用模式目录

文档

贡献

  1. 分叉存储库
  2. 创建要素分支: git checkout -b feature/my-feature
  3. 进行更改并添加测试
  4. 确保测试通过: npm test
  5. 检查代码质量: npm run lint
  6. 提交更改: git commit -am 'Add my feature'
  7. 推送到分支: git push origin feature/my-feature
  8. 创建拉取请求

许可证

MIT许可证-有关详细信息,请参阅许可证文件。

工具与能力

工具数量

1

资源数量

0

提示词数量

0

能力标签

MCP协议TypeScript本地部署HTTP流服务器模板生产就绪

数量来自来源目录的标注,具体工具清单以官方文档为准。

典型使用场景

多步任务编排

把拆解、检索、执行串成一条链,模型按步骤调用工具。

长期上下文

把会话、笔记和知识放到外部存储,换个会话还能接着做。

接自有流程

把内部系统和模型连起来,让助手调用已有的工作流。

选择建议

值得选的地方

  • 只提供 1 个工具,职责集中,接入后不容易误操作。
  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 公开说明写得比较完整,接入前能看清能力边界。

先想清楚的地方

  • stdio 方式要求本地装好 Node.js,换机器要重新装一遍。
  • 需要自备访问 Token,没有凭据没法直接试。
  • 第三方目录整理,版本更新和行为细节以官方仓库为准。

更适合

  • 需要在AI代理场景里让模型直接调用外部能力的人。
  • 想先快速试一下、能接受在本地跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 暂时拿不到访问 Token的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

5 个同类
MCP Server工具数传输方式安装命令收录来源最后核验
Cortexflow AI MCP

MCP World · 本页

1stdio有1 个2026-05-17
Everything Claude Code

MCP World

0stdio有1 个2026-05-17
Filesystem 560c4363

MCP World

13未说明未标注2 个2026-05-17
Time 7365cb6d

MCP.so

2SSE有2 个2026-05-17
Server Everything (everything)

MCP World

11stdio有1 个2026-05-17

按同分类和工具数量挑出最接近的几条,字段以各自详情页为准。

常见问题

5 条

Cortexflow AI MCP 怎么安装?

公开资料给出的安装命令是 npx vitest run tests/unit/tools/hello-tool.test.ts,运行环境为 Node.js。装完后按客户端要求写进 MCP 配置,重启客户端生效。

Cortexflow AI MCP 怎么在 Claude Desktop、Cursor 里配置?

它是stdio 本地进程,客户端配置里要写启动命令和参数,运行环境是 Node.js;保存后完全退出客户端再打开,配置才会生效。

Cortexflow AI MCP 收费吗?

本站只整理公开资料,不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

Cortexflow AI MCP 需要 API Key 吗?

公开资料标注的认证方式是访问 Token,也就是要先拿到凭据才能连上;凭据只填在自己本地的配置里,不要写进公开仓库。

Cortexflow AI MCP 支持哪些客户端?

公开资料没有标注具体客户端;能配置本地 MCP 命令的客户端都能接,配置方式参照官方文档。

来源信息

继续浏览同类 MCP