本页内容

设置Qt Creator MCP服务器

Qt Creator 支持模型上下文协议(MCP),以便 AI 助手对其进行控制,从而实现项目的调试、构建和管理。

要启动 MCP 服务器并使用 MCP 客户端,请安装客户端并激活 MCP 服务器扩展。

查看 MCP 服务器状态

Qt Creator 激活Qt Creator MCP 服务器扩展时,系统会自动启动 MCP 服务器。该服务器在计算机上运行,并通过自动设置的端口接受连接。

要查看 MCP 服务器状态以及更改 IP 地址和端口号,请转至Preferences >AI > Qt Creator MCP Server

AI 首选项中的 Qt Creator MCP 服务器

下表总结了相关首选项。

设置
Enable MCP Server打开或关闭 MCP 服务器。
Listen on设置 MCP 服务器用于监听的服务器地址。
Port设置 MCP 服务器监听的端口。Automatic 会自动选择一个空闲端口,但您也可以设置一个固定的端口号。
Enable cross-origin access启用跨源资源共享 (CORS),您需要此功能才能从 Web 应用程序连接到服务器。

使用 MCP 客户端

当您在Qt Creator 中启用 ACP 客户端扩展并使用 ACP 客户端时,它会自动使用 MCP 服务器。

若要将 MCP 服务器用于其他产品(例如 Claude Code),则必须进行配置。有关详细信息,请参阅该产品的文档。

检查客户端通信

要检查 MCP 客户端与Qt Creator MCP 服务器之间的通信,请转至Tools > Debug Qt Creator >Inspect MCP Servers

“MCP 服务器检查器”对话框

在“Session ”中,选择 MPC 客户端与服务器之间的会话,或选择“Global ”以显示常规消息。

在“Client Message ”中,选择一条消息,即可在“Server Message ”中查看更多信息。

要删除旧条目,请选择“Clear ”。

要将消息保存为文件,请选择“Save ”。

另请参阅 “激活扩展”和“操作指南:使用 AI”。

Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.