使用说明
News broadcast MCP service
Project Introduction
The news broadcast MCP service is a service used to obtain news broadcast scripts on a specified date. It supports MCP protocol and HTTP API calling methods.
Quick Start
Install dependencies
npm install
Start service
production environment
npm start
Development environment (supports hot reloading)
npm run dev
The service will be available http://localhost:8000 Start up.
API documentation
health check
GET /health
Response example:
{
"status": "ok",
"message": "新闻联播MCP服务运行正常"
}
Get news broadcast script (HTTP API)
POST /get_news
Request parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| Date | string | Yes | Date, formatted as YYYYMMDD, for example 20231231 |
Request example:
curl -X POST -H "Content-Type: application/json" -d '{"date":"20231231"}' http://localhost:8000/get_news
Response example:
{
"date": "20231231",
"content": "新闻联播文字稿内容..."
}
MCP protocol support
MCP Service Description
GET /mcp/describe
Response example:
{
"name": "news_联播",
"version": "1.0.0",
"description": "获取指定日期的新闻联播文字稿",
"tools": [
{
"name": "get_news",
"description": "获取指定日期的新闻联播文字稿",
"parameters": {
"type": "object",
"properties": {
"date": {
"type": "string",
"description": "日期,格式为YYYYMMDD,例如20231231"
}
},
"required": ["date"]
}
}
]
}
MCP service call
POST /mcp/call
Request parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| Tool | string | Yes | Tool name, fixed as get_news |
| Params | object | Yes | Tool parameters, including date Fields |
Request example:
curl -X POST -H "Content-Type: application/json" -d '{"tool":"get_news","params":{"date":"20231231"}}' http://localhost:8000/mcp/call
Response example:
{
"date": "20231231",
"content": "新闻联播文字稿内容..."
}
project structure
mcp-newsbroadcast/
├── mcp_server.js # 主服务文件
├── package.json # 项目配置文件
├── package-lock.json # 依赖锁定文件
├── ServerConfig.json # 服务配置文件
├── LICENSE # 许可证文件
└── README.md # 项目说明文档
Service Configuration
Service configuration file ServerConfig.json Contains detailed configuration information for MCP services, while the outer layer only includes mcpServers The field meets the service configuration requirements.
ServerConfig. json content:
{
"mcpServers": {
"default": {
"name": "news_联播",
"version": "1.0.0",
"description": "获取指定日期的新闻联播文字稿",
"command": "npx",
"args": ["news-mcp-service@latest"],
"tools": [
{
"name": "get_news",
"description": "获取指定日期的新闻联播文字稿",
"parameters": {
"type": "object",
"properties": {
"date": {
"type": "string",
"description": "日期,格式为YYYYMMDD,例如20231231"
}
},
"required": ["date"]
}
}
]
}
}
}
Dependency Explanation
| Dependency | Version | Purpose |
|---|---|---|
| Express | ^ 4.18.2 | Web Framework for Building API Services |
| Axios | ^ 1.6.0 | HTTP client, used to request news broadcast data |
| Cheerio | ^ 1.0.0-rc.12 | HTML parsing library for extracting news content |
| Nodemon | ^ 3.0.1 | Development tool for hot reload services |
license
MIT License