Token导航 LogoToken导航TokenDH.com
Weather MCP Server Typescript logo
AI代理未说明官方级别未说明来源级核验

Weather MCP Server Typescript

MCP Server

一个基于Ollama LLM能力的天气信息服务器,提供城市天气查询功能。

工具数

1

提示词数

0

GitHub Stars

0

资源数

0
位置天气LLM应用JavaScriptTypeScript本地部署

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

codewith1984

提供方

codewith1984

最后核验

2026/5/17 20:21

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

🌦️ 气象MCP服务器演示

一种与模型上下文协议(MCP)兼容的服务器,使用Ollama的LLM功能提供天气信息。此服务器公开了一个 get-weather MCP客户端可以使用该工具检索任何城市的天气信息。

______________________________________________________________________

🛠 先决条件

  • v18+
  • 奥拉马 在本地安装并运行
  • Ollama模型: llama3 (或配置您的首选型号)

______________________________________________________________________

🚀 完成设置和安装

✅ 步骤1:克隆并安装

git clone https://github.com/codewith1984/weather-mcp-server-typescript.git
cd weather-mcp-server
npm install

⚙️ 步骤2:设置环境

# Copy environment template
cp .env.example .env

编辑.env文件以包含:

OLLAMA_API_URL=http://localhost:11434/api/generate
OLLAMA_MODEL=llama3

🤖 步骤3:安装和设置Olama

# Install Ollama (if not already installed)
# Visit https://ollama.com/ for installation instructions

# Start Ollama service
ollama serve

# In another terminal, pull the model
ollama pull llama3

# Verify Ollama is working
curl http://localhost:11434/api/version

###

步骤4:测试Ollama连接

# Test if Ollama can generate responses
curl http://localhost:11434/api/generate -d '{
  "model": "llama3",
  "prompt": "Hello world",
  "stream": false
}'

步骤5:运行诊断

# Run diagnostic to check if everything is working
npm run diagnose

🎯 运行MCP服务器

启动服务器

npm start

预期产量:

🚀 MCP气象服务器正在启动。.. 📡 Ollama网址:http://localhost:11434/api/generate 🤖 型号:骆驼3 ✅ MCP服务器已连接并准备就绪!

🔍 MCP检验员测试

方法1:CLI检查器

# Install MCP Inspector globally
npm install -g @modelcontextprotocol/inspector

# Run inspector
mcp-inspector

# Follow the web interface instructions

⚙️ 配置

环境变量(.env文件)

OLLAMA_API_URL=http://localhost:11434/api/generate
OLLAMA_MODEL=llama3

性能调整

服务器针对快速响应进行了优化:

HTTP请求超时15秒 激进的Olama参数,实现更快的发电速度 从HTTP API回退到CLI(如果需要)

##🔧 故障排除

快速诊断

# Run the diagnostic script
npm run diagnose

常见问题及解决方案

问题:“请求超时”错误

# Check if Ollama is running
ps aux | grep ollama

# Start Ollama if not running
ollama serve

# Check if model is available
ollama list | grep llama3

# If model not found, pull it
ollama pull llama3

问题:“请求超时”错误

# Check if Ollama is running
ps aux | grep ollama

# Start Ollama if not running
ollama serve

# Check if model is available
ollama list | grep llama3

# If model not found, pull it
ollama pull llama3

问题:“找不到模型”错误

# List available models
ollama list

# Pull the required model
ollama pull llama3

# Or try a smaller model for faster responses
ollama pull llama3:8b

###

问题:连接错误

# Verify Ollama is accessible
curl http://localhost:11434/api/version

# Check if port 11434 is open
netstat -an | grep 11434

# Restart Ollama service
pkill ollama
ollama serve

问题:MCP检查器连接失败

# Make sure your server is running
npm start

# Check the working directory path is correct
pwd

# Verify tsx is available
npm list tsx

性能提示

# Use a smaller model for faster responses
ollama pull llama3:8b

# Update .env to use the smaller model
echo "OLLAMA_MODEL=llama3:8b" >> .env

# Monitor system resources
top -p $(pgrep ollama)

📁 项目结构

weather-mcp-server/
├── .env                # Environment configuration
├── .env.example       # Environment template
├── .gitignore         # Git ignore rules
├── main.ts            # MCP server implementation
├── ollamaClient.ts    # Ollama API client
├── diagnose.ts        # Diagnostic tool
├── package.json       # Dependencies and scripts
├── tsconfig.json      # TypeScript configuration
└── README.md          # This file

✅ 成功检查表

完成此检查表以确保一切正常:

已安装Node.js v18+ Ollama安装并运行(Ollama服务) 模型已下载(ollama pull llama3) 已安装项目依赖项(npm安装) 已配置环境(.env文件存在) 诊断通过(npm运行诊断) MCP服务器成功启动(npm启动) MCP检查器连接成功 天气工具响应测试命令

🚀 快速启动命令

# Complete setup in one go
git clone https://github.com/your-username/weather-mcp-server.git
cd weather-mcp-server
npm install
cp .env.example .env
ollama serve &
ollama pull llama3
npm run diagnose
npm start

🤝 贡献

  1. 分叉存储库
  2. 创建功能分支:git checkout-b功能名称
  3. 进行更改
  4. 使用MCP检查员进行测试
  5. 提交拉取请求

目录标签

目录标签

位置天气LLM应用JavaScriptTypeScript本地部署天气服务MCP协议Node.js

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

部署方式(deploymentType,部署类型)

local-only

工具数量(toolCount,工具数)

1

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明nonelocal-only

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP