bash展开代码import asyncio
import json
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
async def call_newsnow_mcp():
"""调用 newsnow MCP 获取知乎热门新闻"""
# 1. 配置 MCP 服务器参数
server_params = StdioServerParameters(
command="npx",
args=["-y", "newsnow-mcp-server"],
env={"BASE_URL": "http://101.126.150.28:9044"}
)
# 2. 连接到 MCP 服务器
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
# 3. 初始化会话
await session.initialize()
# 4. 调用工具获取知乎新闻
result = await session.call_tool(
name="get_hottest_latest_news",
arguments={
"id": "zhihu",
"count": 10
}
)
# 5. 打印结果
print("=" * 50)
print("知乎热门新闻(前10条)")
print("=" * 50)
# 解析返回的内容
for item in result.content:
if hasattr(item, 'text'):
# 尝试解析 JSON
try:
news_data = json.loads(item.text)
print(json.dumps(news_data, indent=2, ensure_ascii=False))
except:
print(item.text)
# 运行
if __name__ == "__main__":
asyncio.run(call_newsnow_mcp())
有个mcp服务是这样的:
bash展开代码 "newsnow": {
"command": "npx",
"args": [
"-y",
"newsnow-mcp-server"
],
"env": {
"BASE_URL": "http://101.126.150.28:9044"
}
}
我服务器的801端口是我的博客, 我现在想在外面套一层caddy,自动获取证书 我的域名是tao-blog.site 我如何配置这个caddy
https://huggingface.co/mPLUG/GUI-Owl-32B/tree/main
https://github.com/X-PLUG/MobileAgent
下载:
bash展开代码apt update && apt install -y aria2
wget https://hf-mirror.com/hfd/hfd.sh
chmod a+x hfd.sh
export HF_ENDPOINT=https://hf-mirror.com
./hfd.sh mPLUG/GUI-Owl-32B
部署:
bash展开代码# 使用vLLM启动
python -m vllm.entrypoints.openai.api_server \
--model /mnt/jfs6/model/GUI-Owl-32B \
--served-model-name ui-tars \
--host 0.0.0.0 \
--port 8000 \
--trust-remote-code \
--max-model-len 8192 \
--gpu-memory-utilization 0.9 \
--tensor-parallel-size 4 --api-key "123"
d.xpath('//*[@text="设置"]')d(resourceId="com.example:id/button")d(className="android.widget.Button")d(description="搜索")d.xpath('//android.widget.Button[@text="确定"]')bash展开代码pip install -U huggingface_hub
bash展开代码export HF_ENDPOINT=https://hf-mirror.com
建议写入 ~/.bashrc 或 ~/.zshrc 永久生效:
bash展开代码echo 'export HF_ENDPOINT=https://hf-mirror.com' >> ~/.bashrc
source ~/.bashrc
安装uv:
bash展开代码# 使用官方安装脚本(推荐)
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.local/bin/env
# 这样也可以:
pip install uv
# win的powershell安装:
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
创建虚拟环境,指定D:\python_envs\py313为环境安装目录:
部署:
bash展开代码# 使用vLLM启动
python -m vllm.entrypoints.openai.api_server \
--model /mnt/jfs6/model/UI-TARS-72B-DPO \
--served-model-name ui-tars \
--host 0.0.0.0 \
--port 8000 \
--trust-remote-code \
--max-model-len 8192 \
--gpu-memory-utilization 0.9 \
--tensor-parallel-size 8
Model Context Protocol(MCP)是 Anthropic 推出的开放标准协议,旨在标准化 AI 应用与外部工具、数据源和系统之间的连接方式。就像 USB 标准统一了计算机外设接口一样,MCP 试图解决 AI 集成中的"M×N 问题"——将 M 个不同的 AI 应用与 N 个不同工具的集成从 M×N 个独立实现简化为 M+N 个标准化实现。
在 MCP 架构中,传输层(Transport)是实现客户端与服务器通信的基础。本文将深入探讨 MCP 的四种主要传输类型及其应用场景。