get_news_content
Retrieve detailed news content by providing a news ID, enabling access to full articles from the Juhe News MCP Server.
Instructions
根据新闻ID获取新闻的详细内容
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uniquekey | Yes | 新闻ID(gew_news_list中返回的uniquekey) |
Implementation Reference
- src/jnews_mcp_server/server.py:112-148 (handler)The implementation of the get_news_content tool handler. It makes an HTTP GET request to the Juhe news API endpoint '/content' with the uniquekey and API key, parses the JSON response, and returns the news content as TextContent or an error message.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']}" ) ]
- src/jnews_mcp_server/server.py:47-53 (schema)The JSON Schema for the input parameters of the get_news_content tool, defining 'uniquekey' as a required string.inputSchema={ "type": "object", "properties": { "uniquekey": {"type": "string", "description": "新闻ID(gew_news_list中返回的uniquekey)"}, }, "required": ["uniquekey"], },
- src/jnews_mcp_server/server.py:44-54 (registration)The tool registration in the list_tools() handler, specifying name, description, and input schema for get_news_content.types.Tool( name="get_news_content", description="根据新闻ID获取新闻的详细内容", inputSchema={ "type": "object", "properties": { "uniquekey": {"type": "string", "description": "新闻ID(gew_news_list中返回的uniquekey)"}, }, "required": ["uniquekey"], }, ),