This is page 9 of 16. Use http://codebase.md/fujitsu-ai/mcp-server-for-mas-developments?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/3.3 mcp_edit_source/Program.cs: -------------------------------------------------------------------------------- ```csharp using System; using System.Collections.Generic; using System.Linq; using System.Net.Sockets; using System.Text; using Newtonsoft.Json; namespace MCPEditSourceClient { class Program { static void Main(string[] args) { // Parameterprüfung (mind. 8 Elemente, weil 4 Pflichtargumente: // --server-ip, --server-port, --token, --source-id) // plus optionale Argumente (--title, --content, --groups). if (args.Length < 8) { Console.WriteLine("Usage:"); Console.WriteLine(" --server-ip <IP> --server-port <PORT> --token <TOKEN> --source-id <SOURCE_ID>"); Console.WriteLine(" [--title <TITLE>] [--content <CONTENT>] [--groups <LIST_OF_GROUPS>]"); return; } // Argumente auslesen string serverIp = GetArgument(args, "--server-ip"); string portStr = GetArgument(args, "--server-port"); string token = GetArgument(args, "--token"); string sourceId = GetArgument(args, "--source-id"); string title = GetArgument(args, "--title"); string content = GetArgument(args, "--content"); List<string> groups = GetListArgument(args, "--groups"); if (serverIp == null || portStr == null || token == null || sourceId == null) { Console.WriteLine("Fehler: Mindestens eines der Pflichtargumente wurde nicht angegeben."); return; } if (!int.TryParse(portStr, out int serverPort)) { Console.WriteLine("Fehler: --server-port muss eine ganzzahlige Portangabe sein."); return; } // Anfrage an den Server senden string response = SendEditSourceRequest( serverIp, serverPort, token, sourceId, title, content, groups ); Console.WriteLine("Response from server:"); Console.WriteLine(response); } /// <summary> /// Sendet die Edit-Source-Anfrage an den MCP-Server. /// </summary> /// <param name="serverIp">IP-Adresse des MCP-Servers</param> /// <param name="serverPort">Port des MCP-Servers</param> /// <param name="token">Authentifizierungstoken</param> /// <param name="sourceId">ID der zu bearbeitenden Quelle</param> /// <param name="title">Neuer Titel der Quelle (optional)</param> /// <param name="content">Neuer Inhalt (Markdown) (optional)</param> /// <param name="groups">Liste der neuen Gruppen (optional)</param> /// <returns>String-Antwort des Servers oder Fehlermeldung</returns> static string SendEditSourceRequest( string serverIp, int serverPort, string token, string sourceId, string title = null, string content = null, List<string> groups = null) { // Payload zusammenbauen var arguments = new Dictionary<string, object> { { "sourceId", sourceId } }; // Nur hinzufügen, wenn nicht null if (!string.IsNullOrWhiteSpace(title)) arguments["title"] = title; if (!string.IsNullOrWhiteSpace(content)) arguments["content"] = content; // Falls keine Gruppen übergeben wurden, leere Liste setzen arguments["groups"] = groups ?? new List<string>(); // Payload-Objekt erstellen var payload = new { command = "edit_source", token = token, arguments }; // JSON serialisieren string payloadJson = JsonConvert.SerializeObject(payload); // Per TCP an den Server senden try { using (var client = new TcpClient(serverIp, serverPort)) using (NetworkStream stream = client.GetStream()) { // Senden byte[] data = Encoding.UTF8.GetBytes(payloadJson); stream.Write(data, 0, data.Length); // Antwort empfangen byte[] buffer = new byte[4096]; int bytesRead; StringBuilder responseBuilder = new StringBuilder(); do { bytesRead = stream.Read(buffer, 0, buffer.Length); responseBuilder.Append(Encoding.UTF8.GetString(buffer, 0, bytesRead)); } while (bytesRead == buffer.Length); return responseBuilder.ToString(); } } catch (Exception e) { return $"Error: {e.Message}"; } } /// <summary> /// Liest den Wert eines bestimmten Keys aus args aus (z.B. --server-ip 127.0.0.1). /// </summary> /// <param name="args">Alle Argumente</param> /// <param name="key">Gesuchter Key (z.B. "--server-ip")</param> /// <returns>Wert des Keys oder null</returns> static string GetArgument(string[] args, string key) { int index = Array.IndexOf(args, key); return index >= 0 && index < args.Length - 1 ? args[index + 1] : null; } /// <summary> /// Liest eine Liste an Werten aus, die auf den key folgen (z.B. --groups G1 G2 --irgendeinAndererKey ...). /// </summary> /// <param name="args">Alle Argumente</param> /// <param name="key">Gesuchter Key (z.B. "--groups")</param> /// <returns>Liste gefundener Werte oder eine leere Liste</returns> static List<string> GetListArgument(string[] args, string key) { var result = new List<string>(); int index = Array.IndexOf(args, key); if (index >= 0) { for (int i = index + 1; i < args.Length && !args[i].StartsWith("--"); i++) { result.Add(args[i]); } } return result; } } } ``` -------------------------------------------------------------------------------- /clients/C# .Net/Code Archiv/mcp_edit_source.cs: -------------------------------------------------------------------------------- ```csharp using System; using System.Collections.Generic; using System.Linq; using System.Net.Sockets; using System.Text; using Newtonsoft.Json; namespace MCPEditSourceClient { class Program { static void Main(string[] args) { // Parameterprüfung (mind. 8 Elemente, weil 4 Pflichtargumente: // --server-ip, --server-port, --token, --source-id) // plus optionale Argumente (--title, --content, --groups). if (args.Length < 8) { Console.WriteLine("Usage:"); Console.WriteLine(" --server-ip <IP> --server-port <PORT> --token <TOKEN> --source-id <SOURCE_ID>"); Console.WriteLine(" [--title <TITLE>] [--content <CONTENT>] [--groups <LIST_OF_GROUPS>]"); return; } // Argumente auslesen string serverIp = GetArgument(args, "--server-ip"); string portStr = GetArgument(args, "--server-port"); string token = GetArgument(args, "--token"); string sourceId = GetArgument(args, "--source-id"); string title = GetArgument(args, "--title"); string content = GetArgument(args, "--content"); List<string> groups = GetListArgument(args, "--groups"); if (serverIp == null || portStr == null || token == null || sourceId == null) { Console.WriteLine("Fehler: Mindestens eines der Pflichtargumente wurde nicht angegeben."); return; } if (!int.TryParse(portStr, out int serverPort)) { Console.WriteLine("Fehler: --server-port muss eine ganzzahlige Portangabe sein."); return; } // Anfrage an den Server senden string response = SendEditSourceRequest( serverIp, serverPort, token, sourceId, title, content, groups ); Console.WriteLine("Response from server:"); Console.WriteLine(response); } /// <summary> /// Sendet die Edit-Source-Anfrage an den MCP-Server. /// </summary> /// <param name="serverIp">IP-Adresse des MCP-Servers</param> /// <param name="serverPort">Port des MCP-Servers</param> /// <param name="token">Authentifizierungstoken</param> /// <param name="sourceId">ID der zu bearbeitenden Quelle</param> /// <param name="title">Neuer Titel der Quelle (optional)</param> /// <param name="content">Neuer Inhalt (Markdown) (optional)</param> /// <param name="groups">Liste der neuen Gruppen (optional)</param> /// <returns>String-Antwort des Servers oder Fehlermeldung</returns> static string SendEditSourceRequest( string serverIp, int serverPort, string token, string sourceId, string title = null, string content = null, List<string> groups = null) { // Payload zusammenbauen var arguments = new Dictionary<string, object> { { "sourceId", sourceId } }; // Nur hinzufügen, wenn nicht null if (!string.IsNullOrWhiteSpace(title)) arguments["title"] = title; if (!string.IsNullOrWhiteSpace(content)) arguments["content"] = content; // Falls keine Gruppen übergeben wurden, leere Liste setzen arguments["groups"] = groups ?? new List<string>(); // Payload-Objekt erstellen var payload = new { command = "edit_source", token = token, arguments }; // JSON serialisieren string payloadJson = JsonConvert.SerializeObject(payload); // Per TCP an den Server senden try { using (var client = new TcpClient(serverIp, serverPort)) using (NetworkStream stream = client.GetStream()) { // Senden byte[] data = Encoding.UTF8.GetBytes(payloadJson); stream.Write(data, 0, data.Length); // Antwort empfangen byte[] buffer = new byte[4096]; int bytesRead; StringBuilder responseBuilder = new StringBuilder(); do { bytesRead = stream.Read(buffer, 0, buffer.Length); responseBuilder.Append(Encoding.UTF8.GetString(buffer, 0, bytesRead)); } while (bytesRead == buffer.Length); return responseBuilder.ToString(); } } catch (Exception e) { return $"Error: {e.Message}"; } } /// <summary> /// Liest den Wert eines bestimmten Keys aus args aus (z.B. --server-ip 127.0.0.1). /// </summary> /// <param name="args">Alle Argumente</param> /// <param name="key">Gesuchter Key (z.B. "--server-ip")</param> /// <returns>Wert des Keys oder null</returns> static string GetArgument(string[] args, string key) { int index = Array.IndexOf(args, key); return index >= 0 && index < args.Length - 1 ? args[index + 1] : null; } /// <summary> /// Liest eine Liste an Werten aus, die auf den key folgen (z.B. --groups G1 G2 --irgendeinAndererKey ...). /// </summary> /// <param name="args">Alle Argumente</param> /// <param name="key">Gesuchter Key (z.B. "--groups")</param> /// <returns>Liste gefundener Werte oder eine leere Liste</returns> static List<string> GetListArgument(string[] args, string key) { var result = new List<string>(); int index = Array.IndexOf(args, key); if (index >= 0) { for (int i = index + 1; i < args.Length && !args[i].StartsWith("--"); i++) { result.Add(args[i]); } } return result; } } } ``` -------------------------------------------------------------------------------- /clients/Gradio/SourceManagement.py: -------------------------------------------------------------------------------- ```python import json import socket import ssl def delete_source(self, source_id, use_ssl=False, accept_self_signed=False): """ Sends a request to the MCP server to delete an existing source. :param server_ip: IP address of the MCP server :param server_port: Port number of the MCP server :param token: Authorization token :param source_id: ID of the source to delete :param use_ssl: Whether to use SSL/TLS for the connection :param accept_self_signed: Whether to accept self-signed certificates :return: Response from the server """ payload = { "command": "delete_source", "token": self.token, "arguments": { "sourceId": source_id } } payload_json = json.dumps(payload) raw_socket = None client_socket = None try: raw_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) raw_socket.settimeout(10) if use_ssl: context = ssl.create_default_context() if accept_self_signed: context.check_hostname = False context.verify_mode = ssl.CERT_NONE client_socket = context.wrap_socket(raw_socket, server_hostname=self.server_ip) else: client_socket = raw_socket client_socket.connect((self.server_ip, self.server_port)) client_socket.sendall(payload_json.encode('utf-8')) response = b"" while True: part = client_socket.recv(4096) if not part: break response += part return response.decode('utf-8') except ssl.SSLError: return "Error: Server and/or client may require TLS encryption. Please enable SSL/TLS." except Exception as e: return f"Error: {e}" finally: if client_socket is not None: try: client_socket.shutdown(socket.SHUT_RDWR) except: pass client_socket.close() def send_list_sources_request(self, group_name, use_ssl=False, accept_self_signed=False): """ Sends a request to list sources in a specific group to the MCP server. :param server_ip: IP address of the MCP server :param server_port: Port number of the MCP server :param token: Authentication token :param group_name: Name of the group to list sources from :param use_ssl: Whether to use SSL/TLS for the connection :param accept_self_signed: Whether to accept self-signed certificates :return: Response from the server """ payload = { "command": "list_sources", "token": self.token, "attributes": { "groupName": group_name } } payload_json = json.dumps(payload) raw_socket = None client_socket = None try: raw_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) raw_socket.settimeout(10) if use_ssl: context = ssl.create_default_context() if accept_self_signed: context.check_hostname = False context.verify_mode = ssl.CERT_NONE client_socket = context.wrap_socket(raw_socket, server_hostname=self.server_ip) else: client_socket = raw_socket client_socket.connect((self.server_ip, self.server_port)) client_socket.sendall(payload_json.encode('utf-8')) response = b"" while True: part = client_socket.recv(4096) if not part: break response += part return response.decode('utf-8') except ssl.SSLError: return "Error: Server and/or client may require TLS encryption. Please enable SSL/TLS." except Exception as e: return f"Error: {e}" finally: if client_socket is not None: try: client_socket.shutdown(socket.SHUT_RDWR) except: pass client_socket.close() def send_create_source_request(self, name, content, groups, use_ssl=False, accept_self_signed=False): """ Sends a request to create a new source to the MCP server. :param server_ip: IP address of the MCP server :param server_port: Port number of the MCP server :param token: Authentication token :param name: Name of the new source :param content: Content to be formatted as markdown :param groups: List of groups to assign the source to :param use_ssl: Whether to use SSL/TLS for the connection :param accept_self_signed: Whether to accept self-signed certificates :return: Response from the server """ payload = { "command": "create_source", "token": self.token, "arguments": { "name": name, "content": content, "groups": groups or [] } } # Convert the payload to a JSON string payload_json = json.dumps(payload) raw_socket = None client_socket = None try: # Create a socket object raw_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) raw_socket.settimeout(10) # Establish SSL/TLS connection if required if use_ssl: context = ssl.create_default_context() if accept_self_signed: context.check_hostname = False context.verify_mode = ssl.CERT_NONE client_socket = context.wrap_socket(raw_socket, server_hostname=self.server_ip) else: client_socket = raw_socket # Connect to the server client_socket.connect((self.server_ip, self.server_port)) # Send the request client_socket.sendall(payload_json.encode('utf-8')) # Receive the response response = b"" while True: part = client_socket.recv(4096) if not part: break response += part # Decode the response return response.decode('utf-8') except ssl.SSLError: return "Error: Server and/or client may require TLS encryption. Please enable SSL/TLS." except Exception as e: return f"Error: {e}" finally: if client_socket is not None: try: client_socket.shutdown(socket.SHUT_RDWR) except: pass client_socket.close() ``` -------------------------------------------------------------------------------- /clients/Java/5.0 mcp_store_user/MCPStoreUserClient.java: -------------------------------------------------------------------------------- ```java import org.json.JSONArray; import org.json.JSONObject; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class MCPStoreUserClient { public static void main(String[] args) { // Laut Original soll es mindestens 14 Strings geben, // also 7 Schlüssel-Wert-Paare. (z.B. --server-ip <IP> etc.) if (args.length < 14) { printUsage(); return; } // Argumente auslesen String serverIp = getArgument(args, "--server-ip"); String portStr = getArgument(args, "--server-port"); String token = getArgument(args, "--token"); String name = getArgument(args, "--name"); String email = getArgument(args, "--email"); String password = getArgument(args, "--password"); String language = getArgument(args, "--language"); String timezone = getArgument(args, "--timezone"); if (language == null) { language = "en"; // Standardwert laut Original } if (timezone == null) { timezone = "Europe/Berlin"; // Standardwert laut Original } List<String> roles = getListArgument(args, "--roles"); List<String> groups = getListArgument(args, "--groups"); // Flags boolean usePublic = Arrays.asList(args).contains("--usePublic"); boolean activateFtp= Arrays.asList(args).contains("--activateFtp"); // FTP-Passwort, falls angegeben String ftpPassword = getArgument(args, "--ftpPassword"); if (ftpPassword == null) { ftpPassword = ""; } // Falls kritische Argumente fehlen, Usage anzeigen if (serverIp == null || portStr == null || token == null || name == null || email == null || password == null) { printUsage(); return; } int serverPort = Integer.parseInt(portStr); System.out.println("📤 Sending store user request..."); // JSON-Payload erstellen JSONObject payload = new JSONObject(); payload.put("command", "store_user"); payload.put("token", token); JSONObject arguments = new JSONObject(); arguments.put("name", name); arguments.put("email", email); arguments.put("password", password); arguments.put("language", language); arguments.put("timezone", timezone); arguments.put("usePublic", usePublic); arguments.put("activateFtp", activateFtp); arguments.put("ftpPassword", ftpPassword); // roles & groups als JSON-Arrays JSONArray rolesArray = new JSONArray(roles); arguments.put("roles", rolesArray); JSONArray groupsArray = new JSONArray(groups); arguments.put("groups", groupsArray); payload.put("arguments", arguments); // Request versenden String response = sendRequest(serverIp, serverPort, payload); System.out.println("✔️ Response from server:"); System.out.println(response); } /** * Holt genau ein Argument (z.B. "--server-ip 127.0.0.1"). * Gibt null zurück, falls nicht vorhanden oder kein Wert folgt. */ private static String getArgument(String[] args, String key) { for (int i = 0; i < args.length - 1; i++) { if (args[i].equals(key)) { return args[i + 1]; } } return null; } /** * Ähnlich wie getArgument(), aber liest alle Werte ein, * bis das nächste "--" beginnt oder das Array zu Ende ist. */ private static List<String> getListArgument(String[] args, String key) { List<String> values = new ArrayList<>(); for (int i = 0; i < args.length; i++) { if (args[i].equals(key)) { // ab hier sammeln for (int j = i + 1; j < args.length; j++) { if (args[j].startsWith("--")) { break; } values.add(args[j]); } break; // Nur einmal sammeln } } return values; } /** * Stellt eine TCP-Verbindung her, sendet das JSON-Payload und liest die Antwort. */ private static String sendRequest(String serverIp, int serverPort, JSONObject payload) { String payloadJson = payload.toString(); try (Socket client = new Socket(serverIp, serverPort)) { // Payload senden OutputStream out = client.getOutputStream(); byte[] data = payloadJson.getBytes(StandardCharsets.UTF_8); out.write(data); out.flush(); // Antwort empfangen InputStream in = client.getInputStream(); byte[] buffer = new byte[4096]; StringBuilder responseBuilder = new StringBuilder(); int bytesRead; do { bytesRead = in.read(buffer); if (bytesRead > 0) { responseBuilder.append(new String(buffer, 0, bytesRead, StandardCharsets.UTF_8)); } } while (bytesRead == buffer.length); return responseBuilder.toString(); } catch (IOException e) { return "Error: " + e.getMessage(); } } private static void printUsage() { System.out.println("Usage: --server-ip <IP> --server-port <PORT> --token <TOKEN> --name <NAME> --email <EMAIL> --password <PASSWORD>"); System.out.println(" [--language <LANG>] [--timezone <TIMEZONE>] [--roles <ROLE1 ROLE2>] [--groups <GROUP1 GROUP2>]"); System.out.println(" [--usePublic] [--activateFtp] [--ftpPassword <FTP_PASSWORD>]"); System.out.println(); System.out.println("Example:"); System.out.println(" java -cp .;json-20241224.jar MCPStoreUserClient \\"); System.out.println(" --server-ip 127.0.0.1 --server-port 1234 --token MyToken \\"); System.out.println(" --name Max --email [email protected] --password 12345 \\"); System.out.println(" --language de --timezone Europe/Berlin \\"); System.out.println(" --roles admin manager --groups devops finance \\"); System.out.println(" --usePublic --activateFtp --ftpPassword someFtpPass"); } } ``` -------------------------------------------------------------------------------- /agents/MCP-Client/Python/tools_handler.py: -------------------------------------------------------------------------------- ```python import json import logging import re from typing import Any, Dict, Optional from .messages.send_call_tool import send_call_tool from .messages.send_tools_list import send_tools_list def parse_tool_response(response: str) -> Optional[Dict[str, Any]]: """Parse tool call from Llama's XML-style format.""" function_regex = r"<function=(\w+)>(.*?)</function>" match = re.search(function_regex, response) if match: function_name, args_string = match.groups() try: args = json.loads(args_string) return { "id": f"call_{function_name}", "function": function_name, "arguments": args, } except json.JSONDecodeError as error: logging.debug(f"Error parsing function arguments: {error}") return None async def handle_tool_call(tool_call, conversation_history, server_streams): """ Handle a single tool call for both OpenAI and Llama formats. This function no longer prints directly to stdout. It updates the conversation_history with the tool call and its response. The calling function can then display the results. """ tool_call_id = None tool_name = "unknown_tool" raw_arguments = {} try: # Handle object-style tool calls from both OpenAI and Ollama if hasattr(tool_call, "function") or ( isinstance(tool_call, dict) and "function" in tool_call ): # Get tool name and arguments based on format if hasattr(tool_call, "function"): tool_call_id = tool_call.id tool_name = tool_call.function.name raw_arguments = tool_call.function.arguments else: tool_call_id = tool_call["id"] tool_name = tool_call["function"]["name"] raw_arguments = tool_call["function"]["arguments"] else: # Parse Llama's XML format from the last message last_message = conversation_history[-1]["content"] parsed_tool = parse_tool_response(last_message) if not parsed_tool: logging.debug("Unable to parse tool call from message") return tool_call_id = parsed_tool["id"] tool_name = parsed_tool["function"] raw_arguments = parsed_tool["arguments"] # Parse the tool arguments tool_args = ( json.loads(raw_arguments) if isinstance(raw_arguments, str) else raw_arguments ) # Call the tool (no direct print here) tool_response = {} for read_stream, write_stream in server_streams: tools = await fetch_tools(read_stream, write_stream) server_has_tool = False for tool in tools: if tool["name"] == tool_name: server_has_tool = True if server_has_tool: tool_response = await send_call_tool( tool_name, tool_args, read_stream, write_stream ) if not tool_response.get("isError"): break else: continue if tool_response.get("isError"): logging.debug( f"Error calling tool '{tool_name}': {tool_response.get('content')}" ) # Format the tool response formatted_response = format_tool_response(tool_response.get("content", [])) logging.debug(f"Tool '{tool_name}' Response: {formatted_response}") if formatted_response == "": print(f"Warning Tool '{tool_name}' Response: {formatted_response}") #print(f"Tool '{tool_name}' Response: {formatted_response}") # Update the conversation history with the tool call # Add the tool call itself (for OpenAI tracking) conversation_history.append( { "role": "assistant", "content": None, "tool_calls": [ { "id": tool_call_id, "type": "function", "function": { "name": tool_name, "arguments": json.dumps(tool_args) if isinstance(tool_args, dict) else tool_args, }, } ], } ) # Add the tool response to conversation history conversation_history.append( { "role": "tool", "name": tool_name, "content": str(formatted_response), "tool_call_id": tool_call_id, } ) except json.JSONDecodeError: logging.debug( f"Error decoding arguments for tool '{tool_name}': {raw_arguments}" ) except Exception as e: logging.debug(f"Error handling tool call '{tool_name}': {str(e)}") def format_tool_response(response_content): """Format the response content from a tool.""" if isinstance(response_content, list): return "\n".join( item.get("text", "No content") for item in response_content if item.get("type") == "text" ) return str(response_content) async def fetch_tools(read_stream, write_stream): """Fetch tools from the server.""" logging.debug("\nFetching tools for chat mode...") # get the tools list tools_response = await send_tools_list(read_stream, write_stream) tools = tools_response.get("tools", []) # check if tools are valid if not isinstance(tools, list) or not all(isinstance(tool, dict) for tool in tools): logging.debug("Invalid tools format received.") return None return tools def convert_to_openai_tools(tools): """Convert tools into OpenAI-compatible function definitions.""" openai_tools = [] for tool in tools: # TODO. This works around the mcp-remote library putting the input scheme into another objet if tool.get("inputSchema", {}).get("properties").get("type") == "object": inputScheme = tool.get("inputSchema", {}).get("properties") else: inputScheme = tool.get("inputSchema", {}) entry = { "type": "function", "function": { "name": tool["name"], "description": tool.get("description", ""), "parameters": inputScheme }, } openai_tools.append(entry) return openai_tools ``` -------------------------------------------------------------------------------- /clients/Java/5.1 mcp_edit_user/MCPEditUserClient.java: -------------------------------------------------------------------------------- ```java import org.json.JSONObject; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.Socket; import java.nio.charset.StandardCharsets; import java.util.*; public class MCPEditUserClient { public static void main(String[] args) { // Kurze Validierung der Argumente if (args.length < 8) { System.out.println("Usage: " + "--server-ip <IP> " + "--server-port <PORT> " + "--token <TOKEN> " + "--user-id <USER_ID> [weitere optionale Parameter]"); return; } // Argumente auslesen String serverIp = getArgument(args, "--server-ip"); String portString = getArgument(args, "--server-port"); if (serverIp == null || portString == null) { System.err.println("Server-IP oder Server-Port fehlt!"); return; } int serverPort = Integer.parseInt(portString); String token = getArgument(args, "--token"); String userId = getArgument(args, "--user-id"); // Optional String name = getArgument(args, "--name"); String email = getArgument(args, "--email"); String password = getArgument(args, "--password"); String language = getArgument(args, "--language"); String timezone = getArgument(args, "--timezone"); List<String> roles = getListArgument(args, "--roles"); List<String> groups = getListArgument(args, "--groups"); boolean usePublic = Arrays.asList(args).contains("--usePublic"); boolean activateFtp = Arrays.asList(args).contains("--activateFtp"); String ftpPassword = getArgument(args, "--ftpPassword"); // Argumente in eine Map packen Map<String, Object> argumentsMap = new HashMap<>(); argumentsMap.put("userId", userId); argumentsMap.put("name", name); argumentsMap.put("email", email); argumentsMap.put("password", password); argumentsMap.put("language", language); argumentsMap.put("timezone", timezone); argumentsMap.put("roles", roles); argumentsMap.put("groups", groups); argumentsMap.put("usePublic", usePublic); argumentsMap.put("activateFtp", activateFtp); argumentsMap.put("ftpPassword", ftpPassword); // Null oder leere Strings entfernen argumentsMap = removeNullOrEmpty(argumentsMap); // JSON-Payload zusammenstellen JSONObject payload = new JSONObject(); payload.put("command", "edit_user"); payload.put("token", token); payload.put("arguments", argumentsMap); System.out.println("📤 Sending edit user request..."); String response = sendRequest(serverIp, serverPort, payload.toString()); System.out.println("✔️ Response from server:"); System.out.println(response); } /** * Liest den Wert eines bestimmten Parameters aus dem Argument-Array. * Bsp.: "--server-ip" -> "127.0.0.1" * * @param args Array mit allen Argumenten * @param key Name des Arguments, nach dem gesucht wird (z.B. "--server-ip") * @return Wert des Arguments oder null, falls nicht gefunden */ private static String getArgument(String[] args, String key) { for (int i = 0; i < args.length; i++) { if (args[i].equals(key) && i < args.length - 1) { return args[i + 1]; } } return null; } /** * Liest mehrere Werte für einen Argument-Schlüssel (z.B. "--roles") aus, * bis ein neues Argument mit "--" beginnt. * * @param args Array mit allen Argumenten * @param key Name des Arguments, nach dem gesucht wird (z.B. "--roles") * @return Liste der gefundenen Werte, sonst eine leere Liste */ private static List<String> getListArgument(String[] args, String key) { List<String> values = new ArrayList<>(); for (int i = 0; i < args.length; i++) { if (args[i].equals(key)) { // Sammle solange, bis ein neues "--" beginnt oder args zu Ende for (int j = i + 1; j < args.length && !args[j].startsWith("--"); j++) { values.add(args[j]); } break; } } return values; } /** * Entfernt alle Einträge, deren Wert null oder ein leerer String ist. */ private static Map<String, Object> removeNullOrEmpty(Map<String, Object> original) { Map<String, Object> cleaned = new HashMap<>(); for (Map.Entry<String, Object> entry : original.entrySet()) { Object value = entry.getValue(); if (value != null) { // Wenn String, checke ob leer oder nur Whitespace if (value instanceof String) { String str = (String) value; if (!str.trim().isEmpty()) { cleaned.put(entry.getKey(), value); } } else { // Keine weitere Prüfung für Listen, Booleans, etc. cleaned.put(entry.getKey(), value); } } } return cleaned; } /** * Sendet den gegebenen JSON-String per TCP an den Server und empfängt die Antwort. * * @param serverIp IP des Servers * @param serverPort Port des Servers * @param payload JSON-String * @return Antwort als String oder Fehlermeldung */ private static String sendRequest(String serverIp, int serverPort, String payload) { try (Socket socket = new Socket(serverIp, serverPort)) { // Daten zum Server senden OutputStream output = socket.getOutputStream(); byte[] data = payload.getBytes(StandardCharsets.UTF_8); output.write(data); output.flush(); // Antwort lesen BufferedReader reader = new BufferedReader( new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8) ); StringBuilder sb = new StringBuilder(); char[] buffer = new char[4096]; int charsRead; do { charsRead = reader.read(buffer, 0, buffer.length); if (charsRead > 0) { sb.append(buffer, 0, charsRead); } } while (charsRead == buffer.length); return sb.toString(); } catch (Exception e) { return "Error: " + e.getMessage(); } } } ``` -------------------------------------------------------------------------------- /clients/PHP/2.0 mcp_chat/MCPChatClient.php: -------------------------------------------------------------------------------- ```php <?php /** * MCPChatClient.php * * A PHP script that acts as a chat client. It connects to a server via TCP, * sends a chat request, and receives the server's response. * * Usage: * php MCPChatClient.php --server-ip <IP> --server-port <Port> --token <Token> --question <Question> [--use-public] [--groups <Group1> <Group2> ...] [--language <Language>] */ // Functions for parsing command line arguments function parseArguments($args) { $parsedArgs = []; $argc = count($args); for ($i = 1; $i < $argc; $i++) { switch ($args[$i]) { case '--server-ip': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['serverIp'] = $args[++$i]; } else { fwrite(STDERR, "Error: --server-ip expects a value.\n"); exit(1); } break; case '--server-port': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['serverPort'] = intval($args[++$i]); } else { fwrite(STDERR, "Error: --server-port expects a value.\n"); exit(1); } break; case '--token': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['token'] = $args[++$i]; } else { fwrite(STDERR, "Error: --token expects a value.\n"); exit(1); } break; case '--question': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['question'] = $args[++$i]; } else { fwrite(STDERR, "Error: --question expects a value.\n"); exit(1); } break; case '--use-public': $parsedArgs['usePublic'] = true; break; case '--groups': // Collect all group arguments until the next flag or end $parsedArgs['groups'] = []; while ($i + 1 < $argc && !startsWith($args[$i + 1], '--')) { $parsedArgs['groups'][] = $args[++$i]; } break; case '--language': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['language'] = $args[++$i]; } else { fwrite(STDERR, "Error: --language expects a value.\n"); exit(1); } break; default: fwrite(STDERR, "Warning: Unknown argument: {$args[$i]}\n"); } } return $parsedArgs; } // Helper function to check if a string starts with a specific prefix function startsWith($string, $prefix) { return substr($string, 0, strlen($prefix)) === $prefix; } // Function for interactively prompting a parameter (optional) function askQuestionPrompt($prompt) { if (preg_match('/^win/i', PHP_OS)) { // Windows-specific input prompt $vbscript = sys_get_temp_dir() . 'prompt_input.vbs'; file_put_contents($vbscript, 'wscript.echo(InputBox("' . addslashes($prompt) . '", "", ""))'); $response = shell_exec("cscript //nologo " . escapeshellarg($vbscript)); unlink($vbscript); return trim($response); } else { // Unix/Linux input prompt echo $prompt; $handle = fopen("php://stdin", "r"); $response = trim(fgets($handle)); fclose($handle); return $response; } } // Function to send a chat request over a TCP connection function sendChatRequest($serverIp, $serverPort, $payload) { $jsonPayload = json_encode($payload); if ($jsonPayload === false) { throw new Exception("Error encoding JSON payload."); } $errno = 0; $errstr = ''; $timeout = 30; // seconds $client = @fsockopen($serverIp, $serverPort, $errno, $errstr, $timeout); if (!$client) { throw new Exception("Connection error: $errstr ($errno)"); } echo "🔗 Connection to server established.\n"; echo "📤 Sending payload: $jsonPayload\n"; fwrite($client, $jsonPayload); $responseData = ''; stream_set_timeout($client, $timeout); while (!feof($client)) { $data = fread($client, 1024); if ($data === false) { throw new Exception("Error reading data from server."); } if ($data === '') { break; // No more data } echo "📥 Received data: $data\n"; $responseData .= $data; // Attempt to parse the received data as JSON $parsedData = json_decode($responseData, true); if ($parsedData !== null) { echo "✅ JSON response successfully parsed.\n"; fclose($client); return $parsedData; } // Check if the stream timed out $info = stream_get_meta_data($client); if ($info['timed_out']) { throw new Exception("Timeout waiting for data from server."); } } fclose($client); throw new Exception("Connection to the server was closed before a complete response was received."); } // Main function function main($argv) { $args = parseArguments($argv); $serverIp = $args['serverIp'] ?? null; $serverPort = $args['serverPort'] ?? null; $token = $args['token'] ?? null; $question = $args['question'] ?? null; $usePublic = $args['usePublic'] ?? false; $groups = $args['groups'] ?? []; $language = $args['language'] ?? 'en'; // Default to English // Check if all required parameters are present if (!$serverIp || !$serverPort || !$token || !$question) { fwrite(STDERR, "❌ ERROR: Missing required parameters.\n"); fwrite(STDOUT, "Usage: php MCPChatClient.php --server-ip <IP> --server-port <Port> --token <Token> --question <Question> [--use-public] [--groups <Group1> <Group2> ...] [--language <Language>]\n"); exit(1); } $payload = [ "command" => "chat", "token" => $token, "arguments" => [ "question" => $question, "usePublic" => $usePublic, "groups" => $groups, "language" => $language ] ]; try { echo "💬 Sending chat request...\n"; $response = sendChatRequest($serverIp, $serverPort, $payload); echo "✅ Server Response:\n"; echo json_encode($response, JSON_PRETTY_PRINT) . "\n"; } catch (Exception $e) { fwrite(STDERR, "❌ ERROR: " . $e->getMessage() . "\n"); } } main($argv); ?> ``` -------------------------------------------------------------------------------- /agents/AgentMonitoring/ChatBot-Agent Dashboard Example - Grafana.json: -------------------------------------------------------------------------------- ```json { "annotations": { "list": [ { "builtIn": 1, "datasource": { "type": "grafana", "uid": "-- Grafana --" }, "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", "name": "Annotations & Alerts", "type": "dashboard" } ] }, "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, "id": 3, "links": [], "panels": [ { "datasource": { "type": "prometheus", "uid": "ceej3ydtls1kwb" }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5, "scaleDistribution": { "type": "linear" }, "showPoints": "auto", "spanNulls": false, "stacking": { "group": "A", "mode": "none" }, "thresholdsStyle": { "mode": "off" } }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] }, "unit": "req/s" }, "overrides": [] }, "gridPos": { "h": 8, "w": 12, "x": 0, "y": 0 }, "id": 1, "options": { "legend": { "calcs": [], "displayMode": "list", "placement": "bottom", "showLegend": true }, "tooltip": { "hideZeros": false, "mode": "single", "sort": "none" } }, "pluginVersion": "11.5.2", "targets": [ { "datasource": "prometheus", "editorMode": "code", "expr": "request_count_total{}", "interval": "", "legendFormat": "{{method}} {{endpoint}}", "range": true, "refId": "A" } ], "title": "Request Count (rate)", "type": "timeseries" }, { "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5, "scaleDistribution": { "type": "linear" }, "showPoints": "auto", "spanNulls": false, "stacking": { "group": "A", "mode": "none" }, "thresholdsStyle": { "mode": "off" } }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] }, "unit": "s" }, "overrides": [] }, "gridPos": { "h": 8, "w": 12, "x": 12, "y": 0 }, "id": 2, "options": { "legend": { "calcs": [], "displayMode": "list", "placement": "bottom", "showLegend": true }, "tooltip": { "hideZeros": false, "mode": "single", "sort": "none" } }, "pluginVersion": "11.5.2", "targets": [ { "datasource": "prometheus", "editorMode": "code", "expr": "histogram_quantile(0.95, sum(rate(request_latency_seconds_bucket[1m])) by (le, method, endpoint))", "legendFormat": "p95 latency: {{method}} {{endpoint}}", "refId": "A" } ], "title": "Request Latency (p95)", "type": "timeseries" }, { "datasource": { "type": "prometheus", "uid": "ceej3ydtls1kwb" }, "fieldConfig": { "defaults": { "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] }, "unit": "none" }, "overrides": [] }, "gridPos": { "h": 6, "w": 6, "x": 0, "y": 8 }, "id": 3, "options": { "colorMode": "value", "graphMode": "none", "justifyMode": "center", "orientation": "auto", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "showPercentChange": false, "textMode": "auto", "wideLayout": true }, "pluginVersion": "11.5.2", "targets": [ { "datasource": "prometheus", "editorMode": "code", "expr": "agent_ask_count_total{}", "range": true, "refId": "A" } ], "title": "ASK Count", "type": "stat" } ], "preload": false, "refresh": "5s", "schemaVersion": 40, "tags": [ "PrivateGPT", "Prometheus", "Flask" ], "templating": { "list": [] }, "time": { "from": "now-15m", "to": "now" }, "timepicker": {}, "timezone": "", "title": "PrivateGPT Chatbot Monitoring", "uid": "aeej7wr8gcwlcd", "version": 5, "weekStart": "" } ``` -------------------------------------------------------------------------------- /agents/MCP-Client/Python/chat_handler.py: -------------------------------------------------------------------------------- ```python # chat_handler.py import json import asyncio from rich import print from rich.markdown import Markdown from rich.panel import Panel from rich.prompt import Prompt from .llm_client import LLMClient from .system_prompt_generator import SystemPromptGenerator from .tools_handler import convert_to_openai_tools, fetch_tools, handle_tool_call async def get_input(prompt: str): """Get input asynchronously.""" loop = asyncio.get_event_loop() return await loop.run_in_executor(None, lambda: Prompt.ask(prompt).strip()) async def handle_chat_mode(server_streams, provider="openai", model="gpt-4o-mini"): """Enter chat mode with multi-call support for autonomous tool chaining.""" try: tools = [] for read_stream, write_stream in server_streams: tools.extend(await fetch_tools(read_stream, write_stream)) # for (read_stream, write_stream) in server_streams: # tools = await fetch_tools(read_stream, write_stream) if not tools: print("[red]No tools available. Exiting chat mode.[/red]") return system_prompt = generate_system_prompt(tools) openai_tools = convert_to_openai_tools(tools) #print(openai_tools) client = LLMClient(provider=provider, model=model) conversation_history = [{"role": "system", "content": system_prompt}] while True: try: # Change prompt to yellow user_message = await get_input("[bold yellow]>[/bold yellow]") if user_message.lower() in ["exit", "quit"]: print(Panel("Exiting chat mode.", style="bold red")) break # User panel in bold yellow user_panel_text = user_message if user_message else "[No Message]" print(Panel(user_panel_text, style="bold yellow", title="You")) conversation_history.append({"role": "user", "content": user_message}) await process_conversation( client, conversation_history, openai_tools, server_streams ) except Exception as e: print(f"[red]Error processing message:[/red] {e}") continue except Exception as e: print(f"[red]Error in chat mode:[/red] {e}") async def process_conversation( client, conversation_history, openai_tools, server_streams ): """Process the conversation loop, handling tool calls and responses.""" while True: completion = client.create_completion( messages=conversation_history, tools=openai_tools, ) response_content = completion.get("response", "No response") tool_calls = completion.get("tool_calls", []) if tool_calls: for tool_call in tool_calls: # Extract tool_name and raw_arguments as before if hasattr(tool_call, "function"): print(tool_call.function) tool_name = getattr(tool_call.function, "name", "unknown tool") raw_arguments = getattr(tool_call.function, "arguments", {}) elif isinstance(tool_call, dict) and "function" in tool_call: fn_info = tool_call["function"] tool_name = fn_info.get("name", "unknown tool") raw_arguments = fn_info.get("arguments", {}) else: tool_name = "unknown tool" raw_arguments = {} # If raw_arguments is a string, try to parse it as JSON if isinstance(raw_arguments, str): try: raw_arguments = json.loads(raw_arguments) except json.JSONDecodeError: # If it's not valid JSON, just display as is pass # Now raw_arguments should be a dict or something we can pretty-print as JSON tool_args_str = json.dumps(raw_arguments, indent=2) tool_md = f"**Tool Call:** {tool_name}\n\n```json\n{tool_args_str}\n```" print( Panel( Markdown(tool_md), style="bold magenta", title="Tool Invocation" ) ) await handle_tool_call(tool_call, conversation_history, server_streams) continue # Assistant panel with Markdown assistant_panel_text = response_content if response_content else "[No Response]" print( Panel(Markdown(assistant_panel_text), style="bold blue", title="Assistant") ) conversation_history.append({"role": "assistant", "content": response_content}) break def generate_system_prompt(tools): """ Generate a concise system prompt for the assistant. This prompt is internal and not displayed to the user. """ prompt_generator = SystemPromptGenerator() tools_json = {"tools": tools} system_prompt = prompt_generator.generate_prompt(tools_json) system_prompt += """ **GENERAL GUIDELINES:** 1. Step-by-step reasoning: - Analyze tasks systematically. - Break down complex problems into smaller, manageable parts. - Verify assumptions at each step to avoid errors. - Reflect on results to improve subsequent actions. 2. Effective tool usage: - Explore: - Identify available information and verify its structure. - Check assumptions and understand data relationships. - Iterate: - Start with simple queries or actions. - Build upon successes, adjusting based on observations. - Handle errors: - Carefully analyze error messages. - Use errors as a guide to refine your approach. - Document what went wrong and suggest fixes. 3. Clear communication: - Explain your reasoning and decisions at each step. - Share discoveries transparently with the user. - Outline next steps or ask clarifying questions as needed. EXAMPLES OF BEST PRACTICES: - Working with databases: - Check schema before writing queries. - Verify the existence of columns or tables. - Start with basic queries and refine based on results. - Processing data: - Validate data formats and handle edge cases. - Ensure integrity and correctness of results. - Accessing resources: - Confirm resource availability and permissions. - Handle missing or incomplete data gracefully. REMEMBER: - Be thorough and systematic. - Each tool call should have a clear and well-explained purpose. - Make reasonable assumptions if ambiguous. - Minimize unnecessary user interactions by providing actionable insights. EXAMPLES OF ASSUMPTIONS: - Default sorting (e.g., descending order) if not specified. - Assume basic user intentions, such as fetching top results by a common metric. """ return system_prompt ``` -------------------------------------------------------------------------------- /clients/PHP/2.1 mcp_continue_chat/MCPContinueChatClient.php: -------------------------------------------------------------------------------- ```php <?php /** * MCPContinueChatClient.php * * A PHP script acting as a Continue Chat Client. It connects to a server via TCP, * sends a Continue Chat request, and receives the server's response. * * Usage: * php MCPContinueChatClient.php --server-ip <IP> --server-port <Port> --token <Token> --conversation-id <ConversationID> --message <Message> */ /** * Function to parse command line arguments * * @param array $args Command line arguments * @return array Associative array of parsed arguments */ function parseArguments($args) { $parsedArgs = []; $argc = count($args); for ($i = 1; $i < $argc; $i++) { switch ($args[$i]) { case '--server-ip': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['serverIp'] = $args[++$i]; } else { fwrite(STDERR, "Error: --server-ip expects a value.\n"); exit(1); } break; case '--server-port': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['serverPort'] = intval($args[++$i]); } else { fwrite(STDERR, "Error: --server-port expects a value.\n"); exit(1); } break; case '--token': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['token'] = $args[++$i]; } else { fwrite(STDERR, "Error: --token expects a value.\n"); exit(1); } break; case '--conversation-id': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['conversationId'] = $args[++$i]; } else { fwrite(STDERR, "Error: --conversation-id expects a value.\n"); exit(1); } break; case '--message': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['message'] = $args[++$i]; } else { fwrite(STDERR, "Error: --message expects a value.\n"); exit(1); } break; default: fwrite(STDERR, "⚠️ Warning: Unknown argument: {$args[$i]}\n"); } } return $parsedArgs; } /** * Helper function to check if a string starts with a specific prefix * * @param string $string The string to check * @param string $prefix The prefix * @return bool True if the string starts with the prefix, otherwise False */ function startsWith($string, $prefix) { return substr($string, 0, strlen($prefix)) === $prefix; } /** * Function for interactively prompting a parameter (optional) * * @param string $prompt The prompt message * @return string User input */ function askQuestionPrompt($prompt) { if (preg_match('/^win/i', PHP_OS)) { // Windows-specific input prompt $vbscript = sys_get_temp_dir() . 'prompt_input.vbs'; file_put_contents($vbscript, 'wscript.echo(InputBox("' . addslashes($prompt) . '", "", ""))'); $response = shell_exec("cscript //nologo " . escapeshellarg($vbscript)); unlink($vbscript); return trim($response); } else { // Unix/Linux input prompt echo $prompt; $handle = fopen("php://stdin", "r"); $response = trim(fgets($handle)); fclose($handle); return $response; } } /** * Function to send a Continue Chat request over a TCP connection * * @param string $serverIp Server IP address * @param int $serverPort Server port * @param array $payload Payload to send as an associative array * @return array Server response as an associative array * @throws Exception On connection errors or JSON parsing errors */ function sendContinueChatRequest($serverIp, $serverPort, $payload) { $jsonPayload = json_encode($payload); if ($jsonPayload === false) { throw new Exception("Error encoding JSON payload."); } $errno = 0; $errstr = ''; $timeout = 30; // seconds $client = @fsockopen($serverIp, $serverPort, $errno, $errstr, $timeout); if (!$client) { throw new Exception("Connection error: $errstr ($errno)"); } echo "🔗 Connected to server ({$serverIp}:{$serverPort}).\n"; echo "📤 Sending payload: $jsonPayload\n"; fwrite($client, $jsonPayload); $responseData = ''; stream_set_timeout($client, $timeout); while (!feof($client)) { $data = fread($client, 1024); if ($data === false) { throw new Exception("Error reading data from server."); } if ($data === '') { break; // No more data } echo "📥 Received data: $data\n"; $responseData .= $data; // Attempt to parse received data as JSON $parsedData = json_decode($responseData, true); if ($parsedData !== null) { echo "✅ JSON response successfully parsed.\n"; fclose($client); return $parsedData; } // Check if the stream timed out $info = stream_get_meta_data($client); if ($info['timed_out']) { throw new Exception("Timeout waiting for data from server."); } } fclose($client); throw new Exception("Connection to server closed before a complete response was received."); } /** * Main function of the script */ function main($argv) { $parsedArgs = parseArguments($argv); $serverIp = $parsedArgs['serverIp'] ?? null; $serverPort = $parsedArgs['serverPort'] ?? null; $token = $parsedArgs['token'] ?? null; $conversationId = $parsedArgs['conversationId'] ?? null; $message = $parsedArgs['message'] ?? null; // Check if all required parameters are present if (!$serverIp || !$serverPort || !$token || !$conversationId || !$message) { fwrite(STDERR, "❌ ERROR: Missing required parameters.\n"); fwrite(STDOUT, "Usage: php MCPContinueChatClient.php --server-ip <IP> --server-port <Port> --token <Token> --conversation-id <ConversationID> --message <Message>\n"); exit(1); } $payload = [ "command" => "continue_chat", "token" => $token, "arguments" => [ "chatId" => $conversationId, "question" => $message ] ]; try { echo "💬 Sending Continue Chat request...\n"; $response = sendContinueChatRequest($serverIp, $serverPort, $payload); echo "✅ Server Response:\n"; echo json_encode($response, JSON_PRETTY_PRINT) . "\n"; } catch (Exception $e) { fwrite(STDERR, "❌ ERROR: " . $e->getMessage() . "\n"); } } main($argv); ?> ``` -------------------------------------------------------------------------------- /clients/PHP/3.4 mcp_delete_source/MCPDeleteSourceClient.php: -------------------------------------------------------------------------------- ```php <?php /** * MCPDeleteSourceClient.php * * A PHP script acting as a Delete Source Client. It connects to a server via TCP, * sends a request to delete an existing source, and receives the server's response. * * Usage: * php MCPDeleteSourceClient.php --server-ip <IP> --server-port <Port> --token <Token> --source-id <SourceID> */ /** * Function to parse command line arguments * * @param array $args Command line arguments * @return array Associative array of parsed arguments */ function parseArguments($args) { $parsedArgs = []; $argc = count($args); for ($i = 1; $i < $argc; $i++) { switch ($args[$i]) { case '--server-ip': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['serverIp'] = $args[++$i]; } else { fwrite(STDERR, "Error: --server-ip expects a value.\n"); exit(1); } break; case '--server-port': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['serverPort'] = intval($args[++$i]); } else { fwrite(STDERR, "Error: --server-port expects a value.\n"); exit(1); } break; case '--token': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['token'] = $args[++$i]; } else { fwrite(STDERR, "Error: --token expects a value.\n"); exit(1); } break; case '--source-id': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['sourceId'] = $args[++$i]; } else { fwrite(STDERR, "Error: --source-id expects a value.\n"); exit(1); } break; default: fwrite(STDERR, "⚠️ Warning: Unknown argument: {$args[$i]}\n"); } } return $parsedArgs; } /** * Helper function to check if a string starts with a specific prefix * * @param string $string The string to check * @param string $prefix The prefix * @return bool True if the string starts with the prefix, otherwise False */ function startsWith($string, $prefix) { return substr($string, 0, strlen($prefix)) === $prefix; } /** * Function for interactively prompting a parameter (optional) * * @param string $prompt The prompt message * @return string User input */ function askQuestionPrompt($prompt) { if (preg_match('/^win/i', PHP_OS)) { $vbscript = sys_get_temp_dir() . 'prompt_input.vbs'; file_put_contents($vbscript, 'wscript.echo(InputBox("' . addslashes($prompt) . '", "", ""))'); $response = shell_exec("cscript //nologo " . escapeshellarg($vbscript)); unlink($vbscript); return trim($response); } else { echo $prompt; $handle = fopen("php://stdin", "r"); $response = trim(fgets($handle)); fclose($handle); return $response; } } /** * Function to send a Delete Source request over a TCP connection * * @param string $serverIp The server's IP address * @param int $serverPort The server's port * @param array $payload The payload to send as an associative array * @return array The response received from the server as an associative array * @throws Exception On connection errors or JSON parsing errors */ function sendDeleteSourceRequest($serverIp, $serverPort, $payload) { $jsonPayload = json_encode($payload); if ($jsonPayload === false) { throw new Exception("Error while coding the JSON payload: " . json_last_error_msg()); } $errno = 0; $errstr = ''; $timeout = 10; // Seconds $client = @fsockopen($serverIp, $serverPort, $errno, $errstr, $timeout); if (!$client) { throw new Exception("Connection error: $errstr ($errno)"); } echo "🔗 Connected to the server ({$serverIp}:{$serverPort}).\n"; echo "📤 Sending payload: $jsonPayload\n"; fwrite($client, $jsonPayload); $responseData = ''; stream_set_timeout($client, $timeout); while (!feof($client)) { $data = fread($client, 1024); if ($data === false) { throw new Exception("Error reading data from the server."); } if ($data === '') { break; // No more data } echo "📥 Received data: $data\n"; $responseData .= $data; $parsedData = json_decode($responseData, true); if ($parsedData !== null) { echo "✅ JSON response successfully parsed.\n"; fclose($client); return $parsedData; } $info = stream_get_meta_data($client); if ($info['timed_out']) { throw new Exception("Timeout waiting for data from the server."); } } fclose($client); throw new Exception("Connection to the server was closed before a complete response was received."); } /** * Main function of the script */ function main($argv) { $parsedArgs = parseArguments($argv); $serverIp = $parsedArgs['serverIp'] ?? null; $serverPort = $parsedArgs['serverPort'] ?? null; $token = $parsedArgs['token'] ?? null; $sourceId = $parsedArgs['sourceId'] ?? null; if (!$serverIp) { $serverIp = askQuestionPrompt('🔗 Please enter the server IP: '); } if (!$serverPort) { $portInput = askQuestionPrompt('🔗 Please enter the server port: '); $serverPort = intval($portInput); if ($serverPort <= 0) { fwrite(STDERR, "❌ ERROR: Invalid server port.\n"); exit(1); } } if (!$token) { $token = askQuestionPrompt('🔒 Please enter your authentication token: '); } if (!$sourceId) { $sourceId = askQuestionPrompt('📁 Please enter the Source ID: '); } if (!$serverIp || !$serverPort || !$token || !$sourceId) { fwrite(STDERR, "❌ ERROR: Missing required parameters.\n"); fwrite(STDOUT, "Usage: php MCPDeleteSourceClient.php --server-ip <IP> --server-port <Port> --token <Token> --source-id <SourceID>\n"); exit(1); } $payload = [ "command" => "delete_source", "token" => $token, "arguments" => [ "sourceId" => $sourceId ] ]; try { echo "🗑️ Sending Delete Source request...\n"; $response = sendDeleteSourceRequest($serverIp, $serverPort, $payload); echo "✅ Server Response:\n"; echo json_encode($response, JSON_PRETTY_PRINT) . "\n"; } catch (Exception $e) { fwrite(STDERR, "❌ ERROR: " . $e->getMessage() . "\n"); } } if (version_compare(PHP_VERSION, '7.1.0') < 0) { fwrite(STDERR, "❌ ERROR: This script requires PHP version 7.1 or higher.\n"); exit(1); } main($argv); ?> ``` -------------------------------------------------------------------------------- /clients/PHP/4.2 mcp_delete_group/MCPDeleteGroupClient.php: -------------------------------------------------------------------------------- ```php <?php /** * MCPDeleteGroupClient.php * * A PHP script acting as a Delete Group Client. It connects to a server via TCP, * sends a request to delete an existing group, and receives the server's response. * * Usage: * php MCPDeleteGroupClient.php --server-ip <IP> --server-port <Port> --token <Token> --group-name <GroupName> */ /** * Function to parse command line arguments * * @param array $args Command line arguments * @return array Associative array of parsed arguments */ function parseArguments($args) { $parsedArgs = []; $argc = count($args); for ($i = 1; $i < $argc; $i++) { switch ($args[$i]) { case '--server-ip': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['serverIp'] = $args[++$i]; } else { fwrite(STDERR, "⚠️ Warning: No value provided for --server-ip.\n"); } break; case '--server-port': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['serverPort'] = intval($args[++$i]); } else { fwrite(STDERR, "⚠️ Warning: No value provided for --server-port.\n"); } break; case '--token': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['token'] = $args[++$i]; } else { fwrite(STDERR, "⚠️ Warning: No value provided for --token.\n"); } break; case '--group-name': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['groupName'] = $args[++$i]; } else { fwrite(STDERR, "⚠️ Warning: No value provided for --group-name.\n"); } break; default: fwrite(STDERR, "⚠️ Warning: Unknown argument: {$args[$i]}\n"); } } return $parsedArgs; } /** * Helper function to check if a string starts with a specific prefix * * @param string $string The string to check * @param string $prefix The prefix * @return bool True if the string starts with the prefix, otherwise False */ function startsWith($string, $prefix) { return substr($string, 0, strlen($prefix)) === $prefix; } /** * Function for interactively prompting a parameter (optional) * * @param string $prompt The prompt message * @return string User input */ function askQuestionPrompt($prompt) { if (preg_match('/^win/i', PHP_OS)) { $vbscript = sys_get_temp_dir() . 'prompt_input.vbs'; file_put_contents($vbscript, 'wscript.echo(InputBox("' . addslashes($prompt) . '", "", ""))'); $response = shell_exec("cscript //nologo " . escapeshellarg($vbscript)); unlink($vbscript); return trim($response); } else { echo $prompt; $handle = fopen("php://stdin", "r"); $response = trim(fgets($handle)); fclose($handle); return $response; } } /** * Function to send a Delete Group request over a TCP connection * * @param string $serverIp The server's IP address * @param int $serverPort The server's port * @param string $token The authentication token * @param string $groupName The name of the group to be deleted * @return array The response received from the server as an associative array * @throws Exception On connection errors or JSON parsing errors */ function sendDeleteGroupRequest($serverIp, $serverPort, $token, $groupName) { $payload = [ "command" => "delete_group", "token" => $token, "arguments" => [ "groupName" => $groupName ] ]; $jsonPayload = json_encode($payload); if ($jsonPayload === false) { throw new Exception("Error while coding the JSON payload: " . json_last_error_msg()); } $errno = 0; $errstr = ''; $timeoutDuration = 10; // Seconds $client = @fsockopen($serverIp, $serverPort, $errno, $errstr, $timeoutDuration); if (!$client) { throw new Exception("Connection error: $errstr ($errno)"); } echo "🔗 Connected to the server ({$serverIp}:{$serverPort}).\n"; echo "📤 Sending payload: $jsonPayload\n"; fwrite($client, $jsonPayload); $responseData = ''; stream_set_timeout($client, $timeoutDuration); while (!feof($client)) { $data = fread($client, 1024); if ($data === false) { throw new Exception("Error reading data from the server."); } if ($data === '') { break; } echo "📥 Received data: $data\n"; $responseData .= $data; $parsedData = json_decode($responseData, true); if ($parsedData !== null) { echo "✅ JSON response successfully parsed.\n"; fclose($client); return $parsedData; } $info = stream_get_meta_data($client); if ($info['timed_out']) { throw new Exception("Timeout waiting for data from the server."); } } fclose($client); throw new Exception("Connection to the server was closed before a complete response was received."); } /** * Main function of the script */ function main($argv) { $parsedArgs = parseArguments($argv); $serverIp = $parsedArgs['serverIp'] ?? null; $serverPort = $parsedArgs['serverPort'] ?? null; $token = $parsedArgs['token'] ?? null; $groupName = $parsedArgs['groupName'] ?? null; if (!$serverIp) { $serverIp = askQuestionPrompt('🔗 Please enter the server IP: '); } if (!$serverPort) { $portInput = askQuestionPrompt('🔗 Please enter the server port: '); $serverPort = intval($portInput); if ($serverPort <= 0) { fwrite(STDERR, "❌ ERROR: Invalid server port.\n"); exit(1); } } if (!$token) { $token = askQuestionPrompt('🔒 Please enter your authentication token: '); } if (!$groupName) { $groupName = askQuestionPrompt('👥 Please enter the group name: '); } if (!$serverIp || !$serverPort || !$token || !$groupName) { fwrite(STDERR, "❌ ERROR: Missing required parameters.\n"); fwrite(STDOUT, "Usage: php MCPDeleteGroupClient.php --server-ip <IP> --server-port <Port> --token <Token> --group-name <GroupName>\n"); exit(1); } try { echo "🗑️ Sending Delete Group request...\n"; $response = sendDeleteGroupRequest($serverIp, $serverPort, $token, $groupName); echo "✔️ Server Response:\n"; echo json_encode($response, JSON_PRETTY_PRINT) . "\n"; } catch (Exception $e) { fwrite(STDERR, "❌ ERROR: " . $e->getMessage() . "\n"); } } if (version_compare(PHP_VERSION, '7.1.0') < 0) { fwrite(STDERR, "❌ ERROR: This script requires PHP version 7.1 or higher.\n"); exit(1); } main($argv); ?> ``` -------------------------------------------------------------------------------- /clients/PHP/2.2 mcp_get_chat_info/MCPGetChatInfoClient.php: -------------------------------------------------------------------------------- ```php <?php /** * MCPGetChatInfoClient.php * * A PHP script acting as a Get Chat Info Client. It connects to a server via TCP, * sends a request to retrieve chat information, and receives the server's response. * * Usage: * php MCPGetChatInfoClient.php --server-ip <IP> --server-port <Port> --token <Token> --chat-id <ChatID> */ /** * Function to parse command line arguments * * @param array $args Command line arguments * @return array Associative array of parsed arguments */ function parseArguments($args) { $parsedArgs = []; $argc = count($args); for ($i = 1; $i < $argc; $i++) { switch ($args[$i]) { case '--server-ip': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['serverIp'] = $args[++$i]; } else { fwrite(STDERR, "Error: --server-ip expects a value.\n"); exit(1); } break; case '--server-port': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['serverPort'] = intval($args[++$i]); } else { fwrite(STDERR, "Error: --server-port expects a value.\n"); exit(1); } break; case '--token': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['token'] = $args[++$i]; } else { fwrite(STDERR, "Error: --token expects a value.\n"); exit(1); } break; case '--chat-id': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['chatId'] = $args[++$i]; } else { fwrite(STDERR, "Error: --chat-id expects a value.\n"); exit(1); } break; default: fwrite(STDERR, "⚠️ Warning: Unknown argument: {$args[$i]}\n"); } } return $parsedArgs; } /** * Helper function to check if a string starts with a specific prefix * * @param string $string The string to check * @param string $prefix The prefix * @return bool True if the string starts with the prefix, otherwise False */ function startsWith($string, $prefix) { return substr($string, 0, strlen($prefix)) === $prefix; } /** * Function for interactively prompting a parameter (optional) * * @param string $prompt The prompt message * @return string User input */ function askQuestionPrompt($prompt) { if (preg_match('/^win/i', PHP_OS)) { // Windows-specific input prompt $vbscript = sys_get_temp_dir() . 'prompt_input.vbs'; file_put_contents($vbscript, 'wscript.echo(InputBox("' . addslashes($prompt) . '", "", ""))'); $response = shell_exec("cscript //nologo " . escapeshellarg($vbscript)); unlink($vbscript); return trim($response); } else { // Unix/Linux input prompt echo $prompt; $handle = fopen("php://stdin", "r"); $response = trim(fgets($handle)); fclose($handle); return $response; } } /** * Function to send a request over a TCP connection * * @param string $serverIp The server's IP address * @param int $serverPort The server's port * @param array $payload The payload to send as an associative array * @return array The response received from the server as an associative array * @throws Exception On connection errors or JSON parsing errors */ function sendRequest($serverIp, $serverPort, $payload) { $jsonPayload = json_encode($payload); if ($jsonPayload === false) { throw new Exception("Error while coding the JSON payload: " . json_last_error_msg()); } $errno = 0; $errstr = ''; $timeout = 30; // seconds $client = @fsockopen($serverIp, $serverPort, $errno, $errstr, $timeout); if (!$client) { throw new Exception("Connection error: $errstr ($errno)"); } echo "🔗 Connected to the server ({$serverIp}:{$serverPort}).\n"; echo "📤 Sending payload: $jsonPayload\n"; fwrite($client, $jsonPayload); $responseData = ''; stream_set_timeout($client, $timeout); while (!feof($client)) { $data = fread($client, 1024); if ($data === false) { throw new Exception("Error reading data from the server."); } if ($data === '') { break; // No more data } echo "📥 Received data: $data\n"; $responseData .= $data; // Attempt to parse received data as JSON $parsedData = json_decode($responseData, true); if ($parsedData !== null) { echo "✅ JSON response successfully parsed.\n"; fclose($client); return $parsedData; } // Check if the stream timed out $info = stream_get_meta_data($client); if ($info['timed_out']) { throw new Exception("Timeout waiting for data from the server."); } } fclose($client); throw new Exception("Connection to the server was closed before a complete response was received."); } /** * Main function of the script */ function main($argv) { $parsedArgs = parseArguments($argv); $serverIp = $parsedArgs['serverIp'] ?? null; $serverPort = $parsedArgs['serverPort'] ?? null; $token = $parsedArgs['token'] ?? null; $chatId = $parsedArgs['chatId'] ?? null; // Interactively prompt for missing parameters if (!$serverIp) { $serverIp = askQuestionPrompt('🔗 Please enter the server IP: '); } if (!$serverPort) { $portInput = askQuestionPrompt('🔗 Please enter the server port: '); $serverPort = intval($portInput); if ($serverPort <= 0) { fwrite(STDERR, "❌ ERROR: Invalid server port.\n"); exit(1); } } if (!$token) { $token = askQuestionPrompt('🔒 Please enter your authentication token: '); } if (!$chatId) { $chatId = askQuestionPrompt('💬 Please enter the Chat ID: '); } // Check if all required parameters are now present if (!$serverIp || !$serverPort || !$token || !$chatId) { fwrite(STDERR, "❌ ERROR: Missing required parameters.\n"); fwrite(STDOUT, "Usage: php MCPGetChatInfoClient.php --server-ip <IP> --server-port <Port> --token <Token> --chat-id <ChatID>\n"); exit(1); } $payload = [ "command" => "get_chat_info", "token" => $token, "arguments" => [ "chatId" => $chatId ] ]; try { echo "📤 Sending request...\n"; $response = sendRequest($serverIp, $serverPort, $payload); echo "✅ Server Response:\n"; echo json_encode($response, JSON_PRETTY_PRINT) . "\n"; } catch (Exception $e) { fwrite(STDERR, "❌ ERROR: " . $e->getMessage() . "\n"); } } // Ensure PHP version is at least 7.1 if (version_compare(PHP_VERSION, '7.1.0') < 0) { fwrite(STDERR, "❌ ERROR: This script requires PHP version 7.1 or higher.\n"); exit(1); } // Call the main function main($argv); ?> ``` -------------------------------------------------------------------------------- /agents/SourceManagerAgent/Python/file_tools/loader_factory.py: -------------------------------------------------------------------------------- ```python import os from pathlib import Path from typing import List import pandas as pd os.environ["USER_AGENT"] = "Pgpt" from langchain.docstore.document import Document from langchain_community.document_loaders import (AZLyricsLoader, BSHTMLLoader, ChatGPTLoader, CSVLoader, DirectoryLoader, GitbookLoader, GitLoader, HuggingFaceDatasetLoader, ImageCaptionLoader, IMSDbLoader, JSONLoader, ObsidianLoader, OnlinePDFLoader, PlaywrightURLLoader, PyPDFLoader, SitemapLoader, SRTLoader, TextLoader, UnstructuredEmailLoader, UnstructuredImageLoader, UnstructuredMarkdownLoader, UnstructuredWordDocumentLoader, WebBaseLoader, YoutubeLoader) from langchain_community.document_loaders.figma import FigmaFileLoader from langchain.text_splitter import CharacterTextSplitter class LoadersFactory: @staticmethod def load_file(path: str) -> List[Document]: loader = TextLoader(path, encoding="utf-8") documents = loader.load() return documents @staticmethod def csv(path: str) -> List[Document]: loader = CSVLoader(file_path=path) documents = loader.load() return documents @staticmethod def xlsx(path: str) -> List[Document]: csv_file = path + '.csv' df = pd.read_excel(path) df.to_csv(csv_file, index=False) print(f"File converted successfully and saved as {csv_file}") loader = CSVLoader(file_path=csv_file) documents = loader.load() return documents @staticmethod def directory(path: str, glob: str) -> List[Document]: text_loader_kwargs = {'autodetect_encoding': True} loader = DirectoryLoader(path, glob, loader_kwargs=text_loader_kwargs) documents = loader.load() return documents @staticmethod def html_bs4(path: str, glob: str) -> List[Document]: loader = BSHTMLLoader(path) documents = loader.load() return documents @staticmethod def json(path: str, schema: str) -> List[Document]: loader = JSONLoader(Path(path).read_text(), schema) documents = loader.load() return documents @staticmethod def markdown(path: str) -> List[Document]: loader = UnstructuredMarkdownLoader(path) documents = loader.load() return documents @staticmethod def image(path: str) -> List[Document]: loader = UnstructuredImageLoader(path) documents = loader.load() return documents @staticmethod def pdf(path: str) -> List[Document]: loader = PyPDFLoader(path) documents = loader.load_and_split() return documents @staticmethod def online_pdf(url: str) -> List[Document]: loader = OnlinePDFLoader(url) documents = loader.load() return documents @staticmethod def sitemap(url: str) -> List[Document]: loader = SitemapLoader(url) documents = loader.load() return documents @staticmethod def subtitle(file_path: str) -> List[Document]: loader = SRTLoader(file_path) documents = loader.load() return documents @staticmethod def email(file_path: str) -> List[Document]: loader = UnstructuredEmailLoader(file_path) documents = loader.load() return documents @staticmethod def word(file_path: str) -> List[Document]: loader = UnstructuredWordDocumentLoader(file_path) documents = loader.load() return documents @staticmethod def youtube(url: str) -> List[Document]: loader = YoutubeLoader.from_youtube_url(url, add_video_info=True) documents = loader.load() return documents @staticmethod def playwrite(urls: List[str]) -> List[Document]: loader = PlaywrightURLLoader(urls=urls) documents = loader.load() return documents @staticmethod def web_base(urls: List[str]) -> List[Document]: loader = WebBaseLoader(urls) documents = loader.load() return documents @staticmethod def azlyrics(urls: List[str]) -> List[Document]: loader = AZLyricsLoader(urls) documents = loader.load() return documents @staticmethod def hugging_face(dataset_name: str = "imdb", page_content_column: str = "text") -> List[Document]: loader = HuggingFaceDatasetLoader(dataset_name, page_content_column) documents = loader.load() return documents @staticmethod def imsdb(path: str) -> List[Document]: loader = IMSDbLoader(path) documents = loader.load() return documents @staticmethod def chat_gpt(path: str) -> List[Document]: loader = ChatGPTLoader(path) documents = loader.load() return documents @staticmethod def figma(access_token: str, node_id: str, file_key: str) -> List[Document]: loader = FigmaFileLoader(access_token, node_id, file_key) documents = loader.load() return documents @staticmethod def gitbook(url: str) -> List[Document]: loader = GitbookLoader(url, load_all_paths=True) documents = loader.load() return documents @staticmethod def obsidian(url: str) -> List[Document]: loader = ObsidianLoader(url) documents = loader.load() return documents @staticmethod def git(clone_url: str, repo_path: str, branch: str = "master") -> List[Document]: loader = GitLoader( clone_url=clone_url, repo_path=repo_path, branch=branch ) documents = loader.load() return documents @staticmethod def blip(image_urls: List[str]) -> List[Document]: loader = ImageCaptionLoader(image_urls) documents = loader.load() return documents @staticmethod def split_docs(documents: List[Document], **kwargs) -> List[Document]: text_splitter = CharacterTextSplitter(**kwargs) docs = text_splitter.split_documents(documents) return docs @staticmethod def convert_documents_to_markdown(docs): markdown = "" for idx, doc in enumerate(docs): markdown += f"# Document {idx + 1}\n\n" markdown += f"{doc.page_content}\n\n" # If metadata is available, format it as a section if doc.metadata: markdown += "## Metadata\n" for key, value in doc.metadata.items(): # remove local file paths if key == "source": head, tail = os.path.split(value) value = tail markdown += f"- **{key}**: {value}\n" markdown += "\n---\n\n" # Separator between documents return markdown ``` -------------------------------------------------------------------------------- /clients/Gradio/file_tools/loader_factory.py: -------------------------------------------------------------------------------- ```python import os from pathlib import Path from typing import List import pandas as pd os.environ["USER_AGENT"] = "Pgpt" from langchain.docstore.document import Document from langchain_community.document_loaders import (AZLyricsLoader, BSHTMLLoader, ChatGPTLoader, CSVLoader, DirectoryLoader, GitbookLoader, GitLoader, HuggingFaceDatasetLoader, ImageCaptionLoader, IMSDbLoader, JSONLoader, ObsidianLoader, OnlinePDFLoader, PlaywrightURLLoader, PyPDFLoader, SitemapLoader, SRTLoader, TextLoader, UnstructuredEmailLoader, UnstructuredImageLoader, UnstructuredMarkdownLoader, UnstructuredWordDocumentLoader, WebBaseLoader, YoutubeLoader) from langchain_community.document_loaders.figma import FigmaFileLoader from langchain.text_splitter import CharacterTextSplitter class LoadersFactory: @staticmethod def load_file(path: str) -> List[Document]: loader = TextLoader(path, encoding="utf-8") documents = loader.load() return documents @staticmethod def csv(path: str) -> List[Document]: loader = CSVLoader(file_path=path) documents = loader.load() return documents @staticmethod def xlsx(path: str) -> List[Document]: csv_file = path + '.csv' df = pd.read_excel(path) df.to_csv(csv_file, index=False) print(f"File converted successfully and saved as {csv_file}") loader = CSVLoader(file_path=csv_file) documents = loader.load() return documents @staticmethod def directory(path: str, glob: str) -> List[Document]: text_loader_kwargs = {'autodetect_encoding': True} loader = DirectoryLoader(path, glob, loader_kwargs=text_loader_kwargs) documents = loader.load() return documents @staticmethod def html_bs4(path: str, glob: str) -> List[Document]: loader = BSHTMLLoader(path) documents = loader.load() return documents @staticmethod def json(path: str, schema: str) -> List[Document]: loader = JSONLoader(Path(path).read_text(), schema) documents = loader.load() return documents @staticmethod def markdown(path: str) -> List[Document]: loader = UnstructuredMarkdownLoader(path) documents = loader.load() return documents @staticmethod def image(path: str) -> List[Document]: loader = UnstructuredImageLoader(path) documents = loader.load() return documents @staticmethod def pdf(path: str) -> List[Document]: loader = PyPDFLoader(path) documents = loader.load_and_split() return documents @staticmethod def online_pdf(url: str) -> List[Document]: loader = OnlinePDFLoader(url) documents = loader.load() return documents @staticmethod def sitemap(url: str) -> List[Document]: loader = SitemapLoader(url) documents = loader.load() return documents @staticmethod def subtitle(file_path: str) -> List[Document]: loader = SRTLoader(file_path) documents = loader.load() return documents @staticmethod def email(file_path: str) -> List[Document]: loader = UnstructuredEmailLoader(file_path) documents = loader.load() return documents @staticmethod def word(file_path: str) -> List[Document]: loader = UnstructuredWordDocumentLoader(file_path) documents = loader.load() return documents @staticmethod def youtube(url: str) -> List[Document]: loader = YoutubeLoader.from_youtube_url(url, add_video_info=True) documents = loader.load() return documents @staticmethod def playwrite(urls: List[str]) -> List[Document]: loader = PlaywrightURLLoader(urls=urls) documents = loader.load() return documents @staticmethod def web_base(urls: List[str]) -> List[Document]: loader = WebBaseLoader(urls) documents = loader.load() return documents @staticmethod def azlyrics(urls: List[str]) -> List[Document]: loader = AZLyricsLoader(urls) documents = loader.load() return documents @staticmethod def hugging_face(dataset_name: str = "imdb", page_content_column: str = "text") -> List[Document]: loader = HuggingFaceDatasetLoader(dataset_name, page_content_column) documents = loader.load() return documents @staticmethod def imsdb(path: str) -> List[Document]: loader = IMSDbLoader(path) documents = loader.load() return documents @staticmethod def chat_gpt(path: str) -> List[Document]: loader = ChatGPTLoader(path) documents = loader.load() return documents @staticmethod def figma(access_token: str, node_id: str, file_key: str) -> List[Document]: loader = FigmaFileLoader(access_token, node_id, file_key) documents = loader.load() return documents @staticmethod def gitbook(url: str) -> List[Document]: loader = GitbookLoader(url, load_all_paths=True) documents = loader.load() return documents @staticmethod def obsidian(url: str) -> List[Document]: loader = ObsidianLoader(url) documents = loader.load() return documents @staticmethod def git(clone_url: str, repo_path: str, branch: str = "master") -> List[Document]: loader = GitLoader( clone_url=clone_url, repo_path=repo_path, branch=branch ) documents = loader.load() return documents @staticmethod def blip(image_urls: List[str]) -> List[Document]: loader = ImageCaptionLoader(image_urls) documents = loader.load() return documents @staticmethod def split_docs(documents: List[Document], **kwargs) -> List[Document]: text_splitter = CharacterTextSplitter(**kwargs) docs = text_splitter.split_documents(documents) return docs @staticmethod def convert_documents_to_markdown(docs): markdown = "" for idx, doc in enumerate(docs): markdown += f"# Document {idx + 1}\n\n" markdown += f"{doc.page_content}\n\n" # If metadata is available, format it as a section if doc.metadata: markdown += "## Metadata\n" for key, value in doc.metadata.items(): # remove local file paths if key == "source": head, tail = os.path.split(value) value = tail markdown += f"- **{key}**: {value}\n" markdown += "\n---\n\n" # Separator between documents return markdown ``` -------------------------------------------------------------------------------- /clients/PHP/3.1 mcp_get_source/MCPGetSourceClient.php: -------------------------------------------------------------------------------- ```php <?php /** * MCPGetSourceClient.php * * A PHP script acting as a Get Source Client. It connects to a server via TCP, * sends a request to retrieve source information, and receives the server's response. * * Usage: * php MCPGetSourceClient.php --server-ip <IP> --server-port <Port> --token <Token> --source-id <SourceID> */ /** * Function to parse command line arguments * * @param array $args Command line arguments * @return array Associative array of parsed arguments */ function parseArguments($args) { $parsedArgs = []; $argc = count($args); for ($i = 1; $i < $argc; $i++) { switch ($args[$i]) { case '--server-ip': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['serverIp'] = $args[++$i]; } else { fwrite(STDERR, "Error: --server-ip expects a value.\n"); exit(1); } break; case '--server-port': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['serverPort'] = intval($args[++$i]); } else { fwrite(STDERR, "Error: --server-port expects a value.\n"); exit(1); } break; case '--token': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['token'] = $args[++$i]; } else { fwrite(STDERR, "Error: --token expects a value.\n"); exit(1); } break; case '--source-id': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['sourceId'] = $args[++$i]; } else { fwrite(STDERR, "Error: --source-id expects a value.\n"); exit(1); } break; default: fwrite(STDERR, "⚠️ Warning: Unknown argument: {$args[$i]}\n"); } } return $parsedArgs; } /** * Helper function to check if a string starts with a specific prefix * * @param string $string The string to check * @param string $prefix The prefix * @return bool True if the string starts with the prefix, otherwise False */ function startsWith($string, $prefix) { return substr($string, 0, strlen($prefix)) === $prefix; } /** * Function for interactively prompting a parameter (optional) * * @param string $prompt The prompt message * @return string User input */ function askQuestionPrompt($prompt) { if (preg_match('/^win/i', PHP_OS)) { // Windows-specific input prompt $vbscript = sys_get_temp_dir() . 'prompt_input.vbs'; file_put_contents($vbscript, 'wscript.echo(InputBox("' . addslashes($prompt) . '", "", ""))'); $response = shell_exec("cscript //nologo " . escapeshellarg($vbscript)); unlink($vbscript); return trim($response); } else { // Unix/Linux input prompt echo $prompt; $handle = fopen("php://stdin", "r"); $response = trim(fgets($handle)); fclose($handle); return $response; } } /** * Function to send a Get Source request over a TCP connection * * @param string $serverIp The server's IP address * @param int $serverPort The server's port * @param array $payload The payload to send as an associative array * @return array The response received from the server as an associative array * @throws Exception On connection errors or JSON parsing errors */ function sendGetSourceRequest($serverIp, $serverPort, $payload) { $jsonPayload = json_encode($payload); if ($jsonPayload === false) { throw new Exception("Error while coding the JSON payload: " . json_last_error_msg()); } $errno = 0; $errstr = ''; $timeout = 30; // seconds $client = @fsockopen($serverIp, $serverPort, $errno, $errstr, $timeout); if (!$client) { throw new Exception("Connection error: $errstr ($errno)"); } echo "🔗 Connected to the server ({$serverIp}:{$serverPort}).\n"; echo "📤 Sending payload: $jsonPayload\n"; fwrite($client, $jsonPayload); $responseData = ''; stream_set_timeout($client, $timeout); while (!feof($client)) { $data = fread($client, 1024); if ($data === false) { throw new Exception("Error reading data from the server."); } if ($data === '') { break; // No more data } echo "📥 Received data: $data\n"; $responseData .= $data; // Attempt to parse received data as JSON $parsedData = json_decode($responseData, true); if ($parsedData !== null) { echo "✅ JSON response successfully parsed.\n"; fclose($client); return $parsedData; } // Check if the stream timed out $info = stream_get_meta_data($client); if ($info['timed_out']) { throw new Exception("Timeout waiting for data from the server."); } } fclose($client); throw new Exception("Connection to the server was closed before a complete response was received."); } /** * Main function of the script */ function main($argv) { $parsedArgs = parseArguments($argv); $serverIp = $parsedArgs['serverIp'] ?? null; $serverPort = $parsedArgs['serverPort'] ?? null; $token = $parsedArgs['token'] ?? null; $sourceId = $parsedArgs['sourceId'] ?? null; // Interactively prompt for missing parameters if (!$serverIp) { $serverIp = askQuestionPrompt('🔗 Please enter the server IP: '); } if (!$serverPort) { $portInput = askQuestionPrompt('🔗 Please enter the server port: '); $serverPort = intval($portInput); if ($serverPort <= 0) { fwrite(STDERR, "❌ ERROR: Invalid server port.\n"); exit(1); } } if (!$token) { $token = askQuestionPrompt('🔒 Please enter your authentication token: '); } if (!$sourceId) { $sourceId = askQuestionPrompt('📁 Please enter the Source ID: '); } // Check if all required parameters are now present if (!$serverIp || !$serverPort || !$token || !$sourceId) { fwrite(STDERR, "❌ ERROR: Missing required parameters.\n"); fwrite(STDOUT, "Usage: php MCPGetSourceClient.php --server-ip <IP> --server-port <Port> --token <Token> --source-id <SourceID>\n"); exit(1); } $payload = [ "command" => "get_source", "token" => $token, "arguments" => [ "sourceId" => $sourceId ] ]; try { echo "📤 Sending Get Source request...\n"; $response = sendGetSourceRequest($serverIp, $serverPort, $payload); echo "✅ Server Response:\n"; echo json_encode($response, JSON_PRETTY_PRINT) . "\n"; } catch (Exception $e) { fwrite(STDERR, "❌ ERROR: " . $e->getMessage() . "\n"); } } // Ensure PHP version is at least 7.1 if (version_compare(PHP_VERSION, '7.1.0') < 0) { fwrite(STDERR, "❌ ERROR: This script requires PHP version 7.1 or higher.\n"); exit(1); } // Call the main function main($argv); ?> ``` -------------------------------------------------------------------------------- /clients/PHP/3.2 mcp_list_sources/MCPListSourcesClient.php: -------------------------------------------------------------------------------- ```php <?php /** * MCPListSourcesClient.php * * A PHP script acting as a List Sources Client. It connects to a server via TCP, * sends a request to list sources, and receives the server's response. * * Usage: * php MCPListSourcesClient.php --server-ip <IP> --server-port <Port> --token <Token> --group-name <GroupName> */ /** * Function to parse command line arguments * * @param array $args Command line arguments * @return array Associative array of parsed arguments */ function parseArguments($args) { $parsedArgs = []; $argc = count($args); for ($i = 1; $i < $argc; $i++) { switch ($args[$i]) { case '--server-ip': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['serverIp'] = $args[++$i]; } else { fwrite(STDERR, "Error: --server-ip expects a value.\n"); exit(1); } break; case '--server-port': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['serverPort'] = intval($args[++$i]); } else { fwrite(STDERR, "Error: --server-port expects a value.\n"); exit(1); } break; case '--token': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['token'] = $args[++$i]; } else { fwrite(STDERR, "Error: --token expects a value.\n"); exit(1); } break; case '--group-name': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['groupName'] = $args[++$i]; } else { fwrite(STDERR, "Error: --group-name expects a value.\n"); exit(1); } break; default: fwrite(STDERR, "⚠️ Warning: Unknown argument: {$args[$i]}\n"); } } return $parsedArgs; } /** * Helper function to check if a string starts with a specific prefix * * @param string $string The string to check * @param string $prefix The prefix * @return bool True if the string starts with the prefix, otherwise False */ function startsWith($string, $prefix) { return substr($string, 0, strlen($prefix)) === $prefix; } /** * Function for interactively prompting a parameter (optional) * * @param string $prompt The prompt message * @return string User input */ function askQuestionPrompt($prompt) { if (preg_match('/^win/i', PHP_OS)) { // Windows-specific input prompt $vbscript = sys_get_temp_dir() . 'prompt_input.vbs'; file_put_contents($vbscript, 'wscript.echo(InputBox("' . addslashes($prompt) . '", "", ""))'); $response = shell_exec("cscript //nologo " . escapeshellarg($vbscript)); unlink($vbscript); return trim($response); } else { // Unix/Linux input prompt echo $prompt; $handle = fopen("php://stdin", "r"); $response = trim(fgets($handle)); fclose($handle); return $response; } } /** * Function to send a List Sources request over a TCP connection * * @param string $serverIp The server's IP address * @param int $serverPort The server's port * @param array $payload The payload to send as an associative array * @return array The response received from the server as an associative array * @throws Exception On connection errors or JSON parsing errors */ function sendListSourcesRequest($serverIp, $serverPort, $payload) { $jsonPayload = json_encode($payload); if ($jsonPayload === false) { throw new Exception("Error while coding the JSON payload: " . json_last_error_msg()); } $errno = 0; $errstr = ''; $timeout = 30; // seconds $client = @fsockopen($serverIp, $serverPort, $errno, $errstr, $timeout); if (!$client) { throw new Exception("Connection error: $errstr ($errno)"); } echo "🔗 Connected to the server ({$serverIp}:{$serverPort}).\n"; echo "📤 Sending payload: $jsonPayload\n"; fwrite($client, $jsonPayload); $responseData = ''; stream_set_timeout($client, $timeout); while (!feof($client)) { $data = fread($client, 1024); if ($data === false) { throw new Exception("Error reading data from the server."); } if ($data === '') { break; // No more data } echo "📥 Received data: $data\n"; $responseData .= $data; // Attempt to parse received data as JSON $parsedData = json_decode($responseData, true); if ($parsedData !== null) { echo "✅ JSON response successfully parsed.\n"; fclose($client); return $parsedData; } // Check if the stream timed out $info = stream_get_meta_data($client); if ($info['timed_out']) { throw new Exception("Timeout waiting for data from the server."); } } fclose($client); throw new Exception("Connection to the server was closed before a complete response was received."); } /** * Main function of the script */ function main($argv) { $parsedArgs = parseArguments($argv); $serverIp = $parsedArgs['serverIp'] ?? null; $serverPort = $parsedArgs['serverPort'] ?? null; $token = $parsedArgs['token'] ?? null; $groupName = $parsedArgs['groupName'] ?? null; // Interactively prompt for missing parameters if (!$serverIp) { $serverIp = askQuestionPrompt('🔗 Please enter the server IP: '); } if (!$serverPort) { $portInput = askQuestionPrompt('🔗 Please enter the server port: '); $serverPort = intval($portInput); if ($serverPort <= 0) { fwrite(STDERR, "❌ ERROR: Invalid server port.\n"); exit(1); } } if (!$token) { $token = askQuestionPrompt('🔒 Please enter your authentication token: '); } if (!$groupName) { $groupName = askQuestionPrompt('👥 Please enter the group name: '); } // Check if all required parameters are now present if (!$serverIp || !$serverPort || !$token || !$groupName) { fwrite(STDERR, "❌ ERROR: Missing required parameters.\n"); fwrite(STDOUT, "Usage: php MCPListSourcesClient.php --server-ip <IP> --server-port <Port> --token <Token> --group-name <GroupName>\n"); exit(1); } $payload = [ "command" => "list_sources", "token" => $token, "attributes" => [ "groupName" => $groupName ] ]; try { echo "📤 Sending List Sources request...\n"; $response = sendListSourcesRequest($serverIp, $serverPort, $payload); echo "✅ Server Response:\n"; echo json_encode($response, JSON_PRETTY_PRINT) . "\n"; } catch (Exception $e) { fwrite(STDERR, "❌ ERROR: " . $e->getMessage() . "\n"); } } // Ensure PHP version is at least 7.1 if (version_compare(PHP_VERSION, '7.1.0') < 0) { fwrite(STDERR, "❌ ERROR: This script requires PHP version 7.1 or higher.\n"); exit(1); } // Call the main function main($argv); ?> ``` -------------------------------------------------------------------------------- /clients/PHP/4.1 mcp_store_group/MCPStoreGroupClient.php: -------------------------------------------------------------------------------- ```php <?php /** * MCPStoreGroupClient.php * * A PHP script acting as a Store Group Client. It connects to a server via TCP, * sends a request to store a new group, and receives the server's response. * * Usage: * php MCPStoreGroupClient.php --server-ip <IP> --server-port <Port> --token <Token> --group-name <GroupName> [--description <Description>] */ /** * Function to parse command line arguments * * @param array $args Command line arguments * @return array Associative array of parsed arguments */ function parseArguments($args) { $parsedArgs = []; $argc = count($args); for ($i = 1; $i < $argc; $i++) { switch ($args[$i]) { case '--server-ip': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['serverIp'] = $args[++$i]; } else { fwrite(STDERR, "Error: --server-ip expects a value.\n"); exit(1); } break; case '--server-port': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['serverPort'] = intval($args[++$i]); } else { fwrite(STDERR, "Error: --server-port expects a value.\n"); exit(1); } break; case '--token': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['token'] = $args[++$i]; } else { fwrite(STDERR, "Error: --token expects a value.\n"); exit(1); } break; case '--group-name': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['groupName'] = $args[++$i]; } else { fwrite(STDERR, "Error: --group-name expects a value.\n"); exit(1); } break; case '--description': if (isset($args[$i + 1]) && !startsWith($args[$i + 1], '--')) { $parsedArgs['description'] = $args[++$i]; } else { fwrite(STDERR, "Error: --description expects a value.\n"); exit(1); } break; default: fwrite(STDERR, "⚠️ Warning: Unknown argument: {$args[$i]}\n"); } } return $parsedArgs; } /** * Helper function to check if a string starts with a specific prefix * * @param string $string The string to check * @param string $prefix The prefix * @return bool True if the string starts with the prefix, otherwise False */ function startsWith($string, $prefix) { return substr($string, 0, strlen($prefix)) === $prefix; } /** * Function for interactively prompting a parameter (optional) * * @param string $prompt The prompt message * @return string User input */ function askQuestionPrompt($prompt) { if (preg_match('/^win/i', PHP_OS)) { $vbscript = sys_get_temp_dir() . 'prompt_input.vbs'; file_put_contents($vbscript, 'wscript.echo(InputBox("' . addslashes($prompt) . '", "", ""))'); $response = shell_exec("cscript //nologo " . escapeshellarg($vbscript)); unlink($vbscript); return trim($response); } else { echo $prompt; $handle = fopen("php://stdin", "r"); $response = trim(fgets($handle)); fclose($handle); return $response; } } /** * Function to send a Store Group request over a TCP connection * * @param string $serverIp The server's IP address * @param int $serverPort The server's port * @param string $groupName The group name * @param string $token The authentication token * @param string|null $description The group's description (optional) * @return array The response received from the server as an associative array * @throws Exception On connection errors or JSON parsing errors */ function sendStoreGroupRequest($serverIp, $serverPort, $groupName, $token, $description) { $payload = [ "command" => "store_group", "token" => $token, "arguments" => [ "groupName" => $groupName, "description" => $description ] ]; $jsonPayload = json_encode($payload); if ($jsonPayload === false) { throw new Exception("Error while coding the JSON payload: " . json_last_error_msg()); } $errno = 0; $errstr = ''; $timeoutDuration = 10; // Seconds $client = @fsockopen($serverIp, $serverPort, $errno, $errstr, $timeoutDuration); if (!$client) { throw new Exception("Connection error: $errstr ($errno)"); } echo "🔗 Connected to the server ({$serverIp}:{$serverPort}).\n"; echo "📤 Sending payload: $jsonPayload\n"; fwrite($client, $jsonPayload); $responseData = ''; stream_set_timeout($client, $timeoutDuration); while (!feof($client)) { $data = fread($client, 1024); if ($data === false) { throw new Exception("Error reading data from the server."); } if ($data === '') { break; } echo "📥 Received data: $data\n"; $responseData .= $data; $parsedData = json_decode($responseData, true); if ($parsedData !== null) { echo "✅ JSON response successfully parsed.\n"; fclose($client); return $parsedData; } $info = stream_get_meta_data($client); if ($info['timed_out']) { throw new Exception("Timeout waiting for data from the server."); } } fclose($client); throw new Exception("Connection to the server was closed before a complete response was received."); } /** * Main function of the script */ function main($argv) { $parsedArgs = parseArguments($argv); $serverIp = $parsedArgs['serverIp'] ?? null; $serverPort = $parsedArgs['serverPort'] ?? null; $token = $parsedArgs['token'] ?? null; $groupName = $parsedArgs['groupName'] ?? null; $description = $parsedArgs['description'] ?? null; if (!$serverIp) { $serverIp = askQuestionPrompt('🔗 Please enter the server IP: '); } if (!$serverPort) { $portInput = askQuestionPrompt('🔗 Please enter the server port: '); $serverPort = intval($portInput); if ($serverPort <= 0) { fwrite(STDERR, "❌ ERROR: Invalid server port.\n"); exit(1); } } if (!$token) { $token = askQuestionPrompt('🔒 Please enter your authentication token: '); } if (!$groupName) { $groupName = askQuestionPrompt('📛 Please enter the group name: '); } if (!$serverIp || !$serverPort || !$token || !$groupName) { fwrite(STDERR, "❌ ERROR: Missing required parameters.\n"); fwrite(STDOUT, "Usage: php MCPStoreGroupClient.php --server-ip <IP> --server-port <Port> --token <Token> --group-name <GroupName> [--description <Description>]\n"); exit(1); } try { echo "🗃️ Sending Store Group request...\n"; $response = sendStoreGroupRequest($serverIp, $serverPort, $groupName, $token, $description); echo "✔️ Server Response:\n"; echo json_encode($response, JSON_PRETTY_PRINT) . "\n"; } catch (Exception $e) { fwrite(STDERR, "❌ ERROR: " . $e->getMessage() . "\n"); } } if (version_compare(PHP_VERSION, '7.1.0') < 0) { fwrite(STDERR, "❌ ERROR: This script requires PHP version 7.1 or higher.\n"); exit(1); } main($argv); ?> ``` -------------------------------------------------------------------------------- /agents/AgentMonitoring/IoT-Agent Dashboard Example - Grafana.json: -------------------------------------------------------------------------------- ```json { "annotations": { "list": [ { "builtIn": 1, "datasource": { "type": "grafana", "uid": "-- Grafana --" }, "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", "name": "Annotations & Alerts", "type": "dashboard" } ] }, "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 1, "id": 4, "links": [], "panels": [ { "datasource": { "type": "prometheus", "uid": "ceej3ydtls1kwb" }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5, "scaleDistribution": { "type": "linear" }, "showPoints": "auto", "spanNulls": false, "stacking": { "group": "A", "mode": "none" }, "thresholdsStyle": { "mode": "off" } }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] }, "unit": "msg/s" }, "overrides": [] }, "gridPos": { "h": 8, "w": 12, "x": 0, "y": 0 }, "id": 1, "options": { "legend": { "calcs": [], "displayMode": "list", "placement": "bottom", "showLegend": true }, "tooltip": { "hideZeros": false, "mode": "single", "sort": "none" } }, "pluginVersion": "11.5.2", "targets": [ { "datasource": "prometheus", "editorMode": "code", "expr": "mqtt_message_count_created{}", "interval": "", "legendFormat": "Messages/s", "range": true, "refId": "A" } ], "title": "MQTT Messages Rate", "type": "timeseries" }, { "datasource": { "type": "prometheus" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 10000 } ] }, "unit": "none" }, "overrides": [] }, "gridPos": { "h": 6, "w": 6, "x": 12, "y": 0 }, "id": 2, "options": { "colorMode": "value", "graphMode": "none", "justifyMode": "center", "orientation": "auto", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "showPercentChange": false, "textMode": "auto", "wideLayout": true }, "pluginVersion": "11.5.2", "targets": [ { "datasource": "prometheus", "editorMode": "code", "expr": "mqtt_message_count_total{}", "legendFormat": "", "range": true, "refId": "A" } ], "title": "Total MQTT Messages", "type": "stat" }, { "fieldConfig": { "defaults": { "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] }, "unit": "s" }, "overrides": [] }, "gridPos": { "h": 6, "w": 6, "x": 12, "y": 6 }, "id": 4, "options": { "colorMode": "value", "graphMode": "none", "justifyMode": "center", "orientation": "auto", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "showPercentChange": false, "textMode": "auto", "wideLayout": true }, "pluginVersion": "11.5.2", "targets": [ { "datasource": "prometheus", "editorMode": "code", "expr": "sum(rate(mqtt_message_latency_seconds_sum[5m])) / sum(rate(mqtt_message_latency_seconds_count[5m]))", "legendFormat": "Avg latency", "refId": "A" } ], "title": "Average Latency (last 5m)", "type": "stat" }, { "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5, "scaleDistribution": { "type": "linear" }, "showPoints": "auto", "spanNulls": false, "stacking": { "group": "A", "mode": "none" }, "thresholdsStyle": { "mode": "off" } }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] }, "unit": "s" }, "overrides": [] }, "gridPos": { "h": 8, "w": 12, "x": 0, "y": 8 }, "id": 3, "options": { "legend": { "calcs": [], "displayMode": "list", "placement": "bottom", "showLegend": true }, "tooltip": { "hideZeros": false, "mode": "single", "sort": "none" } }, "pluginVersion": "11.5.2", "targets": [ { "datasource": "prometheus", "editorMode": "code", "expr": "histogram_quantile(0.95, sum(rate(mqtt_message_latency_seconds_bucket[1m])) by (le))", "interval": "", "legendFormat": "p95 latency", "refId": "A" } ], "title": "MQTT Message Latency (95th percentile)", "type": "timeseries" } ], "preload": false, "refresh": "5s", "schemaVersion": 40, "tags": [ "iot_mqtt_agent", "prometheus" ], "templating": { "list": [] }, "time": { "from": "now-15m", "to": "now" }, "timepicker": {}, "timezone": "", "title": "IoT MQTT Agent - Monitoring Dashboard", "uid": "beejfmkg1spa8f", "version": 3, "weekStart": "" } ```