MCP服务器构建器

NextChat的定制版本,通过聊天交互创建和部署MCP(模型上下文协议)服务器,支持OpenRouter集成多种LLM模型。

  • by vredrick2
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 vredrick2/nextchat-mcp

使用说明

下一篇与MCP服务器构建器聊天

这是NextChat的定制版本,它增加了通过聊天交互创建和部署MCP(模型上下文协议)服务器的能力,使用OpenRouter用于LLM模型。

特性

  • 基于聊天的MCP服务器创建:只需与AI聊天即可创建MCP服务器
  • 工具提取:自动从您的描述中提取工具
  • 一键部署:只需单击一下即可部署MCP服务器
  • 集成指南:获取各种AI系统的集成说明
  • OpenRouter集成:通过OpenRouter使用各种LLM模型

入门指南

先决条件

  • Node.js 18.0.0或更高版本
  • npm或纱线
  • 一个OpenRouter API密钥

安装

  1. 克隆存储库:
git clone https://github.com/vredrick2/NextChat.git
cd NextChat
  1. 安装依赖项:
npm install
# or
yarn
  1. 创建一个 .env.local 包含以下内容的文件:
# Enable MCP functionality
ENABLE_MCP=true

# OpenRouter API key
OPENAI_API_KEY=your_openrouter_api_key

# Set OpenRouter as the base URL
BASE_URL=https://openrouter.ai/api/v1

# Default model (can be changed to any OpenRouter model)
DEFAULT_MODEL=openrouter/anthropic/claude-3-opus

# Hide user API key input since we'll be using OpenRouter
HIDE_USER_API_KEY=1

# Enable custom models
CUSTOM_MODELS=+openrouter/anthropic/claude-3-opus,+openrouter/anthropic/claude-3-sonnet,+openrouter/google/gemini-pro
  1. 启动开发服务器:
npm run dev
# or
yarn dev
  1. 打开 http://localhost:3000 在您的浏览器中。

创建MCP服务器

  1. 开始新的聊天
  2. 键入“创建MCP服务器”或类似短语
  3. 按照提示命名服务器并描述其功能
  4. 系统将从您的描述中提取工具并部署服务器
  5. 您将收到使用MCP服务器与各种AI系统的集成说明

实现细节

MCP服务器创建界面

MCP服务器创建接口实现为React组件,引导用户完成创建和部署MCP服务器的过程。界面包括:

  • 名称输入
  • 描述输入
  • 工具提取
  • 部署
  • 集成指南生成

工具提取

使用模式匹配从用户描述中提取工具。系统会查找指示特定工具类型的关键字,例如:

  • 计算器工具
  • 转换工具
  • 气象工具
  • 搜索工具
  • 翻译工具

部署

当前的实现使用模拟URL模拟部署。在生产环境中,这将连接到真实的部署服务。

整合

该系统为各种AI系统生成集成指南:

  • 光标
  • 克劳德桌面
  • 帆板运动
  • API直接访问

项目结构

  • /app/utils/mcp/types.ts:MCP服务器和工具的TypeScript接口
  • /app/utils/mcp/storage.ts:用于管理MCP服务器的存储实用程序
  • /app/utils/mcp/extraction.ts:工具提取功能
  • /app/utils/mcp/deployment.ts:部署实用程序
  • /app/utils/mcp/chat-integration.ts:聊天集成实用程序
  • /app/api/mcp/create/route.ts:用于创建MCP服务器的API端点
  • /app/components/mcp/server-creation.tsx:MCP服务器创建组件
  • /app/components/mcp/server-list.tsx:MCP服务器列表组件

未来的增强功能

  • 使用OpenRouter AI模型增强工具提取
  • 真正部署到无服务器功能
  • 工具测试界面
  • 已部署服务器的分析
  • MCP服务器的版本控制

许可证

此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。

致谢