humanus.cpp/server/mcp_server_main.cpp

41 lines
1.1 KiB
C++
Raw Normal View History

2025-03-16 17:17:01 +08:00
/**
* @file mcp_server_main.cpp
2025-03-17 16:35:11 +08:00
* @brief OpenManus MCP Server Implementation
2025-03-16 17:17:01 +08:00
*
2025-03-17 16:35:11 +08:00
* This file implements the OpenManus MCP server that provides tool invocation functionality.
* Currently implements the PythonExecute tool.
2025-03-16 17:17:01 +08:00
*/
2025-03-17 01:58:37 +08:00
#include "../mcp/include/mcp_server.h"
#include "../mcp/include/mcp_tool.h"
#include "../mcp/include/mcp_resource.h"
2025-03-16 17:17:01 +08:00
#include <iostream>
#include <string>
#include <memory>
#include <filesystem>
2025-03-17 16:35:11 +08:00
// Import Python execution tool
2025-03-16 17:17:01 +08:00
extern void register_python_execute_tool(mcp::server& server);
int main() {
2025-03-17 16:35:11 +08:00
// Create and configure server
2025-03-16 17:17:01 +08:00
mcp::server server("localhost", 8818);
server.set_server_info("OpenManusMCPServer", "0.0.1");
2025-03-17 16:35:11 +08:00
// Set server capabilities
2025-03-16 17:17:01 +08:00
mcp::json capabilities = {
{"tools", mcp::json::object()}
};
server.set_capabilities(capabilities);
2025-03-17 16:35:11 +08:00
// Register Python execution tool
2025-03-16 17:17:01 +08:00
register_python_execute_tool(server);
2025-03-17 16:35:11 +08:00
// Start server
std::cout << "Starting OpenManus MCP server at localhost:8818..." << std::endl;
std::cout << "Press Ctrl+C to stop server" << std::endl;
server.start(true); // Blocking mode
2025-03-16 17:17:01 +08:00
return 0;
2025-03-17 16:35:11 +08:00
}