Skip to main content
Glama
juhemcp

Juhe News MCP Server

Official
by juhemcp

get_news_content

Retrieve detailed news content by providing a unique news ID, enabling access to full articles from the Juhe News MCP Server for analysis or integration.

Instructions

根据新闻ID获取新闻的详细内容

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uniquekeyYes新闻ID(gew_news_list中返回的uniquekey)

Implementation Reference

  • The core handler function that implements the 'get_news_content' tool logic. It makes an HTTP request to the Juhe News API with the uniquekey to retrieve detailed news content and returns it as TextContent.
    async def get_news_content(uniquekey: str) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: """ 根据新闻ID(uniquekey)获取新闻的详细内容. """ url = f"{JUHE_NEWS_API_BASE}/content" params = { "uniquekey": uniquekey, "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_content = data["result"] return [ # types.TextContent( # type="text", # text=f""" # 标题: {news_content['title']} # 作者: {news_content['author_name']} # URL: {news_content['url']} # 新闻id: {news_content['uniquekey']} # 新闻内容: {news_content['content']} # """ # ) types.TextContent( type="text", text=f"{news_content}" ) ] else: return [ types.TextContent( type="text", text=f"Error: {data['reason']}" ) ]
  • Registration of the 'get_news_content' tool in the @server.list_tools() handler, including the tool name, description, and input JSON schema requiring 'uniquekey'.
    types.Tool( name="get_news_content", description="根据新闻ID获取新闻的详细内容", inputSchema={ "type": "object", "properties": { "uniquekey": {"type": "string", "description": "新闻ID(gew_news_list中返回的uniquekey)"}, }, "required": ["uniquekey"], }, ),
  • Input schema definition for the 'get_news_content' tool, specifying the required 'uniquekey' parameter.
    inputSchema={ "type": "object", "properties": { "uniquekey": {"type": "string", "description": "新闻ID(gew_news_list中返回的uniquekey)"}, }, "required": ["uniquekey"], },
  • Dispatch logic in the @server.call_tool() handler that extracts the 'uniquekey' argument and invokes the get_news_content function.
    elif name == "get_news_content": uniquekey = arguments.get("uniquekey") if arguments else None if not uniquekey: raise ValueError("Missing name or content") return await get_news_content(uniquekey)

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