这是一个使用TypeScript编写的开源项目,通过Model Context Protocol(MCP)提供多种功能模块,能满足用户对热点信息获取、历史数据查询等多方面的需求。
项目启动后,可访问以下接口来体验功能。示例代码如下:
import { McpClient } from "@modelcontextprotocol/sdk/client";
async function example() {
const client = new McpClient();
// 获取实时热搜榜
const realtimeHotRanking = await client.callTool("realtime-hot-ranking", {});
console.log(realtimeHotRanking.content);
// 获取每日热榜
const dailyHotRanking = await client.callTool("daily-hot-ranking", {});
console.log(dailyHotRanking.content);
// 查询历史数据(过去7天)
const historyData = await client.callTool("history-data", { days: 7 });
console.log(historyData.content);
}
克隆仓库:
git clone https://github.com/wangtsiao/your-project.git
cd your-project
安装依赖:
npm install
启动服务:
npm run dev
src/tools/目录下创建新文件(例如:newFeature.ts)// src/tools/newFeature.ts
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
export function registerNewFeature(server: McpServer) {
server.tool(
"new-feature",
"新功能描述",
{
param1: z.string().describe("参数说明")
},
async (params) => {
// 实现新功能逻辑
return {
content: [
{ type: "text", text: "返回结果示例" }
]
};
}
);
}
src/index.ts中注册新工具:import { registerNewFeature } from './tools/newFeature.js';
// 注册新工具
registerNewFeature(server);
欢迎贡献!请按照以下步骤进行:
git fork https://github.com/wangtsiao/your-project.git
git checkout -b feature/amazing-feature
git add .
git commit -m '添加神奇功能'
git push origin feature/amazing-feature
本项目使用MIT许可证,具体内容请参阅LICENSE文件。
感谢韩小韩API提供的免费接口支持!