Skip to main content
Glama

MCP Interactive Service

Integrations
  • Used as the web framework for the MCP service's web interface, enabling HTTP-based interactions between AI tools and users through a browser.

  • The primary language for the MCP service, providing the foundation for all UI types (CLI, Web, PyQt) and tool implementations.

  • Mentioned as an example implementation option in the select_option tool, allowing AI tools to present PyTorch as an implementation choice to users.

MCP互动服务

这是一个使用 FastMCP 库实现的 MCP 服务,旨在与 Cursor、Windsurf 等 AI 工具交互。当 AI 工具在调用大型语言模型时需要用户输入或选项选择时,可以调用此 MCP 服务。

核心目的

该插件的核心目的是实现 AI 工具(如 Cursor 和 Windsurf)与用户之间的高频通信和确认。它通过以下方式显著提高 AI 交互的效率和效果:

  1. 减少资源浪费:通过允许用户在 AI 采取可能错误的解决方案路径之前确认或重定向 AI 的方法,该插件最大限度地减少了 API 调用和计算资源的浪费。
  2. 最大化资源利用率:对 Cursor 或 Windsurf 的每次 API 调用都会变得更有效率,因为 AI 可以在继续之前向用户验证其理解和方法。
  3. 防止注意力分散:通过尽早确认方法,该插件有助于将注意力集中在正确的解决方案路径上,而不是将注意力转移到不正确的方法上。
  4. 实现交互式决策:用户可以积极参与决策过程,并向人工智能提供即时反馈和指导。
  5. 简化复杂任务:对于多步骤任务,该插件可确保每个关键决策点上的用户期望与 AI 执行保持一致。

特征

  • 选项选择:显示选项列表,供用户通过输入数字或提供自定义答案进行选择
  • 信息补充:当AI模型需要更完整的信息时,可以请求用户直接输入补充信息
  • 多用户界面:支持 CLI、Web 和 PyQt 界面

UI 类型

该项目支持三种不同的用户界面类型,每种类型都有自己的特点:

CLI(命令行界面)

  • 描述:打开一个新的命令提示符窗口供用户交互
  • 优点
    • 最小依赖性(无需额外的包)
    • 可以同时处理多个对话窗口
    • 在没有图形界面的环境中也能很好地工作
    • 轻量且启动快速
  • 缺点
    • 基本视觉呈现
    • 对于非技术用户来说可能不那么直观
  • 最适合:服务器环境、资源有限的系统或需要同时进行多个对话的情况

PyQt 接口

  • 描述:使用 PyQt 提供现代图形用户界面
  • 优点
    • 简洁、专业的对话框
    • 熟悉的桌面应用程序体验
    • 适合所有类型的用户使用
  • 缺点
    • 一次只能显示一个对话框
    • 需要 PyQt 依赖项(更大的安装)
  • 最适合:桌面使用,视觉吸引力很重要,并且一次只需要一个对话框

Web 界面

  • 描述:在网络浏览器中打开对话框
  • 优点
    • 可以同时处理多个对话窗口
    • 通过网络浏览器从任何地方访问
    • 现代、可定制的界面
  • 缺点
    • 需要安装网络浏览器
    • 稍微复杂一点的设置
  • 最适合:远程访问场景、优先使用 Web 界面的环境或需要同时进行多个对话的情况

使用指南

1. 入门(两种选择)

选项 A:使用预编译的可执行文件(推荐用于 Windows)
  1. GitHub 发布页面下载最新的预编译可执行文件。
  2. 无需安装 - 只需下载并运行可执行文件。
  3. 您可以使用以下命令测试功能:
# Test option selection with PyQt interface .\dist\mcp-interactive.exe test select_option --ui pyqt # Test information supplement with PyQt interface .\dist\mcp-interactive.exe test request_additional_info --ui pyqt # You can also specify a file path for testing the request_additional_info tool .\dist\mcp-interactive.exe test request_additional_info --ui pyqt D:\Path\To\Your\File.md
  1. 跳至下面的步骤 3 进行配置。
选项 B:从源代码安装

该项目根据不同的 UI 类型分离依赖项:

  • requirements-base.txt :基本依赖项,由所有 UI 类型共享
  • requirements-pyqt.txt :PyQt5 UI 依赖项
  • requirements-web.txt :Web UI(Flask)依赖项

您可以选择使用传统的 pip 或更快的 uv 包管理器来安装依赖项。

使用 pip(传统方法)

根据要使用的 UI 类型选择适当的依赖文件:

cd requirements # CLI UI (minimal dependencies) pip install -r requirements-base.txt # PyQt5 UI pip install -r requirements-pyqt.txt # Web UI pip install -r requirements-web.txt

注意:每个特定的 UI 依赖文件已经包含对基本依赖项的引用(通过-r requirements-base.txt ),因此您只需安装一个文件。

使用 uv(推荐,更快)

如果已经安装了uv ,可以使用以下命令创建虚拟环境并安装依赖项:

# Create a virtual environment uv venv # Activate the virtual environment # Windows .venv\Scripts\activate # macOS / Linux source .venv/bin/activate # Install dependencies based on UI type cd requirements # CLI UI (minimal dependencies) uv pip install -r requirements-base.txt # PyQt5 UI uv pip install -r requirements-pyqt.txt # Web UI uv pip install -r requirements-web.txt

您也可以使用项目的 pyproject.toml 文件直接安装所有依赖项:

# Install base dependencies uv pip install -e . # Install specific UI type dependencies uv pip install -e ".[pyqt]" # PyQt5 UI uv pip install -e ".[web]" # Web UI uv pip install -e ".[all]" # All UI types

2.启动程序

启动不同的UI响应方法:

# Command line interface (default) python main.py run --ui=cli # Web interface python main.py run --ui=web # PyQt interface python main.py run --ui=pyqt

其他服务启动选项:

# Start the service with default settings (address: 127.0.0.1, port: 7888) python main.py run # Specify host and port python main.py run --host 0.0.0.0 --port 8888 # Specify log level python main.py run --log-level warning

3. 配置 Cursor、Windsurf 或 Claude

使用 stdio 协议(推荐)

stdio 协议是最稳定和推荐的连接方式,通过标准输入/输出直接与 Python 脚本通信,具有以下优点:

  • 更高的稳定性和可靠性
  • 可以同时打开多个对话框
  • 简单直接,无需处理网络连接问题
  • 与系统集成更紧密,响应速度更快

配置示例:

与 Python 一起使用(源代码)
{ "ai-interaction": { "command": "python", "args": ["path/to/main.py", "run", "--transport", "stdio", "--ui", "cli"], "env": {} } }
与可执行文件一起使用
{ "ai-interaction": { "command": "D:/Path/To/Your/mcp-interactive.exe", "args": ["run", "--transport", "stdio", "--ui", "pyqt"], "env": {} } }
使用 SSE 协议(替代)

如果需要通过网络连接远程服务器,可以使用SSE协议:

本地启动:

python main.py run --transport sse

游标配置:

{ "ai-interaction": { "type": "sse", "url": "http://127.0.0.1:8000/sse", "env": {} } }

风帆冲浪配置:

{ "ai-interaction": { "serverUrl": "http://127.0.0.1:7888/sse", "disabled": false } }

4.配置AI交互规则

为了最大限度地提高 Cursor 和 Windsurf 中 AI 交互的有效性,请配置 AI 在使用 MCP 时要遵循的以下规则:

  1. 当AI对某项任务不清楚或者需要更多信息时,它应该调用MCP ai-interaction来向用户请求澄清。
  2. 当 AI 对某个解决方案有多种可能的方法时,它应该调用 MCP ai-interaction 来让用户选择首选方法。
  3. 当AI完成一个任务后,应该调用MCP ai-interaction来确认是否还有其他任务需要执行。
  4. 人工智能应该将任务分解为多个阶段,并且在开始新阶段之前,调用 MCP ai-interaction 询问用户是否需要加入任何其他想法或考虑。
  5. 人工智能应该主动使用 MCP 来确认关键决策,而不是做出假设。

这些规则确保高质量、交互式的 AI 辅助,同时最大化每个 API 调用的价值。

其他功能

查看可用工具
python main.py list-tools
测试工具
# Test option selection tool python main.py test select_option --ui=cli # Test information supplement tool python main.py test request_additional_info --ui=cli
交互式测试客户端

该项目包括一个交互式测试客户端,允许您使用不同的 UI 类型和方法测试 MCP 服务:

# Run the interactive test client python mcp_client_en.py --host localhost --port 7888 --ui cli

选项:

  • --host :服务器主机(默认值:localhost)
  • --port :服务器端口(默认值:7888)
  • --ui :要使用的 UI 类型(cli、pyqt、web)

客户提供:

  • 使用 MCP 服务进行连接测试
  • 选择要测试的 UI 类型
  • 测试 select_option 和 request_additional_info 方法
  • 每种方法都有多个参数预设
  • 请求和响应的完全可视化

这对于以下情况尤其有用:

  • 调试 UI 交互问题
  • 测试不同 UI 类型的行为
  • 向用户演示服务
  • 验证服务器功能
STDIO 测试客户端

为了专门测试 stdio 传输协议,我们提供了一个命令行工具:

# Test stdio connection with default settings python mcp_client_stdio.py # Specify UI type python mcp_client_stdio.py --ui=pyqt # Test specific tools python mcp_client_stdio.py --test=select_option

有关更多详细信息,请参阅STDIO 测试指南

UI 测试
# Test PyQt interface python test_ui.py --ui=pyqt # Test Web interface python test_ui.py --ui=web # Test CLI interface python test_ui.py --ui=cli

工具描述

选项选择(select_option)

该工具用于向用户呈现一组选项,并让他们通过输入数字或提供自定义答案来选择。

参数:

  • options :选项列表,可以是字符串或字典列表
  • prompt :向用户显示的提示信息

返回:包含选择结果的字典,格式为:

{ "selected_index": 0, // Index of the user's selection, -1 if custom answer "selected_option": {}, // Content of the user's selected option "custom_input": "", // User's custom input, if any "is_custom": false // Whether it's a custom answer }

信息补充(request_additional_info)

此工具用于向用户请求补充信息。

参数:

  • prompt :请求信息的提示
  • current_info :当前信息,显示给用户作为参考

返回:用户输入的补充信息(字符串)

与AI工具集成

要将此 MCP 服务与 AI 工具集成,请按照以下步骤操作:

  1. 使用可执行文件或 Python 源代码启动 MCP 服务:
    • 使用可执行文件: mcp-interactive.exe run
    • 使用 Python 源代码: python main.py run
  2. 在 AI 工具中配置 MCP 端点,根据需要选择 stdio 或 SSE 协议
  3. 当AI模型需要用户输入或选项选择时,调用适当的MCP工具

克劳德积分

要在 Anthropic 的官方产品或第三方应用程序中与 Claude 集成:

  1. 在您的 AI 工具设置中配置 stdio 连接:
    { "mcp-interaction": { "command": "D:/Path/To/Your/mcp-interactive.exe", "args": ["run", "--transport", "stdio", "--ui", "pyqt"], "env": {} } }
  2. 配置 Claude 在需要时使用交互服务,具体说明如下:
    • “当需要用户输入或确认时,请使用 MCP 交互服务”
    • 对于多项选择选项,请调用 select_option 工具
    • “要收集其他用户信息,请调用 request_additional_info 工具”
  3. 克劳德现在可以直接通过 MCP 服务提供选项并请求更多信息。

示例

选项选择示例

from fastmcp import Client async with Client("http://127.0.0.1:8000/sse") as client: options = [ "Option 1: Implement with TensorFlow", "Option 2: Implement with PyTorch", {"title": "Option 3: Implement with JAX", "description": "Better for research purposes"} ] result = await client.call_tool( "select_option", {"options": options, "prompt": "Please select a framework implementation"} ) selected_option = result.json print(f"User selected: {selected_option}")

信息补充示例

from fastmcp import Client async with Client("http://127.0.0.1:8000/sse") as client: additional_info = await client.call_tool( "request_additional_info", { "prompt": "Please provide specific project requirements", "current_info": "This is a data analysis project" } ) print(f"User provided information: {additional_info.text}")

开发说明

  • 除非您需要开发或测试多种 UI 类型,否则建议仅安装一个 UI 依赖项
  • 如果需要添加新的依赖项,请将其添加到相应的依赖文件中

目前发展状况

请注意以下实施状态:

  • Windows :CLI 和 PyQt UI 版本功能齐全。Web UI 仍存在一些问题需要解决。
  • Linux/Mac :这些平台尚未经过全面测试。您的体验可能会有所不同。

我们正在积极致力于提高所有平台和 UI 类型的兼容性。

建筑和配送

构建可执行文件

该项目包括一个为 Windows 构建独立可执行文件的脚本:

# Build the Windows executable build_executable.bat

这将在dist目录中创建mcp-interactive.exe ,您无需安装 Python 即可运行它。

跨平台构建

为不同平台构建可执行文件:

视窗
# Using the batch script build_executable.bat # Or manual PyInstaller command pyinstaller mcp-interactive.spec
macOS
# Ensure PyInstaller is installed pip install pyinstaller # Build using the spec file pyinstaller mcp-interactive.spec
Linux
# Ensure PyInstaller is installed pip install pyinstaller # Build using the spec file pyinstaller mcp-interactive.spec

注意:您必须在目标平台上构建(您不能从 Windows 等构建 macOS 可执行文件)

通过 GitHub 分发

要使您构建的可执行文件可供下载:

  1. 为你的项目创建 GitHub 版本
  2. 将构建的可执行文件上传为发布资产
  3. 提供清晰的文档,说明每个平台应使用哪个可执行文件

示例步骤:

  1. 导航到你的 GitHub 存储库
  2. 点击右侧边栏中的“发布”
  3. 点击“创建新版本”
  4. 设置版本标签(例如,v1.0.0)
  5. 为您的发布添加标题和描述
  6. 拖放或上传适用于不同平台的可执行文件
  7. 点击“发布版本”

然后,用户可以从 GitHub 发布页面下载适合其操作系统的版本。

执照

该项目根据 MIT 许可证发布。

-
security - not tested
F
license - not found
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

一种支持 AI 工具(如 Cursor 和 Windsurf)与用户之间高频通信的接口,允许通过 CLI、Web 或 PyQt 接口进行选项选择和信息收集。

  1. 核心目的
    1. 特征
      1. UI 类型
        1. CLI(命令行界面)
        2. PyQt 接口
        3. Web 界面
      2. 使用指南
        1. 入门(两种选择)
        2. 2.启动程序
        3. 配置 Cursor、Windsurf 或 Claude
        4. 4.配置AI交互规则
        5. 其他功能
      3. 工具描述
        1. 选项选择(select\_option)
        2. 信息补充(request\_additional\_info)
      4. 与AI工具集成
        1. 克劳德积分
      5. 示例
        1. 选项选择示例
        2. 信息补充示例
      6. 开发说明
        1. 目前发展状况
          1. 建筑和配送
            1. 构建可执行文件
            2. 跨平台构建
            3. 通过 GitHub 分发
          2. 执照

            Related MCP Servers

            • -
              security
              F
              license
              -
              quality
              This server acts as a Message Communication Protocol (MCP) service for integrating Apifox and Cursor, enabling OpenAPI interface implementation through AI-driven interaction.
              Last updated -
              7
              TypeScript
            • -
              security
              F
              license
              -
              quality
              A Model Context Protocol server that enables AI assistants to explore and interact with Cursor IDE's SQLite databases, providing access to project data, chat history, and composer information.
              Last updated -
              10
              Python
              • Apple
            • -
              security
              F
              license
              -
              quality
              A server that connects AI coding assistants like Cursor and Cline to Apifox API definitions, allowing developers to implement API interfaces through natural language commands.
              Last updated -
              832
              1
              • Apple
              • Linux
            • -
              security
              F
              license
              -
              quality
              This server enables AI assistants (CLINE, Cursor, Windsurf, Claude Desktop) to share a common knowledge base through Retrieval Augmented Generation (RAG), providing consistent information access across multiple tools.
              Last updated -
              1
              TypeScript
              • Apple

            View all related MCP servers

            MCP directory API

            We provide all the information about MCP servers via our MCP API.

            curl -X GET 'https://glama.ai/api/mcp/v1/servers/DanielZhao1990/interaction-mcp'

            If you have feedback or need assistance with the MCP directory API, please join our Discord server