mcpField
G
GetIpInfo

GetIpInfo

远程服务
github.com/StanLee12地图与出行079 周前更新
代码仓库

关于 GetIpInfo

GetIpInfo 是基于 mcp-framework 构建的 MCP 服务项目,定位为按 IP 地址获取信息。README 展示了示例工具和搭建说明,但未说明 IP 查询的具体实现。

主要功能

  1. 01基于 mcp-framework 构建 MCP 服务
  2. 02提供示例工具脚手架
  3. 03通过 CLI 创建工具
  4. 04提供构建与 npm 发布说明

适用场景

  1. 01创建查询 IP 信息的 MCP 工具
  2. 02为现有服务项目添加工具

MCP 相关

这是一个供 MCP 客户端加载工具的 MCP 服务,示例客户端包括 Claude Desktop。README 提供本地运行和通过 npx 配置的示例。

配置

远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。

服务地址http://ip-mcp.stanlee.top/mcp
一键复制安装命令
Claude CodeTerminal
Cursor.cursor/mcp.json
VS Code.vscode/mcp.json
Claude Desktopclaude_desktop_config.json
Windsurf~/.codeium/windsurf/mcp_config.json

命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。

工具

详细介绍

get-ip-mcp-server

使用 mcp-framework 构建的模型上下文协议(MCP)服务。

快速开始

# Install dependencies
npm install

# Build the project
npm run build

项目结构

get-ip-mcp-server/
├── 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
    get-ip-mcp-server  # 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": {
    "get-ip-mcp-server": {
      "command": "node",
      "args":["/absolute/path/to/get-ip-mcp-server/dist/index.js"]
    }
  }
}
发布后

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

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

{
  "mcpServers": {
    "get-ip-mcp-server": {
      "command": "npx",
      "args": ["get-ip-mcp-server"]
    }
  }
}

构建和测试

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

了解更多

评论

支持 Markdown

第一次接触 MCP?

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

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