关于MCP的概念不再介绍。
MCP是大模型上下文的有力补充,搭建有效的MCP Server以实现大模型能力的增强是目前AI应用开发的重要手段。
快速开发一个MCP Server是目前众多工程师搭建AI应用的迫切需要。
作者开源了一个基于TypeScript的脚手架,实现了快速、敏捷地搭建MCP Server应用,避免了繁复的项目初始化、依赖安装等重复性的前置环节工作,提高了搭建MCP应用的效率。
项目已经在NPM发布:mcp-ts-server
多说无益
- 开始
推荐在node v18+环境下,通过执行这个命令,使用脚手架,并安装提示一步步初始化MCP Servr工程配置
npx create-ts-mcp-server your-mcp-server-name
- 初始化配置
# 工程名字
? What is the name of your MCP (Model Context Protocol) server? (your-mcp-server-name)
# 工程描述
? What is the description of your server? (A Model Context Protocol server)
# @modelcontextprotocol/sdk API层级,High-Level上层封装的简单易用API(适用于大多简单场景,比较推荐), Low-Level便底层细节处理的API适用于复杂场景)
? What is the API level of your server?
High-Level use (Recommended): It is a commonly used and encapsulated interface for developers. It shields many complex details, is easy to use, and is suitable for most scenarios.
Low-Level use: It is a low-level interface, which is suitable for developers who need to customize the implementation details. (Use arrow keys)
❯ High-Level API
Low-Level API
# 成功初始化脚手架
✔ MCP server created successfully!
Next steps:
cd t2
npm install
npm run build # or: npm run watch
npm link # optional, to make available globally
- 基于脚手架敏捷开发,专注于自己的业务逻辑
-
脚手架中已经完成了相关项目初始化和必要的包依赖(如@modelcontextprotocol/sdk、zod等)配置,
-
脚手架中还提供了基础的 MCP Server初始化,简单的MCP tools、resources、prompt demo。
-
开发者可以基于项目配置,参考demo,直接开始自己的业务开发
-