Skip to main content
Glama

MCP Command and Search Server

by mjunaid46

基于 MCP 的命令执行器和 Brave Search 客户端-服务器应用程序

概述

该项目实现了一个**客户端-服务器架构,使用 MCP(模型上下文协议)来处理用户提示,使用大型语言模型 (LLM)**确定其意图,并将其路由到适当的服务进行执行。该系统由两个主要组件组成:

  • **客户端:**处理用户输入,将其发送给 LLM,并根据 LLM 的决定将请求转发到适当的服务器。
  • **服务器:**根据 LLM 的 JSON 响应中指定的工具处理请求。它要么执行系统命令,要么使用 Brave Search API 获取 Web 数据。

LLM 会判断用户请求是需要执行命令还是网页搜索。如果提示不明确,LLM 会询问后续问题,然后生成结构化的**JSON 响应,**其中会指定工具名称( command_executionfetch_web_data )及其所需参数。

流程图

在职的

  1. **用户输入:**用户在 CLI 中输入提示。
  2. **客户端处理:**客户端将提示转发给 LLM。
  3. 法学硕士决定:
    • 如果意图不明确,LLM 会询问后续问题。
    • 它生成一个指定工具名称和所需参数的 JSON 响应。
  4. 客户端路由:
    • 如果工具是command_execution
      • 请求被发送到命令服务器
      • 命令服务器使用 Python 的subprocess模块执行命令。
      • 返回成功或失败的响应。
    • 如果该工具是fetch_web_data
      • 该请求被发送到Fetch Web Data Server
      • 服务器查询Brave Search API以获取相关结果。
      • 搜索结果返回给客户端。
  5. **客户端响应:**客户端通过 CLI 将最终响应发送回用户。

先决条件

安装

1. 克隆存储库

git clone -https://github.com/mjunaid46/mcp cd mcp

2.创建虚拟环境并激活

# Create a virtual environment uv venv # Activate virtual environment # On Unix or MacOS: source .venv/bin/activate # On Windows: .venv\Scripts\activate

3.安装依赖项

pip install -r requirements.txt python -m ensurepip

4.配置LLM模型

使用 Ollama 模型
  1. 按照Ollama 安装指南中的说明安装 Ollama CLI 工具。
  2. 然后,检查 Ollama:
    ollama list
  3. 在客户端命令中指定模型(llama3或llama2):
    uv run client/client.py server/command_server.py server/web_server.py ollama llama3
使用 Groq 模型
  1. 创建一个.env文件来存储 Groq 的 API Key:
    touch .env
  2. 将您的 Groq 的 API 密钥添加到.env文件:
    GROQ_API_KEY=<your_groq_api_key_here>

5.配置 Brave Search API

将您的 Brave 的 API 密钥添加到.env文件:

BRAVE_SEARCH_API_KEY=<your_brave_search_api_key_here>

跑步

  • 使用 Ollama 模型
uv run client/client.py server/command_server.py server/web_server.py ollama llama3
  • 使用 Groq 模型
uv run client/client.py server/command_server.py server/web_server.py groq

测试

向客户端发出查询(例如, touch test.txtcreate text file with testrm test.txt file等)

# Try the below prompts one by one to test. What is the capital of Pakistan. What is MCP? Create a file in my present working directory

🚀 Docker 项目设置指南

📌 运行代码的步骤

1️⃣ 克隆 Git 存储库

git clone https://github.com/mjunaid46/mcp/ cd mcp

2️⃣ 编辑模型选择配置

修改config.ini文件,指定模型类型和名称:

[settings] model_type = ollama # Change to "groq" if using Groq model_name = llama3 # Update model name if needed

3️⃣ 构建 Docker 容器

docker-compose build

4️⃣ 运行模型客户端

docker-compose run pull-model-client
-
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.

通过大型语言模型 (LLM) 解释用户意图,有助于执行系统命令并使用 Brave Search API 检索网络数据。

  1. 概述
    1. 流程图
      1. 在职的
        1. 先决条件
          1. 安装
            1. 克隆存储库
            2. 2.创建虚拟环境并激活
            3. 3.安装依赖项
            4. 4.配置LLM模型
            5. 5.配置 Brave Search API
          2. 跑步
            1. 测试
              1. 🚀 Docker 项目设置指南
                1. 📌 运行代码的步骤

              Related MCP Servers

              • A
                security
                A
                license
                A
                quality
                Facilitates integration of Brave Search functionalities with AI assistants through the Model Context Protocol, enabling web and local searches using the Brave Search API.
                Last updated -
                2
                4
                Python
                MIT License
              • -
                security
                F
                license
                -
                quality
                Enables LLMs to perform sophisticated web searches through proxy servers using Tavily's API, supporting comprehensive web searches, direct question answering, and recent news article retrieval with AI-extracted content.
                Last updated -
                1
                Python
              • A
                security
                A
                license
                A
                quality
                Enables extracting data from websites using natural language prompts, allowing users to specify exactly what content they want in plain English and returning structured JSON data.
                Last updated -
                1
                1,379
                4
                TypeScript
                MIT License
                • Apple
                • Linux
              • -
                security
                A
                license
                -
                quality
                Provides AI-powered web search capabilities using Tavily's search API, enabling LLMs to perform sophisticated web searches, get direct answers to questions, and search recent news articles.
                Last updated -
                53
                Python
                MIT License
                • Linux
                • 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/mjunaid46/mcp'

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