智能工作区系统

一个基于模型上下文协议(MCP)的智能工作区,集成了知识库服务器、本地文本处理服务器和命令行客户端,提供智能问答和文本分析功能。

  • by restinbark
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 restinbark/mcp_smart_workspace

使用说明

📌 1. 概述.

该项目演示了使用模型上下文协议(MCP)构建的最小但功能强大的智能工作区。

该项目被命名为smart_workspace,因为它代表了一个智能的、由MCP驱动的工作空间,该工作空间集成了多个服务器(知识库和本地实用程序),并通过统一的MCP客户端提供智能助手界面。它的行为就像一个小型的人工智能驱动的个人工作空间环境。

它包括:

  A Knowledge Base Server

  A Local Utility/Text Processing Server

  A Stdio-based MCP client

  A simple question–answer engine

  JSON-based storage

  command line interface (CLI) interface to interact with the system

📁 2.项目结构

       mcp_smart_workspace/
    │
    ├── client/
    │   └── workspace_client.py     # MCP client demo
            │
    ├── servers/
    │   ├── local_text_server/      # text utility server
    │   │   └── server.py
    │   │
        │   └── knowledge_base_server/  # Q/A knowledge base server
    │       ├── server.py
    │       ├── data.json           # knowledge base
    │       └── build_embedding.py  # (experimental, unused)
    │
    └── README.md

⚙️ 3.已实现的功能

  1. 本地实用程序MCP服务器(STDIO)

    Purpose: Runs simple text-processing tools.
    Tech: Python MCP SDK .
    Transport: STDIN/STDOUT (stdio).
    
    Features:
    
    Word & character count
    
    Sentence estimate
    
    Reading-time estimate
    
    Simple sentiment check
    
    Runs locally as a subprocess started by the client.
    
  2. 知识库服务器(HTTP API)

    Purpose: Stores and returns information from a JSON knowledge base.
    Tech: FastAPI + Uvicorn
    Transport: HTTP
    
    Features:
    
    Search the KB
    
    Get item by ID
    
    Add new entries
    
    Update entries
    

    使用干净的REST端点加载和修改data.json。

✅ 3.JSON知识库

  Example entries:

 {
    "id": 1,
    "title": "What is MCP?",
    "content": "MCP is the Model Context Protocol..."
 }

我还添加了我的自定义条目,包括:

  Barkilign profile

  iCog Labs facts

  Internship facts

  Custom Q/A entries

✅ 4.工作MCP客户端(CLI)

  Client can:

  Connect to servers

  Perform analysis

  Query the Knowledge Base

  Display results cleanly

 Loop input until user types exit

输出示例:

  Workspace Client starting...

   Analyzing: Hello I am an mcp_smart_workspace develpoed by Barkilign!
   {
      "summary": {"words": 8, "chars": 53, "sentences": 0, "reading_time_min": 0.04},
      "sentiment": {"label": "neutral", "pos_score": 0, "neg_score": 0}
   }

✅ 5.多服务器架构

   The client successfully:

   Starts local STDIO server

   Connects to KB server

   Combines outputs

   Demonstrates MCP interoperability

🧪 4.如何运行系统

1.️⃣ 激活虚拟环境 .\venv\Scripts\activate

2.️⃣ 运行知识库服务器 cd服务器/知识库服务器 uvicorn服务器:应用程序--重新加载--端口8001

3.️⃣ 运行MCP客户端 cd客户端 python workspace_client.py

📚 5.端到端有效的方法

     Client starts correctly

    Text analysis works

    Knowledge Base can be searched

    Exact Q/A retrieval works

    JSON KB entries load successfully

    Adding new KB entries works

    Client ↔ Server communication stable

✨ 6.尝试了什么(但今天不需要)

由于时间限制,这些已开始但未包括在内:

 OpenAI semantic embeddings

 Fuzzy semantic ranking

 LLM answer generation

 Vector search

 Full OpenAI integration
  1. 作者

Barkilign 开始 人工智能研究实习生–iCog 任务2