Skip to main content
Glama
juhemcp

Juhe News MCP Server

Official
by juhemcp

get_news_list

Fetch trending news headlines by specifying a category and pagination parameters. Use to retrieve updates on topics like technology, sports, finance, and health from the Juhe News MCP Server.

Instructions

通过新闻类型获取今日热点新闻头条

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNo当前页数, 默认1, 最大50
page_sizeNo每页返回新闻条数, 默认20, 最大50
typeNo新闻类型:top(推荐,默认),guonei(国内),guoji(国际),yule(娱乐),tiyu(体育),junshi(军事),keji(科技),caijing(财经),youxi(游戏),qiche(汽车),jiankang(健康)

Implementation Reference

  • The core handler function implementing the get_news_list tool logic. Fetches news data from the Juhe API using httpx and returns TextContent with the news list or error.
    async def get_news_list(type: str = "top", page: int = 1, page_size: int = 20) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: """ 根据新闻类型获取今日热点新闻头条. """ url = f"{JUHE_NEWS_API_BASE}/index" params = { "type": type, "page": page, "page_size": page_size, "key": JUHE_NEWS_API_KEY } async with httpx.AsyncClient() as client: response = await client.get(url, params=params) data = response.json() if data["error_code"] == 0: news_list = data["result"]["data"] return [ types.TextContent( type="text", text=f"{news_list}" ) ] else: return [ types.TextContent( type="text", text=f"Error: {data['reason']}" ) ]
  • JSON Schema defining the input parameters (type, page, page_size) for the get_news_list tool.
    inputSchema={ "type": "object", "properties": { "type": { "type": "string", "description": "新闻类型:top(推荐,默认),guonei(国内),guoji(国际),yule(娱乐),tiyu(体育),junshi(军事),keji(科技),caijing(财经),youxi(游戏),qiche(汽车),jiankang(健康)", }, "page": { "type": "number", "description": "当前页数, 默认1, 最大50" }, "page_size": { "type": "number", "description": "每页返回新闻条数, 默认20, 最大50" }, }, # "required": ["type"], },
  • Registers the get_news_list tool in the MCP server's list_tools() response, including name, description, and input schema.
    types.Tool( name="get_news_list", description="通过新闻类型获取今日热点新闻头条", inputSchema={ "type": "object", "properties": { "type": { "type": "string", "description": "新闻类型:top(推荐,默认),guonei(国内),guoji(国际),yule(娱乐),tiyu(体育),junshi(军事),keji(科技),caijing(财经),youxi(游戏),qiche(汽车),jiankang(健康)", }, "page": { "type": "number", "description": "当前页数, 默认1, 最大50" }, "page_size": { "type": "number", "description": "每页返回新闻条数, 默认20, 最大50" }, }, # "required": ["type"], }, ),
  • Helper code in the call_tool handler that routes requests for 'get_news_list' to the tool's implementation function.
    if name == "get_news_list": type_value = type_value = arguments.get("type", "top") if arguments else "top" return await get_news_list(type_value)

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/juhemcp/jnews-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server