├── .gitignore ├── LICENSE ├── README.md ├── icon.icns ├── icon.ico ├── icon.png ├── package-lock.json ├── package.json ├── src ├── main │ ├── client.ts │ ├── config.json │ ├── main.ts │ └── types.ts ├── preload │ └── preload.ts └── renderer │ └── index.html └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Electron App 2 | artifacts/ 3 | 4 | # Logs 5 | logs 6 | *.log 7 | npm-debug.log* 8 | yarn-debug.log* 9 | yarn-error.log* 10 | lerna-debug.log* 11 | .pnpm-debug.log* 12 | 13 | # Diagnostic reports (https://nodejs.org/api/report.html) 14 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 15 | 16 | # Runtime data 17 | pids 18 | *.pid 19 | *.seed 20 | *.pid.lock 21 | 22 | # Directory for instrumented libs generated by jscoverage/JSCover 23 | lib-cov 24 | 25 | # Coverage directory used by tools like istanbul 26 | coverage 27 | *.lcov 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # Bower dependency directory (https://bower.io/) 36 | bower_components 37 | 38 | # node-waf configuration 39 | .lock-wscript 40 | 41 | # Compiled binary addons (https://nodejs.org/api/addons.html) 42 | build/Release 43 | 44 | # Dependency directories 45 | node_modules/ 46 | jspm_packages/ 47 | 48 | # Snowpack dependency directory (https://snowpack.dev/) 49 | web_modules/ 50 | 51 | # TypeScript cache 52 | *.tsbuildinfo 53 | 54 | # Optional npm cache directory 55 | .npm 56 | 57 | # Optional eslint cache 58 | .eslintcache 59 | 60 | # Optional stylelint cache 61 | .stylelintcache 62 | 63 | # Microbundle cache 64 | .rpt2_cache/ 65 | .rts2_cache_cjs/ 66 | .rts2_cache_es/ 67 | .rts2_cache_umd/ 68 | 69 | # Optional REPL history 70 | .node_repl_history 71 | 72 | # Output of 'npm pack' 73 | *.tgz 74 | 75 | # Yarn Integrity file 76 | .yarn-integrity 77 | 78 | # dotenv environment variable files 79 | .env 80 | .env.development.local 81 | .env.test.local 82 | .env.production.local 83 | .env.local 84 | 85 | # parcel-bundler cache (https://parceljs.org/) 86 | .cache 87 | .parcel-cache 88 | 89 | # Next.js build output 90 | .next 91 | out 92 | 93 | # Nuxt.js build / generate output 94 | .nuxt 95 | dist 96 | 97 | # Gatsby files 98 | .cache/ 99 | # Comment in the public line in if your project uses Gatsby and not Next.js 100 | # https://nextjs.org/blog/next-9-1#public-directory-support 101 | # public 102 | 103 | # vuepress build output 104 | .vuepress/dist 105 | 106 | # vuepress v2.x temp and cache directory 107 | .temp 108 | .cache 109 | 110 | # Docusaurus cache and generated files 111 | .docusaurus 112 | 113 | # Serverless directories 114 | .serverless/ 115 | 116 | # FuseBox cache 117 | .fusebox/ 118 | 119 | # DynamoDB Local files 120 | .dynamodb/ 121 | 122 | # TernJS port file 123 | .tern-port 124 | 125 | # Stores VSCode versions used for testing VSCode extensions 126 | .vscode-test 127 | 128 | # yarn v2 129 | .yarn/cache 130 | .yarn/unplugged 131 | .yarn/build-state.yml 132 | .yarn/install-state.gz 133 | .pnp.* 134 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2024 AIQL.COM 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MCP Chat Desktop App 2 | ## A Cross-Platform Interface for LLMs 3 | 4 | This desktop application utilizes the MCP (Model Context Protocol) to seamlessly connect and interact with various Large Language Models (LLMs). Built on Electron, the app ensures full cross-platform compatibility, enabling smooth operation across different operating systems. 5 | 6 | The primary objective of this project is to deliver a clean, minimalistic codebase that simplifies understanding the core principles of MCP. Additionally, it provides a quick and efficient way to test multiple servers and LLMs, making it an ideal tool for developers and researchers alike. 7 | 8 | ## News 9 | 10 | This project originated as a modified version of Chat-UI, initially adopting a minimalist code approach to implement core MCP functionality for educational purposes. 11 | 12 | Through iterative updates to MCP, I received community feedback advocating for a completely new architecture - one that eliminates third-party CDN dependencies and establishes clearer modular structure to better support derivative development and debugging workflows. 13 | 14 | This led to the creation of [Tool Unitary User Interface](https://github.com/AI-QL/tuui), a restructured desktop application optimized for AI-powered development. Building upon the original foundation, TUUI serves as a practical AI-assisted development paradigm, if you're interested, you can also leverage AI to develop new features for TUUI. The platform employs a strict linting and formatting system to ensure AI-generated code adheres to coding standards. 15 | 16 | > **📢 Update: June 2025** 17 | > The current project refactoring has been largely completed, and a pre-release version is now available. Please refer to the following documentation for details: 18 | > - [TUUI GitHub Repository](https://github.com/AI-QL/tuui) 19 | > - [TUUI Architecture](https://deepwiki.com/AI-QL/tuui) 20 | > - [TUUI Official Website](https://www.tuui.com/) 21 | 22 | ## Features 23 | 24 | - Cross-Platform Compatibility: Supports Linux, macOS, and Windows. 25 | 26 | - Flexible Apache-2.0 License: Allows easy modification and building of your own desktop applications. 27 | 28 | - Dynamic LLM Configuration: Compatible with all OpenAI SDK-supported LLMs, enabling quick testing of multiple backends through manual or preset configurations. 29 | 30 | - Multi-Client Management: Configure and manage multiple clients to connect to multiple servers using MCP config. 31 | 32 | - UI Adaptability: The UI can be directly extracted for web use, ensuring consistent ecosystem and interaction logic across web and desktop versions. 33 | 34 | 35 | ## Architecture 36 | 37 | Adopted a straightforward architecture consistent with the MCP documentation to facilitate a clear understanding of MCP principles by: 38 | 39 | [DeepWiki](https://deepwiki.com/AI-QL/chat-mcp) 40 | 41 | ## How to use 42 | 43 | After cloning or downloading this repository: 44 | 45 | 1. Please modify the `config.json` file located in [src/main](src/main). 46 | Ensure that the `command` and `path` specified in the `args` are valid. 47 | 48 | 2. Please ensure that [Node.js](https://nodejs.org/) is installed on your system. 49 | You can verify this by running `node -v` and `npm -v` in your terminal to check their respective versions. 50 | 51 | 3. `npm install` 52 | 53 | 4. `npm start` 54 | 55 | ## Configuration 56 | 57 | Create a `.json` file and paste the following content into it. This file can then be provided as the interface configuration for the Chat UI. 58 | 59 | - `gtp-api.json` 60 | 61 | ```json 62 | { 63 | "chatbotStore": { 64 | "apiKey": "", 65 | "url": "https://api.aiql.com", 66 | "path": "/v1/chat/completions", 67 | "model": "gpt-4o-mini", 68 | "max_tokens_value": "", 69 | "mcp": true 70 | }, 71 | "defaultChoiceStore": { 72 | "model": [ 73 | "gpt-4o-mini", 74 | "gpt-4o", 75 | "gpt-4", 76 | "gpt-4-turbo" 77 | ] 78 | } 79 | } 80 | ``` 81 | 82 | You can replace the 'url' if you have direct access to the OpenAI API. 83 | 84 | Alternatively, you can also use another API endpoint that supports function calls: 85 | 86 | - `qwen-api.json` 87 | 88 | ```json 89 | { 90 | "chatbotStore": { 91 | "apiKey": "", 92 | "url": "https://dashscope.aliyuncs.com/compatible-mode", 93 | "path": "/v1/chat/completions", 94 | "model": "qwen-turbo", 95 | "max_tokens_value": "", 96 | "mcp": true 97 | }, 98 | "defaultChoiceStore": { 99 | "model": [ 100 | "qwen-turbo", 101 | "qwen-plus", 102 | "qwen-max" 103 | ] 104 | } 105 | } 106 | ``` 107 | 108 | - `deepinfra.json` 109 | 110 | ```json 111 | { 112 | "chatbotStore": { 113 | "apiKey": "", 114 | "url": "https://api.deepinfra.com", 115 | "path": "/v1/openai/chat/completions", 116 | "model": "meta-llama/Meta-Llama-3.1-70B-Instruct", 117 | "max_tokens_value": "32000", 118 | "mcp": true 119 | }, 120 | "defaultChoiceStore": { 121 | "model": [ 122 | "meta-llama/Meta-Llama-3.1-70B-Instruct", 123 | "meta-llama/Meta-Llama-3.1-405B-Instruct", 124 | "meta-llama/Meta-Llama-3.1-8B-Instruct" 125 | ] 126 | } 127 | } 128 | ``` 129 | 130 | ## Build Application 131 | 132 | You can build your own desktop application by: 133 | 134 | ```bash 135 | npm run build-app 136 | ``` 137 | 138 | This CLI helps you build and package your application for your current OS, with artifacts stored in the /artifacts directory. 139 | 140 | For Debian/Ubuntu users experiencing RPM build issues, try one of the following solutions: 141 | 142 | - Edit `package.json` to skip the RPM build step. Or 143 | 144 | - Install `rpm` using `sudo apt-get install rpm` (You may need to run `sudo apt update` to ensure your package list is up-to-date) 145 | 146 | 147 | # Troubleshooting 148 | 149 | ## Error: spawn npx ENOENT - [ISSUE 40](https://github.com/modelcontextprotocol/servers/issues/40) 150 | 151 | Modify the `config.json` in [src/main](src/main) 152 | 153 | On windows, npx may not work, please refer my workaround: [ISSUE 101](https://github.com/modelcontextprotocol/typescript-sdk/issues/101) 154 | 155 | - Or you can use `node` in config.json: 156 | ```json 157 | { 158 | "mcpServers": { 159 | "filesystem": { 160 | "command": "node", 161 | "args": [ 162 | "node_modules/@modelcontextprotocol/server-filesystem/dist/index.js", 163 | "D:/Github/mcp-test" 164 | ] 165 | } 166 | } 167 | } 168 | ``` 169 | 170 | Please ensure that the provided path is valid, especially if you are using a relative path. It is highly recommended to provide an absolute path for better clarity and accuracy. 171 | 172 | By default, I will install `server-everything`, `server-filesystem`, and `server-puppeteer` for test purposes. However, you can install additional server libraries or use `npx` to utilize other server libraries as needed. 173 | 174 | ## Installation timeout 175 | 176 | Generally, after executing `npm install` for the entire project, the total size of files in the `node_modules` directory typically exceeds 500MB. 177 | 178 | If the installation process stalls at less than 300MB and the progress bar remains static, it is likely due to a timeout during the installation of the latter part, specifically Electron. 179 | 180 | This issue often arises because the download speed from Electron's default server is excessively slow or even inaccessible in certain regions. To resolve this, you can modify the environment or global variable `ELECTRON_MIRROR` to switch to an Electron mirror site that is accessible from your location. 181 | 182 | ## Electron builder timeout 183 | 184 | When using electron-builder to package files, it automatically downloads several large release packages from GitHub. If the network connection is unstable, this process may be interrupted or timeout. 185 | 186 | On Windows, you may need to clear the cache located under the `electron` and `electron-builder` directories within `C:\Users\YOURUSERNAME\AppData\Local` before attempting to retry. 187 | 188 | Due to potential terminal permission issues, it is recommended to use the default shell terminal instead of VSCode's built-in terminal. 189 | 190 | ## Demo 191 | 192 | ### Multimodal Support 193 | ![](https://gcore.jsdelivr.net/gh/AI-QL/.github/public/chat-mcp/demo-multimodal.png) 194 | 195 | ### Reasoning and Latex Support 196 | ![](https://gcore.jsdelivr.net/gh/AI-QL/.github/public/chat-mcp/demo-latex.png) 197 | 198 | ### MCP Tools Visualization 199 | ![](https://gcore.jsdelivr.net/gh/AI-QL/.github/public/chat-mcp/demo-tools.png) 200 | 201 | ### MCP Toolcall Process Overview 202 | ![](https://gcore.jsdelivr.net/gh/AI-QL/.github/public/chat-mcp/demo-toolcall.png) 203 | 204 | ### MCP Prompts Template 205 | ![](https://gcore.jsdelivr.net/gh/AI-QL/.github/public/chat-mcp/demo-prompts.png) 206 | 207 | ### Dynamic LLM Config 208 | ![](https://gcore.jsdelivr.net/gh/AI-QL/.github/public/chat-mcp/demo-llms.png) 209 | 210 | ### DevTool Troubleshooting 211 | ![](https://gcore.jsdelivr.net/gh/AI-QL/.github/public/chat-mcp/demo-devtool.png) 212 | -------------------------------------------------------------------------------- /icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AI-QL/chat-mcp/f2fa9f7ae47441261d815864906acacf7d271283/icon.icns -------------------------------------------------------------------------------- /icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AI-QL/chat-mcp/f2fa9f7ae47441261d815864906acacf7d271283/icon.ico -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AI-QL/chat-mcp/f2fa9f7ae47441261d815864906acacf7d271283/icon.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aiql-desktop", 3 | "version": "1.0.0", 4 | "author": { 5 | "name": "AIQL", 6 | "email": "contact@aiql.com" 7 | }, 8 | "description": "MCP Chat Desktop by AIQL.com", 9 | "main": "dist/main/main.js", 10 | "type": "module", 11 | "scripts": { 12 | "start": "npm run build && electron ./dist/main/main.js", 13 | "build": "tsc && copyfiles -u 1 src/**/* -e src/**/*.ts dist", 14 | "build-app": "npm run build && electron-builder" 15 | }, 16 | "build": { 17 | "appId": "com.aiql.chat-mcp", 18 | "directories": { 19 | "output": "artifacts" 20 | }, 21 | "files": [ 22 | "**/*" 23 | ], 24 | "extraFiles": [ 25 | { 26 | "from": "./src/main/config.json", 27 | "to": "." 28 | } 29 | ], 30 | "win": { 31 | "target": "nsis", 32 | "icon": "icon.ico" 33 | }, 34 | "mac": { 35 | "target": "dmg", 36 | "icon": "icon.icns" 37 | }, 38 | "linux": { 39 | "target": [ 40 | "AppImage", 41 | "deb", 42 | "rpm" 43 | ], 44 | "icon": "icon.png" 45 | }, 46 | "nsis": { 47 | "oneClick": false, 48 | "allowToChangeInstallationDirectory": true 49 | } 50 | }, 51 | "devDependencies": { 52 | "@types/node-notifier": "^8.0.5", 53 | "copyfiles": "^2.4.1", 54 | "electron": "^34.0.0", 55 | "electron-builder": "^25.1.8", 56 | "electron-debug": "^4.1.0", 57 | "node-notifier": "^10.0.1", 58 | "typescript": "^5.7.3" 59 | }, 60 | "dependencies": { 61 | "@modelcontextprotocol/sdk": "^1.12.1" 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/client.ts: -------------------------------------------------------------------------------- 1 | // client.ts 2 | import { Client, StdioClientTransport, CreateMessageRequestSchema, ServerConfig } from './types.js'; 3 | 4 | export async function initializeClient(name: String, config: ServerConfig) { 5 | const transport = new StdioClientTransport({ 6 | ...config, 7 | }); 8 | const client_name = `${name}-client`; 9 | const client = new Client({ 10 | name: client_name, 11 | version: "1.0.0", 12 | }, { 13 | capabilities: { 14 | "sampling": {} 15 | } 16 | }); 17 | await client.connect(transport); 18 | console.log(`${client_name} connected.`); 19 | 20 | client.setRequestHandler(CreateMessageRequestSchema, async (request) => { 21 | console.log('Sampling request received:\n', request) 22 | return { 23 | model: "test-sampling-model", 24 | stopReason: "endTurn", 25 | role: "assistant", 26 | content: { 27 | type: "text", 28 | text: "This is a test message from the client used for sampling the LLM. If you receive this message, please stop further attempts, as the sampling test has been successful.", 29 | } 30 | }; 31 | }); 32 | 33 | return client; 34 | } 35 | 36 | export async function manageRequests( 37 | client: Client, 38 | method: string, 39 | schema: any, 40 | params?: any 41 | ) { 42 | const requestObject = { 43 | method: method, 44 | ...(params && { params: params }) 45 | }; 46 | 47 | const result = await client.request(requestObject, schema); 48 | console.log(result); 49 | return result; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/main/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "mcpServers": { 3 | "everything": { 4 | "command": "npx", 5 | "args": [ 6 | "-y", 7 | "@modelcontextprotocol/server-everything" 8 | ] 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /src/main/main.ts: -------------------------------------------------------------------------------- 1 | // main.ts 2 | import { app, BrowserWindow, ipcMain } from 'electron'; 3 | import { 4 | Client, McpServersConfig, 5 | ListToolsResultSchema, CallToolResultSchema, 6 | ListPromptsResultSchema, GetPromptResultSchema, 7 | ListResourcesResultSchema, ReadResourceResultSchema, ListResourceTemplatesResultSchema 8 | } from './types.js'; 9 | import { initializeClient, manageRequests } from './client.js'; 10 | 11 | import notifier from 'node-notifier'; 12 | 13 | import path from 'path'; 14 | import { dirname } from 'path'; 15 | import { fileURLToPath } from 'url'; 16 | import { readFileSync } from 'fs'; 17 | 18 | let appPath; 19 | 20 | if (app.isPackaged) { 21 | // Electron Packaged 22 | appPath = path.dirname(process.execPath); 23 | } else { 24 | // Dev 25 | appPath = app.getAppPath(); 26 | } 27 | 28 | console.log('Current Path:', appPath); 29 | 30 | const configPath = path.join(appPath, 'config.json'); 31 | 32 | const __filename = fileURLToPath(import.meta.url); 33 | const __dirname = dirname(__filename); 34 | 35 | const preloadPath = path.resolve(__dirname, '..', 'preload', 'preload.js'); 36 | const indexPath = path.resolve(__dirname, '..', 'renderer', 'index.html'); 37 | 38 | interface ClientObj { 39 | name: string; 40 | client: Client; 41 | capabilities: Record | undefined; 42 | } 43 | 44 | function readConfig(configPath: string): McpServersConfig | null { 45 | try { 46 | const config = readFileSync(configPath, 'utf8'); 47 | return JSON.parse(config); 48 | } catch (error) { 49 | console.error('Error reading config file:', error); 50 | return null; 51 | } 52 | } 53 | 54 | async function initClient(): Promise { 55 | const config = readConfig(configPath); 56 | if (config) { 57 | console.log('Config loaded:', config); 58 | 59 | try { 60 | const clients = await Promise.all( 61 | Object.entries(config.mcpServers).map(async ([name, serverConfig]) => { 62 | console.log(`Initializing client for ${name} with config:`, serverConfig); 63 | 64 | const timeoutPromise = new Promise((resolve, reject) => { 65 | setTimeout(() => { 66 | reject(new Error(`Initialization of client for ${name} timed out after 30 seconds`)); 67 | }, 30000); // 30 seconds 68 | }); 69 | 70 | const client = await Promise.race([ 71 | initializeClient(name, serverConfig), 72 | timeoutPromise, 73 | ]); 74 | 75 | console.log(`${name} initialized.`); 76 | const capabilities = client.getServerCapabilities(); 77 | return { name, client, capabilities }; 78 | }) 79 | ); 80 | 81 | console.log('All clients initialized.'); 82 | notifier.notify({ 83 | appID: 'AIQL', 84 | title: "MCP Servers are ready", 85 | message: "All Clients initialized." 86 | }); 87 | 88 | return clients; 89 | } catch (error) { 90 | console.error('Error during client initialization:', error?.message); 91 | notifier.notify({ 92 | appID: 'AIQL', 93 | title: 'Client initialization failed', 94 | message: "Cannot start with current config, " + error?.message, 95 | }); 96 | 97 | process.exit(1); 98 | } 99 | } else { 100 | console.log('NO clients initialized.'); 101 | notifier.notify({ 102 | appID: 'AIQL', 103 | title: 'NO clients initialized', 104 | message: "NO valid JSON config found.", 105 | }); 106 | return []; 107 | } 108 | } 109 | 110 | async function createWindow() { 111 | const mainWindow = new BrowserWindow({ 112 | width: 1920, 113 | height: 1080, 114 | webPreferences: { 115 | nodeIntegration: false, 116 | contextIsolation: true, 117 | preload: preloadPath 118 | } 119 | }); 120 | 121 | mainWindow.loadFile(indexPath); 122 | 123 | // You can uncomment the following line to enable DevTools permanently. 124 | // mainWindow.webContents.openDevTools(); 125 | } 126 | 127 | app.whenReady().then(async () => { 128 | 129 | const clients = await initClient(); 130 | 131 | createWindow(); 132 | 133 | app.on('activate', () => { 134 | if (BrowserWindow.getAllWindows().length === 0) createWindow(); 135 | }); 136 | 137 | ipcMain.handle('list-clients', () => { 138 | return features; 139 | }); 140 | 141 | function registerIpcHandlers( 142 | name: string, 143 | client: Client, 144 | capabilities: Record | undefined) { 145 | 146 | const feature: { [key: string]: any } = { name }; 147 | 148 | const registerHandler = (method: string, schema: any) => { 149 | const eventName = `${name}-${method}`; 150 | console.log(`IPC Main ${eventName}`); 151 | ipcMain.handle(eventName, async (event, params) => { 152 | return await manageRequests(client, `${method}`, schema, params); 153 | }); 154 | return eventName; 155 | }; 156 | 157 | const capabilitySchemas = { 158 | tools: { 159 | list: ListToolsResultSchema, 160 | call: CallToolResultSchema, 161 | }, 162 | prompts: { 163 | list: ListPromptsResultSchema, 164 | get: GetPromptResultSchema, 165 | }, 166 | resources: { 167 | list: ListResourcesResultSchema, 168 | read: ReadResourceResultSchema, 169 | 'templates/list': ListResourceTemplatesResultSchema, 170 | }, 171 | }; 172 | 173 | for (const [type, actions] of Object.entries(capabilitySchemas)) { 174 | if (capabilities?.[type]) { 175 | feature[type] = {}; 176 | for (const [action, schema] of Object.entries(actions)) { 177 | feature[type][action] = registerHandler(`${type}/${action}`, schema); 178 | } 179 | } 180 | } 181 | 182 | return feature; 183 | } 184 | 185 | const features = clients.map(({ name, client, capabilities }) => { 186 | console.log('Capabilities:', name, '\n', capabilities); 187 | return registerIpcHandlers(name, client, capabilities); 188 | }); 189 | 190 | console.log(features) 191 | 192 | }); 193 | 194 | app.on('window-all-closed', () => { 195 | if (process.platform !== 'darwin') app.quit(); 196 | }); 197 | 198 | -------------------------------------------------------------------------------- /src/main/types.ts: -------------------------------------------------------------------------------- 1 | // types.ts 2 | export { Client } from "@modelcontextprotocol/sdk/client/index.js"; 3 | export { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"; 4 | 5 | export { 6 | CreateMessageRequestSchema, 7 | 8 | CompleteResultSchema, 9 | 10 | ListToolsResultSchema, 11 | CallToolResultSchema, 12 | 13 | ListPromptsResultSchema, 14 | GetPromptResultSchema, 15 | 16 | ListResourcesResultSchema, 17 | ReadResourceResultSchema, 18 | ListResourceTemplatesResultSchema 19 | 20 | } from "@modelcontextprotocol/sdk/types.js"; 21 | 22 | 23 | export interface McpServersConfig { 24 | mcpServers: { 25 | [key: string]: ServerConfig; 26 | }; 27 | } 28 | 29 | export interface ServerConfig { 30 | command: string; 31 | // ---- Example ---- 32 | // args: string[]; 33 | [key: string]: any 34 | } 35 | -------------------------------------------------------------------------------- /src/preload/preload.ts: -------------------------------------------------------------------------------- 1 | const { contextBridge, ipcRenderer } = require('electron'); 2 | 3 | type AsyncFunction = (...args: any[]) => Promise; 4 | 5 | interface MCPAPI { 6 | [key: string]: { 7 | tools?: { 8 | list?: AsyncFunction; 9 | call?: AsyncFunction; 10 | }; 11 | prompts?: { 12 | list?: AsyncFunction; 13 | get?: AsyncFunction; 14 | }; 15 | resources?: { 16 | list?: AsyncFunction; 17 | read?: AsyncFunction; 18 | }; 19 | } 20 | } 21 | 22 | interface CLIENT { 23 | name: string; 24 | tools?: Record; 25 | prompts?: Record; 26 | resources?: Record; 27 | } 28 | 29 | 30 | async function listClients(): Promise { 31 | return await ipcRenderer.invoke('list-clients'); 32 | } 33 | 34 | async function exposeAPIs() { 35 | const clients = await listClients(); 36 | const api: MCPAPI = {}; 37 | 38 | const createAPIMethods = (methods: Record) => { 39 | const result: Record Promise> = {}; 40 | Object.keys(methods).forEach(key => { 41 | const methodName = methods[key]; 42 | result[key] = (...args: any) => ipcRenderer.invoke(methodName, ...args); 43 | }); 44 | return result; 45 | }; 46 | 47 | clients.forEach(client => { 48 | const { name, tools, prompts, resources } = client; 49 | api[name] = {}; 50 | 51 | if (tools) { 52 | api[name]['tools'] = createAPIMethods(tools); 53 | } 54 | if (prompts) { 55 | api[name]['prompts'] = createAPIMethods(prompts); 56 | } 57 | if (resources) { 58 | api[name]['resources'] = createAPIMethods(resources); 59 | } 60 | }); 61 | 62 | contextBridge.exposeInMainWorld('mcpServers', api); 63 | } 64 | 65 | exposeAPIs(); 66 | 67 | -------------------------------------------------------------------------------- /src/renderer/index.html: -------------------------------------------------------------------------------- 1 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 42 | Chatbot 43 | 76 |
77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 118 | 119 | 322 | 323 | 324 | 325 |
326 | 327 | 328 | 334 | 335 | 336 | 338 |
339 |
340 |
341 | 342 | 343 | 347 | 349 | 350 | 351 | 354 | 355 | 360 | 361 | 363 | 367 | 368 | 369 | 370 | 371 | 372 | 374 | 375 | 377 | 378 | 380 | 382 | 383 | 384 | 385 | 386 | 387 | 391 | 402 | 403 | 404 | 405 |
406 | 408 | 409 | 411 | 413 | 417 | 420 | 421 | 423 | 424 | 425 | 428 | 429 |
430 |
431 |
432 | 433 | 434 | 435 |
436 | {{ snackbarStore.getIcon() }} 437 | {{$t(snackbarStore.message)}} 438 |
439 | 440 | 445 |
446 | 447 | 448 | 449 | 456 | 457 | 458 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 500 | 501 | 502 | 503 | 504 | 505 | 511 | 512 | 513 | 514 | 515 | 516 | 528 | 529 | 530 | 531 | 532 | 533 | 536 | 537 | 538 | 539 | 540 | 541 | 544 | 545 | 546 | 547 | 548 | 549 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 592 | 593 | 594 | 595 | 597 | 598 | 600 | 601 | 603 | 604 | 605 | 606 | 607 | 611 | 612 | 615 | 616 | 617 | 618 | 623 | 624 | 628 | 629 | 630 | 633 | 634 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 649 | 650 | 651 | OK 652 | 653 | 654 | 655 | 656 | 657 | 658 | 660 | 667 | 686 | 687 | 688 | 689 | 690 | 693 | 694 | 695 |
{{promptStore.promptSelect.description}}
696 |
697 |
698 | 701 |
702 | 703 | 704 | 705 | Get 707 | 708 |
709 |
710 |
711 | 712 | 713 | 714 | 717 | 718 | 719 | 720 | 721 | 722 | 725 | 741 | 742 | 745 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 765 | 771 | 772 | 773 | 774 | 775 | 776 |
777 |
{{ column.key }}
778 | 779 | 780 | 782 | 783 |
784 | 785 | 786 | 787 | 791 |
792 | Cancel 794 | 795 | Add 797 |
798 |
799 | 800 | 801 | 804 | 815 | 816 |
817 |
818 | 819 | 820 |
MCP
821 | 822 | 826 |
827 |
828 | 829 |
830 |
831 |
832 | 833 | 834 | 835 | 836 | Edit Card 837 | 839 | 840 | 841 | 842 |
843 | 846 | 847 | 849 | 850 | {{ agentStore.card?.refText }} 851 | 852 |
853 | 854 | 855 | 858 | 859 | Cancel 860 | Save 861 | 862 |
863 |
864 | 865 |
867 | mdi-tools 868 |
869 | 870 | 871 | 872 | 873 | 874 | mdi-store-remove 875 | 876 | 877 | 878 | 879 | 880 | 881 | mdi-close 882 | 883 | 884 | 885 |
886 |
887 | 888 | 1002 | 1003 | 1018 | 1019 | 1048 | 1049 | 2654 | 2655 | 2656 | 2657 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "es2022", 4 | "target": "es2017", 5 | "lib": [ 6 | "es6", 7 | "dom" 8 | ], 9 | "types": [ 10 | "node" 11 | ], 12 | "esModuleInterop": true, 13 | "moduleResolution": "node", 14 | "resolveJsonModule": true, 15 | "allowSyntheticDefaultImports": true, 16 | "useUnknownInCatchVariables": false, 17 | "strict": true, 18 | "outDir": "./dist", 19 | "rootDir": "./src" 20 | }, 21 | "include": [ 22 | "src/**/*.ts" 23 | ], 24 | "exclude": [ 25 | "node_modules" 26 | ] 27 | } --------------------------------------------------------------------------------