有个mcp服务是这样的:
bash展开代码 "newsnow": {
"command": "npx",
"args": [
"-y",
"newsnow-mcp-server"
],
"env": {
"BASE_URL": "http://101.126.150.28:9044"
}
}
python展开代码import asyncio
import json
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
async def list_mcp_tools():
# 配置服务器参数
server_params = StdioServerParameters(
command="npx",
args=["-y", "newsnow-mcp-server"],
env={"BASE_URL": "http://101.126.150.28:9044"}
)
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
# 初始化连接
await session.initialize()
# 获取工具列表
tools = await session.list_tools()
print("可用的工具:")
print(json.dumps(tools.model_dump(), indent=2, ensure_ascii=False))
# 运行
asyncio.run(list_mcp_tools())
安装依赖:
bash展开代码uv pip install mcp
得到描述:
bash展开代码{
"meta": null,
"nextCursor": null,
"tools": [
{
"name": "get_hottest_latest_news",
"title": null,
"description": "get hottest or latest news from source by {id}, return {count: 10} news.",
"inputSchema": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "source id. e.g. V2EX-最新分享 id is v2ex-share;知乎 id is zhihu;微博-实时热搜 id is weibo;联合
早报 id is zaobao;酷安-今日最热 id is coolapk;MKTNews-快讯 id is mktnews-flash;华尔街见闻-实时快讯 id is wallstreetcn-quick;华尔街见闻-最新资讯 id is wallstreetcn-news;华尔街见闻-最热文章 id is wallstreetcn-hot;36氪-快讯 id is 36kr-quick;抖音 id is douyin;虎扑-主干道热帖 id is hupu;百度贴吧-热议 id is tieba;今日头条 id is toutiao;IT之家 id is ithome;澎湃新闻-热榜 id is thepaper;卫星通讯社 id is sputniknewscn;参考消息 id is cankaoxiaoxi;远景论坛-Windows 11 id is pcbeta-windows11;财联社-电报 id is cls-telegraph;财联社-深度 id is cls-depth;财联社-热门 id is cls-hot;雪球-热门股票 id is xueqiu-hotstock;格隆汇-事件 id is gelonghui;法布财经-快讯 id is fastbull-express;法布财经-头条 id is fastbull-news;Solidot id is solidot;Hacker News id is hackernews;Product Hunt id is producthunt;Github-Today id is github-trending-today;哔哩哔哩-热搜 id is bilibili-hot-search;哔哩哔哩-热门视频 id is bilibili-hot-video;哔哩哔哩-排行榜 id is bilibili-ranking;快手 id is kuaishou;靠谱新闻 id is kaopu;金十数据 id is jin10;百度热搜 id is baidu;牛客 id is nowcoder;少数派 id is sspai;稀土掘金 id is juejin;凤凰网-热点资讯 id is ifeng;虫部落-最新 id is chongbuluo-latest;虫部落-最热 id is chongbuluo-hot"
},
"count": {
"default": 10,
"description": "count of news to return."
}
},
"required": [
"id"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
},
"outputSchema": null,
"icons": null,
"annotations": null,
"meta": null
}
]
}
bash展开代码# 安装 MCP Inspector
npm install -g @modelcontextprotocol/inspector
# 运行 Inspector 连接你的 MCP 服务器
npx @modelcontextprotocol/inspector
调试面板:



本文作者:Dong
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC。本作品采用《知识共享署名-非商业性使用 4.0 国际许可协议》进行许可。您可以在非商业用途下自由转载和修改,但必须注明出处并提供原作者链接。 许可协议。转载请注明出处!