humanus.cpp/server/mcp_server_main.cpp

41 lines
1.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/**
* @file mcp_server_main.cpp
* @brief OpenManus MCP服务器实现
*
* 这个文件实现了OpenManus的MCP服务器提供工具调用功能。
* 当前实现了PythonExecute工具。
*/
#include "../mcp/include/mcp_server.h"
#include "../mcp/include/mcp_tool.h"
#include "../mcp/include/mcp_resource.h"
#include <iostream>
#include <string>
#include <memory>
#include <filesystem>
// 导入Python执行工具
extern void register_python_execute_tool(mcp::server& server);
int main() {
// 创建并配置服务器
mcp::server server("localhost", 8818);
server.set_server_info("OpenManusMCPServer", "0.0.1");
// 设置服务器能力
mcp::json capabilities = {
{"tools", mcp::json::object()}
};
server.set_capabilities(capabilities);
// 注册Python执行工具
register_python_execute_tool(server);
// 启动服务器
std::cout << "启动OpenManus MCP服务器地址: localhost:8818..." << std::endl;
std::cout << "按Ctrl+C停止服务器" << std::endl;
server.start(true); // 阻塞模式
return 0;
}