mcpField
W
weather-mcp-s

weather-mcp-s

本地服务
github.com/bee1194媒体与设计081 周前更新

关于 weather-mcp-s

weather-mcp-s 是一个基于 mcp-framework 构建的示例 MCP 服务,面向学习 MCP 工具开发的人。项目提供示例工具,并说明如何添加工具及连接 Claude Desktop。

主要功能

  1. 01基于 mcp-framework 构建
  2. 02提供示例工具
  3. 03通过 CLI 添加工具
  4. 04构建并加载工具

适用场景

  1. 01学习 MCP 服务开发
  2. 02添加自定义 MCP 工具
  3. 03连接 Claude Desktop

MCP 相关

该项目是 MCP 服务,通过工具向 MCP 客户端提供功能;README 展示了与 Claude Desktop 的本地配置方式。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

暂未收录安装方式

我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。

代码仓库

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

weather-mcp-s

使用 mcp-framework 构建的 Model Context Protocol(MCP)服务。

快速开始

# Install dependencies
npm install

# Build the project
npm run build

项目结构

weather-mcp-s/
├── src/
│   ├── tools/        # MCP Tools
│   │   └── ExampleTool.ts
│   └── index.ts      # Server entry point
├── package.json
└── tsconfig.json

添加组件

项目包含一个位于 src/tools/ExampleTool.ts 的示例工具。你可以使用 CLI 添加更多工具:

# Add a new tool
mcp add tool my-tool

# Example tools you might create:
mcp add tool data-processor
mcp add tool api-client
mcp add tool file-handler

工具开发

示例工具结构:

import { MCPTool } from "mcp-framework";
import { z } from "zod";

interface MyToolInput {
  message: string;
}

class MyTool extends MCPTool<MyToolInput> {
  name = "my_tool";
  description = "Describes what your tool does";

  schema = {
    message: {
      type: z.string(),
      description: "Description of this input parameter",
    },
  };

  async execute(input: MyToolInput) {
    // Your tool logic here
    return `Processed: ${input.message}`;
  }
}

export default MyTool;

发布到 npm

  1. 更新你的 package.json:

    • 确保 name 唯一,并符合 npm 命名规范
    • 设置合适的 version
    • 添加 description、author、license 等信息
    • 检查 bin 是否指向正确的入口文件
  2. 在本地构建并测试:

    npm run build
    npm link
    weather-mcp-s  # Test your CLI locally
    
  3. 登录 npm(如有需要,请创建账号):

    npm login
    
  4. 发布你的包:

    npm publish
    

发布后,用户可以将其添加到 Claude 桌面客户端(见下文),或使用 npx 运行


## Using with Claude Desktop

### Local Development

Add this configuration to your Claude Desktop config file:

**MacOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
**Windows**: `%APPDATA%/Claude/claude_desktop_config.json`

```json
{
  "mcpServers": {
    "weather-mcp-s": {
      "command": "/absolute/path/to/node",
      "args":["/absolute/path/to/weather-mcp-s/dist/index.js"]
    }
  }
}
发布后

将此配置添加到你的 Claude Desktop 配置文件中:

MacOS:~/Library/Application Support/Claude/claude_desktop_config.json Windows:%APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "weather-mcp-s": {
      "command": "npx",
      "args": ["weather-mcp-s"]
      "env": {
        "OPENWEATHERMAP_API_KEY": "your_api_key"
      }
    }
  }
}

构建与测试

  1. 修改你的工具
  2. 运行 npm run build 进行编译
  3. 服务将在启动时自动加载你的工具

了解更多

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。