ip查询mcp
用于IP查询服务的模型上下文协议(MCP)服务器,可通过npm安装。
安装
全球安装
npm install -g ip-query-mcp使用npx(无需安装)
您也可以直接将其与npx一起使用,而无需安装:
npx --yes ip-query-mcp包裹信息
- npm包: ip查询mcp
- 版本: 1.0.0
- 许可证:MIT
快速开始
0.获取API凭据
在使用之前,您需要从IP查询服务网站获取API凭据(AppId和Secret):
- 访问 http://ips.chataudit.net/
- 注册/登录您的帐户
- 得到你的 应用ID 和 秘密 从用户中心或API文档页面
小贴士:AppId和Secret用于API身份验证。请确保它们的安全,不要与他人分享。
1.配置
方法1:环境变量(推荐)
将上一步中获得的AppId和Secret配置为环境变量:
# Windows (PowerShell)
$env:MCP_APP_ID="your_app_id"
$env:MCP_SECRET="your_secret"
$env:MCP_API_BASE_URL="http://ips.chataudit.net"
# Windows (CMD)
set MCP_APP_ID=your_app_id
set MCP_SECRET=your_secret
set MCP_API_BASE_URL=http://ips.chataudit.net
# Linux/macOS
export MCP_APP_ID=your_app_id
export MCP_SECRET=your_secret
export MCP_API_BASE_URL=http://ips.chataudit.net方法2:配置文件
创建配置文件 ~/.ip-mcp/config.json 并填写从网站获得的AppId和Secret:
{
"app_id": "your_app_id",
"secret": "your_secret",
"api_base_url": "http://ips.chataudit.net"
}备注:
- Windows路径:
C:\Users\YourName\.ip-mcp\config.json - Linux/macOS路径:
~/.ip-mcp/config.json
2.配置MCP客户端
克劳德桌面
编辑配置文件(位置因系统而异):
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json\ 视窗: %APPDATA%\Claude\claude_desktop_config.json\ Linux: ~/.config/Claude/claude_desktop_config.json
选项1:使用全局安装
{
"mcpServers": {
"ip-query": {
"command": "ip-query-mcp",
"args": [],
"env": {
"MCP_APP_ID": "your_app_id",
"MCP_SECRET": "your_secret",
"MCP_API_BASE_URL": "http://ips.chataudit.net"
}
}
}
}选项2:使用npx(推荐)
{
"mcpServers": {
"ip-query": {
"command": "npx",
"args": ["--yes", "ip-query-mcp"],
"env": {
"MCP_APP_ID": "your_app_id",
"MCP_SECRET": "your_secret",
"MCP_API_BASE_URL": "http://ips.chataudit.net"
}
}
}
}如果使用配置文件方法,可以简化为:
{
"mcpServers": {
"ip-query": {
"command": "ip-query-mcp"
}
}
}光标
编辑MCP配置文件(通常位于 ~/.cursor/mcp.json 在Windows上,或 ~/.config/Cursor/mcp.json 在Linux/macOS上):
视窗: %USERPROFILE%\.cursor\mcp.json\ macOS/Linux: ~/.config/Cursor/mcp.json
{
"mcpServers": {
"ip-query": {
"command": "cmd",
"args": ["/c", "npx", "--yes", "ip-query-mcp"],
"env": {
"MCP_APP_ID": "your_app_id",
"MCP_SECRET": "your_secret",
"MCP_API_BASE_URL": "http://ips.chataudit.net"
}
}
}
}Windows用户注意事项:使用 cmd 随着 /c 和 npx 运行该包。对于Linux/macOS,您可以使用:
{
"mcpServers": {
"ip-query": {
"command": "npx",
"args": ["--yes", "ip-query-mcp"],
"env": {
"MCP_APP_ID": "your_app_id",
"MCP_SECRET": "your_secret",
"MCP_API_BASE_URL": "http://ips.chataudit.net"
}
}
}
}如果使用配置文件方法,可以简化为:
{
"mcpServers": {
"ip-query": {
"command": "cmd",
"args": ["/c", "npx", "--yes", "ip-query-mcp"]
}
}
}3.使用方法
配置后,您可以直接在AI助手中使用它:
- “查询IP地址8.8.8.8的位置”
- “我的账户余额是多少?”
- “我今天使用了多少个查询?”
可用工具
query_ip
查询IP地址位置信息。
参数:
ip(可选):要查询的IP地址。如果未提供,则查询请求者的IP
退货:
{
"code": 200,
"ip": "8.8.8.8",
"country": "United States",
"province": "California",
"city": "Mountain View",
"area": "",
"isp": "Google"
}get_balance
获取当前账户余额。
参数:无
退货:
{
"code": 200,
"msg": "Balance retrieved successfully",
"balance": "850"
}get_usage_stats
获取帐户使用统计信息。
参数:无
退货:
{
"code": 200,
"msg": "Usage data retrieved successfully",
"day": 15,
"total": 120,
"balance": 850
}发展
地方发展
# Clone repository
git clone
cd ip-query-mcp
# Install dependencies
npm install
# Run in development mode
npm run dev
# Build
npm run build
# Run
npm start故障排除
未找到命令
如果你找不到 ip-query-mcp 安装后的命令:
- 检查npm全局bin目录是否在PATH中:
npm config get prefix- 将npm全局bin目录添加到PATH(如果还没有)
认证失败
- 检查AppId和Secret是否正确(从获取 http://ips.chataudit.net/)
- 确保IP查询服务正在运行
- 检查API基础URL是否正确(默认值:
http://ips.chataudit.net) - 验证账户余额是否充足
工具调用失败
- 检查账户余额是否充足
- 检查IP查询服务日志
- 验证网络连接
许可证
麻省理工学院
