深度研究MCP(深度研究模型上下文协议)是一个智能研究平台,它基于模型上下文协议构建,支持与Claude Desktop等工具集成。该系统借助调用OpenAI和Firecrawl API,为用户提供强大的研究功能。
本项目是一个基于模型上下文协议构建的智能研究平台,支持与Claude Desktop等工具集成,通过调用OpenAI和Firecrawl API提供强大的研究功能。下面为你介绍如何快速开启使用。
将项目仓库克隆到本地,并安装所需依赖。
git clone https://github.com/yourusername/deep-research-mcp.git
cd deep-research-mcp
npm install
安装完成后,启动项目服务。
node dist/index.js
interface ResearchInitialization {
query: string;
depth: number;
}
interface ResearchStepExecution {
sessionId: string;
}
interface ReportGeneration {
sessionId: string;
timeout?: number;
}
以下是使用客户端与服务端进行交互的示例代码,展示了如何初始化研究、执行研究步骤以及生成最终报告。
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
async function main() {
// 连接到服务端
const transport = new StdioClientTransport({
command: "node",
args: ["dist/index.js"]
});
const client = new Client({ name: "deep-research-client", version: "1.0.0" });
await client.connect(transport);
// 初始化研究
const initResult = await client.callTool({
name: "initialize-research",
arguments: {
query: "人工智能对医疗保健的影响",
depth: 3
}
});
// 解析响应以获取 sessionId
const { sessionId } = JSON.parse(initResult.content[0].text);
// 执行步骤直到完成
let currentDepth = 0;
while (currentDepth < 3) {
const stepResult = await client.callTool({
name: "execute-research-step",
arguments: { sessionId }
});
const stepInfo = JSON.parse(stepResult.content[0].text);
currentDepth = stepInfo.currentDepth;
console.log(`完成步骤 ${stepInfo.currentDepth}/${stepInfo.maxDepth}`);
}
// 生成最终报告带有超时设置
const report = await client.callTool({
name: "generate-report",
arguments: {
sessionId,
timeout: 180000 // 设置3分钟的超时时间
}
});
console.log("最终报告:");
console.log(report.content[0].text);
}
main().catch(console.error);
超出令牌限制:对于非常大的研究主题,可能会遇到OpenAI令牌限制错误。解决方法:
超时错误:对于复杂的研究,过程可能会超时。解决方案:
complete-research工具并设置更长的超时时间API速率限制:如果遇到OpenAI或Firecrawl的速率限制错误:
项目采用MIT许可证,具体请参考LICENSE文件。
欢迎贡献!请参阅CONTRIBUTING.md了解如何为项目做出贡献。