Back to MCP directory
publicPublicdnsLocal runtime

create-mcp-ts

一个用于创建MCP TypeScript项目的工具包

article

README

🚀 如何使用 create-mcp-ts 快速搭建 TypeScript 项目

本项目提供了 create-mcp-ts 工具,能帮助开发者快速搭建 TypeScript 项目,节省项目初始化的时间和精力。

🚀 快速开始

安装

使用 create-mcp-ts 前,你需要先进行安装,支持使用 npmyarn 进行全局安装。

# 使用 npm 安装
npm install -g create-mcp-ts

# 或者使用 yarn 安装
yarn global add create-mcp-ts

创建项目

安装完成后,你可以在终端中运行以下命令来创建项目,运行命令后需输入项目名称。

create-mcp-ts <project-name>

例如,创建一个名为 mcp-project 的项目:

create-mcp-ts mcp-project

创建完成后,进入生成的项目目录:

cd mcp-project

启动开发服务器

进入项目目录后,运行以下命令启动开发服务器:

npm run dev

默认情况下,开发服务器会在 http://localhost:3000 开启服务。

构建生产环境

当项目开发完成后,运行以下命令进行项目构建:

npm run build

构建后的文件会存放在 dist 文件夹中。

📦 安装指南

  • 使用 npm 全局安装:npm install -g create-mcp-ts
  • 使用 yarn 全局安装:yarn global add create-mcp-ts

💻 使用示例

提供类型定义

在项目的根目录下创建或修改 declaration.d.ts 文件,添加以下内容以提供全局类型定义:

declare namespace NodeJS {
  interface ProcessEnv {
    NODE_ENV: 'development' | 'production';
    PORT: string;
  }
}

interface Window {
  __env__: {
    NODE_ENV: string;
    PORT: string;
  };
}

环境变量的使用

在项目中使用环境变量:

import { env } from '$process';

const port = env.PORT; // 或者直接访问 process.env.PORT

配置

你可以修改 tsconfig.json 和其他配置文件以满足项目需求。

📚 详细文档

贡献指南

欢迎大家为项目做出贡献!如果你想贡献代码,请 fork 仓库并提交 Pull Request。

📄 许可证

本项目遵循 MIT 许可证。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client