MT

mcpdotdirect/template-mcp-server

开发工具官方

本页由 AI 翻译,技术细节请以原文为准。 查看原文

76 stars 37 forks 质量 72 趋势 14MIT

mcpdotdirect/template-mcp-server 是从 https://github.com/mcpdotdirect/template-mcp-server. 导入的 MCP 候选服务器

概览

mcpdotdirect/template-mcp-server 是从 https://github.com/mcpdotdirect/template-mcp-server. 导入的 MCP 候选服务器

概述(AI 翻译)

一个CLI工具,帮助快速开始使用FastMCP构建你自己的MCP(模型上下文协议)服务器

📋 用途

🔭 包含内容

该模板包括:

  • 基础服务器搭建,支持使用FastMCP的标准和HTTP传输选项
  • 定义MCP工具、资源和提示词的结构
  • TypeScript配置
  • 开发脚本与配置

✨ 特色

  • FastMCP:采用FastMCP框架构建,实现更简单
  • 双重传输支持:通过stdio或HTTP运行MCP服务器
  • TypeScript:类型安全的完整TypeScript支持。
  • 可扩展:易于添加自定义工具、资源和提示

🚀 开始

创建项目后:

  1. 使用你偏好的包管理器安装依赖:

  2. 启动服务器:

  3. 用于自动装填开发:

注意:package.json 中的默认脚本使用 Bun 作为运行时(例如 bun run src/index.ts。如果你更喜欢使用不同的包管理器或运行时,可以在package.json文件中修改这些脚本,使其使用 Node.js 或你选择的其他运行时。

📖 详细用法

运输方式

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

@mcpdotdirect/template-mcp-server

A CLI tool to quickly get started building your very own MCP (Model Context Protocol) server using FastMCP

📋 Usage

# with npx
npx @mcpdotdirect/create-mcp-server

# Or with npm
npm init @mcpdotdirect/mcp-server

🔭 What’s Included

The template includes:

  • Basic server setup with both stdio and HTTP transport options using FastMCP
  • Structure for defining MCP tools, resources, and prompts
  • TypeScript configuration
  • Development scripts and configuration

✨ Features

  • FastMCP: Built using the FastMCP framework for simpler implementation
  • Dual Transport Support: Run your MCP server over stdio or HTTP
  • TypeScript: Full TypeScript support for type safety
  • Extensible: Easy to add custom tools, resources, and prompts

🚀 Getting Started

After creating your project:

  1. Install dependencies using your preferred package manager:

    # Using npm
    npm install
    
    # Using yarn
    yarn
    
    # Using pnpm
    pnpm install
    
    # Using bun
    bun install
    
  2. Start the server:

    # Start the stdio server
    npm start
    
    # Or start the HTTP server
    npm run start:http
    
  3. For development with auto-reload:

    # Development mode with stdio
    npm run dev
    
    # Development mode with HTTP
    npm run dev:http
    

Note: The default scripts in package.json use Bun as the runtime (e.g., bun run src/index.ts). If you prefer to use a different package manager or runtime, you can modify these scripts in your package.json file to use Node.js or another runtime of your choice.

📖 Detailed Usage

Transport Methods

The MCP server supports two transport methods:

  1. stdio Transport (Command Line Mode):

    • Runs on your local machine
    • Managed automatically by Cursor
    • Communicates directly via stdout
    • Only accessible by you locally
    • Ideal for personal development and tools
  2. SSE Transport (HTTP Web Mode):

    • Can run locally or remotely
    • Managed and run by you
    • Communicates over the network
    • Can be shared across machines
    • Ideal for team collaboration and shared tools

Running the Server Locally

stdio Transport (CLI Mode)

Start the server in stdio mode for CLI tools:

# Start the stdio server
npm start
# or with other package managers
yarn start
pnpm start
bun start

# Start the server in development mode with auto-reload
npm run dev
# or
yarn dev
pnpm dev
bun dev

HTTP Transport (Web Mode)

Start the server in HTTP mode for web applications:

# Start the HTTP server
npm run start:http
# or
yarn start:http
pnpm start:http
bun start:http

# Start the HTTP server in development mode with auto-reload
npm run dev:http
# or
yarn dev:http
pnpm dev:http
bun dev:http
在 GitHub 查看完整 README

安装

npx @mcpdotdirect/create-mcp-server
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "my-mcp-stdio": { "command": "npm", "args": [ "start" ], "env": { "NODE_ENV": "development" } }, "my-mcp-sse": { "url": "http://localhost:3001/sse" } } }