This is page 12 of 20. Use http://codebase.md/fujitsu-ai/mcp-server-for-mas-developments?lines=true&page={x} to view the full context. # Directory Structure ``` ├── .gitattributes ├── .gitignore ├── agents │ ├── __init__.py │ ├── AgentInterface │ │ ├── __init__.py │ │ ├── Python │ │ │ ├── __init__.py │ │ │ ├── agent.py │ │ │ ├── color.py │ │ │ ├── config.py │ │ │ ├── language.py │ │ │ ├── local_file_handler.py │ │ │ └── network.py │ │ └── requirements.txt │ ├── AgentMonitoring │ │ ├── ChatBot-Agent Dashboard Example - Grafana.json │ │ ├── images │ │ │ ├── Grafana.png │ │ │ └── Prometheus.png │ │ ├── IoT-Agent Dashboard Example - Grafana.json │ │ ├── OpenAI compatible API - Agent Dashboard Example - Grafana.json │ │ ├── prometheus Example.yml │ │ └── README.md │ ├── ChatBotAgent │ │ ├── __init__.py │ │ ├── config.json.example │ │ ├── html │ │ │ ├── favicon.ico │ │ │ ├── index_de.html │ │ │ ├── index.html │ │ │ ├── Logo_light.svg │ │ │ ├── start_http_server.ps1 │ │ │ └── start_http_server.sh │ │ ├── Python │ │ │ ├── __init__.py │ │ │ └── chatbot_agent.py │ │ ├── README.md │ │ └── requirements.txt │ ├── IoTAgent │ │ ├── config_example.json │ │ ├── Python │ │ │ ├── iot_mqtt_agent.py │ │ │ └── language.py │ │ ├── README.md │ │ └── requirements.txt │ ├── MCP-Client │ │ ├── __init__.py │ │ ├── .env.example │ │ ├── Python │ │ │ ├── __init__.py │ │ │ ├── chat_handler.py │ │ │ ├── config.py │ │ │ ├── environment.py │ │ │ ├── llm_client.py │ │ │ ├── mcp_client_sse.py │ │ │ ├── mcp_client.py │ │ │ ├── messages │ │ │ │ ├── __init__.py │ │ │ │ ├── message_types │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── incrementing_id_message.py │ │ │ │ │ ├── initialize_message.py │ │ │ │ │ ├── json_rpc_message.py │ │ │ │ │ ├── ping_message.py │ │ │ │ │ ├── prompts_messages.py │ │ │ │ │ ├── prompts_models.py │ │ │ │ │ ├── resources_messages.py │ │ │ │ │ └── tools_messages.py │ │ │ │ ├── send_call_tool.py │ │ │ │ ├── send_initialize_message.py │ │ │ │ ├── send_message.py │ │ │ │ ├── send_ping.py │ │ │ │ ├── send_prompts.py │ │ │ │ ├── send_resources.py │ │ │ │ └── send_tools_list.py │ │ │ ├── system_prompt_generator.py │ │ │ ├── tools_handler.py │ │ │ └── transport │ │ │ ├── __init__.py │ │ │ └── stdio │ │ │ ├── __init__.py │ │ │ ├── stdio_client.py │ │ │ ├── stdio_server_parameters.py │ │ │ └── stdio_server_shutdown.py │ │ ├── README.md │ │ ├── requirements.txt │ │ └── server_config.json │ ├── OpenAI_Compatible_API_Agent │ │ ├── __init__.py │ │ ├── docker-compose.yml │ │ ├── Dockerfile │ │ ├── pgpt_openai_api_mcp.json.example │ │ ├── pgpt_openai_api_proxy.json.example │ │ ├── Python │ │ │ ├── __init__.py │ │ │ ├── client_tests │ │ │ │ ├── __init__.py │ │ │ │ ├── openai_test_client_structured.py │ │ │ │ ├── openai_test_client_tools.py │ │ │ │ ├── openai_test_client.py │ │ │ │ ├── vllm_client_multimodal.py │ │ │ │ ├── vllm_client.py │ │ │ │ ├── vllm_structured.py │ │ │ │ └── vllm_structured2.py │ │ │ ├── generate_api_key.py │ │ │ ├── open_ai_helper.py │ │ │ ├── openai_compatible_api.py │ │ │ ├── openai_mcp_api.py │ │ │ ├── pgpt_api.py │ │ │ ├── privategpt_api.py │ │ │ └── vllmproxy.py │ │ ├── README.md │ │ └── requirements.txt │ └── SourceManagerAgent │ ├── __init__.py │ ├── config.json.example │ └── Python │ ├── __init__.py │ ├── file_tools │ │ └── loader_factory.py │ ├── file_upload_agent.py │ └── local_db.py ├── clients │ ├── __init__.py │ ├── C# .Net │ │ ├── 1.0 mcp_login │ │ │ ├── bin │ │ │ │ └── Debug │ │ │ │ └── net9.0 │ │ │ │ ├── mcp_login.deps.json │ │ │ │ ├── mcp_login.dll │ │ │ │ ├── mcp_login.exe │ │ │ │ ├── mcp_login.pdb │ │ │ │ ├── mcp_login.runtimeconfig.json │ │ │ │ └── Newtonsoft.Json.dll │ │ │ ├── mcp_login.csproj │ │ │ ├── obj │ │ │ │ ├── Debug │ │ │ │ │ └── net9.0 │ │ │ │ │ ├── .NETCoreApp,Version=v9.0.AssemblyAttributes.cs │ │ │ │ │ ├── apphost.exe │ │ │ │ │ ├── mcp_login.AssemblyInfo.cs │ │ │ │ │ ├── mcp_login.AssemblyInfoInputs.cache │ │ │ │ │ ├── mcp_login.assets.cache │ │ │ │ │ ├── mcp_login.csproj.AssemblyReference.cache │ │ │ │ │ ├── mcp_login.csproj.CoreCompileInputs.cache │ │ │ │ │ ├── mcp_login.csproj.FileListAbsolute.txt │ │ │ │ │ ├── mcp_login.csproj.Up2Date │ │ │ │ │ ├── mcp_login.dll │ │ │ │ │ ├── mcp_login.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ │ ├── mcp_login.genruntimeconfig.cache │ │ │ │ │ ├── mcp_login.GlobalUsings.g.cs │ │ │ │ │ ├── mcp_login.pdb │ │ │ │ │ ├── ref │ │ │ │ │ │ └── mcp_login.dll │ │ │ │ │ └── refint │ │ │ │ │ └── mcp_login.dll │ │ │ │ ├── mcp_login.csproj.nuget.dgspec.json │ │ │ │ ├── mcp_login.csproj.nuget.g.props │ │ │ │ ├── mcp_login.csproj.nuget.g.targets │ │ │ │ ├── project.assets.json │ │ │ │ └── project.nuget.cache │ │ │ └── Program.cs │ │ ├── 1.1 mcp_logout │ │ │ ├── bin │ │ │ │ └── Debug │ │ │ │ └── net9.0 │ │ │ │ ├── mcp_logout.deps.json │ │ │ │ ├── mcp_logout.dll │ │ │ │ ├── mcp_logout.exe │ │ │ │ ├── mcp_logout.pdb │ │ │ │ ├── mcp_logout.runtimeconfig.json │ │ │ │ └── Newtonsoft.Json.dll │ │ │ ├── mcp_logout.csproj │ │ │ ├── obj │ │ │ │ ├── Debug │ │ │ │ │ └── net9.0 │ │ │ │ │ ├── .NETCoreApp,Version=v9.0.AssemblyAttributes.cs │ │ │ │ │ ├── apphost.exe │ │ │ │ │ ├── mcp_logout.AssemblyInfo.cs │ │ │ │ │ ├── mcp_logout.AssemblyInfoInputs.cache │ │ │ │ │ ├── mcp_logout.assets.cache │ │ │ │ │ ├── mcp_logout.csproj.AssemblyReference.cache │ │ │ │ │ ├── mcp_logout.csproj.CoreCompileInputs.cache │ │ │ │ │ ├── mcp_logout.csproj.FileListAbsolute.txt │ │ │ │ │ ├── mcp_logout.csproj.Up2Date │ │ │ │ │ ├── mcp_logout.dll │ │ │ │ │ ├── mcp_logout.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ │ ├── mcp_logout.genruntimeconfig.cache │ │ │ │ │ ├── mcp_logout.GlobalUsings.g.cs │ │ │ │ │ ├── mcp_logout.pdb │ │ │ │ │ ├── ref │ │ │ │ │ │ └── mcp_logout.dll │ │ │ │ │ └── refint │ │ │ │ │ └── mcp_logout.dll │ │ │ │ ├── mcp_logout.csproj.nuget.dgspec.json │ │ │ │ ├── mcp_logout.csproj.nuget.g.props │ │ │ │ ├── mcp_logout.csproj.nuget.g.targets │ │ │ │ ├── project.assets.json │ │ │ │ └── project.nuget.cache │ │ │ └── Program.cs │ │ ├── 2.0 mcp_chat │ │ │ ├── bin │ │ │ │ └── Debug │ │ │ │ └── net9.0 │ │ │ │ ├── mcp_chat.deps.json │ │ │ │ ├── mcp_chat.dll │ │ │ │ ├── mcp_chat.exe │ │ │ │ ├── mcp_chat.pdb │ │ │ │ ├── mcp_chat.runtimeconfig.json │ │ │ │ └── Newtonsoft.Json.dll │ │ │ ├── mcp_chat.csproj │ │ │ ├── obj │ │ │ │ ├── Debug │ │ │ │ │ └── net9.0 │ │ │ │ │ ├── .NETCoreApp,Version=v9.0.AssemblyAttributes.cs │ │ │ │ │ ├── apphost.exe │ │ │ │ │ ├── mcp_chat.AssemblyInfo.cs │ │ │ │ │ ├── mcp_chat.AssemblyInfoInputs.cache │ │ │ │ │ ├── mcp_chat.assets.cache │ │ │ │ │ ├── mcp_chat.csproj.AssemblyReference.cache │ │ │ │ │ ├── mcp_chat.csproj.CoreCompileInputs.cache │ │ │ │ │ ├── mcp_chat.csproj.FileListAbsolute.txt │ │ │ │ │ ├── mcp_chat.csproj.Up2Date │ │ │ │ │ ├── mcp_chat.dll │ │ │ │ │ ├── mcp_chat.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ │ ├── mcp_chat.genruntimeconfig.cache │ │ │ │ │ ├── mcp_chat.GlobalUsings.g.cs │ │ │ │ │ ├── mcp_chat.pdb │ │ │ │ │ ├── ref │ │ │ │ │ │ └── mcp_chat.dll │ │ │ │ │ └── refint │ │ │ │ │ └── mcp_chat.dll │ │ │ │ ├── mcp_chat.csproj.nuget.dgspec.json │ │ │ │ ├── mcp_chat.csproj.nuget.g.props │ │ │ │ ├── mcp_chat.csproj.nuget.g.targets │ │ │ │ ├── project.assets.json │ │ │ │ └── project.nuget.cache │ │ │ └── Program.cs │ │ ├── 2.1 mcp_continue_chat │ │ │ ├── bin │ │ │ │ └── Debug │ │ │ │ └── net9.0 │ │ │ │ ├── mcp_continue_chat.deps.json │ │ │ │ ├── mcp_continue_chat.dll │ │ │ │ ├── mcp_continue_chat.exe │ │ │ │ ├── mcp_continue_chat.pdb │ │ │ │ ├── mcp_continue_chat.runtimeconfig.json │ │ │ │ └── Newtonsoft.Json.dll │ │ │ ├── mcp_continue_chat.csproj │ │ │ ├── obj │ │ │ │ ├── Debug │ │ │ │ │ └── net9.0 │ │ │ │ │ ├── .NETCoreApp,Version=v9.0.AssemblyAttributes.cs │ │ │ │ │ ├── apphost.exe │ │ │ │ │ ├── mcp_cont.EF178231.Up2Date │ │ │ │ │ ├── mcp_continue_chat.AssemblyInfo.cs │ │ │ │ │ ├── mcp_continue_chat.AssemblyInfoInputs.cache │ │ │ │ │ ├── mcp_continue_chat.assets.cache │ │ │ │ │ ├── mcp_continue_chat.csproj.AssemblyReference.cache │ │ │ │ │ ├── mcp_continue_chat.csproj.CoreCompileInputs.cache │ │ │ │ │ ├── mcp_continue_chat.csproj.FileListAbsolute.txt │ │ │ │ │ ├── mcp_continue_chat.dll │ │ │ │ │ ├── mcp_continue_chat.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ │ ├── mcp_continue_chat.genruntimeconfig.cache │ │ │ │ │ ├── mcp_continue_chat.GlobalUsings.g.cs │ │ │ │ │ ├── mcp_continue_chat.pdb │ │ │ │ │ ├── ref │ │ │ │ │ │ └── mcp_continue_chat.dll │ │ │ │ │ └── refint │ │ │ │ │ └── mcp_continue_chat.dll │ │ │ │ ├── mcp_continue_chat.csproj.nuget.dgspec.json │ │ │ │ ├── mcp_continue_chat.csproj.nuget.g.props │ │ │ │ ├── mcp_continue_chat.csproj.nuget.g.targets │ │ │ │ ├── project.assets.json │ │ │ │ └── project.nuget.cache │ │ │ └── Program.cs │ │ ├── 2.2 mcp_get_chat_info │ │ │ ├── bin │ │ │ │ └── Debug │ │ │ │ └── net9.0 │ │ │ │ ├── mcp_get_chat_info.deps.json │ │ │ │ ├── mcp_get_chat_info.dll │ │ │ │ ├── mcp_get_chat_info.exe │ │ │ │ ├── mcp_get_chat_info.pdb │ │ │ │ ├── mcp_get_chat_info.runtimeconfig.json │ │ │ │ └── Newtonsoft.Json.dll │ │ │ ├── Dokumente - Verknüpfung.lnk │ │ │ ├── mcp_get_chat_info.csproj │ │ │ ├── obj │ │ │ │ ├── Debug │ │ │ │ │ └── net9.0 │ │ │ │ │ ├── .NETCoreApp,Version=v9.0.AssemblyAttributes.cs │ │ │ │ │ ├── apphost.exe │ │ │ │ │ ├── mcp_get_.DFF47B4E.Up2Date │ │ │ │ │ ├── mcp_get_chat_info.AssemblyInfo.cs │ │ │ │ │ ├── mcp_get_chat_info.AssemblyInfoInputs.cache │ │ │ │ │ ├── mcp_get_chat_info.assets.cache │ │ │ │ │ ├── mcp_get_chat_info.csproj.AssemblyReference.cache │ │ │ │ │ ├── mcp_get_chat_info.csproj.CoreCompileInputs.cache │ │ │ │ │ ├── mcp_get_chat_info.csproj.FileListAbsolute.txt │ │ │ │ │ ├── mcp_get_chat_info.dll │ │ │ │ │ ├── mcp_get_chat_info.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ │ ├── mcp_get_chat_info.genruntimeconfig.cache │ │ │ │ │ ├── mcp_get_chat_info.GlobalUsings.g.cs │ │ │ │ │ ├── mcp_get_chat_info.pdb │ │ │ │ │ ├── ref │ │ │ │ │ │ └── mcp_get_chat_info.dll │ │ │ │ │ └── refint │ │ │ │ │ └── mcp_get_chat_info.dll │ │ │ │ ├── mcp_get_chat_info.csproj.nuget.dgspec.json │ │ │ │ ├── mcp_get_chat_info.csproj.nuget.g.props │ │ │ │ ├── mcp_get_chat_info.csproj.nuget.g.targets │ │ │ │ ├── project.assets.json │ │ │ │ └── project.nuget.cache │ │ │ └── Program.cs │ │ ├── 3.0 mcp_create_source │ │ │ ├── bin │ │ │ │ └── Debug │ │ │ │ └── net9.0 │ │ │ │ ├── mcp_create_source.deps.json │ │ │ │ ├── mcp_create_source.dll │ │ │ │ ├── mcp_create_source.exe │ │ │ │ ├── mcp_create_source.pdb │ │ │ │ ├── mcp_create_source.runtimeconfig.json │ │ │ │ └── Newtonsoft.Json.dll │ │ │ ├── mcp_create_source.csproj │ │ │ ├── obj │ │ │ │ ├── Debug │ │ │ │ │ └── net9.0 │ │ │ │ │ ├── .NETCoreApp,Version=v9.0.AssemblyAttributes.cs │ │ │ │ │ ├── apphost.exe │ │ │ │ │ ├── mcp_crea.CB4ED912.Up2Date │ │ │ │ │ ├── mcp_create_source.AssemblyInfo.cs │ │ │ │ │ ├── mcp_create_source.AssemblyInfoInputs.cache │ │ │ │ │ ├── mcp_create_source.assets.cache │ │ │ │ │ ├── mcp_create_source.csproj.AssemblyReference.cache │ │ │ │ │ ├── mcp_create_source.csproj.CoreCompileInputs.cache │ │ │ │ │ ├── mcp_create_source.csproj.FileListAbsolute.txt │ │ │ │ │ ├── mcp_create_source.dll │ │ │ │ │ ├── mcp_create_source.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ │ ├── mcp_create_source.genruntimeconfig.cache │ │ │ │ │ ├── mcp_create_source.GlobalUsings.g.cs │ │ │ │ │ ├── mcp_create_source.pdb │ │ │ │ │ ├── ref │ │ │ │ │ │ └── mcp_create_source.dll │ │ │ │ │ └── refint │ │ │ │ │ └── mcp_create_source.dll │ │ │ │ ├── mcp_create_source.csproj.nuget.dgspec.json │ │ │ │ ├── mcp_create_source.csproj.nuget.g.props │ │ │ │ ├── mcp_create_source.csproj.nuget.g.targets │ │ │ │ ├── project.assets.json │ │ │ │ └── project.nuget.cache │ │ │ └── Program.cs │ │ ├── 3.1 mcp_get_source │ │ │ ├── bin │ │ │ │ └── Debug │ │ │ │ └── net9.0 │ │ │ │ ├── mcp_get_source.deps.json │ │ │ │ ├── mcp_get_source.dll │ │ │ │ ├── mcp_get_source.exe │ │ │ │ ├── mcp_get_source.pdb │ │ │ │ ├── mcp_get_source.runtimeconfig.json │ │ │ │ └── Newtonsoft.Json.dll │ │ │ ├── mcp_get_source.csproj │ │ │ ├── obj │ │ │ │ ├── Debug │ │ │ │ │ └── net9.0 │ │ │ │ │ ├── .NETCoreApp,Version=v9.0.AssemblyAttributes.cs │ │ │ │ │ ├── apphost.exe │ │ │ │ │ ├── mcp_get_.4E61956F.Up2Date │ │ │ │ │ ├── mcp_get_source.AssemblyInfo.cs │ │ │ │ │ ├── mcp_get_source.AssemblyInfoInputs.cache │ │ │ │ │ ├── mcp_get_source.assets.cache │ │ │ │ │ ├── mcp_get_source.csproj.AssemblyReference.cache │ │ │ │ │ ├── mcp_get_source.csproj.CoreCompileInputs.cache │ │ │ │ │ ├── mcp_get_source.csproj.FileListAbsolute.txt │ │ │ │ │ ├── mcp_get_source.dll │ │ │ │ │ ├── mcp_get_source.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ │ ├── mcp_get_source.genruntimeconfig.cache │ │ │ │ │ ├── mcp_get_source.GlobalUsings.g.cs │ │ │ │ │ ├── mcp_get_source.pdb │ │ │ │ │ ├── ref │ │ │ │ │ │ └── mcp_get_source.dll │ │ │ │ │ └── refint │ │ │ │ │ └── mcp_get_source.dll │ │ │ │ ├── mcp_get_source.csproj.nuget.dgspec.json │ │ │ │ ├── mcp_get_source.csproj.nuget.g.props │ │ │ │ ├── mcp_get_source.csproj.nuget.g.targets │ │ │ │ ├── project.assets.json │ │ │ │ └── project.nuget.cache │ │ │ └── Program.cs │ │ ├── 3.2 mcp_list_sources │ │ │ ├── bin │ │ │ │ └── Debug │ │ │ │ └── net9.0 │ │ │ │ ├── mcp_list_sources.deps.json │ │ │ │ ├── mcp_list_sources.dll │ │ │ │ ├── mcp_list_sources.exe │ │ │ │ ├── mcp_list_sources.pdb │ │ │ │ ├── mcp_list_sources.runtimeconfig.json │ │ │ │ └── Newtonsoft.Json.dll │ │ │ ├── mcp_list_sources.csproj │ │ │ ├── obj │ │ │ │ ├── Debug │ │ │ │ │ └── net9.0 │ │ │ │ │ ├── .NETCoreApp,Version=v9.0.AssemblyAttributes.cs │ │ │ │ │ ├── apphost.exe │ │ │ │ │ ├── mcp_list_sources.AssemblyInfo.cs │ │ │ │ │ ├── mcp_list_sources.AssemblyInfoInputs.cache │ │ │ │ │ ├── mcp_list_sources.assets.cache │ │ │ │ │ ├── mcp_list_sources.csproj.AssemblyReference.cache │ │ │ │ │ ├── mcp_list_sources.csproj.CoreCompileInputs.cache │ │ │ │ │ ├── mcp_list_sources.csproj.FileListAbsolute.txt │ │ │ │ │ ├── mcp_list_sources.dll │ │ │ │ │ ├── mcp_list_sources.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ │ ├── mcp_list_sources.genruntimeconfig.cache │ │ │ │ │ ├── mcp_list_sources.GlobalUsings.g.cs │ │ │ │ │ ├── mcp_list_sources.pdb │ │ │ │ │ ├── mcp_list.A720E197.Up2Date │ │ │ │ │ ├── ref │ │ │ │ │ │ └── mcp_list_sources.dll │ │ │ │ │ └── refint │ │ │ │ │ └── mcp_list_sources.dll │ │ │ │ ├── mcp_list_sources.csproj.nuget.dgspec.json │ │ │ │ ├── mcp_list_sources.csproj.nuget.g.props │ │ │ │ ├── mcp_list_sources.csproj.nuget.g.targets │ │ │ │ ├── project.assets.json │ │ │ │ └── project.nuget.cache │ │ │ └── Program.cs │ │ ├── 3.3 mcp_edit_source │ │ │ ├── bin │ │ │ │ └── Debug │ │ │ │ └── net9.0 │ │ │ │ ├── mcp_edit_source.deps.json │ │ │ │ ├── mcp_edit_source.dll │ │ │ │ ├── mcp_edit_source.exe │ │ │ │ ├── mcp_edit_source.pdb │ │ │ │ ├── mcp_edit_source.runtimeconfig.json │ │ │ │ └── Newtonsoft.Json.dll │ │ │ ├── mcp_edit_source.csproj │ │ │ ├── obj │ │ │ │ ├── Debug │ │ │ │ │ └── net9.0 │ │ │ │ │ ├── .NETCoreApp,Version=v9.0.AssemblyAttributes.cs │ │ │ │ │ ├── apphost.exe │ │ │ │ │ ├── mcp_edit_source.AssemblyInfo.cs │ │ │ │ │ ├── mcp_edit_source.AssemblyInfoInputs.cache │ │ │ │ │ ├── mcp_edit_source.assets.cache │ │ │ │ │ ├── mcp_edit_source.csproj.AssemblyReference.cache │ │ │ │ │ ├── mcp_edit_source.csproj.CoreCompileInputs.cache │ │ │ │ │ ├── mcp_edit_source.csproj.FileListAbsolute.txt │ │ │ │ │ ├── mcp_edit_source.dll │ │ │ │ │ ├── mcp_edit_source.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ │ ├── mcp_edit_source.genruntimeconfig.cache │ │ │ │ │ ├── mcp_edit_source.GlobalUsings.g.cs │ │ │ │ │ ├── mcp_edit_source.pdb │ │ │ │ │ ├── mcp_edit.7303BE3B.Up2Date │ │ │ │ │ ├── ref │ │ │ │ │ │ └── mcp_edit_source.dll │ │ │ │ │ └── refint │ │ │ │ │ └── mcp_edit_source.dll │ │ │ │ ├── mcp_edit_source.csproj.nuget.dgspec.json │ │ │ │ ├── mcp_edit_source.csproj.nuget.g.props │ │ │ │ ├── mcp_edit_source.csproj.nuget.g.targets │ │ │ │ ├── project.assets.json │ │ │ │ └── project.nuget.cache │ │ │ └── Program.cs │ │ ├── 3.4 mcp_delete_source │ │ │ ├── bin │ │ │ │ └── Debug │ │ │ │ └── net9.0 │ │ │ │ ├── mcp_delete_source.deps.json │ │ │ │ ├── mcp_delete_source.dll │ │ │ │ ├── mcp_delete_source.exe │ │ │ │ ├── mcp_delete_source.pdb │ │ │ │ ├── mcp_delete_source.runtimeconfig.json │ │ │ │ └── Newtonsoft.Json.dll │ │ │ ├── mcp_delete_source.csproj │ │ │ ├── obj │ │ │ │ ├── Debug │ │ │ │ │ └── net9.0 │ │ │ │ │ ├── .NETCoreApp,Version=v9.0.AssemblyAttributes.cs │ │ │ │ │ ├── apphost.exe │ │ │ │ │ ├── mcp_dele.67DD13F9.Up2Date │ │ │ │ │ ├── mcp_delete_source.AssemblyInfo.cs │ │ │ │ │ ├── mcp_delete_source.AssemblyInfoInputs.cache │ │ │ │ │ ├── mcp_delete_source.assets.cache │ │ │ │ │ ├── mcp_delete_source.csproj.AssemblyReference.cache │ │ │ │ │ ├── mcp_delete_source.csproj.CoreCompileInputs.cache │ │ │ │ │ ├── mcp_delete_source.csproj.FileListAbsolute.txt │ │ │ │ │ ├── mcp_delete_source.dll │ │ │ │ │ ├── mcp_delete_source.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ │ ├── mcp_delete_source.genruntimeconfig.cache │ │ │ │ │ ├── mcp_delete_source.GlobalUsings.g.cs │ │ │ │ │ ├── mcp_delete_source.pdb │ │ │ │ │ ├── ref │ │ │ │ │ │ └── mcp_delete_source.dll │ │ │ │ │ └── refint │ │ │ │ │ └── mcp_delete_source.dll │ │ │ │ ├── mcp_delete_source.csproj.nuget.dgspec.json │ │ │ │ ├── mcp_delete_source.csproj.nuget.g.props │ │ │ │ ├── mcp_delete_source.csproj.nuget.g.targets │ │ │ │ ├── project.assets.json │ │ │ │ └── project.nuget.cache │ │ │ └── Program.cs │ │ ├── 4.0 mcp_list_groups │ │ │ ├── bin │ │ │ │ └── Debug │ │ │ │ └── net9.0 │ │ │ │ ├── mcp_list_groups.deps.json │ │ │ │ ├── mcp_list_groups.dll │ │ │ │ ├── mcp_list_groups.exe │ │ │ │ ├── mcp_list_groups.pdb │ │ │ │ ├── mcp_list_groups.runtimeconfig.json │ │ │ │ └── Newtonsoft.Json.dll │ │ │ ├── mcp_list_groups.csproj │ │ │ ├── obj │ │ │ │ ├── Debug │ │ │ │ │ └── net9.0 │ │ │ │ │ ├── .NETCoreApp,Version=v9.0.AssemblyAttributes.cs │ │ │ │ │ ├── apphost.exe │ │ │ │ │ ├── mcp_list_groups.AssemblyInfo.cs │ │ │ │ │ ├── mcp_list_groups.AssemblyInfoInputs.cache │ │ │ │ │ ├── mcp_list_groups.assets.cache │ │ │ │ │ ├── mcp_list_groups.csproj.AssemblyReference.cache │ │ │ │ │ ├── mcp_list_groups.csproj.CoreCompileInputs.cache │ │ │ │ │ ├── mcp_list_groups.csproj.FileListAbsolute.txt │ │ │ │ │ ├── mcp_list_groups.dll │ │ │ │ │ ├── mcp_list_groups.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ │ ├── mcp_list_groups.genruntimeconfig.cache │ │ │ │ │ ├── mcp_list_groups.GlobalUsings.g.cs │ │ │ │ │ ├── mcp_list_groups.pdb │ │ │ │ │ ├── mcp_list.EBD5E0D2.Up2Date │ │ │ │ │ ├── ref │ │ │ │ │ │ └── mcp_list_groups.dll │ │ │ │ │ └── refint │ │ │ │ │ └── mcp_list_groups.dll │ │ │ │ ├── mcp_list_groups.csproj.nuget.dgspec.json │ │ │ │ ├── mcp_list_groups.csproj.nuget.g.props │ │ │ │ ├── mcp_list_groups.csproj.nuget.g.targets │ │ │ │ ├── project.assets.json │ │ │ │ └── project.nuget.cache │ │ │ └── Program.cs │ │ ├── 4.1 mcp_store_group │ │ │ ├── bin │ │ │ │ └── Debug │ │ │ │ └── net9.0 │ │ │ │ ├── mcp_store_group.deps.json │ │ │ │ ├── mcp_store_group.dll │ │ │ │ ├── mcp_store_group.exe │ │ │ │ ├── mcp_store_group.pdb │ │ │ │ ├── mcp_store_group.runtimeconfig.json │ │ │ │ └── Newtonsoft.Json.dll │ │ │ ├── mcp_store_group.csproj │ │ │ ├── obj │ │ │ │ ├── Debug │ │ │ │ │ └── net9.0 │ │ │ │ │ ├── .NETCoreApp,Version=v9.0.AssemblyAttributes.cs │ │ │ │ │ ├── apphost.exe │ │ │ │ │ ├── mcp_stor.AFB4AA35.Up2Date │ │ │ │ │ ├── mcp_store_group.AssemblyInfo.cs │ │ │ │ │ ├── mcp_store_group.AssemblyInfoInputs.cache │ │ │ │ │ ├── mcp_store_group.assets.cache │ │ │ │ │ ├── mcp_store_group.csproj.AssemblyReference.cache │ │ │ │ │ ├── mcp_store_group.csproj.CoreCompileInputs.cache │ │ │ │ │ ├── mcp_store_group.csproj.FileListAbsolute.txt │ │ │ │ │ ├── mcp_store_group.dll │ │ │ │ │ ├── mcp_store_group.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ │ ├── mcp_store_group.genruntimeconfig.cache │ │ │ │ │ ├── mcp_store_group.GlobalUsings.g.cs │ │ │ │ │ ├── mcp_store_group.pdb │ │ │ │ │ ├── ref │ │ │ │ │ │ └── mcp_store_group.dll │ │ │ │ │ └── refint │ │ │ │ │ └── mcp_store_group.dll │ │ │ │ ├── mcp_store_group.csproj.nuget.dgspec.json │ │ │ │ ├── mcp_store_group.csproj.nuget.g.props │ │ │ │ ├── mcp_store_group.csproj.nuget.g.targets │ │ │ │ ├── project.assets.json │ │ │ │ └── project.nuget.cache │ │ │ └── Program.cs │ │ ├── 4.2 mcp_delete_group │ │ │ ├── bin │ │ │ │ └── Debug │ │ │ │ └── net9.0 │ │ │ │ ├── mcp_delete_group.deps.json │ │ │ │ ├── mcp_delete_group.dll │ │ │ │ ├── mcp_delete_group.exe │ │ │ │ ├── mcp_delete_group.pdb │ │ │ │ ├── mcp_delete_group.runtimeconfig.json │ │ │ │ └── Newtonsoft.Json.dll │ │ │ ├── mcp_delete_group.csproj │ │ │ ├── obj │ │ │ │ ├── Debug │ │ │ │ │ └── net9.0 │ │ │ │ │ ├── .NETCoreApp,Version=v9.0.AssemblyAttributes.cs │ │ │ │ │ ├── apphost.exe │ │ │ │ │ ├── mcp_dele.FE1C6298.Up2Date │ │ │ │ │ ├── mcp_delete_group.AssemblyInfo.cs │ │ │ │ │ ├── mcp_delete_group.AssemblyInfoInputs.cache │ │ │ │ │ ├── mcp_delete_group.assets.cache │ │ │ │ │ ├── mcp_delete_group.csproj.AssemblyReference.cache │ │ │ │ │ ├── mcp_delete_group.csproj.CoreCompileInputs.cache │ │ │ │ │ ├── mcp_delete_group.csproj.FileListAbsolute.txt │ │ │ │ │ ├── mcp_delete_group.dll │ │ │ │ │ ├── mcp_delete_group.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ │ ├── mcp_delete_group.genruntimeconfig.cache │ │ │ │ │ ├── mcp_delete_group.GlobalUsings.g.cs │ │ │ │ │ ├── mcp_delete_group.pdb │ │ │ │ │ ├── ref │ │ │ │ │ │ └── mcp_delete_group.dll │ │ │ │ │ └── refint │ │ │ │ │ └── mcp_delete_group.dll │ │ │ │ ├── mcp_delete_group.csproj.nuget.dgspec.json │ │ │ │ ├── mcp_delete_group.csproj.nuget.g.props │ │ │ │ ├── mcp_delete_group.csproj.nuget.g.targets │ │ │ │ ├── project.assets.json │ │ │ │ └── project.nuget.cache │ │ │ └── Program.cs │ │ ├── 5.0 mcp_store_user │ │ │ ├── bin │ │ │ │ └── Debug │ │ │ │ └── net9.0 │ │ │ │ ├── mcp_store_user.deps.json │ │ │ │ ├── mcp_store_user.dll │ │ │ │ ├── mcp_store_user.exe │ │ │ │ ├── mcp_store_user.pdb │ │ │ │ ├── mcp_store_user.runtimeconfig.json │ │ │ │ └── Newtonsoft.Json.dll │ │ │ ├── mcp_store_user.csproj │ │ │ ├── obj │ │ │ │ ├── Debug │ │ │ │ │ └── net9.0 │ │ │ │ │ ├── .NETCoreApp,Version=v9.0.AssemblyAttributes.cs │ │ │ │ │ ├── apphost.exe │ │ │ │ │ ├── mcp_stor.6C0F0C8A.Up2Date │ │ │ │ │ ├── mcp_store_user.AssemblyInfo.cs │ │ │ │ │ ├── mcp_store_user.AssemblyInfoInputs.cache │ │ │ │ │ ├── mcp_store_user.assets.cache │ │ │ │ │ ├── mcp_store_user.csproj.AssemblyReference.cache │ │ │ │ │ ├── mcp_store_user.csproj.CoreCompileInputs.cache │ │ │ │ │ ├── mcp_store_user.csproj.FileListAbsolute.txt │ │ │ │ │ ├── mcp_store_user.dll │ │ │ │ │ ├── mcp_store_user.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ │ ├── mcp_store_user.genruntimeconfig.cache │ │ │ │ │ ├── mcp_store_user.GlobalUsings.g.cs │ │ │ │ │ ├── mcp_store_user.pdb │ │ │ │ │ ├── ref │ │ │ │ │ │ └── mcp_store_user.dll │ │ │ │ │ └── refint │ │ │ │ │ └── mcp_store_user.dll │ │ │ │ ├── mcp_store_user.csproj.nuget.dgspec.json │ │ │ │ ├── mcp_store_user.csproj.nuget.g.props │ │ │ │ ├── mcp_store_user.csproj.nuget.g.targets │ │ │ │ ├── project.assets.json │ │ │ │ └── project.nuget.cache │ │ │ └── Program.cs │ │ ├── 5.1 mcp_edit_user │ │ │ ├── bin │ │ │ │ └── Debug │ │ │ │ └── net9.0 │ │ │ │ ├── mcp_edit_user.deps.json │ │ │ │ ├── mcp_edit_user.dll │ │ │ │ ├── mcp_edit_user.exe │ │ │ │ ├── mcp_edit_user.pdb │ │ │ │ ├── mcp_edit_user.runtimeconfig.json │ │ │ │ └── Newtonsoft.Json.dll │ │ │ ├── mcp_edit_user.csproj │ │ │ ├── obj │ │ │ │ ├── Debug │ │ │ │ │ └── net9.0 │ │ │ │ │ ├── .NETCoreApp,Version=v9.0.AssemblyAttributes.cs │ │ │ │ │ ├── apphost.exe │ │ │ │ │ ├── mcp_edit_user.AssemblyInfo.cs │ │ │ │ │ ├── mcp_edit_user.AssemblyInfoInputs.cache │ │ │ │ │ ├── mcp_edit_user.assets.cache │ │ │ │ │ ├── mcp_edit_user.csproj.AssemblyReference.cache │ │ │ │ │ ├── mcp_edit_user.csproj.CoreCompileInputs.cache │ │ │ │ │ ├── mcp_edit_user.csproj.FileListAbsolute.txt │ │ │ │ │ ├── mcp_edit_user.dll │ │ │ │ │ ├── mcp_edit_user.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ │ ├── mcp_edit_user.genruntimeconfig.cache │ │ │ │ │ ├── mcp_edit_user.GlobalUsings.g.cs │ │ │ │ │ ├── mcp_edit_user.pdb │ │ │ │ │ ├── mcp_edit.94A30270.Up2Date │ │ │ │ │ ├── ref │ │ │ │ │ │ └── mcp_edit_user.dll │ │ │ │ │ └── refint │ │ │ │ │ └── mcp_edit_user.dll │ │ │ │ ├── mcp_edit_user.csproj.nuget.dgspec.json │ │ │ │ ├── mcp_edit_user.csproj.nuget.g.props │ │ │ │ ├── mcp_edit_user.csproj.nuget.g.targets │ │ │ │ ├── project.assets.json │ │ │ │ └── project.nuget.cache │ │ │ └── Program.cs │ │ ├── 5.2 mcp_delete_user │ │ │ ├── bin │ │ │ │ └── Debug │ │ │ │ └── net9.0 │ │ │ │ ├── mcp_delete_user.deps.json │ │ │ │ ├── mcp_delete_user.dll │ │ │ │ ├── mcp_delete_user.exe │ │ │ │ ├── mcp_delete_user.pdb │ │ │ │ ├── mcp_delete_user.runtimeconfig.json │ │ │ │ └── Newtonsoft.Json.dll │ │ │ ├── mcp_delete_user.csproj │ │ │ ├── obj │ │ │ │ ├── Debug │ │ │ │ │ └── net9.0 │ │ │ │ │ ├── .NETCoreApp,Version=v9.0.AssemblyAttributes.cs │ │ │ │ │ ├── apphost.exe │ │ │ │ │ ├── mcp_dele.CEB7E33D.Up2Date │ │ │ │ │ ├── mcp_delete_user.AssemblyInfo.cs │ │ │ │ │ ├── mcp_delete_user.AssemblyInfoInputs.cache │ │ │ │ │ ├── mcp_delete_user.assets.cache │ │ │ │ │ ├── mcp_delete_user.csproj.AssemblyReference.cache │ │ │ │ │ ├── mcp_delete_user.csproj.CoreCompileInputs.cache │ │ │ │ │ ├── mcp_delete_user.csproj.FileListAbsolute.txt │ │ │ │ │ ├── mcp_delete_user.dll │ │ │ │ │ ├── mcp_delete_user.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ │ ├── mcp_delete_user.genruntimeconfig.cache │ │ │ │ │ ├── mcp_delete_user.GlobalUsings.g.cs │ │ │ │ │ ├── mcp_delete_user.pdb │ │ │ │ │ ├── ref │ │ │ │ │ │ └── mcp_delete_user.dll │ │ │ │ │ └── refint │ │ │ │ │ └── mcp_delete_user.dll │ │ │ │ ├── mcp_delete_user.csproj.nuget.dgspec.json │ │ │ │ ├── mcp_delete_user.csproj.nuget.g.props │ │ │ │ ├── mcp_delete_user.csproj.nuget.g.targets │ │ │ │ ├── project.assets.json │ │ │ │ └── project.nuget.cache │ │ │ └── Program.cs │ │ ├── Code Archiv │ │ │ ├── mcp_chat.cs │ │ │ ├── mcp_continue_chat.cs │ │ │ ├── mcp_create_source.cs │ │ │ ├── mcp_delete_group.cs │ │ │ ├── mcp_delete_source.cs │ │ │ ├── mcp_delete_user.cs │ │ │ ├── mcp_edit_source.cs │ │ │ ├── mcp_edit_user.cs │ │ │ ├── mcp_get_chat_info.cs │ │ │ ├── mcp_get_source.cs │ │ │ ├── mcp_list_groups.cs │ │ │ ├── mcp_list_sources.cs │ │ │ ├── mcp_login.cs │ │ │ ├── mcp_logout.cs │ │ │ ├── mcp_store_group.cs │ │ │ └── mcp_store_user.cs │ │ └── README.md │ ├── C++ │ │ ├── .vscode │ │ │ └── launch.json │ │ ├── 1.0 mcp_login │ │ │ ├── MCPLoginClient.cpp │ │ │ └── Non-TLS version │ │ │ ├── MCPLoginClient.cpp │ │ │ └── MCPLoginClient.exe │ │ ├── 1.1 mcp_logout │ │ │ ├── MCPLogoutClient.cpp │ │ │ └── MCPLogoutClient.exe │ │ ├── 2.0 mcp_chat │ │ │ ├── MCPChatClient.cpp │ │ │ └── MCPChatClient.exe │ │ ├── 2.1 mcp_continue_chat │ │ │ ├── MCPChatContinuationClient.cpp │ │ │ └── MCPChatContinuationClient.exe │ │ ├── 2.2 mcp_get_chat_info │ │ │ ├── MCPGetChatInfoClient.cpp │ │ │ └── MCPGetChatInfoClient.exe │ │ ├── 3.0 mcp_create_source │ │ │ ├── MCPCreateSourceClient.cpp │ │ │ └── MCPCreateSourceClient.exe │ │ ├── 3.1 mcp_get_source │ │ │ ├── MCPGetSourceClient.cpp │ │ │ └── MCPGetSourceClient.exe │ │ ├── 3.2 mcp_list_sources │ │ │ ├── MCPListSourcesClient.cpp │ │ │ └── MCPListSourcesClient.exe │ │ ├── 3.3 mcp_edit_source │ │ │ ├── MCPEditSourceClient.cpp │ │ │ └── MCPEditSourceClient.exe │ │ ├── 3.4 mcp_delete_source │ │ │ ├── MCPDeleteSourceClient.cpp │ │ │ └── MCPDeleteSourceClient.exe │ │ ├── 4.0 mcp_list_groups │ │ │ ├── MCPListGroupsClient.cpp │ │ │ └── MCPListGroupsClient.exe │ │ ├── 4.1 mcp_store_group │ │ │ ├── MCPStoreGroupClient.cpp │ │ │ └── MCPStoreGroupClient.exe │ │ ├── 4.2 mcp_delete_group │ │ │ ├── MPCDeleteGroupClient.cpp │ │ │ └── MPCDeleteGroupClient.exe │ │ ├── 5.0 mcp_store_user │ │ │ ├── MCPStoreUserClient.cpp │ │ │ └── MCPStoreUserClient.exe │ │ ├── 5.1 mcp_edit_user │ │ │ ├── MCPEditUserClient.cpp │ │ │ └── MCPEditUserClient.exe │ │ ├── 5.2 mcp_delete_user │ │ │ ├── MCPDeleteUserClient.cpp │ │ │ └── MCPDeleteUserClient.exe │ │ ├── 9.0 mcp_keygen │ │ │ ├── MCPKeygenClient.cpp │ │ │ └── MCPKeygenClient.exe │ │ └── README.md │ ├── Go │ │ ├── 1.0 mcp_login │ │ │ ├── go.mod │ │ │ ├── MCPLoginClient.exe │ │ │ └── MCPLoginClient.go │ │ ├── 1.1 mcp_logout │ │ │ ├── MCPLogoutClient.exe │ │ │ └── MCPLogoutClient.go │ │ ├── 2.0 mcp_chat │ │ │ ├── MCPChatClient.exe │ │ │ └── MCPChatClient.go │ │ ├── 2.1 mcp_continue_chat │ │ │ ├── MCPChatContinuationClient.exe │ │ │ └── MCPChatContinuationClient.go │ │ ├── 2.2 mcp_get_chat_info │ │ │ ├── MCPGetChatInfoClient.exe │ │ │ └── MCPGetChatInfoClient.go │ │ ├── 3.0 mcp_create_source │ │ │ ├── MCPCreateSourceClient.exe │ │ │ └── MCPCreateSourceClient.go │ │ ├── 3.1 mcp_get_source │ │ │ ├── MCPGetSourceClient.exe │ │ │ └── MCPGetSourceClient.go │ │ ├── 3.2 mcp_list_sources │ │ │ ├── MCPListSourcesClient.exe │ │ │ └── MCPListSourcesClient.go │ │ ├── 3.3 mcp_edit_source │ │ │ ├── MCPEditSourceClient.exe │ │ │ └── MCPEditSourceClient.go │ │ ├── 3.4 mcp_delete_source │ │ │ ├── MCPDeleteSourceClient.exe │ │ │ └── MCPDeleteSourceClient.go │ │ ├── 4.0 mcp_list_groups │ │ │ ├── MCPListGroupsClient.exe │ │ │ └── MCPListGroupsClient.go │ │ ├── 4.1 mcp_store_group │ │ │ ├── MCPStoreGroupClient.exe │ │ │ └── MCPStoreGroupClient.go │ │ ├── 4.2 mcp_delete_group │ │ │ ├── MCPDeleteGroupClient.exe │ │ │ └── MCPDeleteGroupClient.go │ │ ├── 5.0 mcp_store_user │ │ │ ├── MCPStoreUserClient.exe │ │ │ └── MCPStoreUserClient.go │ │ ├── 5.1 mcp_edit_user │ │ │ ├── MCPEditUserClient.exe │ │ │ └── MCPEditUserClient.go │ │ ├── 5.2 mcp_delete_user │ │ │ ├── MCPDeleteUserClient.exe │ │ │ └── MCPDeleteUserClient.go │ │ ├── 9.0 mcp_keygen │ │ │ ├── MCPKeygenClient.exe │ │ │ └── MCPKeygenClient.go │ │ └── README.md │ ├── Gradio │ │ ├── Api.py │ │ ├── config.json.example │ │ ├── config.py │ │ ├── favicon.ico │ │ ├── file_tools │ │ │ └── loader_factory.py │ │ ├── language.py │ │ ├── logos │ │ │ ├── fsas.png │ │ │ └── Logo_dark.svg │ │ ├── main.py │ │ ├── mcp_client.py │ │ ├── mcp_servers │ │ │ ├── arxiv │ │ │ │ ├── arxiv-stdio.js │ │ │ │ ├── package.json │ │ │ │ ├── README.md │ │ │ │ ├── requirements.txt │ │ │ │ └── server_config.example.json │ │ │ ├── demo-mcp-server │ │ │ │ ├── demo-tools-sse.js │ │ │ │ ├── demo-tools-stdio.js │ │ │ │ └── tools │ │ │ │ ├── assets.js │ │ │ │ ├── calculator.js │ │ │ │ └── weather.js │ │ │ ├── filesystem │ │ │ │ ├── Dockerfile │ │ │ │ ├── index.ts │ │ │ │ ├── package.json │ │ │ │ ├── README.md │ │ │ │ ├── test │ │ │ │ │ └── new.txt │ │ │ │ └── tsconfig.json │ │ │ ├── moondream │ │ │ │ └── server.py │ │ │ ├── pgpt │ │ │ │ ├── __init__.py │ │ │ │ ├── Api.py │ │ │ │ ├── config.json.example │ │ │ │ ├── config.py │ │ │ │ ├── language.py │ │ │ │ ├── pyproject.toml │ │ │ │ ├── README.md │ │ │ │ └── server.py │ │ │ ├── replicate_flux │ │ │ │ └── server.py │ │ │ └── sqlite │ │ │ ├── .python-version │ │ │ ├── Dockerfile │ │ │ ├── pyproject.toml │ │ │ ├── README.md │ │ │ └── src │ │ │ └── mcp_server_sqlite │ │ │ ├── __init__.py │ │ │ └── server.py │ │ ├── messages │ │ │ ├── __init__.py │ │ │ ├── message_types │ │ │ │ ├── __init__.py │ │ │ │ ├── incrementing_id_message.py │ │ │ │ ├── initialize_message.py │ │ │ │ ├── json_rpc_message.py │ │ │ │ ├── ping_message.py │ │ │ │ ├── prompts_messages.py │ │ │ │ ├── prompts_models.py │ │ │ │ ├── resources_messages.py │ │ │ │ └── tools_messages.py │ │ │ ├── send_call_tool.py │ │ │ ├── send_initialize_message.py │ │ │ ├── send_message.py │ │ │ ├── send_ping.py │ │ │ ├── send_prompts.py │ │ │ ├── send_resources.py │ │ │ └── send_tools_list.py │ │ ├── README.md │ │ ├── requirements.txt │ │ ├── server_config.json │ │ ├── SourceManagement.py │ │ ├── transport │ │ │ ├── __init__.py │ │ │ └── stdio │ │ │ ├── __init__.py │ │ │ ├── stdio_client.py │ │ │ ├── stdio_server_parameters.py │ │ │ └── stdio_server_shutdown.py │ │ ├── tsconfig.json │ │ └── UserManagement.py │ ├── Java │ │ ├── 1.0 mcp_login │ │ │ ├── json-20241224.jar │ │ │ ├── MCPLoginClient.class │ │ │ └── MCPLoginClient.java │ │ ├── 1.1 mcp_logout │ │ │ ├── json-20241224.jar │ │ │ ├── MCPLogoutClient.class │ │ │ └── MCPLogoutClient.java │ │ ├── 2.0 mcp_chat │ │ │ ├── json-20241224.jar │ │ │ ├── MCPChatClient.class │ │ │ └── MCPChatClient.java │ │ ├── 2.1 mcp_continue_chat │ │ │ ├── json-20241224.jar │ │ │ ├── MCPContinueChatClient.class │ │ │ └── MCPContinueChatClient.java │ │ ├── 2.2 mcp_get_chat_info │ │ │ ├── json-20241224.jar │ │ │ ├── MCPGetChatInfoClient.class │ │ │ └── MCPGetChatInfoClient.java │ │ ├── 3.0 mcp_create_source │ │ │ ├── json-20241224.jar │ │ │ ├── MCPCreateSourceClient.class │ │ │ └── MCPCreateSourceClient.java │ │ ├── 3.1 mcp_get_source │ │ │ ├── json-20241224.jar │ │ │ ├── MCPGetSourceClient.class │ │ │ └── MCPGetSourceClient.java │ │ ├── 3.2 mcp_list_sources │ │ │ ├── json-20241224.jar │ │ │ ├── MCPListSourcesClient.class │ │ │ └── MCPListSourcesClient.java │ │ ├── 3.3 mcp_edit_source │ │ │ ├── json-20241224.jar │ │ │ ├── MCPEditSourceClient.class │ │ │ └── MCPEditSourceClient.java │ │ ├── 3.4 mcp_delete_source │ │ │ ├── json-20241224.jar │ │ │ ├── MCPDeleteSourceClient.class │ │ │ └── MCPDeleteSourceClient.java │ │ ├── 4.0 mcp_list_groups │ │ │ ├── json-20241224.jar │ │ │ ├── MCPListGroupsClient.class │ │ │ └── MCPListGroupsClient.java │ │ ├── 4.1 mcp_store_group │ │ │ ├── json-20241224.jar │ │ │ ├── MCPStoreGroupClient.class │ │ │ └── MCPStoreGroupClient.java │ │ ├── 4.2 mcp_delete_group │ │ │ ├── json-20241224.jar │ │ │ ├── MCPDeleteGroupClient.class │ │ │ └── MCPDeleteGroupClient.java │ │ ├── 5.0 mcp_store_user │ │ │ ├── json-20241224.jar │ │ │ ├── MCPStoreUserClient.class │ │ │ └── MCPStoreUserClient.java │ │ ├── 5.1 mcp_edit_user │ │ │ ├── json-20241224.jar │ │ │ ├── MCPEditUserClient.class │ │ │ └── MCPEditUserClient.java │ │ ├── 5.2 mcp_delete_user │ │ │ ├── json-20241224.jar │ │ │ ├── MCPDeleteUserClient.class │ │ │ └── MCPDeleteUserClient.java │ │ └── README.md │ ├── JavaScript │ │ ├── 1.0 mcp_login │ │ │ └── MCPLoginClient.js │ │ ├── 1.1 mcp_logout │ │ │ └── MCPLogoutClient.js │ │ ├── 2.0 mcp_chat │ │ │ └── MCPChatClient.js │ │ ├── 2.1 mcp_continue_chat │ │ │ └── MCPContinueChatClient.js │ │ ├── 2.2 mcp_get_chat_info │ │ │ └── MCPGetChatInfoClient.js │ │ ├── 3.0 mcp_create_source │ │ │ └── MCPCreateSourceClient.js │ │ ├── 3.1 mcp_get_source │ │ │ └── MCPGetSourceClient.js │ │ ├── 3.2 mcp_list_sources │ │ │ └── MCPListSourcesClient.js │ │ ├── 3.3 mcp_edit_source │ │ │ └── MCPEditSourceClient.js │ │ ├── 3.4 mcp_delete_source │ │ │ └── MCPDeleteSourceClient.js │ │ ├── 4.0 mcp_list_groups │ │ │ └── MCPListGroupsClient.js │ │ ├── 4.1 mcp_store_group │ │ │ └── MCPStoreGroupClient.js │ │ ├── 4.2 mcp_delete_group │ │ │ └── MCPDeleteGroupClient.js │ │ ├── 5.0 mcp_store_user │ │ │ └── MCPStoreUserClient.js │ │ ├── 5.1 mcp_edit_user │ │ │ └── MCPEditUserClient.js │ │ ├── 5.2 mcp_delete_user │ │ │ └── MCPDeleteUserClient.js │ │ ├── 9.0 mcp_keygen │ │ │ └── MCPKeygenClient.js │ │ └── README.md │ ├── PHP │ │ ├── 1.0 mcp_login │ │ │ └── MCPLoginClient.php │ │ ├── 1.1 mcp_logout │ │ │ └── MCPLogoutClient.php │ │ ├── 2.0 mcp_chat │ │ │ └── MCPChatClient.php │ │ ├── 2.1 mcp_continue_chat │ │ │ └── MCPContinueChatClient.php │ │ ├── 2.2 mcp_get_chat_info │ │ │ └── MCPGetChatInfoClient.php │ │ ├── 3.0 mcp_create_source │ │ │ └── MCPCreateSourceClient.php │ │ ├── 3.1 mcp_get_source │ │ │ └── MCPGetSourceClient.php │ │ ├── 3.2 mcp_list_sources │ │ │ └── MCPListSourcesClient.php │ │ ├── 3.3 mcp_edit_source │ │ │ └── MCPEditSourceClient.php │ │ ├── 3.4 mcp_delete_source │ │ │ └── MCPDeleteSourceClient.php │ │ ├── 4.0 mcp_list_groups │ │ │ └── MCPListGroupsClient.php │ │ ├── 4.1 mcp_store_group │ │ │ └── MCPStoreGroupClient.php │ │ ├── 4.2 mcp_delete_group │ │ │ └── MCPDeleteGroupClient.php │ │ ├── 5.0 mcp_store_user │ │ │ └── MCPStoreUserClient.php │ │ ├── 5.1 mcp_edit_user │ │ │ └── MCPEditUserClient.php │ │ ├── 5.2 mcp_delete_user │ │ │ └── MCPDeleteUserClient.php │ │ ├── 9.0 mcp_keygen │ │ │ └── MCPKeygenClient.php │ │ └── README.md │ └── Python │ ├── __init__.py │ ├── 1.0 mcp_login │ │ └── MCPLoginClient.py │ ├── 1.1 mcp_logout │ │ └── MCPLogoutClient.py │ ├── 2.0 mcp_chat │ │ └── MCPChatClient.py │ ├── 2.1 mcp_continue_chat │ │ └── MCPContinueChatClient.py │ ├── 2.2 mcp_get_chat_info │ │ └── MCPGetChatInfoClient.py │ ├── 2.3 mcp_delete_all_chats │ │ └── MCPDeleteAllChatsClient.py │ ├── 2.4 mcp_delete_chat │ │ └── MCPDeleteChatClient.py │ ├── 3.0 mcp_create_source │ │ └── MCPCreateSourceClient.py │ ├── 3.1 mcp_get_source │ │ └── MCPGetSourceClient.py │ ├── 3.2 mcp_list_sources │ │ └── MCPListSourcesClient.py │ ├── 3.3 mcp_edit_source │ │ └── MCPEditSourceClient.py │ ├── 3.4 mcp_delete_source │ │ └── MCPDeleteSourceClient.py │ ├── 4.0 mcp_list_groups │ │ └── MCPListGroupsClient.py │ ├── 4.1 mcp_store_group │ │ └── MCPStoreGroupClient.py │ ├── 4.2 mcp_delete_group │ │ └── MCPDeleteGroupClient.py │ ├── 5.0 mcp_store_user │ │ └── MCPStoreUserClient.py │ ├── 5.1 mcp_edit_user │ │ └── MCPEditUserClient.py │ ├── 5.2 mcp_delete_user │ │ └── MCPDeleteUserClient.py │ ├── 9.0 mcp_keygen │ │ └── MCPKeygenClient.py │ ├── Gradio │ │ ├── __init__.py │ │ └── server_config.json │ └── README.md ├── examples │ ├── create_users_from_csv │ │ ├── config.json.example │ │ ├── config.py │ │ ├── create_users_from_csv.py │ │ └── language.py │ ├── dynamic_sources │ │ └── rss_reader │ │ ├── Api.py │ │ ├── config.json.example │ │ ├── config.py │ │ ├── demo_dynamic_sources.py │ │ └── rss_parser.py │ ├── example_users_to_add_no_tz.csv │ └── sftp_upload_with_id │ ├── Api.py │ ├── config_ftp.json.example │ ├── config.py │ ├── demo_upload.py │ ├── language.py │ └── requirements.txt ├── images │ ├── alternative mcp client.png │ ├── favicon │ │ ├── android-chrome-192x192.png │ │ ├── android-chrome-512x512.png │ │ ├── apple-touch-icon.png │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── favicon.ico │ │ └── site.webmanifest │ ├── mcp-general-architecture.png │ ├── privateGPT-MCP.png │ └── privateGPT.png ├── InstallMPCServer.sh ├── jest.config.js ├── LICENSE ├── package.json ├── pgpt.env.json.example ├── README.md ├── security │ ├── generate_decrypted_password.js │ └── generate_encrypted_password.js ├── src │ ├── helper.js │ ├── index.js │ ├── logger.js │ ├── pgpt-messages.js │ ├── public │ │ ├── index.html │ │ └── pgpt-mcp-logo.png │ ├── services │ │ └── pgpt-service.ts │ └── types │ └── api.ts ├── start_chatbot_agent.ps1 ├── start_chatbot_agent.sh ├── start_iot_agent.ps1 ├── start_iot_agent.sh ├── start_openai_compatible_api_agent.ps1 ├── start_openai_compatible_api_agent.sh ├── tsconfig.json ├── ver │ ├── index_np.js │ └── index_proxy_np.js └── WORKLOG.md ``` # Files -------------------------------------------------------------------------------- /clients/C# .Net/Code Archiv/mcp_edit_source.cs: -------------------------------------------------------------------------------- ```csharp 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net.Sockets; 5 | using System.Text; 6 | using Newtonsoft.Json; 7 | 8 | namespace MCPEditSourceClient 9 | { 10 | class Program 11 | { 12 | static void Main(string[] args) 13 | { 14 | // Parameterprüfung (mind. 8 Elemente, weil 4 Pflichtargumente: 15 | // --server-ip, --server-port, --token, --source-id) 16 | // plus optionale Argumente (--title, --content, --groups). 17 | if (args.Length < 8) 18 | { 19 | Console.WriteLine("Usage:"); 20 | Console.WriteLine(" --server-ip <IP> --server-port <PORT> --token <TOKEN> --source-id <SOURCE_ID>"); 21 | Console.WriteLine(" [--title <TITLE>] [--content <CONTENT>] [--groups <LIST_OF_GROUPS>]"); 22 | return; 23 | } 24 | 25 | // Argumente auslesen 26 | string serverIp = GetArgument(args, "--server-ip"); 27 | string portStr = GetArgument(args, "--server-port"); 28 | string token = GetArgument(args, "--token"); 29 | string sourceId = GetArgument(args, "--source-id"); 30 | string title = GetArgument(args, "--title"); 31 | string content = GetArgument(args, "--content"); 32 | List<string> groups = GetListArgument(args, "--groups"); 33 | 34 | if (serverIp == null || portStr == null || token == null || sourceId == null) 35 | { 36 | Console.WriteLine("Fehler: Mindestens eines der Pflichtargumente wurde nicht angegeben."); 37 | return; 38 | } 39 | 40 | if (!int.TryParse(portStr, out int serverPort)) 41 | { 42 | Console.WriteLine("Fehler: --server-port muss eine ganzzahlige Portangabe sein."); 43 | return; 44 | } 45 | 46 | // Anfrage an den Server senden 47 | string response = SendEditSourceRequest( 48 | serverIp, 49 | serverPort, 50 | token, 51 | sourceId, 52 | title, 53 | content, 54 | groups 55 | ); 56 | 57 | Console.WriteLine("Response from server:"); 58 | Console.WriteLine(response); 59 | } 60 | 61 | /// <summary> 62 | /// Sendet die Edit-Source-Anfrage an den MCP-Server. 63 | /// </summary> 64 | /// <param name="serverIp">IP-Adresse des MCP-Servers</param> 65 | /// <param name="serverPort">Port des MCP-Servers</param> 66 | /// <param name="token">Authentifizierungstoken</param> 67 | /// <param name="sourceId">ID der zu bearbeitenden Quelle</param> 68 | /// <param name="title">Neuer Titel der Quelle (optional)</param> 69 | /// <param name="content">Neuer Inhalt (Markdown) (optional)</param> 70 | /// <param name="groups">Liste der neuen Gruppen (optional)</param> 71 | /// <returns>String-Antwort des Servers oder Fehlermeldung</returns> 72 | static string SendEditSourceRequest( 73 | string serverIp, 74 | int serverPort, 75 | string token, 76 | string sourceId, 77 | string title = null, 78 | string content = null, 79 | List<string> groups = null) 80 | { 81 | // Payload zusammenbauen 82 | var arguments = new Dictionary<string, object> 83 | { 84 | { "sourceId", sourceId } 85 | }; 86 | 87 | // Nur hinzufügen, wenn nicht null 88 | if (!string.IsNullOrWhiteSpace(title)) 89 | arguments["title"] = title; 90 | 91 | if (!string.IsNullOrWhiteSpace(content)) 92 | arguments["content"] = content; 93 | 94 | // Falls keine Gruppen übergeben wurden, leere Liste setzen 95 | arguments["groups"] = groups ?? new List<string>(); 96 | 97 | // Payload-Objekt erstellen 98 | var payload = new 99 | { 100 | command = "edit_source", 101 | token = token, 102 | arguments 103 | }; 104 | 105 | // JSON serialisieren 106 | string payloadJson = JsonConvert.SerializeObject(payload); 107 | 108 | // Per TCP an den Server senden 109 | try 110 | { 111 | using (var client = new TcpClient(serverIp, serverPort)) 112 | using (NetworkStream stream = client.GetStream()) 113 | { 114 | // Senden 115 | byte[] data = Encoding.UTF8.GetBytes(payloadJson); 116 | stream.Write(data, 0, data.Length); 117 | 118 | // Antwort empfangen 119 | byte[] buffer = new byte[4096]; 120 | int bytesRead; 121 | StringBuilder responseBuilder = new StringBuilder(); 122 | 123 | do 124 | { 125 | bytesRead = stream.Read(buffer, 0, buffer.Length); 126 | responseBuilder.Append(Encoding.UTF8.GetString(buffer, 0, bytesRead)); 127 | } while (bytesRead == buffer.Length); 128 | 129 | return responseBuilder.ToString(); 130 | } 131 | } 132 | catch (Exception e) 133 | { 134 | return $"Error: {e.Message}"; 135 | } 136 | } 137 | 138 | /// <summary> 139 | /// Liest den Wert eines bestimmten Keys aus args aus (z.B. --server-ip 127.0.0.1). 140 | /// </summary> 141 | /// <param name="args">Alle Argumente</param> 142 | /// <param name="key">Gesuchter Key (z.B. "--server-ip")</param> 143 | /// <returns>Wert des Keys oder null</returns> 144 | static string GetArgument(string[] args, string key) 145 | { 146 | int index = Array.IndexOf(args, key); 147 | return index >= 0 && index < args.Length - 1 ? args[index + 1] : null; 148 | } 149 | 150 | /// <summary> 151 | /// Liest eine Liste an Werten aus, die auf den key folgen (z.B. --groups G1 G2 --irgendeinAndererKey ...). 152 | /// </summary> 153 | /// <param name="args">Alle Argumente</param> 154 | /// <param name="key">Gesuchter Key (z.B. "--groups")</param> 155 | /// <returns>Liste gefundener Werte oder eine leere Liste</returns> 156 | static List<string> GetListArgument(string[] args, string key) 157 | { 158 | var result = new List<string>(); 159 | int index = Array.IndexOf(args, key); 160 | if (index >= 0) 161 | { 162 | for (int i = index + 1; i < args.Length && !args[i].StartsWith("--"); i++) 163 | { 164 | result.Add(args[i]); 165 | } 166 | } 167 | return result; 168 | } 169 | } 170 | } 171 | ``` -------------------------------------------------------------------------------- /clients/Gradio/SourceManagement.py: -------------------------------------------------------------------------------- ```python 1 | import json 2 | import socket 3 | import ssl 4 | 5 | 6 | def delete_source(self, source_id, use_ssl=False, accept_self_signed=False): 7 | """ 8 | Sends a request to the MCP server to delete an existing source. 9 | 10 | :param server_ip: IP address of the MCP server 11 | :param server_port: Port number of the MCP server 12 | :param token: Authorization token 13 | :param source_id: ID of the source to delete 14 | :param use_ssl: Whether to use SSL/TLS for the connection 15 | :param accept_self_signed: Whether to accept self-signed certificates 16 | :return: Response from the server 17 | """ 18 | payload = { 19 | "command": "delete_source", 20 | "token": self.token, 21 | "arguments": { 22 | "sourceId": source_id 23 | } 24 | } 25 | 26 | payload_json = json.dumps(payload) 27 | 28 | raw_socket = None 29 | client_socket = None 30 | 31 | try: 32 | raw_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 33 | raw_socket.settimeout(10) 34 | 35 | if use_ssl: 36 | context = ssl.create_default_context() 37 | if accept_self_signed: 38 | context.check_hostname = False 39 | context.verify_mode = ssl.CERT_NONE 40 | client_socket = context.wrap_socket(raw_socket, server_hostname=self.server_ip) 41 | else: 42 | client_socket = raw_socket 43 | 44 | client_socket.connect((self.server_ip, self.server_port)) 45 | client_socket.sendall(payload_json.encode('utf-8')) 46 | 47 | response = b"" 48 | while True: 49 | part = client_socket.recv(4096) 50 | if not part: 51 | break 52 | response += part 53 | 54 | return response.decode('utf-8') 55 | except ssl.SSLError: 56 | return "Error: Server and/or client may require TLS encryption. Please enable SSL/TLS." 57 | except Exception as e: 58 | return f"Error: {e}" 59 | 60 | finally: 61 | if client_socket is not None: 62 | try: 63 | client_socket.shutdown(socket.SHUT_RDWR) 64 | except: 65 | pass 66 | client_socket.close() 67 | 68 | 69 | def send_list_sources_request(self, group_name, use_ssl=False, accept_self_signed=False): 70 | """ 71 | Sends a request to list sources in a specific group to the MCP server. 72 | 73 | :param server_ip: IP address of the MCP server 74 | :param server_port: Port number of the MCP server 75 | :param token: Authentication token 76 | :param group_name: Name of the group to list sources from 77 | :param use_ssl: Whether to use SSL/TLS for the connection 78 | :param accept_self_signed: Whether to accept self-signed certificates 79 | :return: Response from the server 80 | """ 81 | payload = { 82 | "command": "list_sources", 83 | "token": self.token, 84 | "attributes": { 85 | "groupName": group_name 86 | } 87 | } 88 | 89 | payload_json = json.dumps(payload) 90 | 91 | raw_socket = None 92 | client_socket = None 93 | 94 | try: 95 | raw_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 96 | raw_socket.settimeout(10) 97 | 98 | if use_ssl: 99 | context = ssl.create_default_context() 100 | if accept_self_signed: 101 | context.check_hostname = False 102 | context.verify_mode = ssl.CERT_NONE 103 | client_socket = context.wrap_socket(raw_socket, server_hostname=self.server_ip) 104 | else: 105 | client_socket = raw_socket 106 | 107 | client_socket.connect((self.server_ip, self.server_port)) 108 | client_socket.sendall(payload_json.encode('utf-8')) 109 | 110 | response = b"" 111 | while True: 112 | part = client_socket.recv(4096) 113 | if not part: 114 | break 115 | response += part 116 | 117 | return response.decode('utf-8') 118 | except ssl.SSLError: 119 | return "Error: Server and/or client may require TLS encryption. Please enable SSL/TLS." 120 | except Exception as e: 121 | return f"Error: {e}" 122 | 123 | finally: 124 | if client_socket is not None: 125 | try: 126 | client_socket.shutdown(socket.SHUT_RDWR) 127 | except: 128 | pass 129 | client_socket.close() 130 | 131 | 132 | def send_create_source_request(self, name, content, groups, use_ssl=False, 133 | accept_self_signed=False): 134 | """ 135 | Sends a request to create a new source to the MCP server. 136 | 137 | :param server_ip: IP address of the MCP server 138 | :param server_port: Port number of the MCP server 139 | :param token: Authentication token 140 | :param name: Name of the new source 141 | :param content: Content to be formatted as markdown 142 | :param groups: List of groups to assign the source to 143 | :param use_ssl: Whether to use SSL/TLS for the connection 144 | :param accept_self_signed: Whether to accept self-signed certificates 145 | :return: Response from the server 146 | """ 147 | payload = { 148 | "command": "create_source", 149 | "token": self.token, 150 | "arguments": { 151 | "name": name, 152 | "content": content, 153 | "groups": groups or [] 154 | } 155 | } 156 | 157 | # Convert the payload to a JSON string 158 | payload_json = json.dumps(payload) 159 | 160 | raw_socket = None 161 | client_socket = None 162 | 163 | try: 164 | # Create a socket object 165 | raw_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 166 | raw_socket.settimeout(10) 167 | 168 | # Establish SSL/TLS connection if required 169 | if use_ssl: 170 | context = ssl.create_default_context() 171 | if accept_self_signed: 172 | context.check_hostname = False 173 | context.verify_mode = ssl.CERT_NONE 174 | client_socket = context.wrap_socket(raw_socket, server_hostname=self.server_ip) 175 | else: 176 | client_socket = raw_socket 177 | 178 | # Connect to the server 179 | client_socket.connect((self.server_ip, self.server_port)) 180 | 181 | # Send the request 182 | client_socket.sendall(payload_json.encode('utf-8')) 183 | 184 | # Receive the response 185 | response = b"" 186 | while True: 187 | part = client_socket.recv(4096) 188 | if not part: 189 | break 190 | response += part 191 | 192 | # Decode the response 193 | return response.decode('utf-8') 194 | 195 | except ssl.SSLError: 196 | return "Error: Server and/or client may require TLS encryption. Please enable SSL/TLS." 197 | except Exception as e: 198 | return f"Error: {e}" 199 | 200 | finally: 201 | if client_socket is not None: 202 | try: 203 | client_socket.shutdown(socket.SHUT_RDWR) 204 | except: 205 | pass 206 | client_socket.close() ``` -------------------------------------------------------------------------------- /clients/Java/5.0 mcp_store_user/MCPStoreUserClient.java: -------------------------------------------------------------------------------- ```java 1 | import org.json.JSONArray; 2 | import org.json.JSONObject; 3 | 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.io.OutputStream; 7 | import java.net.Socket; 8 | import java.nio.charset.StandardCharsets; 9 | import java.util.ArrayList; 10 | import java.util.Arrays; 11 | import java.util.List; 12 | 13 | public class MCPStoreUserClient { 14 | 15 | public static void main(String[] args) { 16 | // Laut Original soll es mindestens 14 Strings geben, 17 | // also 7 Schlüssel-Wert-Paare. (z.B. --server-ip <IP> etc.) 18 | if (args.length < 14) { 19 | printUsage(); 20 | return; 21 | } 22 | 23 | // Argumente auslesen 24 | String serverIp = getArgument(args, "--server-ip"); 25 | String portStr = getArgument(args, "--server-port"); 26 | String token = getArgument(args, "--token"); 27 | String name = getArgument(args, "--name"); 28 | String email = getArgument(args, "--email"); 29 | String password = getArgument(args, "--password"); 30 | String language = getArgument(args, "--language"); 31 | String timezone = getArgument(args, "--timezone"); 32 | 33 | if (language == null) { 34 | language = "en"; // Standardwert laut Original 35 | } 36 | if (timezone == null) { 37 | timezone = "Europe/Berlin"; // Standardwert laut Original 38 | } 39 | 40 | List<String> roles = getListArgument(args, "--roles"); 41 | List<String> groups = getListArgument(args, "--groups"); 42 | 43 | // Flags 44 | boolean usePublic = Arrays.asList(args).contains("--usePublic"); 45 | boolean activateFtp= Arrays.asList(args).contains("--activateFtp"); 46 | 47 | // FTP-Passwort, falls angegeben 48 | String ftpPassword = getArgument(args, "--ftpPassword"); 49 | if (ftpPassword == null) { 50 | ftpPassword = ""; 51 | } 52 | 53 | // Falls kritische Argumente fehlen, Usage anzeigen 54 | if (serverIp == null || portStr == null || token == null 55 | || name == null || email == null || password == null) { 56 | printUsage(); 57 | return; 58 | } 59 | 60 | int serverPort = Integer.parseInt(portStr); 61 | 62 | System.out.println("📤 Sending store user request..."); 63 | 64 | // JSON-Payload erstellen 65 | JSONObject payload = new JSONObject(); 66 | payload.put("command", "store_user"); 67 | payload.put("token", token); 68 | 69 | JSONObject arguments = new JSONObject(); 70 | arguments.put("name", name); 71 | arguments.put("email", email); 72 | arguments.put("password", password); 73 | arguments.put("language", language); 74 | arguments.put("timezone", timezone); 75 | arguments.put("usePublic", usePublic); 76 | arguments.put("activateFtp", activateFtp); 77 | arguments.put("ftpPassword", ftpPassword); 78 | 79 | // roles & groups als JSON-Arrays 80 | JSONArray rolesArray = new JSONArray(roles); 81 | arguments.put("roles", rolesArray); 82 | 83 | JSONArray groupsArray = new JSONArray(groups); 84 | arguments.put("groups", groupsArray); 85 | 86 | payload.put("arguments", arguments); 87 | 88 | // Request versenden 89 | String response = sendRequest(serverIp, serverPort, payload); 90 | System.out.println("✔️ Response from server:"); 91 | System.out.println(response); 92 | } 93 | 94 | /** 95 | * Holt genau ein Argument (z.B. "--server-ip 127.0.0.1"). 96 | * Gibt null zurück, falls nicht vorhanden oder kein Wert folgt. 97 | */ 98 | private static String getArgument(String[] args, String key) { 99 | for (int i = 0; i < args.length - 1; i++) { 100 | if (args[i].equals(key)) { 101 | return args[i + 1]; 102 | } 103 | } 104 | return null; 105 | } 106 | 107 | /** 108 | * Ähnlich wie getArgument(), aber liest alle Werte ein, 109 | * bis das nächste "--" beginnt oder das Array zu Ende ist. 110 | */ 111 | private static List<String> getListArgument(String[] args, String key) { 112 | List<String> values = new ArrayList<>(); 113 | for (int i = 0; i < args.length; i++) { 114 | if (args[i].equals(key)) { 115 | // ab hier sammeln 116 | for (int j = i + 1; j < args.length; j++) { 117 | if (args[j].startsWith("--")) { 118 | break; 119 | } 120 | values.add(args[j]); 121 | } 122 | break; // Nur einmal sammeln 123 | } 124 | } 125 | return values; 126 | } 127 | 128 | /** 129 | * Stellt eine TCP-Verbindung her, sendet das JSON-Payload und liest die Antwort. 130 | */ 131 | private static String sendRequest(String serverIp, int serverPort, JSONObject payload) { 132 | String payloadJson = payload.toString(); 133 | 134 | try (Socket client = new Socket(serverIp, serverPort)) { 135 | // Payload senden 136 | OutputStream out = client.getOutputStream(); 137 | byte[] data = payloadJson.getBytes(StandardCharsets.UTF_8); 138 | out.write(data); 139 | out.flush(); 140 | 141 | // Antwort empfangen 142 | InputStream in = client.getInputStream(); 143 | byte[] buffer = new byte[4096]; 144 | StringBuilder responseBuilder = new StringBuilder(); 145 | int bytesRead; 146 | do { 147 | bytesRead = in.read(buffer); 148 | if (bytesRead > 0) { 149 | responseBuilder.append(new String(buffer, 0, bytesRead, StandardCharsets.UTF_8)); 150 | } 151 | } while (bytesRead == buffer.length); 152 | 153 | return responseBuilder.toString(); 154 | 155 | } catch (IOException e) { 156 | return "Error: " + e.getMessage(); 157 | } 158 | } 159 | 160 | private static void printUsage() { 161 | System.out.println("Usage: --server-ip <IP> --server-port <PORT> --token <TOKEN> --name <NAME> --email <EMAIL> --password <PASSWORD>"); 162 | System.out.println(" [--language <LANG>] [--timezone <TIMEZONE>] [--roles <ROLE1 ROLE2>] [--groups <GROUP1 GROUP2>]"); 163 | System.out.println(" [--usePublic] [--activateFtp] [--ftpPassword <FTP_PASSWORD>]"); 164 | System.out.println(); 165 | System.out.println("Example:"); 166 | System.out.println(" java -cp .;json-20241224.jar MCPStoreUserClient \\"); 167 | System.out.println(" --server-ip 127.0.0.1 --server-port 1234 --token MyToken \\"); 168 | System.out.println(" --name Max --email [email protected] --password 12345 \\"); 169 | System.out.println(" --language de --timezone Europe/Berlin \\"); 170 | System.out.println(" --roles admin manager --groups devops finance \\"); 171 | System.out.println(" --usePublic --activateFtp --ftpPassword someFtpPass"); 172 | } 173 | } 174 | ``` -------------------------------------------------------------------------------- /agents/MCP-Client/Python/tools_handler.py: -------------------------------------------------------------------------------- ```python 1 | import json 2 | import logging 3 | import re 4 | from typing import Any, Dict, Optional 5 | from .messages.send_call_tool import send_call_tool 6 | from .messages.send_tools_list import send_tools_list 7 | 8 | 9 | def parse_tool_response(response: str) -> Optional[Dict[str, Any]]: 10 | """Parse tool call from Llama's XML-style format.""" 11 | function_regex = r"<function=(\w+)>(.*?)</function>" 12 | match = re.search(function_regex, response) 13 | 14 | if match: 15 | function_name, args_string = match.groups() 16 | try: 17 | args = json.loads(args_string) 18 | return { 19 | "id": f"call_{function_name}", 20 | "function": function_name, 21 | "arguments": args, 22 | } 23 | except json.JSONDecodeError as error: 24 | logging.debug(f"Error parsing function arguments: {error}") 25 | return None 26 | 27 | 28 | async def handle_tool_call(tool_call, conversation_history, server_streams): 29 | """ 30 | Handle a single tool call for both OpenAI and Llama formats. 31 | This function no longer prints directly to stdout. It updates the conversation_history 32 | with the tool call and its response. The calling function can then display the results. 33 | """ 34 | tool_call_id = None 35 | tool_name = "unknown_tool" 36 | raw_arguments = {} 37 | 38 | 39 | try: 40 | # Handle object-style tool calls from both OpenAI and Ollama 41 | if hasattr(tool_call, "function") or ( 42 | isinstance(tool_call, dict) and "function" in tool_call 43 | ): 44 | # Get tool name and arguments based on format 45 | if hasattr(tool_call, "function"): 46 | tool_call_id = tool_call.id 47 | tool_name = tool_call.function.name 48 | raw_arguments = tool_call.function.arguments 49 | else: 50 | tool_call_id = tool_call["id"] 51 | tool_name = tool_call["function"]["name"] 52 | raw_arguments = tool_call["function"]["arguments"] 53 | else: 54 | # Parse Llama's XML format from the last message 55 | last_message = conversation_history[-1]["content"] 56 | parsed_tool = parse_tool_response(last_message) 57 | if not parsed_tool: 58 | logging.debug("Unable to parse tool call from message") 59 | return 60 | 61 | tool_call_id = parsed_tool["id"] 62 | tool_name = parsed_tool["function"] 63 | raw_arguments = parsed_tool["arguments"] 64 | 65 | # Parse the tool arguments 66 | tool_args = ( 67 | json.loads(raw_arguments) 68 | if isinstance(raw_arguments, str) 69 | else raw_arguments 70 | ) 71 | 72 | # Call the tool (no direct print here) 73 | tool_response = {} 74 | for read_stream, write_stream in server_streams: 75 | 76 | tools = await fetch_tools(read_stream, write_stream) 77 | server_has_tool = False 78 | for tool in tools: 79 | if tool["name"] == tool_name: 80 | server_has_tool = True 81 | if server_has_tool: 82 | tool_response = await send_call_tool( 83 | tool_name, tool_args, read_stream, write_stream 84 | ) 85 | 86 | if not tool_response.get("isError"): 87 | break 88 | else: 89 | continue 90 | 91 | if tool_response.get("isError"): 92 | logging.debug( 93 | f"Error calling tool '{tool_name}': {tool_response.get('content')}" 94 | ) 95 | 96 | # Format the tool response 97 | formatted_response = format_tool_response(tool_response.get("content", [])) 98 | logging.debug(f"Tool '{tool_name}' Response: {formatted_response}") 99 | if formatted_response == "": 100 | print(f"Warning Tool '{tool_name}' Response: {formatted_response}") 101 | #print(f"Tool '{tool_name}' Response: {formatted_response}") 102 | # Update the conversation history with the tool call 103 | # Add the tool call itself (for OpenAI tracking) 104 | 105 | 106 | conversation_history.append( 107 | { 108 | "role": "assistant", 109 | "content": None, 110 | "tool_calls": [ 111 | { 112 | "id": tool_call_id, 113 | "type": "function", 114 | "function": { 115 | "name": tool_name, 116 | "arguments": json.dumps(tool_args) 117 | if isinstance(tool_args, dict) 118 | else tool_args, 119 | }, 120 | } 121 | ], 122 | } 123 | ) 124 | 125 | # Add the tool response to conversation history 126 | conversation_history.append( 127 | { 128 | "role": "tool", 129 | "name": tool_name, 130 | "content": str(formatted_response), 131 | "tool_call_id": tool_call_id, 132 | } 133 | ) 134 | 135 | except json.JSONDecodeError: 136 | logging.debug( 137 | f"Error decoding arguments for tool '{tool_name}': {raw_arguments}" 138 | ) 139 | except Exception as e: 140 | logging.debug(f"Error handling tool call '{tool_name}': {str(e)}") 141 | 142 | 143 | def format_tool_response(response_content): 144 | """Format the response content from a tool.""" 145 | if isinstance(response_content, list): 146 | return "\n".join( 147 | item.get("text", "No content") 148 | for item in response_content 149 | if item.get("type") == "text" 150 | ) 151 | return str(response_content) 152 | 153 | 154 | async def fetch_tools(read_stream, write_stream): 155 | """Fetch tools from the server.""" 156 | logging.debug("\nFetching tools for chat mode...") 157 | 158 | # get the tools list 159 | tools_response = await send_tools_list(read_stream, write_stream) 160 | tools = tools_response.get("tools", []) 161 | 162 | # check if tools are valid 163 | if not isinstance(tools, list) or not all(isinstance(tool, dict) for tool in tools): 164 | logging.debug("Invalid tools format received.") 165 | return None 166 | 167 | return tools 168 | 169 | 170 | def convert_to_openai_tools(tools): 171 | """Convert tools into OpenAI-compatible function definitions.""" 172 | openai_tools = [] 173 | for tool in tools: 174 | # TODO. This works around the mcp-remote library putting the input scheme into another objet 175 | if tool.get("inputSchema", {}).get("properties").get("type") == "object": 176 | inputScheme = tool.get("inputSchema", {}).get("properties") 177 | else: 178 | inputScheme = tool.get("inputSchema", {}) 179 | 180 | entry = { 181 | "type": "function", 182 | "function": { 183 | "name": tool["name"], 184 | "description": tool.get("description", ""), 185 | "parameters": inputScheme 186 | }, 187 | } 188 | 189 | 190 | openai_tools.append(entry) 191 | 192 | return openai_tools 193 | ``` -------------------------------------------------------------------------------- /clients/Java/5.1 mcp_edit_user/MCPEditUserClient.java: -------------------------------------------------------------------------------- ```java 1 | import org.json.JSONObject; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.InputStreamReader; 5 | import java.io.OutputStream; 6 | import java.net.Socket; 7 | import java.nio.charset.StandardCharsets; 8 | import java.util.*; 9 | 10 | public class MCPEditUserClient { 11 | public static void main(String[] args) { 12 | // Kurze Validierung der Argumente 13 | if (args.length < 8) { 14 | System.out.println("Usage: " + 15 | "--server-ip <IP> " + 16 | "--server-port <PORT> " + 17 | "--token <TOKEN> " + 18 | "--user-id <USER_ID> [weitere optionale Parameter]"); 19 | return; 20 | } 21 | 22 | // Argumente auslesen 23 | String serverIp = getArgument(args, "--server-ip"); 24 | String portString = getArgument(args, "--server-port"); 25 | if (serverIp == null || portString == null) { 26 | System.err.println("Server-IP oder Server-Port fehlt!"); 27 | return; 28 | } 29 | int serverPort = Integer.parseInt(portString); 30 | String token = getArgument(args, "--token"); 31 | String userId = getArgument(args, "--user-id"); 32 | 33 | // Optional 34 | String name = getArgument(args, "--name"); 35 | String email = getArgument(args, "--email"); 36 | String password = getArgument(args, "--password"); 37 | String language = getArgument(args, "--language"); 38 | String timezone = getArgument(args, "--timezone"); 39 | 40 | List<String> roles = getListArgument(args, "--roles"); 41 | List<String> groups = getListArgument(args, "--groups"); 42 | 43 | boolean usePublic = Arrays.asList(args).contains("--usePublic"); 44 | boolean activateFtp = Arrays.asList(args).contains("--activateFtp"); 45 | String ftpPassword = getArgument(args, "--ftpPassword"); 46 | 47 | // Argumente in eine Map packen 48 | Map<String, Object> argumentsMap = new HashMap<>(); 49 | argumentsMap.put("userId", userId); 50 | argumentsMap.put("name", name); 51 | argumentsMap.put("email", email); 52 | argumentsMap.put("password", password); 53 | argumentsMap.put("language", language); 54 | argumentsMap.put("timezone", timezone); 55 | argumentsMap.put("roles", roles); 56 | argumentsMap.put("groups", groups); 57 | argumentsMap.put("usePublic", usePublic); 58 | argumentsMap.put("activateFtp", activateFtp); 59 | argumentsMap.put("ftpPassword", ftpPassword); 60 | 61 | // Null oder leere Strings entfernen 62 | argumentsMap = removeNullOrEmpty(argumentsMap); 63 | 64 | // JSON-Payload zusammenstellen 65 | JSONObject payload = new JSONObject(); 66 | payload.put("command", "edit_user"); 67 | payload.put("token", token); 68 | payload.put("arguments", argumentsMap); 69 | 70 | System.out.println("📤 Sending edit user request..."); 71 | String response = sendRequest(serverIp, serverPort, payload.toString()); 72 | System.out.println("✔️ Response from server:"); 73 | System.out.println(response); 74 | } 75 | 76 | /** 77 | * Liest den Wert eines bestimmten Parameters aus dem Argument-Array. 78 | * Bsp.: "--server-ip" -> "127.0.0.1" 79 | * 80 | * @param args Array mit allen Argumenten 81 | * @param key Name des Arguments, nach dem gesucht wird (z.B. "--server-ip") 82 | * @return Wert des Arguments oder null, falls nicht gefunden 83 | */ 84 | private static String getArgument(String[] args, String key) { 85 | for (int i = 0; i < args.length; i++) { 86 | if (args[i].equals(key) && i < args.length - 1) { 87 | return args[i + 1]; 88 | } 89 | } 90 | return null; 91 | } 92 | 93 | /** 94 | * Liest mehrere Werte für einen Argument-Schlüssel (z.B. "--roles") aus, 95 | * bis ein neues Argument mit "--" beginnt. 96 | * 97 | * @param args Array mit allen Argumenten 98 | * @param key Name des Arguments, nach dem gesucht wird (z.B. "--roles") 99 | * @return Liste der gefundenen Werte, sonst eine leere Liste 100 | */ 101 | private static List<String> getListArgument(String[] args, String key) { 102 | List<String> values = new ArrayList<>(); 103 | for (int i = 0; i < args.length; i++) { 104 | if (args[i].equals(key)) { 105 | // Sammle solange, bis ein neues "--" beginnt oder args zu Ende 106 | for (int j = i + 1; j < args.length && !args[j].startsWith("--"); j++) { 107 | values.add(args[j]); 108 | } 109 | break; 110 | } 111 | } 112 | return values; 113 | } 114 | 115 | /** 116 | * Entfernt alle Einträge, deren Wert null oder ein leerer String ist. 117 | */ 118 | private static Map<String, Object> removeNullOrEmpty(Map<String, Object> original) { 119 | Map<String, Object> cleaned = new HashMap<>(); 120 | for (Map.Entry<String, Object> entry : original.entrySet()) { 121 | Object value = entry.getValue(); 122 | if (value != null) { 123 | // Wenn String, checke ob leer oder nur Whitespace 124 | if (value instanceof String) { 125 | String str = (String) value; 126 | if (!str.trim().isEmpty()) { 127 | cleaned.put(entry.getKey(), value); 128 | } 129 | } else { 130 | // Keine weitere Prüfung für Listen, Booleans, etc. 131 | cleaned.put(entry.getKey(), value); 132 | } 133 | } 134 | } 135 | return cleaned; 136 | } 137 | 138 | /** 139 | * Sendet den gegebenen JSON-String per TCP an den Server und empfängt die Antwort. 140 | * 141 | * @param serverIp IP des Servers 142 | * @param serverPort Port des Servers 143 | * @param payload JSON-String 144 | * @return Antwort als String oder Fehlermeldung 145 | */ 146 | private static String sendRequest(String serverIp, int serverPort, String payload) { 147 | try (Socket socket = new Socket(serverIp, serverPort)) { 148 | // Daten zum Server senden 149 | OutputStream output = socket.getOutputStream(); 150 | byte[] data = payload.getBytes(StandardCharsets.UTF_8); 151 | output.write(data); 152 | output.flush(); 153 | 154 | // Antwort lesen 155 | BufferedReader reader = new BufferedReader( 156 | new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8) 157 | ); 158 | StringBuilder sb = new StringBuilder(); 159 | char[] buffer = new char[4096]; 160 | int charsRead; 161 | do { 162 | charsRead = reader.read(buffer, 0, buffer.length); 163 | if (charsRead > 0) { 164 | sb.append(buffer, 0, charsRead); 165 | } 166 | } while (charsRead == buffer.length); 167 | 168 | return sb.toString(); 169 | 170 | } catch (Exception e) { 171 | return "Error: " + e.getMessage(); 172 | } 173 | } 174 | } 175 | ``` -------------------------------------------------------------------------------- /clients/PHP/2.0 mcp_chat/MCPChatClient.php: -------------------------------------------------------------------------------- ```php 1 | <?php 2 | /** 3 | * MCPChatClient.php 4 | * 5 | * A PHP script that acts as a chat client. It connects to a server via TCP, 6 | * sends a chat request, and receives the server's response. 7 | * 8 | * Usage: 9 | * php MCPChatClient.php --server-ip <IP> --server-port <Port> --token <Token> --question <Question> [--use-public] [--groups <Group1> <Group2> ...] [--language <Language>] 10 | */ 11 | 12 | // Functions for parsing command line arguments 13 | function parseArguments($args) { 14 | $parsedArgs = []; 15 | $argc = count($args); 16 | for ($i = 1; $i < $argc; $i++) { 17 | switch ($args[$i]) { 18 | case '--server-ip': 19 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 20 | $parsedArgs['serverIp'] = $args[++$i]; 21 | } else { 22 | fwrite(STDERR, "Error: --server-ip expects a value.\n"); 23 | exit(1); 24 | } 25 | break; 26 | case '--server-port': 27 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 28 | $parsedArgs['serverPort'] = intval($args[++$i]); 29 | } else { 30 | fwrite(STDERR, "Error: --server-port expects a value.\n"); 31 | exit(1); 32 | } 33 | break; 34 | case '--token': 35 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 36 | $parsedArgs['token'] = $args[++$i]; 37 | } else { 38 | fwrite(STDERR, "Error: --token expects a value.\n"); 39 | exit(1); 40 | } 41 | break; 42 | case '--question': 43 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 44 | $parsedArgs['question'] = $args[++$i]; 45 | } else { 46 | fwrite(STDERR, "Error: --question expects a value.\n"); 47 | exit(1); 48 | } 49 | break; 50 | case '--use-public': 51 | $parsedArgs['usePublic'] = true; 52 | break; 53 | case '--groups': 54 | // Collect all group arguments until the next flag or end 55 | $parsedArgs['groups'] = []; 56 | while ($i + 1 < $argc && !startsWith($args[$i + 1], '--')) { 57 | $parsedArgs['groups'][] = $args[++$i]; 58 | } 59 | break; 60 | case '--language': 61 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 62 | $parsedArgs['language'] = $args[++$i]; 63 | } else { 64 | fwrite(STDERR, "Error: --language expects a value.\n"); 65 | exit(1); 66 | } 67 | break; 68 | default: 69 | fwrite(STDERR, "Warning: Unknown argument: {$args[$i]}\n"); 70 | } 71 | } 72 | return $parsedArgs; 73 | } 74 | 75 | // Helper function to check if a string starts with a specific prefix 76 | function startsWith($string, $prefix) { 77 | return substr($string, 0, strlen($prefix)) === $prefix; 78 | } 79 | 80 | // Function for interactively prompting a parameter (optional) 81 | function askQuestionPrompt($prompt) { 82 | if (preg_match('/^win/i', PHP_OS)) { 83 | // Windows-specific input prompt 84 | $vbscript = sys_get_temp_dir() . 'prompt_input.vbs'; 85 | file_put_contents($vbscript, 'wscript.echo(InputBox("' . addslashes($prompt) . '", "", ""))'); 86 | $response = shell_exec("cscript //nologo " . escapeshellarg($vbscript)); 87 | unlink($vbscript); 88 | return trim($response); 89 | } else { 90 | // Unix/Linux input prompt 91 | echo $prompt; 92 | $handle = fopen("php://stdin", "r"); 93 | $response = trim(fgets($handle)); 94 | fclose($handle); 95 | return $response; 96 | } 97 | } 98 | 99 | // Function to send a chat request over a TCP connection 100 | function sendChatRequest($serverIp, $serverPort, $payload) { 101 | $jsonPayload = json_encode($payload); 102 | if ($jsonPayload === false) { 103 | throw new Exception("Error encoding JSON payload."); 104 | } 105 | 106 | $errno = 0; 107 | $errstr = ''; 108 | $timeout = 30; // seconds 109 | $client = @fsockopen($serverIp, $serverPort, $errno, $errstr, $timeout); 110 | 111 | if (!$client) { 112 | throw new Exception("Connection error: $errstr ($errno)"); 113 | } 114 | 115 | echo "🔗 Connection to server established.\n"; 116 | echo "📤 Sending payload: $jsonPayload\n"; 117 | 118 | fwrite($client, $jsonPayload); 119 | 120 | $responseData = ''; 121 | stream_set_timeout($client, $timeout); 122 | 123 | while (!feof($client)) { 124 | $data = fread($client, 1024); 125 | if ($data === false) { 126 | throw new Exception("Error reading data from server."); 127 | } 128 | if ($data === '') { 129 | break; // No more data 130 | } 131 | echo "📥 Received data: $data\n"; 132 | $responseData .= $data; 133 | 134 | // Attempt to parse the received data as JSON 135 | $parsedData = json_decode($responseData, true); 136 | if ($parsedData !== null) { 137 | echo "✅ JSON response successfully parsed.\n"; 138 | fclose($client); 139 | return $parsedData; 140 | } 141 | 142 | // Check if the stream timed out 143 | $info = stream_get_meta_data($client); 144 | if ($info['timed_out']) { 145 | throw new Exception("Timeout waiting for data from server."); 146 | } 147 | } 148 | 149 | fclose($client); 150 | throw new Exception("Connection to the server was closed before a complete response was received."); 151 | } 152 | 153 | // Main function 154 | function main($argv) { 155 | $args = parseArguments($argv); 156 | $serverIp = $args['serverIp'] ?? null; 157 | $serverPort = $args['serverPort'] ?? null; 158 | $token = $args['token'] ?? null; 159 | $question = $args['question'] ?? null; 160 | $usePublic = $args['usePublic'] ?? false; 161 | $groups = $args['groups'] ?? []; 162 | $language = $args['language'] ?? 'en'; // Default to English 163 | 164 | // Check if all required parameters are present 165 | if (!$serverIp || !$serverPort || !$token || !$question) { 166 | fwrite(STDERR, "❌ ERROR: Missing required parameters.\n"); 167 | fwrite(STDOUT, "Usage: php MCPChatClient.php --server-ip <IP> --server-port <Port> --token <Token> --question <Question> [--use-public] [--groups <Group1> <Group2> ...] [--language <Language>]\n"); 168 | exit(1); 169 | } 170 | 171 | $payload = [ 172 | "command" => "chat", 173 | "token" => $token, 174 | "arguments" => [ 175 | "question" => $question, 176 | "usePublic" => $usePublic, 177 | "groups" => $groups, 178 | "language" => $language 179 | ] 180 | ]; 181 | 182 | try { 183 | echo "💬 Sending chat request...\n"; 184 | $response = sendChatRequest($serverIp, $serverPort, $payload); 185 | echo "✅ Server Response:\n"; 186 | echo json_encode($response, JSON_PRETTY_PRINT) . "\n"; 187 | } catch (Exception $e) { 188 | fwrite(STDERR, "❌ ERROR: " . $e->getMessage() . "\n"); 189 | } 190 | } 191 | 192 | main($argv); 193 | ?> 194 | ``` -------------------------------------------------------------------------------- /agents/AgentMonitoring/ChatBot-Agent Dashboard Example - Grafana.json: -------------------------------------------------------------------------------- ```json 1 | { 2 | "annotations": { 3 | "list": [ 4 | { 5 | "builtIn": 1, 6 | "datasource": { 7 | "type": "grafana", 8 | "uid": "-- Grafana --" 9 | }, 10 | "enable": true, 11 | "hide": true, 12 | "iconColor": "rgba(0, 211, 255, 1)", 13 | "name": "Annotations & Alerts", 14 | "type": "dashboard" 15 | } 16 | ] 17 | }, 18 | "editable": true, 19 | "fiscalYearStartMonth": 0, 20 | "graphTooltip": 0, 21 | "id": 3, 22 | "links": [], 23 | "panels": [ 24 | { 25 | "datasource": { 26 | "type": "prometheus", 27 | "uid": "ceej3ydtls1kwb" 28 | }, 29 | "fieldConfig": { 30 | "defaults": { 31 | "color": { 32 | "mode": "palette-classic" 33 | }, 34 | "custom": { 35 | "axisBorderShow": false, 36 | "axisCenteredZero": false, 37 | "axisColorMode": "text", 38 | "axisLabel": "", 39 | "axisPlacement": "auto", 40 | "barAlignment": 0, 41 | "barWidthFactor": 0.6, 42 | "drawStyle": "line", 43 | "fillOpacity": 0, 44 | "gradientMode": "none", 45 | "hideFrom": { 46 | "legend": false, 47 | "tooltip": false, 48 | "viz": false 49 | }, 50 | "insertNulls": false, 51 | "lineInterpolation": "linear", 52 | "lineWidth": 1, 53 | "pointSize": 5, 54 | "scaleDistribution": { 55 | "type": "linear" 56 | }, 57 | "showPoints": "auto", 58 | "spanNulls": false, 59 | "stacking": { 60 | "group": "A", 61 | "mode": "none" 62 | }, 63 | "thresholdsStyle": { 64 | "mode": "off" 65 | } 66 | }, 67 | "mappings": [], 68 | "thresholds": { 69 | "mode": "absolute", 70 | "steps": [ 71 | { 72 | "color": "green", 73 | "value": null 74 | }, 75 | { 76 | "color": "red", 77 | "value": 80 78 | } 79 | ] 80 | }, 81 | "unit": "req/s" 82 | }, 83 | "overrides": [] 84 | }, 85 | "gridPos": { 86 | "h": 8, 87 | "w": 12, 88 | "x": 0, 89 | "y": 0 90 | }, 91 | "id": 1, 92 | "options": { 93 | "legend": { 94 | "calcs": [], 95 | "displayMode": "list", 96 | "placement": "bottom", 97 | "showLegend": true 98 | }, 99 | "tooltip": { 100 | "hideZeros": false, 101 | "mode": "single", 102 | "sort": "none" 103 | } 104 | }, 105 | "pluginVersion": "11.5.2", 106 | "targets": [ 107 | { 108 | "datasource": "prometheus", 109 | "editorMode": "code", 110 | "expr": "request_count_total{}", 111 | "interval": "", 112 | "legendFormat": "{{method}} {{endpoint}}", 113 | "range": true, 114 | "refId": "A" 115 | } 116 | ], 117 | "title": "Request Count (rate)", 118 | "type": "timeseries" 119 | }, 120 | { 121 | "fieldConfig": { 122 | "defaults": { 123 | "color": { 124 | "mode": "palette-classic" 125 | }, 126 | "custom": { 127 | "axisBorderShow": false, 128 | "axisCenteredZero": false, 129 | "axisColorMode": "text", 130 | "axisLabel": "", 131 | "axisPlacement": "auto", 132 | "barAlignment": 0, 133 | "barWidthFactor": 0.6, 134 | "drawStyle": "line", 135 | "fillOpacity": 0, 136 | "gradientMode": "none", 137 | "hideFrom": { 138 | "legend": false, 139 | "tooltip": false, 140 | "viz": false 141 | }, 142 | "insertNulls": false, 143 | "lineInterpolation": "linear", 144 | "lineWidth": 1, 145 | "pointSize": 5, 146 | "scaleDistribution": { 147 | "type": "linear" 148 | }, 149 | "showPoints": "auto", 150 | "spanNulls": false, 151 | "stacking": { 152 | "group": "A", 153 | "mode": "none" 154 | }, 155 | "thresholdsStyle": { 156 | "mode": "off" 157 | } 158 | }, 159 | "mappings": [], 160 | "thresholds": { 161 | "mode": "absolute", 162 | "steps": [ 163 | { 164 | "color": "green", 165 | "value": null 166 | }, 167 | { 168 | "color": "red", 169 | "value": 80 170 | } 171 | ] 172 | }, 173 | "unit": "s" 174 | }, 175 | "overrides": [] 176 | }, 177 | "gridPos": { 178 | "h": 8, 179 | "w": 12, 180 | "x": 12, 181 | "y": 0 182 | }, 183 | "id": 2, 184 | "options": { 185 | "legend": { 186 | "calcs": [], 187 | "displayMode": "list", 188 | "placement": "bottom", 189 | "showLegend": true 190 | }, 191 | "tooltip": { 192 | "hideZeros": false, 193 | "mode": "single", 194 | "sort": "none" 195 | } 196 | }, 197 | "pluginVersion": "11.5.2", 198 | "targets": [ 199 | { 200 | "datasource": "prometheus", 201 | "editorMode": "code", 202 | "expr": "histogram_quantile(0.95, sum(rate(request_latency_seconds_bucket[1m])) by (le, method, endpoint))", 203 | "legendFormat": "p95 latency: {{method}} {{endpoint}}", 204 | "refId": "A" 205 | } 206 | ], 207 | "title": "Request Latency (p95)", 208 | "type": "timeseries" 209 | }, 210 | { 211 | "datasource": { 212 | "type": "prometheus", 213 | "uid": "ceej3ydtls1kwb" 214 | }, 215 | "fieldConfig": { 216 | "defaults": { 217 | "mappings": [], 218 | "thresholds": { 219 | "mode": "absolute", 220 | "steps": [ 221 | { 222 | "color": "green", 223 | "value": null 224 | }, 225 | { 226 | "color": "red", 227 | "value": 80 228 | } 229 | ] 230 | }, 231 | "unit": "none" 232 | }, 233 | "overrides": [] 234 | }, 235 | "gridPos": { 236 | "h": 6, 237 | "w": 6, 238 | "x": 0, 239 | "y": 8 240 | }, 241 | "id": 3, 242 | "options": { 243 | "colorMode": "value", 244 | "graphMode": "none", 245 | "justifyMode": "center", 246 | "orientation": "auto", 247 | "percentChangeColorMode": "standard", 248 | "reduceOptions": { 249 | "calcs": [ 250 | "lastNotNull" 251 | ], 252 | "fields": "", 253 | "values": false 254 | }, 255 | "showPercentChange": false, 256 | "textMode": "auto", 257 | "wideLayout": true 258 | }, 259 | "pluginVersion": "11.5.2", 260 | "targets": [ 261 | { 262 | "datasource": "prometheus", 263 | "editorMode": "code", 264 | "expr": "agent_ask_count_total{}", 265 | "range": true, 266 | "refId": "A" 267 | } 268 | ], 269 | "title": "ASK Count", 270 | "type": "stat" 271 | } 272 | ], 273 | "preload": false, 274 | "refresh": "5s", 275 | "schemaVersion": 40, 276 | "tags": [ 277 | "PrivateGPT", 278 | "Prometheus", 279 | "Flask" 280 | ], 281 | "templating": { 282 | "list": [] 283 | }, 284 | "time": { 285 | "from": "now-15m", 286 | "to": "now" 287 | }, 288 | "timepicker": {}, 289 | "timezone": "", 290 | "title": "PrivateGPT Chatbot Monitoring", 291 | "uid": "aeej7wr8gcwlcd", 292 | "version": 5, 293 | "weekStart": "" 294 | } ``` -------------------------------------------------------------------------------- /agents/MCP-Client/Python/chat_handler.py: -------------------------------------------------------------------------------- ```python 1 | # chat_handler.py 2 | import json 3 | import asyncio 4 | 5 | from rich import print 6 | from rich.markdown import Markdown 7 | from rich.panel import Panel 8 | from rich.prompt import Prompt 9 | 10 | from .llm_client import LLMClient 11 | from .system_prompt_generator import SystemPromptGenerator 12 | from .tools_handler import convert_to_openai_tools, fetch_tools, handle_tool_call 13 | 14 | async def get_input(prompt: str): 15 | """Get input asynchronously.""" 16 | loop = asyncio.get_event_loop() 17 | return await loop.run_in_executor(None, lambda: Prompt.ask(prompt).strip()) 18 | 19 | async def handle_chat_mode(server_streams, provider="openai", model="gpt-4o-mini"): 20 | """Enter chat mode with multi-call support for autonomous tool chaining.""" 21 | try: 22 | tools = [] 23 | for read_stream, write_stream in server_streams: 24 | tools.extend(await fetch_tools(read_stream, write_stream)) 25 | 26 | # for (read_stream, write_stream) in server_streams: 27 | # tools = await fetch_tools(read_stream, write_stream) 28 | if not tools: 29 | print("[red]No tools available. Exiting chat mode.[/red]") 30 | return 31 | 32 | system_prompt = generate_system_prompt(tools) 33 | openai_tools = convert_to_openai_tools(tools) 34 | #print(openai_tools) 35 | client = LLMClient(provider=provider, model=model) 36 | conversation_history = [{"role": "system", "content": system_prompt}] 37 | 38 | while True: 39 | try: 40 | # Change prompt to yellow 41 | user_message = await get_input("[bold yellow]>[/bold yellow]") 42 | if user_message.lower() in ["exit", "quit"]: 43 | print(Panel("Exiting chat mode.", style="bold red")) 44 | break 45 | 46 | # User panel in bold yellow 47 | user_panel_text = user_message if user_message else "[No Message]" 48 | print(Panel(user_panel_text, style="bold yellow", title="You")) 49 | 50 | conversation_history.append({"role": "user", "content": user_message}) 51 | await process_conversation( 52 | client, conversation_history, openai_tools, server_streams 53 | ) 54 | 55 | except Exception as e: 56 | print(f"[red]Error processing message:[/red] {e}") 57 | continue 58 | except Exception as e: 59 | print(f"[red]Error in chat mode:[/red] {e}") 60 | 61 | 62 | async def process_conversation( 63 | client, conversation_history, openai_tools, server_streams 64 | ): 65 | """Process the conversation loop, handling tool calls and responses.""" 66 | while True: 67 | completion = client.create_completion( 68 | messages=conversation_history, 69 | tools=openai_tools, 70 | ) 71 | 72 | response_content = completion.get("response", "No response") 73 | tool_calls = completion.get("tool_calls", []) 74 | 75 | if tool_calls: 76 | for tool_call in tool_calls: 77 | # Extract tool_name and raw_arguments as before 78 | if hasattr(tool_call, "function"): 79 | print(tool_call.function) 80 | tool_name = getattr(tool_call.function, "name", "unknown tool") 81 | raw_arguments = getattr(tool_call.function, "arguments", {}) 82 | elif isinstance(tool_call, dict) and "function" in tool_call: 83 | fn_info = tool_call["function"] 84 | tool_name = fn_info.get("name", "unknown tool") 85 | raw_arguments = fn_info.get("arguments", {}) 86 | else: 87 | tool_name = "unknown tool" 88 | raw_arguments = {} 89 | 90 | # If raw_arguments is a string, try to parse it as JSON 91 | if isinstance(raw_arguments, str): 92 | try: 93 | raw_arguments = json.loads(raw_arguments) 94 | except json.JSONDecodeError: 95 | # If it's not valid JSON, just display as is 96 | pass 97 | 98 | # Now raw_arguments should be a dict or something we can pretty-print as JSON 99 | tool_args_str = json.dumps(raw_arguments, indent=2) 100 | 101 | 102 | 103 | tool_md = f"**Tool Call:** {tool_name}\n\n```json\n{tool_args_str}\n```" 104 | print( 105 | Panel( 106 | Markdown(tool_md), style="bold magenta", title="Tool Invocation" 107 | ) 108 | ) 109 | 110 | await handle_tool_call(tool_call, conversation_history, server_streams) 111 | continue 112 | 113 | # Assistant panel with Markdown 114 | assistant_panel_text = response_content if response_content else "[No Response]" 115 | print( 116 | Panel(Markdown(assistant_panel_text), style="bold blue", title="Assistant") 117 | ) 118 | conversation_history.append({"role": "assistant", "content": response_content}) 119 | break 120 | 121 | 122 | def generate_system_prompt(tools): 123 | """ 124 | Generate a concise system prompt for the assistant. 125 | 126 | This prompt is internal and not displayed to the user. 127 | """ 128 | prompt_generator = SystemPromptGenerator() 129 | tools_json = {"tools": tools} 130 | 131 | system_prompt = prompt_generator.generate_prompt(tools_json) 132 | system_prompt += """ 133 | 134 | **GENERAL GUIDELINES:** 135 | 136 | 1. Step-by-step reasoning: 137 | - Analyze tasks systematically. 138 | - Break down complex problems into smaller, manageable parts. 139 | - Verify assumptions at each step to avoid errors. 140 | - Reflect on results to improve subsequent actions. 141 | 142 | 2. Effective tool usage: 143 | - Explore: 144 | - Identify available information and verify its structure. 145 | - Check assumptions and understand data relationships. 146 | - Iterate: 147 | - Start with simple queries or actions. 148 | - Build upon successes, adjusting based on observations. 149 | - Handle errors: 150 | - Carefully analyze error messages. 151 | - Use errors as a guide to refine your approach. 152 | - Document what went wrong and suggest fixes. 153 | 154 | 3. Clear communication: 155 | - Explain your reasoning and decisions at each step. 156 | - Share discoveries transparently with the user. 157 | - Outline next steps or ask clarifying questions as needed. 158 | 159 | EXAMPLES OF BEST PRACTICES: 160 | 161 | - Working with databases: 162 | - Check schema before writing queries. 163 | - Verify the existence of columns or tables. 164 | - Start with basic queries and refine based on results. 165 | 166 | - Processing data: 167 | - Validate data formats and handle edge cases. 168 | - Ensure integrity and correctness of results. 169 | 170 | - Accessing resources: 171 | - Confirm resource availability and permissions. 172 | - Handle missing or incomplete data gracefully. 173 | 174 | REMEMBER: 175 | - Be thorough and systematic. 176 | - Each tool call should have a clear and well-explained purpose. 177 | - Make reasonable assumptions if ambiguous. 178 | - Minimize unnecessary user interactions by providing actionable insights. 179 | 180 | EXAMPLES OF ASSUMPTIONS: 181 | - Default sorting (e.g., descending order) if not specified. 182 | - Assume basic user intentions, such as fetching top results by a common metric. 183 | """ 184 | return system_prompt 185 | ``` -------------------------------------------------------------------------------- /clients/PHP/2.1 mcp_continue_chat/MCPContinueChatClient.php: -------------------------------------------------------------------------------- ```php 1 | <?php 2 | /** 3 | * MCPContinueChatClient.php 4 | * 5 | * A PHP script acting as a Continue Chat Client. It connects to a server via TCP, 6 | * sends a Continue Chat request, and receives the server's response. 7 | * 8 | * Usage: 9 | * php MCPContinueChatClient.php --server-ip <IP> --server-port <Port> --token <Token> --conversation-id <ConversationID> --message <Message> 10 | */ 11 | 12 | /** 13 | * Function to parse command line arguments 14 | * 15 | * @param array $args Command line arguments 16 | * @return array Associative array of parsed arguments 17 | */ 18 | function parseArguments($args) { 19 | $parsedArgs = []; 20 | $argc = count($args); 21 | for ($i = 1; $i < $argc; $i++) { 22 | switch ($args[$i]) { 23 | case '--server-ip': 24 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 25 | $parsedArgs['serverIp'] = $args[++$i]; 26 | } else { 27 | fwrite(STDERR, "Error: --server-ip expects a value.\n"); 28 | exit(1); 29 | } 30 | break; 31 | case '--server-port': 32 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 33 | $parsedArgs['serverPort'] = intval($args[++$i]); 34 | } else { 35 | fwrite(STDERR, "Error: --server-port expects a value.\n"); 36 | exit(1); 37 | } 38 | break; 39 | case '--token': 40 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 41 | $parsedArgs['token'] = $args[++$i]; 42 | } else { 43 | fwrite(STDERR, "Error: --token expects a value.\n"); 44 | exit(1); 45 | } 46 | break; 47 | case '--conversation-id': 48 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 49 | $parsedArgs['conversationId'] = $args[++$i]; 50 | } else { 51 | fwrite(STDERR, "Error: --conversation-id expects a value.\n"); 52 | exit(1); 53 | } 54 | break; 55 | case '--message': 56 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 57 | $parsedArgs['message'] = $args[++$i]; 58 | } else { 59 | fwrite(STDERR, "Error: --message expects a value.\n"); 60 | exit(1); 61 | } 62 | break; 63 | default: 64 | fwrite(STDERR, "⚠️ Warning: Unknown argument: {$args[$i]}\n"); 65 | } 66 | } 67 | return $parsedArgs; 68 | } 69 | 70 | /** 71 | * Helper function to check if a string starts with a specific prefix 72 | * 73 | * @param string $string The string to check 74 | * @param string $prefix The prefix 75 | * @return bool True if the string starts with the prefix, otherwise False 76 | */ 77 | function startsWith($string, $prefix) { 78 | return substr($string, 0, strlen($prefix)) === $prefix; 79 | } 80 | 81 | /** 82 | * Function for interactively prompting a parameter (optional) 83 | * 84 | * @param string $prompt The prompt message 85 | * @return string User input 86 | */ 87 | function askQuestionPrompt($prompt) { 88 | if (preg_match('/^win/i', PHP_OS)) { 89 | // Windows-specific input prompt 90 | $vbscript = sys_get_temp_dir() . 'prompt_input.vbs'; 91 | file_put_contents($vbscript, 'wscript.echo(InputBox("' . addslashes($prompt) . '", "", ""))'); 92 | $response = shell_exec("cscript //nologo " . escapeshellarg($vbscript)); 93 | unlink($vbscript); 94 | return trim($response); 95 | } else { 96 | // Unix/Linux input prompt 97 | echo $prompt; 98 | $handle = fopen("php://stdin", "r"); 99 | $response = trim(fgets($handle)); 100 | fclose($handle); 101 | return $response; 102 | } 103 | } 104 | 105 | /** 106 | * Function to send a Continue Chat request over a TCP connection 107 | * 108 | * @param string $serverIp Server IP address 109 | * @param int $serverPort Server port 110 | * @param array $payload Payload to send as an associative array 111 | * @return array Server response as an associative array 112 | * @throws Exception On connection errors or JSON parsing errors 113 | */ 114 | function sendContinueChatRequest($serverIp, $serverPort, $payload) { 115 | $jsonPayload = json_encode($payload); 116 | if ($jsonPayload === false) { 117 | throw new Exception("Error encoding JSON payload."); 118 | } 119 | 120 | $errno = 0; 121 | $errstr = ''; 122 | $timeout = 30; // seconds 123 | $client = @fsockopen($serverIp, $serverPort, $errno, $errstr, $timeout); 124 | 125 | if (!$client) { 126 | throw new Exception("Connection error: $errstr ($errno)"); 127 | } 128 | 129 | echo "🔗 Connected to server ({$serverIp}:{$serverPort}).\n"; 130 | echo "📤 Sending payload: $jsonPayload\n"; 131 | 132 | fwrite($client, $jsonPayload); 133 | 134 | $responseData = ''; 135 | stream_set_timeout($client, $timeout); 136 | 137 | while (!feof($client)) { 138 | $data = fread($client, 1024); 139 | if ($data === false) { 140 | throw new Exception("Error reading data from server."); 141 | } 142 | if ($data === '') { 143 | break; // No more data 144 | } 145 | echo "📥 Received data: $data\n"; 146 | $responseData .= $data; 147 | 148 | // Attempt to parse received data as JSON 149 | $parsedData = json_decode($responseData, true); 150 | if ($parsedData !== null) { 151 | echo "✅ JSON response successfully parsed.\n"; 152 | fclose($client); 153 | return $parsedData; 154 | } 155 | 156 | // Check if the stream timed out 157 | $info = stream_get_meta_data($client); 158 | if ($info['timed_out']) { 159 | throw new Exception("Timeout waiting for data from server."); 160 | } 161 | } 162 | 163 | fclose($client); 164 | throw new Exception("Connection to server closed before a complete response was received."); 165 | } 166 | 167 | /** 168 | * Main function of the script 169 | */ 170 | function main($argv) { 171 | $parsedArgs = parseArguments($argv); 172 | $serverIp = $parsedArgs['serverIp'] ?? null; 173 | $serverPort = $parsedArgs['serverPort'] ?? null; 174 | $token = $parsedArgs['token'] ?? null; 175 | $conversationId = $parsedArgs['conversationId'] ?? null; 176 | $message = $parsedArgs['message'] ?? null; 177 | 178 | // Check if all required parameters are present 179 | if (!$serverIp || !$serverPort || !$token || !$conversationId || !$message) { 180 | fwrite(STDERR, "❌ ERROR: Missing required parameters.\n"); 181 | fwrite(STDOUT, "Usage: php MCPContinueChatClient.php --server-ip <IP> --server-port <Port> --token <Token> --conversation-id <ConversationID> --message <Message>\n"); 182 | exit(1); 183 | } 184 | 185 | $payload = [ 186 | "command" => "continue_chat", 187 | "token" => $token, 188 | "arguments" => [ 189 | "chatId" => $conversationId, 190 | "question" => $message 191 | ] 192 | ]; 193 | 194 | try { 195 | echo "💬 Sending Continue Chat request...\n"; 196 | $response = sendContinueChatRequest($serverIp, $serverPort, $payload); 197 | echo "✅ Server Response:\n"; 198 | echo json_encode($response, JSON_PRETTY_PRINT) . "\n"; 199 | } catch (Exception $e) { 200 | fwrite(STDERR, "❌ ERROR: " . $e->getMessage() . "\n"); 201 | } 202 | } 203 | 204 | main($argv); 205 | ?> 206 | ``` -------------------------------------------------------------------------------- /clients/PHP/3.4 mcp_delete_source/MCPDeleteSourceClient.php: -------------------------------------------------------------------------------- ```php 1 | <?php 2 | /** 3 | * MCPDeleteSourceClient.php 4 | * 5 | * A PHP script acting as a Delete Source Client. It connects to a server via TCP, 6 | * sends a request to delete an existing source, and receives the server's response. 7 | * 8 | * Usage: 9 | * php MCPDeleteSourceClient.php --server-ip <IP> --server-port <Port> --token <Token> --source-id <SourceID> 10 | */ 11 | 12 | /** 13 | * Function to parse command line arguments 14 | * 15 | * @param array $args Command line arguments 16 | * @return array Associative array of parsed arguments 17 | */ 18 | function parseArguments($args) { 19 | $parsedArgs = []; 20 | $argc = count($args); 21 | for ($i = 1; $i < $argc; $i++) { 22 | switch ($args[$i]) { 23 | case '--server-ip': 24 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 25 | $parsedArgs['serverIp'] = $args[++$i]; 26 | } else { 27 | fwrite(STDERR, "Error: --server-ip expects a value.\n"); 28 | exit(1); 29 | } 30 | break; 31 | case '--server-port': 32 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 33 | $parsedArgs['serverPort'] = intval($args[++$i]); 34 | } else { 35 | fwrite(STDERR, "Error: --server-port expects a value.\n"); 36 | exit(1); 37 | } 38 | break; 39 | case '--token': 40 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 41 | $parsedArgs['token'] = $args[++$i]; 42 | } else { 43 | fwrite(STDERR, "Error: --token expects a value.\n"); 44 | exit(1); 45 | } 46 | break; 47 | case '--source-id': 48 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 49 | $parsedArgs['sourceId'] = $args[++$i]; 50 | } else { 51 | fwrite(STDERR, "Error: --source-id expects a value.\n"); 52 | exit(1); 53 | } 54 | break; 55 | default: 56 | fwrite(STDERR, "⚠️ Warning: Unknown argument: {$args[$i]}\n"); 57 | } 58 | } 59 | return $parsedArgs; 60 | } 61 | 62 | /** 63 | * Helper function to check if a string starts with a specific prefix 64 | * 65 | * @param string $string The string to check 66 | * @param string $prefix The prefix 67 | * @return bool True if the string starts with the prefix, otherwise False 68 | */ 69 | function startsWith($string, $prefix) { 70 | return substr($string, 0, strlen($prefix)) === $prefix; 71 | } 72 | 73 | /** 74 | * Function for interactively prompting a parameter (optional) 75 | * 76 | * @param string $prompt The prompt message 77 | * @return string User input 78 | */ 79 | function askQuestionPrompt($prompt) { 80 | if (preg_match('/^win/i', PHP_OS)) { 81 | $vbscript = sys_get_temp_dir() . 'prompt_input.vbs'; 82 | file_put_contents($vbscript, 'wscript.echo(InputBox("' . addslashes($prompt) . '", "", ""))'); 83 | $response = shell_exec("cscript //nologo " . escapeshellarg($vbscript)); 84 | unlink($vbscript); 85 | return trim($response); 86 | } else { 87 | echo $prompt; 88 | $handle = fopen("php://stdin", "r"); 89 | $response = trim(fgets($handle)); 90 | fclose($handle); 91 | return $response; 92 | } 93 | } 94 | 95 | /** 96 | * Function to send a Delete Source request over a TCP connection 97 | * 98 | * @param string $serverIp The server's IP address 99 | * @param int $serverPort The server's port 100 | * @param array $payload The payload to send as an associative array 101 | * @return array The response received from the server as an associative array 102 | * @throws Exception On connection errors or JSON parsing errors 103 | */ 104 | function sendDeleteSourceRequest($serverIp, $serverPort, $payload) { 105 | $jsonPayload = json_encode($payload); 106 | if ($jsonPayload === false) { 107 | throw new Exception("Error while coding the JSON payload: " . json_last_error_msg()); 108 | } 109 | 110 | $errno = 0; 111 | $errstr = ''; 112 | $timeout = 10; // Seconds 113 | $client = @fsockopen($serverIp, $serverPort, $errno, $errstr, $timeout); 114 | 115 | if (!$client) { 116 | throw new Exception("Connection error: $errstr ($errno)"); 117 | } 118 | 119 | echo "🔗 Connected to the server ({$serverIp}:{$serverPort}).\n"; 120 | echo "📤 Sending payload: $jsonPayload\n"; 121 | 122 | fwrite($client, $jsonPayload); 123 | 124 | $responseData = ''; 125 | stream_set_timeout($client, $timeout); 126 | 127 | while (!feof($client)) { 128 | $data = fread($client, 1024); 129 | if ($data === false) { 130 | throw new Exception("Error reading data from the server."); 131 | } 132 | if ($data === '') { 133 | break; // No more data 134 | } 135 | echo "📥 Received data: $data\n"; 136 | $responseData .= $data; 137 | 138 | $parsedData = json_decode($responseData, true); 139 | if ($parsedData !== null) { 140 | echo "✅ JSON response successfully parsed.\n"; 141 | fclose($client); 142 | return $parsedData; 143 | } 144 | 145 | $info = stream_get_meta_data($client); 146 | if ($info['timed_out']) { 147 | throw new Exception("Timeout waiting for data from the server."); 148 | } 149 | } 150 | 151 | fclose($client); 152 | throw new Exception("Connection to the server was closed before a complete response was received."); 153 | } 154 | 155 | /** 156 | * Main function of the script 157 | */ 158 | function main($argv) { 159 | $parsedArgs = parseArguments($argv); 160 | $serverIp = $parsedArgs['serverIp'] ?? null; 161 | $serverPort = $parsedArgs['serverPort'] ?? null; 162 | $token = $parsedArgs['token'] ?? null; 163 | $sourceId = $parsedArgs['sourceId'] ?? null; 164 | 165 | if (!$serverIp) { 166 | $serverIp = askQuestionPrompt('🔗 Please enter the server IP: '); 167 | } 168 | if (!$serverPort) { 169 | $portInput = askQuestionPrompt('🔗 Please enter the server port: '); 170 | $serverPort = intval($portInput); 171 | if ($serverPort <= 0) { 172 | fwrite(STDERR, "❌ ERROR: Invalid server port.\n"); 173 | exit(1); 174 | } 175 | } 176 | if (!$token) { 177 | $token = askQuestionPrompt('🔒 Please enter your authentication token: '); 178 | } 179 | if (!$sourceId) { 180 | $sourceId = askQuestionPrompt('📁 Please enter the Source ID: '); 181 | } 182 | 183 | if (!$serverIp || !$serverPort || !$token || !$sourceId) { 184 | fwrite(STDERR, "❌ ERROR: Missing required parameters.\n"); 185 | fwrite(STDOUT, "Usage: php MCPDeleteSourceClient.php --server-ip <IP> --server-port <Port> --token <Token> --source-id <SourceID>\n"); 186 | exit(1); 187 | } 188 | 189 | $payload = [ 190 | "command" => "delete_source", 191 | "token" => $token, 192 | "arguments" => [ 193 | "sourceId" => $sourceId 194 | ] 195 | ]; 196 | 197 | try { 198 | echo "🗑️ Sending Delete Source request...\n"; 199 | $response = sendDeleteSourceRequest($serverIp, $serverPort, $payload); 200 | echo "✅ Server Response:\n"; 201 | echo json_encode($response, JSON_PRETTY_PRINT) . "\n"; 202 | } catch (Exception $e) { 203 | fwrite(STDERR, "❌ ERROR: " . $e->getMessage() . "\n"); 204 | } 205 | } 206 | 207 | if (version_compare(PHP_VERSION, '7.1.0') < 0) { 208 | fwrite(STDERR, "❌ ERROR: This script requires PHP version 7.1 or higher.\n"); 209 | exit(1); 210 | } 211 | 212 | main($argv); 213 | ?> 214 | ``` -------------------------------------------------------------------------------- /clients/PHP/4.2 mcp_delete_group/MCPDeleteGroupClient.php: -------------------------------------------------------------------------------- ```php 1 | <?php 2 | /** 3 | * MCPDeleteGroupClient.php 4 | * 5 | * A PHP script acting as a Delete Group Client. It connects to a server via TCP, 6 | * sends a request to delete an existing group, and receives the server's response. 7 | * 8 | * Usage: 9 | * php MCPDeleteGroupClient.php --server-ip <IP> --server-port <Port> --token <Token> --group-name <GroupName> 10 | */ 11 | 12 | /** 13 | * Function to parse command line arguments 14 | * 15 | * @param array $args Command line arguments 16 | * @return array Associative array of parsed arguments 17 | */ 18 | function parseArguments($args) { 19 | $parsedArgs = []; 20 | $argc = count($args); 21 | for ($i = 1; $i < $argc; $i++) { 22 | switch ($args[$i]) { 23 | case '--server-ip': 24 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 25 | $parsedArgs['serverIp'] = $args[++$i]; 26 | } else { 27 | fwrite(STDERR, "⚠️ Warning: No value provided for --server-ip.\n"); 28 | } 29 | break; 30 | case '--server-port': 31 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 32 | $parsedArgs['serverPort'] = intval($args[++$i]); 33 | } else { 34 | fwrite(STDERR, "⚠️ Warning: No value provided for --server-port.\n"); 35 | } 36 | break; 37 | case '--token': 38 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 39 | $parsedArgs['token'] = $args[++$i]; 40 | } else { 41 | fwrite(STDERR, "⚠️ Warning: No value provided for --token.\n"); 42 | } 43 | break; 44 | case '--group-name': 45 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 46 | $parsedArgs['groupName'] = $args[++$i]; 47 | } else { 48 | fwrite(STDERR, "⚠️ Warning: No value provided for --group-name.\n"); 49 | } 50 | break; 51 | default: 52 | fwrite(STDERR, "⚠️ Warning: Unknown argument: {$args[$i]}\n"); 53 | } 54 | } 55 | return $parsedArgs; 56 | } 57 | 58 | /** 59 | * Helper function to check if a string starts with a specific prefix 60 | * 61 | * @param string $string The string to check 62 | * @param string $prefix The prefix 63 | * @return bool True if the string starts with the prefix, otherwise False 64 | */ 65 | function startsWith($string, $prefix) { 66 | return substr($string, 0, strlen($prefix)) === $prefix; 67 | } 68 | 69 | /** 70 | * Function for interactively prompting a parameter (optional) 71 | * 72 | * @param string $prompt The prompt message 73 | * @return string User input 74 | */ 75 | function askQuestionPrompt($prompt) { 76 | if (preg_match('/^win/i', PHP_OS)) { 77 | $vbscript = sys_get_temp_dir() . 'prompt_input.vbs'; 78 | file_put_contents($vbscript, 'wscript.echo(InputBox("' . addslashes($prompt) . '", "", ""))'); 79 | $response = shell_exec("cscript //nologo " . escapeshellarg($vbscript)); 80 | unlink($vbscript); 81 | return trim($response); 82 | } else { 83 | echo $prompt; 84 | $handle = fopen("php://stdin", "r"); 85 | $response = trim(fgets($handle)); 86 | fclose($handle); 87 | return $response; 88 | } 89 | } 90 | 91 | /** 92 | * Function to send a Delete Group request over a TCP connection 93 | * 94 | * @param string $serverIp The server's IP address 95 | * @param int $serverPort The server's port 96 | * @param string $token The authentication token 97 | * @param string $groupName The name of the group to be deleted 98 | * @return array The response received from the server as an associative array 99 | * @throws Exception On connection errors or JSON parsing errors 100 | */ 101 | function sendDeleteGroupRequest($serverIp, $serverPort, $token, $groupName) { 102 | $payload = [ 103 | "command" => "delete_group", 104 | "token" => $token, 105 | "arguments" => [ 106 | "groupName" => $groupName 107 | ] 108 | ]; 109 | 110 | $jsonPayload = json_encode($payload); 111 | if ($jsonPayload === false) { 112 | throw new Exception("Error while coding the JSON payload: " . json_last_error_msg()); 113 | } 114 | 115 | $errno = 0; 116 | $errstr = ''; 117 | $timeoutDuration = 10; // Seconds 118 | $client = @fsockopen($serverIp, $serverPort, $errno, $errstr, $timeoutDuration); 119 | 120 | if (!$client) { 121 | throw new Exception("Connection error: $errstr ($errno)"); 122 | } 123 | 124 | echo "🔗 Connected to the server ({$serverIp}:{$serverPort}).\n"; 125 | echo "📤 Sending payload: $jsonPayload\n"; 126 | 127 | fwrite($client, $jsonPayload); 128 | 129 | $responseData = ''; 130 | stream_set_timeout($client, $timeoutDuration); 131 | 132 | while (!feof($client)) { 133 | $data = fread($client, 1024); 134 | if ($data === false) { 135 | throw new Exception("Error reading data from the server."); 136 | } 137 | if ($data === '') { 138 | break; 139 | } 140 | echo "📥 Received data: $data\n"; 141 | $responseData .= $data; 142 | 143 | $parsedData = json_decode($responseData, true); 144 | if ($parsedData !== null) { 145 | echo "✅ JSON response successfully parsed.\n"; 146 | fclose($client); 147 | return $parsedData; 148 | } 149 | 150 | $info = stream_get_meta_data($client); 151 | if ($info['timed_out']) { 152 | throw new Exception("Timeout waiting for data from the server."); 153 | } 154 | } 155 | 156 | fclose($client); 157 | throw new Exception("Connection to the server was closed before a complete response was received."); 158 | } 159 | 160 | /** 161 | * Main function of the script 162 | */ 163 | function main($argv) { 164 | $parsedArgs = parseArguments($argv); 165 | $serverIp = $parsedArgs['serverIp'] ?? null; 166 | $serverPort = $parsedArgs['serverPort'] ?? null; 167 | $token = $parsedArgs['token'] ?? null; 168 | $groupName = $parsedArgs['groupName'] ?? null; 169 | 170 | if (!$serverIp) { 171 | $serverIp = askQuestionPrompt('🔗 Please enter the server IP: '); 172 | } 173 | if (!$serverPort) { 174 | $portInput = askQuestionPrompt('🔗 Please enter the server port: '); 175 | $serverPort = intval($portInput); 176 | if ($serverPort <= 0) { 177 | fwrite(STDERR, "❌ ERROR: Invalid server port.\n"); 178 | exit(1); 179 | } 180 | } 181 | if (!$token) { 182 | $token = askQuestionPrompt('🔒 Please enter your authentication token: '); 183 | } 184 | if (!$groupName) { 185 | $groupName = askQuestionPrompt('👥 Please enter the group name: '); 186 | } 187 | 188 | if (!$serverIp || !$serverPort || !$token || !$groupName) { 189 | fwrite(STDERR, "❌ ERROR: Missing required parameters.\n"); 190 | fwrite(STDOUT, "Usage: php MCPDeleteGroupClient.php --server-ip <IP> --server-port <Port> --token <Token> --group-name <GroupName>\n"); 191 | exit(1); 192 | } 193 | 194 | try { 195 | echo "🗑️ Sending Delete Group request...\n"; 196 | $response = sendDeleteGroupRequest($serverIp, $serverPort, $token, $groupName); 197 | echo "✔️ Server Response:\n"; 198 | echo json_encode($response, JSON_PRETTY_PRINT) . "\n"; 199 | } catch (Exception $e) { 200 | fwrite(STDERR, "❌ ERROR: " . $e->getMessage() . "\n"); 201 | } 202 | } 203 | 204 | if (version_compare(PHP_VERSION, '7.1.0') < 0) { 205 | fwrite(STDERR, "❌ ERROR: This script requires PHP version 7.1 or higher.\n"); 206 | exit(1); 207 | } 208 | 209 | main($argv); 210 | ?> 211 | ``` -------------------------------------------------------------------------------- /clients/PHP/2.2 mcp_get_chat_info/MCPGetChatInfoClient.php: -------------------------------------------------------------------------------- ```php 1 | <?php 2 | /** 3 | * MCPGetChatInfoClient.php 4 | * 5 | * A PHP script acting as a Get Chat Info Client. It connects to a server via TCP, 6 | * sends a request to retrieve chat information, and receives the server's response. 7 | * 8 | * Usage: 9 | * php MCPGetChatInfoClient.php --server-ip <IP> --server-port <Port> --token <Token> --chat-id <ChatID> 10 | */ 11 | 12 | /** 13 | * Function to parse command line arguments 14 | * 15 | * @param array $args Command line arguments 16 | * @return array Associative array of parsed arguments 17 | */ 18 | function parseArguments($args) { 19 | $parsedArgs = []; 20 | $argc = count($args); 21 | for ($i = 1; $i < $argc; $i++) { 22 | switch ($args[$i]) { 23 | case '--server-ip': 24 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 25 | $parsedArgs['serverIp'] = $args[++$i]; 26 | } else { 27 | fwrite(STDERR, "Error: --server-ip expects a value.\n"); 28 | exit(1); 29 | } 30 | break; 31 | case '--server-port': 32 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 33 | $parsedArgs['serverPort'] = intval($args[++$i]); 34 | } else { 35 | fwrite(STDERR, "Error: --server-port expects a value.\n"); 36 | exit(1); 37 | } 38 | break; 39 | case '--token': 40 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 41 | $parsedArgs['token'] = $args[++$i]; 42 | } else { 43 | fwrite(STDERR, "Error: --token expects a value.\n"); 44 | exit(1); 45 | } 46 | break; 47 | case '--chat-id': 48 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 49 | $parsedArgs['chatId'] = $args[++$i]; 50 | } else { 51 | fwrite(STDERR, "Error: --chat-id expects a value.\n"); 52 | exit(1); 53 | } 54 | break; 55 | default: 56 | fwrite(STDERR, "⚠️ Warning: Unknown argument: {$args[$i]}\n"); 57 | } 58 | } 59 | return $parsedArgs; 60 | } 61 | 62 | /** 63 | * Helper function to check if a string starts with a specific prefix 64 | * 65 | * @param string $string The string to check 66 | * @param string $prefix The prefix 67 | * @return bool True if the string starts with the prefix, otherwise False 68 | */ 69 | function startsWith($string, $prefix) { 70 | return substr($string, 0, strlen($prefix)) === $prefix; 71 | } 72 | 73 | /** 74 | * Function for interactively prompting a parameter (optional) 75 | * 76 | * @param string $prompt The prompt message 77 | * @return string User input 78 | */ 79 | function askQuestionPrompt($prompt) { 80 | if (preg_match('/^win/i', PHP_OS)) { 81 | // Windows-specific input prompt 82 | $vbscript = sys_get_temp_dir() . 'prompt_input.vbs'; 83 | file_put_contents($vbscript, 'wscript.echo(InputBox("' . addslashes($prompt) . '", "", ""))'); 84 | $response = shell_exec("cscript //nologo " . escapeshellarg($vbscript)); 85 | unlink($vbscript); 86 | return trim($response); 87 | } else { 88 | // Unix/Linux input prompt 89 | echo $prompt; 90 | $handle = fopen("php://stdin", "r"); 91 | $response = trim(fgets($handle)); 92 | fclose($handle); 93 | return $response; 94 | } 95 | } 96 | 97 | /** 98 | * Function to send a request over a TCP connection 99 | * 100 | * @param string $serverIp The server's IP address 101 | * @param int $serverPort The server's port 102 | * @param array $payload The payload to send as an associative array 103 | * @return array The response received from the server as an associative array 104 | * @throws Exception On connection errors or JSON parsing errors 105 | */ 106 | function sendRequest($serverIp, $serverPort, $payload) { 107 | $jsonPayload = json_encode($payload); 108 | if ($jsonPayload === false) { 109 | throw new Exception("Error while coding the JSON payload: " . json_last_error_msg()); 110 | } 111 | 112 | $errno = 0; 113 | $errstr = ''; 114 | $timeout = 30; // seconds 115 | $client = @fsockopen($serverIp, $serverPort, $errno, $errstr, $timeout); 116 | 117 | if (!$client) { 118 | throw new Exception("Connection error: $errstr ($errno)"); 119 | } 120 | 121 | echo "🔗 Connected to the server ({$serverIp}:{$serverPort}).\n"; 122 | echo "📤 Sending payload: $jsonPayload\n"; 123 | 124 | fwrite($client, $jsonPayload); 125 | 126 | $responseData = ''; 127 | stream_set_timeout($client, $timeout); 128 | 129 | while (!feof($client)) { 130 | $data = fread($client, 1024); 131 | if ($data === false) { 132 | throw new Exception("Error reading data from the server."); 133 | } 134 | if ($data === '') { 135 | break; // No more data 136 | } 137 | echo "📥 Received data: $data\n"; 138 | $responseData .= $data; 139 | 140 | // Attempt to parse received data as JSON 141 | $parsedData = json_decode($responseData, true); 142 | if ($parsedData !== null) { 143 | echo "✅ JSON response successfully parsed.\n"; 144 | fclose($client); 145 | return $parsedData; 146 | } 147 | 148 | // Check if the stream timed out 149 | $info = stream_get_meta_data($client); 150 | if ($info['timed_out']) { 151 | throw new Exception("Timeout waiting for data from the server."); 152 | } 153 | } 154 | 155 | fclose($client); 156 | throw new Exception("Connection to the server was closed before a complete response was received."); 157 | } 158 | 159 | /** 160 | * Main function of the script 161 | */ 162 | function main($argv) { 163 | $parsedArgs = parseArguments($argv); 164 | $serverIp = $parsedArgs['serverIp'] ?? null; 165 | $serverPort = $parsedArgs['serverPort'] ?? null; 166 | $token = $parsedArgs['token'] ?? null; 167 | $chatId = $parsedArgs['chatId'] ?? null; 168 | 169 | // Interactively prompt for missing parameters 170 | if (!$serverIp) { 171 | $serverIp = askQuestionPrompt('🔗 Please enter the server IP: '); 172 | } 173 | if (!$serverPort) { 174 | $portInput = askQuestionPrompt('🔗 Please enter the server port: '); 175 | $serverPort = intval($portInput); 176 | if ($serverPort <= 0) { 177 | fwrite(STDERR, "❌ ERROR: Invalid server port.\n"); 178 | exit(1); 179 | } 180 | } 181 | if (!$token) { 182 | $token = askQuestionPrompt('🔒 Please enter your authentication token: '); 183 | } 184 | if (!$chatId) { 185 | $chatId = askQuestionPrompt('💬 Please enter the Chat ID: '); 186 | } 187 | 188 | // Check if all required parameters are now present 189 | if (!$serverIp || !$serverPort || !$token || !$chatId) { 190 | fwrite(STDERR, "❌ ERROR: Missing required parameters.\n"); 191 | fwrite(STDOUT, "Usage: php MCPGetChatInfoClient.php --server-ip <IP> --server-port <Port> --token <Token> --chat-id <ChatID>\n"); 192 | exit(1); 193 | } 194 | 195 | $payload = [ 196 | "command" => "get_chat_info", 197 | "token" => $token, 198 | "arguments" => [ 199 | "chatId" => $chatId 200 | ] 201 | ]; 202 | 203 | try { 204 | echo "📤 Sending request...\n"; 205 | $response = sendRequest($serverIp, $serverPort, $payload); 206 | echo "✅ Server Response:\n"; 207 | echo json_encode($response, JSON_PRETTY_PRINT) . "\n"; 208 | } catch (Exception $e) { 209 | fwrite(STDERR, "❌ ERROR: " . $e->getMessage() . "\n"); 210 | } 211 | } 212 | 213 | // Ensure PHP version is at least 7.1 214 | if (version_compare(PHP_VERSION, '7.1.0') < 0) { 215 | fwrite(STDERR, "❌ ERROR: This script requires PHP version 7.1 or higher.\n"); 216 | exit(1); 217 | } 218 | 219 | // Call the main function 220 | main($argv); 221 | ?> 222 | ``` -------------------------------------------------------------------------------- /agents/SourceManagerAgent/Python/file_tools/loader_factory.py: -------------------------------------------------------------------------------- ```python 1 | import os 2 | from pathlib import Path 3 | from typing import List 4 | import pandas as pd 5 | os.environ["USER_AGENT"] = "Pgpt" 6 | 7 | 8 | from langchain.docstore.document import Document 9 | from langchain_community.document_loaders import (AZLyricsLoader, BSHTMLLoader, 10 | ChatGPTLoader, CSVLoader, 11 | DirectoryLoader, GitbookLoader, 12 | GitLoader, HuggingFaceDatasetLoader, 13 | ImageCaptionLoader, IMSDbLoader, 14 | JSONLoader, ObsidianLoader, 15 | OnlinePDFLoader, PlaywrightURLLoader, 16 | PyPDFLoader, SitemapLoader, SRTLoader, 17 | TextLoader, UnstructuredEmailLoader, 18 | UnstructuredImageLoader, 19 | UnstructuredMarkdownLoader, 20 | UnstructuredWordDocumentLoader, 21 | WebBaseLoader, YoutubeLoader) 22 | from langchain_community.document_loaders.figma import FigmaFileLoader 23 | from langchain.text_splitter import CharacterTextSplitter 24 | 25 | 26 | 27 | 28 | class LoadersFactory: 29 | @staticmethod 30 | def load_file(path: str) -> List[Document]: 31 | loader = TextLoader(path, encoding="utf-8") 32 | documents = loader.load() 33 | return documents 34 | 35 | @staticmethod 36 | def csv(path: str) -> List[Document]: 37 | loader = CSVLoader(file_path=path) 38 | documents = loader.load() 39 | return documents 40 | 41 | @staticmethod 42 | def xlsx(path: str) -> List[Document]: 43 | csv_file = path + '.csv' 44 | df = pd.read_excel(path) 45 | df.to_csv(csv_file, index=False) 46 | 47 | print(f"File converted successfully and saved as {csv_file}") 48 | loader = CSVLoader(file_path=csv_file) 49 | documents = loader.load() 50 | return documents 51 | 52 | @staticmethod 53 | def directory(path: str, glob: str) -> List[Document]: 54 | text_loader_kwargs = {'autodetect_encoding': True} 55 | loader = DirectoryLoader(path, glob, loader_kwargs=text_loader_kwargs) 56 | documents = loader.load() 57 | return documents 58 | 59 | @staticmethod 60 | def html_bs4(path: str, glob: str) -> List[Document]: 61 | loader = BSHTMLLoader(path) 62 | documents = loader.load() 63 | return documents 64 | 65 | @staticmethod 66 | def json(path: str, schema: str) -> List[Document]: 67 | loader = JSONLoader(Path(path).read_text(), schema) 68 | documents = loader.load() 69 | return documents 70 | 71 | @staticmethod 72 | def markdown(path: str) -> List[Document]: 73 | loader = UnstructuredMarkdownLoader(path) 74 | documents = loader.load() 75 | return documents 76 | 77 | @staticmethod 78 | def image(path: str) -> List[Document]: 79 | loader = UnstructuredImageLoader(path) 80 | documents = loader.load() 81 | return documents 82 | 83 | @staticmethod 84 | def pdf(path: str) -> List[Document]: 85 | loader = PyPDFLoader(path) 86 | documents = loader.load_and_split() 87 | return documents 88 | 89 | @staticmethod 90 | def online_pdf(url: str) -> List[Document]: 91 | loader = OnlinePDFLoader(url) 92 | documents = loader.load() 93 | return documents 94 | 95 | @staticmethod 96 | def sitemap(url: str) -> List[Document]: 97 | loader = SitemapLoader(url) 98 | documents = loader.load() 99 | return documents 100 | 101 | @staticmethod 102 | def subtitle(file_path: str) -> List[Document]: 103 | loader = SRTLoader(file_path) 104 | documents = loader.load() 105 | return documents 106 | 107 | @staticmethod 108 | def email(file_path: str) -> List[Document]: 109 | loader = UnstructuredEmailLoader(file_path) 110 | documents = loader.load() 111 | return documents 112 | 113 | @staticmethod 114 | def word(file_path: str) -> List[Document]: 115 | loader = UnstructuredWordDocumentLoader(file_path) 116 | documents = loader.load() 117 | return documents 118 | 119 | @staticmethod 120 | def youtube(url: str) -> List[Document]: 121 | loader = YoutubeLoader.from_youtube_url(url, add_video_info=True) 122 | documents = loader.load() 123 | return documents 124 | 125 | @staticmethod 126 | def playwrite(urls: List[str]) -> List[Document]: 127 | loader = PlaywrightURLLoader(urls=urls) 128 | documents = loader.load() 129 | return documents 130 | 131 | @staticmethod 132 | def web_base(urls: List[str]) -> List[Document]: 133 | loader = WebBaseLoader(urls) 134 | documents = loader.load() 135 | return documents 136 | 137 | @staticmethod 138 | def azlyrics(urls: List[str]) -> List[Document]: 139 | loader = AZLyricsLoader(urls) 140 | documents = loader.load() 141 | return documents 142 | 143 | @staticmethod 144 | def hugging_face(dataset_name: str = "imdb", page_content_column: str = "text") -> List[Document]: 145 | loader = HuggingFaceDatasetLoader(dataset_name, page_content_column) 146 | documents = loader.load() 147 | return documents 148 | 149 | @staticmethod 150 | def imsdb(path: str) -> List[Document]: 151 | loader = IMSDbLoader(path) 152 | documents = loader.load() 153 | return documents 154 | 155 | @staticmethod 156 | def chat_gpt(path: str) -> List[Document]: 157 | loader = ChatGPTLoader(path) 158 | documents = loader.load() 159 | return documents 160 | 161 | @staticmethod 162 | def figma(access_token: str, node_id: str, file_key: str) -> List[Document]: 163 | loader = FigmaFileLoader(access_token, node_id, file_key) 164 | documents = loader.load() 165 | return documents 166 | 167 | @staticmethod 168 | def gitbook(url: str) -> List[Document]: 169 | loader = GitbookLoader(url, load_all_paths=True) 170 | documents = loader.load() 171 | return documents 172 | 173 | @staticmethod 174 | def obsidian(url: str) -> List[Document]: 175 | loader = ObsidianLoader(url) 176 | documents = loader.load() 177 | return documents 178 | 179 | @staticmethod 180 | def git(clone_url: str, repo_path: str, branch: str = "master") -> List[Document]: 181 | loader = GitLoader( 182 | clone_url=clone_url, 183 | repo_path=repo_path, 184 | branch=branch 185 | ) 186 | documents = loader.load() 187 | return documents 188 | 189 | @staticmethod 190 | def blip(image_urls: List[str]) -> List[Document]: 191 | loader = ImageCaptionLoader(image_urls) 192 | documents = loader.load() 193 | return documents 194 | 195 | @staticmethod 196 | def split_docs(documents: List[Document], **kwargs) -> List[Document]: 197 | text_splitter = CharacterTextSplitter(**kwargs) 198 | docs = text_splitter.split_documents(documents) 199 | return docs 200 | 201 | 202 | @staticmethod 203 | def convert_documents_to_markdown(docs): 204 | markdown = "" 205 | 206 | for idx, doc in enumerate(docs): 207 | markdown += f"# Document {idx + 1}\n\n" 208 | markdown += f"{doc.page_content}\n\n" 209 | 210 | # If metadata is available, format it as a section 211 | if doc.metadata: 212 | markdown += "## Metadata\n" 213 | for key, value in doc.metadata.items(): 214 | # remove local file paths 215 | if key == "source": 216 | head, tail = os.path.split(value) 217 | value = tail 218 | markdown += f"- **{key}**: {value}\n" 219 | markdown += "\n---\n\n" # Separator between documents 220 | 221 | return markdown 222 | 223 | 224 | 225 | ``` -------------------------------------------------------------------------------- /clients/Gradio/file_tools/loader_factory.py: -------------------------------------------------------------------------------- ```python 1 | import os 2 | from pathlib import Path 3 | from typing import List 4 | import pandas as pd 5 | os.environ["USER_AGENT"] = "Pgpt" 6 | 7 | 8 | from langchain.docstore.document import Document 9 | from langchain_community.document_loaders import (AZLyricsLoader, BSHTMLLoader, 10 | ChatGPTLoader, CSVLoader, 11 | DirectoryLoader, GitbookLoader, 12 | GitLoader, HuggingFaceDatasetLoader, 13 | ImageCaptionLoader, IMSDbLoader, 14 | JSONLoader, ObsidianLoader, 15 | OnlinePDFLoader, PlaywrightURLLoader, 16 | PyPDFLoader, SitemapLoader, SRTLoader, 17 | TextLoader, UnstructuredEmailLoader, 18 | UnstructuredImageLoader, 19 | UnstructuredMarkdownLoader, 20 | UnstructuredWordDocumentLoader, 21 | WebBaseLoader, YoutubeLoader) 22 | from langchain_community.document_loaders.figma import FigmaFileLoader 23 | from langchain.text_splitter import CharacterTextSplitter 24 | 25 | 26 | 27 | 28 | class LoadersFactory: 29 | @staticmethod 30 | def load_file(path: str) -> List[Document]: 31 | loader = TextLoader(path, encoding="utf-8") 32 | documents = loader.load() 33 | return documents 34 | 35 | @staticmethod 36 | def csv(path: str) -> List[Document]: 37 | loader = CSVLoader(file_path=path) 38 | documents = loader.load() 39 | return documents 40 | 41 | @staticmethod 42 | def xlsx(path: str) -> List[Document]: 43 | csv_file = path + '.csv' 44 | df = pd.read_excel(path) 45 | df.to_csv(csv_file, index=False) 46 | 47 | print(f"File converted successfully and saved as {csv_file}") 48 | loader = CSVLoader(file_path=csv_file) 49 | documents = loader.load() 50 | return documents 51 | 52 | @staticmethod 53 | def directory(path: str, glob: str) -> List[Document]: 54 | text_loader_kwargs = {'autodetect_encoding': True} 55 | loader = DirectoryLoader(path, glob, loader_kwargs=text_loader_kwargs) 56 | documents = loader.load() 57 | return documents 58 | 59 | @staticmethod 60 | def html_bs4(path: str, glob: str) -> List[Document]: 61 | loader = BSHTMLLoader(path) 62 | documents = loader.load() 63 | return documents 64 | 65 | @staticmethod 66 | def json(path: str, schema: str) -> List[Document]: 67 | loader = JSONLoader(Path(path).read_text(), schema) 68 | documents = loader.load() 69 | return documents 70 | 71 | @staticmethod 72 | def markdown(path: str) -> List[Document]: 73 | loader = UnstructuredMarkdownLoader(path) 74 | documents = loader.load() 75 | return documents 76 | 77 | @staticmethod 78 | def image(path: str) -> List[Document]: 79 | loader = UnstructuredImageLoader(path) 80 | documents = loader.load() 81 | return documents 82 | 83 | @staticmethod 84 | def pdf(path: str) -> List[Document]: 85 | loader = PyPDFLoader(path) 86 | documents = loader.load_and_split() 87 | return documents 88 | 89 | @staticmethod 90 | def online_pdf(url: str) -> List[Document]: 91 | loader = OnlinePDFLoader(url) 92 | documents = loader.load() 93 | return documents 94 | 95 | @staticmethod 96 | def sitemap(url: str) -> List[Document]: 97 | loader = SitemapLoader(url) 98 | documents = loader.load() 99 | return documents 100 | 101 | @staticmethod 102 | def subtitle(file_path: str) -> List[Document]: 103 | loader = SRTLoader(file_path) 104 | documents = loader.load() 105 | return documents 106 | 107 | @staticmethod 108 | def email(file_path: str) -> List[Document]: 109 | loader = UnstructuredEmailLoader(file_path) 110 | documents = loader.load() 111 | return documents 112 | 113 | @staticmethod 114 | def word(file_path: str) -> List[Document]: 115 | loader = UnstructuredWordDocumentLoader(file_path) 116 | documents = loader.load() 117 | return documents 118 | 119 | @staticmethod 120 | def youtube(url: str) -> List[Document]: 121 | loader = YoutubeLoader.from_youtube_url(url, add_video_info=True) 122 | documents = loader.load() 123 | return documents 124 | 125 | @staticmethod 126 | def playwrite(urls: List[str]) -> List[Document]: 127 | loader = PlaywrightURLLoader(urls=urls) 128 | documents = loader.load() 129 | return documents 130 | 131 | @staticmethod 132 | def web_base(urls: List[str]) -> List[Document]: 133 | loader = WebBaseLoader(urls) 134 | documents = loader.load() 135 | return documents 136 | 137 | @staticmethod 138 | def azlyrics(urls: List[str]) -> List[Document]: 139 | loader = AZLyricsLoader(urls) 140 | documents = loader.load() 141 | return documents 142 | 143 | @staticmethod 144 | def hugging_face(dataset_name: str = "imdb", page_content_column: str = "text") -> List[Document]: 145 | loader = HuggingFaceDatasetLoader(dataset_name, page_content_column) 146 | documents = loader.load() 147 | return documents 148 | 149 | @staticmethod 150 | def imsdb(path: str) -> List[Document]: 151 | loader = IMSDbLoader(path) 152 | documents = loader.load() 153 | return documents 154 | 155 | @staticmethod 156 | def chat_gpt(path: str) -> List[Document]: 157 | loader = ChatGPTLoader(path) 158 | documents = loader.load() 159 | return documents 160 | 161 | @staticmethod 162 | def figma(access_token: str, node_id: str, file_key: str) -> List[Document]: 163 | loader = FigmaFileLoader(access_token, node_id, file_key) 164 | documents = loader.load() 165 | return documents 166 | 167 | @staticmethod 168 | def gitbook(url: str) -> List[Document]: 169 | loader = GitbookLoader(url, load_all_paths=True) 170 | documents = loader.load() 171 | return documents 172 | 173 | @staticmethod 174 | def obsidian(url: str) -> List[Document]: 175 | loader = ObsidianLoader(url) 176 | documents = loader.load() 177 | return documents 178 | 179 | @staticmethod 180 | def git(clone_url: str, repo_path: str, branch: str = "master") -> List[Document]: 181 | loader = GitLoader( 182 | clone_url=clone_url, 183 | repo_path=repo_path, 184 | branch=branch 185 | ) 186 | documents = loader.load() 187 | return documents 188 | 189 | @staticmethod 190 | def blip(image_urls: List[str]) -> List[Document]: 191 | loader = ImageCaptionLoader(image_urls) 192 | documents = loader.load() 193 | return documents 194 | 195 | @staticmethod 196 | def split_docs(documents: List[Document], **kwargs) -> List[Document]: 197 | text_splitter = CharacterTextSplitter(**kwargs) 198 | docs = text_splitter.split_documents(documents) 199 | return docs 200 | 201 | 202 | @staticmethod 203 | def convert_documents_to_markdown(docs): 204 | markdown = "" 205 | 206 | for idx, doc in enumerate(docs): 207 | markdown += f"# Document {idx + 1}\n\n" 208 | markdown += f"{doc.page_content}\n\n" 209 | 210 | # If metadata is available, format it as a section 211 | if doc.metadata: 212 | markdown += "## Metadata\n" 213 | for key, value in doc.metadata.items(): 214 | # remove local file paths 215 | if key == "source": 216 | head, tail = os.path.split(value) 217 | value = tail 218 | markdown += f"- **{key}**: {value}\n" 219 | markdown += "\n---\n\n" # Separator between documents 220 | 221 | return markdown 222 | 223 | 224 | 225 | ``` -------------------------------------------------------------------------------- /clients/PHP/3.1 mcp_get_source/MCPGetSourceClient.php: -------------------------------------------------------------------------------- ```php 1 | <?php 2 | /** 3 | * MCPGetSourceClient.php 4 | * 5 | * A PHP script acting as a Get Source Client. It connects to a server via TCP, 6 | * sends a request to retrieve source information, and receives the server's response. 7 | * 8 | * Usage: 9 | * php MCPGetSourceClient.php --server-ip <IP> --server-port <Port> --token <Token> --source-id <SourceID> 10 | */ 11 | 12 | /** 13 | * Function to parse command line arguments 14 | * 15 | * @param array $args Command line arguments 16 | * @return array Associative array of parsed arguments 17 | */ 18 | function parseArguments($args) { 19 | $parsedArgs = []; 20 | $argc = count($args); 21 | for ($i = 1; $i < $argc; $i++) { 22 | switch ($args[$i]) { 23 | case '--server-ip': 24 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 25 | $parsedArgs['serverIp'] = $args[++$i]; 26 | } else { 27 | fwrite(STDERR, "Error: --server-ip expects a value.\n"); 28 | exit(1); 29 | } 30 | break; 31 | case '--server-port': 32 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 33 | $parsedArgs['serverPort'] = intval($args[++$i]); 34 | } else { 35 | fwrite(STDERR, "Error: --server-port expects a value.\n"); 36 | exit(1); 37 | } 38 | break; 39 | case '--token': 40 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 41 | $parsedArgs['token'] = $args[++$i]; 42 | } else { 43 | fwrite(STDERR, "Error: --token expects a value.\n"); 44 | exit(1); 45 | } 46 | break; 47 | case '--source-id': 48 | if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { 49 | $parsedArgs['sourceId'] = $args[++$i]; 50 | } else { 51 | fwrite(STDERR, "Error: --source-id expects a value.\n"); 52 | exit(1); 53 | } 54 | break; 55 | default: 56 | fwrite(STDERR, "⚠️ Warning: Unknown argument: {$args[$i]}\n"); 57 | } 58 | } 59 | return $parsedArgs; 60 | } 61 | 62 | /** 63 | * Helper function to check if a string starts with a specific prefix 64 | * 65 | * @param string $string The string to check 66 | * @param string $prefix The prefix 67 | * @return bool True if the string starts with the prefix, otherwise False 68 | */ 69 | function startsWith($string, $prefix) { 70 | return substr($string, 0, strlen($prefix)) === $prefix; 71 | } 72 | 73 | /** 74 | * Function for interactively prompting a parameter (optional) 75 | * 76 | * @param string $prompt The prompt message 77 | * @return string User input 78 | */ 79 | function askQuestionPrompt($prompt) { 80 | if (preg_match('/^win/i', PHP_OS)) { 81 | // Windows-specific input prompt 82 | $vbscript = sys_get_temp_dir() . 'prompt_input.vbs'; 83 | file_put_contents($vbscript, 'wscript.echo(InputBox("' . addslashes($prompt) . '", "", ""))'); 84 | $response = shell_exec("cscript //nologo " . escapeshellarg($vbscript)); 85 | unlink($vbscript); 86 | return trim($response); 87 | } else { 88 | // Unix/Linux input prompt 89 | echo $prompt; 90 | $handle = fopen("php://stdin", "r"); 91 | $response = trim(fgets($handle)); 92 | fclose($handle); 93 | return $response; 94 | } 95 | } 96 | 97 | /** 98 | * Function to send a Get Source request over a TCP connection 99 | * 100 | * @param string $serverIp The server's IP address 101 | * @param int $serverPort The server's port 102 | * @param array $payload The payload to send as an associative array 103 | * @return array The response received from the server as an associative array 104 | * @throws Exception On connection errors or JSON parsing errors 105 | */ 106 | function sendGetSourceRequest($serverIp, $serverPort, $payload) { 107 | $jsonPayload = json_encode($payload); 108 | if ($jsonPayload === false) { 109 | throw new Exception("Error while coding the JSON payload: " . json_last_error_msg()); 110 | } 111 | 112 | $errno = 0; 113 | $errstr = ''; 114 | $timeout = 30; // seconds 115 | $client = @fsockopen($serverIp, $serverPort, $errno, $errstr, $timeout); 116 | 117 | if (!$client) { 118 | throw new Exception("Connection error: $errstr ($errno)"); 119 | } 120 | 121 | echo "🔗 Connected to the server ({$serverIp}:{$serverPort}).\n"; 122 | echo "📤 Sending payload: $jsonPayload\n"; 123 | 124 | fwrite($client, $jsonPayload); 125 | 126 | $responseData = ''; 127 | stream_set_timeout($client, $timeout); 128 | 129 | while (!feof($client)) { 130 | $data = fread($client, 1024); 131 | if ($data === false) { 132 | throw new Exception("Error reading data from the server."); 133 | } 134 | if ($data === '') { 135 | break; // No more data 136 | } 137 | echo "📥 Received data: $data\n"; 138 | $responseData .= $data; 139 | 140 | // Attempt to parse received data as JSON 141 | $parsedData = json_decode($responseData, true); 142 | if ($parsedData !== null) { 143 | echo "✅ JSON response successfully parsed.\n"; 144 | fclose($client); 145 | return $parsedData; 146 | } 147 | 148 | // Check if the stream timed out 149 | $info = stream_get_meta_data($client); 150 | if ($info['timed_out']) { 151 | throw new Exception("Timeout waiting for data from the server."); 152 | } 153 | } 154 | 155 | fclose($client); 156 | throw new Exception("Connection to the server was closed before a complete response was received."); 157 | } 158 | 159 | /** 160 | * Main function of the script 161 | */ 162 | function main($argv) { 163 | $parsedArgs = parseArguments($argv); 164 | $serverIp = $parsedArgs['serverIp'] ?? null; 165 | $serverPort = $parsedArgs['serverPort'] ?? null; 166 | $token = $parsedArgs['token'] ?? null; 167 | $sourceId = $parsedArgs['sourceId'] ?? null; 168 | 169 | // Interactively prompt for missing parameters 170 | if (!$serverIp) { 171 | $serverIp = askQuestionPrompt('🔗 Please enter the server IP: '); 172 | } 173 | if (!$serverPort) { 174 | $portInput = askQuestionPrompt('🔗 Please enter the server port: '); 175 | $serverPort = intval($portInput); 176 | if ($serverPort <= 0) { 177 | fwrite(STDERR, "❌ ERROR: Invalid server port.\n"); 178 | exit(1); 179 | } 180 | } 181 | if (!$token) { 182 | $token = askQuestionPrompt('🔒 Please enter your authentication token: '); 183 | } 184 | if (!$sourceId) { 185 | $sourceId = askQuestionPrompt('📁 Please enter the Source ID: '); 186 | } 187 | 188 | // Check if all required parameters are now present 189 | if (!$serverIp || !$serverPort || !$token || !$sourceId) { 190 | fwrite(STDERR, "❌ ERROR: Missing required parameters.\n"); 191 | fwrite(STDOUT, "Usage: php MCPGetSourceClient.php --server-ip <IP> --server-port <Port> --token <Token> --source-id <SourceID>\n"); 192 | exit(1); 193 | } 194 | 195 | $payload = [ 196 | "command" => "get_source", 197 | "token" => $token, 198 | "arguments" => [ 199 | "sourceId" => $sourceId 200 | ] 201 | ]; 202 | 203 | try { 204 | echo "📤 Sending Get Source request...\n"; 205 | $response = sendGetSourceRequest($serverIp, $serverPort, $payload); 206 | echo "✅ Server Response:\n"; 207 | echo json_encode($response, JSON_PRETTY_PRINT) . "\n"; 208 | } catch (Exception $e) { 209 | fwrite(STDERR, "❌ ERROR: " . $e->getMessage() . "\n"); 210 | } 211 | } 212 | 213 | // Ensure PHP version is at least 7.1 214 | if (version_compare(PHP_VERSION, '7.1.0') < 0) { 215 | fwrite(STDERR, "❌ ERROR: This script requires PHP version 7.1 or higher.\n"); 216 | exit(1); 217 | } 218 | 219 | // Call the main function 220 | main($argv); 221 | ?> 222 | ```