// Copyright (C) 2026 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \page creator-how-to-mcp-server.html
    \previouspage creator-how-tos.html

    \ingroup creator-how-to-ai

    \title Set up \QC MCP server

    \QC supports the model context protocol (MCP) to let AI assistants control it
    for debugging, building, and managing projects.

    To start the MCP server and use an MCP client, install a client and activate
    the MCP server extension.

    \section1 View MCP server status

    \QC starts the MCP server when you activate the \QC MCP server extension. The
    server runs on the computer and accepts connections on an automatically set
    port.

    To view the MCP server status and to change the IP address and port
    number, go to \preferences > \uicontrol {AI} > \uicontrol {\QC MCP Server}.

    \image {qtcreator-mcp-server-status.webp} {Qt Creator MCP Server in the AI Preferences}

    The following table summarizes the preferences.

    \table
    \header
        \li Setting
        \li Value
    \row
        \li \uicontrol {Enable MCP Server}
        \li Turns the MCP server on and off.
    \row
        \li \uicontrol {Listen on}
        \li Sets the server address for the MCP server to listen on.
    \row
        \li \uicontrol {Port}
        \li Sets the port for the MCP server to listen on. \uicontrol {Automatic}
            automatically selects a free port, but you can also set a fixed port
            number.
    \row
        \li \uicontrol {Enable cross-origin access}
        \li Turns on cross-origin resource sharing (CORS), which you need to
            connect to the server from a web application.
    \endtable

    \section1 Use MCP clients

    When you enable the ACP Client extension and use an ACP client in \QC, it
    uses the MCP server automatically.

    To use the MCP server for other products, such as Claude Code, you must
    configure it. For more information, see the documentation of the product.

    \section2 Inspect client communication

    To inspect the communication between MCP clients and the \QC MCP server,
    go to \uicontrol Tools > \uicontrol {Debug \QC} >
    \uicontrol {Inspect MCP Servers}.

    \image qtcreator-mcp-server-inspector.webp {MCP Server Inspector dialog}

    In \uicontrol {Session}, select a session between an MPC client and server,
    or \uicontrol {Global} to show general messages.

    In \uicontrol {Client Message}, select a message to view more information in
    \uicontrol {Server Message}.

    To remove old entries, select \uicontrol Clear.

    To save messages as a file, select \uicontrol Save.

    \sa {Activate extensions}, {Use AI}{How to: Use AI}
*/

/*!
    \page creator-how-to-add-mcp-servers.html
    \previouspage creator-how-tos.html

    \ingroup creator-how-to-ai

    \title Add MCP servers

    You can configure connections to MCP servers to:

    \list
        \li Complete \l{MCP: Tasks}{Tasks}
        \li Connect to the server from a web application using
            cross-origin resource sharing (CORS)
    \endlist

    You can use tools for:

    \list
        \li Running command-line tools and other executables
        \li Version control repositories
        \li Listing visible files
        \li Managing breakpoints
        \li Getting debugger stack traces
        \li Finding and triggering actions
    \endlist

    You can execute commands for:

    \list
        \li Retrieving project dependencies
        \li Listing issues for a file
        \li Finding files in projects
        \li Searching and replacing text in project files and other files
    \endlist

    \section1 Connect to MCP servers

    To add connections to MCP servers:

    \list 1
        \li Go to \preferences > \uicontrol {AI} > \uicontrol {MCP Servers}.
            \image {qtcreator-preferences-ai-mcp-servers.webp} {MCP Servers tab in the AI Preferences}
        \li Select \uicontrol Add.
        \li Set preferences for the server.
        \li Select \uicontrol Apply.
    \endlist

    The following table summarizes the preferences.

    \table
    \header
        \li Setting
        \li Value
    \row
        \li \uicontrol {Connection type}
        \li The type of the connection to use for the MCP server.
    \row
        \li \uicontrol {Executable}
        \li The executable to launch the MCP server process. Only used for standard
            IO connections.
    \row
        \li \uicontrol {Arguments}
        \li Arguments for the launch command.
    \row
        \li \uicontrol {Environment}
        \li Environment changes applied when launching the MCP server process
            over a standard IO connection.
    \endtable

    \section1 Add MCP servers from the registry

    To install MCP servers from the registry and create connections to them:

        \list 1
        \li Go to \preferences > \uicontrol {AI} > \uicontrol {MCP Servers}.
        \li Select \uicontrol {Add from Registry}.
        \li Select an MPC server from the list.
            \image {qtcreator-preferences-ai-mcp-server-registry.webp} {Add MCP Server from Registry dialog}
        \li Select \uicontrol OK.
    \endlist

    \sa {Activate extensions}, {Use AI}{How to: Use AI}
*/
