MCP服务器框架

Golf MCP TypeScript是一个用于简化使用TypeScript创建MCP服务器应用程序的框架,支持自动发现、解析和编译组件,加速开发过程。

  • by Joseph19820124
  • 本地部署
  • 更新于
在 GitHub 查看 joseph19820124/golf-mcp-joseph

使用说明

⛳ 高尔夫MCP-TypeScript版

Easiest framework for building MCP servers in TypeScript

概述

高尔夫MCP TypeScript是一个 框架 旨在使用TypeScript简化MCP(模型上下文协议)服务器应用程序的创建。它允许开发人员定义服务器功能--工具, 鼓励,以及 资源--作为传统目录结构中的简单TypeScript文件。然后,Golf会自动发现、解析这些组件,并将其编译成可运行的MCP服务器,从而最大限度地减少样板文件并加速开发。

这是原始的TypeScript端口 高尔夫mcp Python框架,通过TypeScript的类型安全和生态系统提供同样优雅的开发人员体验。

🚧 进行中

这是高尔夫mcp框架的完整TypeScript实现。该项目包括:

  • ✅ 带有init、build和run命令的完整CLI
  • ✅ TypeScript第一组件发现和解析
  • ✅ 使用Zod验证进行类型安全配置管理
  • ✅ MCP协议的自动服务器代码生成
  • ✅ 开发工具链(ESLint、Prettier、Jest)
  • ✅ 带有示例的项目模板
  • ✅ 遥测和分析支持
  • ✅ 与原始高尔夫mcp兼容的项目结构

快速开始

# Install the framework
npm install -g golf-mcp-typescript

# Create a new project
golf init my-mcp-server

# Build and run
cd my-mcp-server
npm install
npm run dev

特性

🔍 类型安全

  • 完全支持TypeScript,具有输入和输出接口
  • 编译时错误检查
  • IDE中的智能感知和自动完成

📦 现代工具

  • 基于现代Node.js和npm生态系统构建
  • 支持ES模块和CommonJS
  • 开发过程中的热重载

🚀 演出

  • 使用编译的JavaScript快速启动
  • 高效的模块加载和缓存
  • 用于生产构建的可选TypeScript编译

项目结构

my-project/
├─ golf.json          # Configuration
├─ tools/             # MCP tools
│   └─ hello.ts       # Example tool
├─ resources/         # MCP resources  
│   └─ info.ts        # Example resource
├─ prompts/           # MCP prompts
│   └─ welcome.ts     # Example prompt
├─ package.json       # Dependencies
└─ tsconfig.json      # TypeScript config

示例工具

// tools/hello.ts
/**
 * Hello World tool
 */
export interface Input {
  name?: string;     // The name of the person to greet
  greeting?: string; // The greeting phrase to use
}

export interface Output {
  message: string;   // Response from the hello tool
}

export default async function hello(input: Input): Promise<Output> {
  const { name = "World", greeting = "Hello" } = input;
  
  return {
    message: `${greeting}, ${name}!`
  };
}

命令

  • golf init <project-name> -初始化新项目
  • golf build dev -为发展而建设
  • golf build prod -为生产而建
  • golf run -运行内置服务器
  • golf telemetry enable/disable -管理遥测

许可证

Apache许可证2.0-请参阅 许可证 了解详情。

致谢

该项目受到原版的启发,并保持与原版的兼容性 高尔夫mcp Python框架。特别感谢原作者创建了如此优雅的MCP服务器开发方法。