智能问候服务器

一个基于Model Context Protocol (MCP)的服务器,提供多语言、时区感知的智能问候服务,支持个性化设置。

  • by gustavorobertux
  • JavaScript
  • 本地部署
  • 更新于
在 GitHub 查看 gustavorobertux/mcp-greeting-server

使用说明

🌍 MCP问候服务器

一种模型上下文协议(MCP)服务器,以多种语言和时区提供智能、时间感知的问候语。

✨ 特性

  • 🕐 注重时间的问候 -根据当前时间自动说早上好、下午好或晚上好
  • 🌍 多语言支持 -英语、葡萄牙语、西班牙语和法语
  • 🌎 时区灵活性 -适用于任何时区(默认为巴西/圣保罗)
  • 👤 个性化 -个性化问候的可选名称参数
  • 🎯 MCP兼容 -已准备好与Claude和其他MCP客户端一起使用

🚀 快速开始

先决条件

  • Node.js 18+
  • npm或纱线

安装

# Clone the repository
git clone https://github.com/gustavorobertux/mcp-greeting-server.git
cd mcp-greeting-server

# Install dependencies
npm install

# Start the server
npm start

🔧 克劳德配置

方法1:克劳德桌面应用程序

  1. 安装克劳德桌面 从 克劳德·艾

  2. 找到配置文件:

    # Windows
    %APPDATA%\Claude\claude_desktop_config.json
    
    # macOS
    ~/Library/Application Support/Claude/claude_desktop_config.json
    
    # Linux
    ~/.config/Claude/claude_desktop_config.json
    
  3. 添加MCP服务器配置:

    {
      "mcpServers": {
        "greeting": {
          "command": "node",
          "args": ["/full/path/to/mcp-greeting-server/index.js"]
        }
      }
    }
    
  4. 重新启动克劳德桌面 您将看到可用的问候工具!

方法2:Claude Web/API与MCP客户端

import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";

// Connect to the greeting server
const transport = new StdioClientTransport({
  command: "node",
  args: ["/path/to/mcp-greeting-server/index.js"]
});

const client = new Client({
  name: "greeting-client",
  version: "1.0.0"
}, {
  capabilities: {}
});

await client.connect(transport);

// Use the greeting tool
const result = await client.request({
  method: "tools/call",
  params: {
    name: "greet",
    arguments: {
      name: "Alice",
      language: "en"
    }
  }
});

console.log(result.content[0].text);

方法3:NPX(快速测试)

# Run directly with npx (after publishing to npm)
npx mcp-greeting-server

# Or clone and run locally
git clone https://github.com/gustavorobertux/mcp-greeting-server.git
cd mcp-greeting-server
npm install
npm start

故障排除

问题: Claude Desktop未显示问候工具

  • ✅ 检查文件路径是否为绝对路径
  • ✅ 验证Node.js是否在PATH中
  • ✅ 完全重新启动克劳德桌面
  • ✅ 检查Claude Desktop日志是否有错误

问题: 权限不足

# Make the script executable (Linux/macOS)
chmod +x index.js

# Or run with node explicitly
"command": "node"

问题: 未找到模块

# Install dependencies in the project folder
cd /path/to/mcp-greeting-server
npm install

MCP配置

添加到MCP客户端配置中:

{
  "mcpServers": {
    "greeting": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-greeting-server/index.js"]
    }
  }
}

🧪 与Claude一起测试

配置后,您可以在Claude中进行测试:

Hey Claude, can you greet me?

克劳德将使用 greet 工具,并以适当的问候语回应!

Hey Claude, greet me in Portuguese with my name "João"

克劳德将致电: greet({ name: "João", language: "pt" })

📖 用法

与克劳德

一旦配置了Claude,只需自然地请求问候:

User: "Hey Claude, can you greet me?"
Claude: Uses greet() → "🌅 Good morning! friend! 🤝 It's 09:30 now. Hope you're having a great time!"

User: "Greet me in Portuguese as João"  
Claude: Uses greet({name: "João", language: "pt"}) → "☀️ Boa tarde! João! 🤝 São 14:30 agora. Espero que esteja tendo um ótimo momento!"

API直接使用

基本问候语

// Simple greeting (uses defaults: English, current timezone)
greet()
// Output: "🌅 Good morning! friend! 🤝\n\nIt's 09:30 now. Hope you're having a great time!"

个性化问候

// With name
greet({ name: "Alice" })
// Output: "☀️ Good afternoon! Alice! 🤝\n\nIt's 14:30 now. Hope you're having a great time!"

多语言支持

// Portuguese
greet({ name: "João", language: "pt" })
// Output: "🌅 Bom dia! João! 🤝\n\nSão 09:30 agora. Espero que esteja tendo um ótimo momento!"

// Spanish
greet({ name: "María", language: "es" })
// Output: "🌙 ¡Buenas noches! María! 🤝\n\nSon las 21:30 ahora. ¡Espero que estés teniendo un gran momento!"

// French
greet({ name: "Pierre", language: "fr" })
// Output: "☀️ Bon après-midi! Pierre! 🤝\n\nIl est 15:30 maintenant. J'espère que vous passez un bon moment!"

不同的时区

// New York time
greet({ timezone: "America/New_York" })

// London time
greet({ timezone: "Europe/London" })

// Tokyo time
greet({ timezone: "Asia/Tokyo" })

⚙️ api参考

工具: greet

说明: 根据当前时间返回适当的问候语

参数:

参数 类型 必填 默认 说明
name string 否 - 用于个性化设置的人名
timezone string 否 America/Sao_Paulo 问候的时区
language string 否 en 语言代码(en, pt, es, fr)

示例响应:

{
  "content": [
    {
      "type": "text",
      "text": "🌅 Good morning! Alice! 🤝\n\nIt's 09:30 now. Hope you're having a great time!"
    }
  ]
}

🌐 支持的语言

语言 代码 示例
英语 en “早上好!朋友!”
葡萄牙语 pt “早上好,朋友!”
西班牙语 es “早上好!朋友!”
法语 fr “你好!朋友!”

🕐 时间段

时间范围 问候语类型 表情符号
05:00-11:59 上午 🌅
12:00-17:59 下午 ☀️
18:00-04:59 晚上/夜间 🌙

🛠️ 发展

项目结构

mcp-greeting-server/
├── index.js          # Main server file
├── package.json       # Dependencies and scripts
├── README.md          # This file
└── .gitignore        # Git ignore rules

在发展中奔跑

# Install dependencies
npm install

# Start the server
node index.js

# Or with npm script
npm start

测试

# Test the greeting function
npm test

🤝 贡献

  1. 分叉存储库
  2. 创建要素分支(git checkout -b feature/amazing-feature)
  3. 提交您的更改(git commit -m 'Add amazing feature')
  4. 推到分支(git push origin feature/amazing-feature)
  5. 打开拉取请求

添加新语言

要添加对新语言的支持,请执行以下操作:

  1. 将语言添加到 greetings 对象在 handleGreet 方法
  2. 包括以下翻译: morning, afternoon, evening, friend, timeText, hopeText
  3. 更新README.md支持的语言表
  4. 将语言代码添加到架构枚举中

📝 许可证

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

🙏 致谢

  • 内置于 模型上下文协议SDK
  • 受到对国际化、注重时间的问候需求的启发
  • 非常适合Claude集成和其他MCP客户

📞 支持


由以下材料制成❤️ 对于MCP社区