计算机桌面txt文件助手

yangweijie111/compputer_txt_mcp_helper
1 Stars 67 次浏览 一只小绵羊 更新于 2026-08-23

该项目展示了如何使用 MCP (模型上下文协议) 来创建和使用各种智能助手和工具。项目包含了多个示例,展示了不同场景下的 MCP 应用。

该服务暂未提供标准配置,请参考 README 手动接入

服务介绍

MCP (Model Context Protocol) Example Project

This project demonstrates how to use MCP (Model Context Protocol) to create and utilize various intelligent assistants and tools. The project includes multiple examples showcasing the application of MCP in different scenarios.

Project Structure

day11_MCP_A2A/
├── CASE-A2A/ # Agent to Agent example case
├── MCP-demo01/ # Basic MCP example
└── MCP-demo02/ # Advanced MCP example

Main Functional Modules

1. CASE-A2A

Agent to Agent (A2A) communication example, demonstrating how different agents can collaborate through a standard protocol.

Component Description

  • BasketBallAgent.py: Basketball activity scheduling agent

    • Communicates with WeatherAgent via A2A protocol
    • Makes intelligent decisions on whether to schedule basketball activities based on weather conditions
    • Supports custom date activity scheduling
    • Includes a complete error handling mechanism
  • WeatherAgent.py: Weather service agent

    • Implemented as a RESTful service using FastAPI
    • Provides standard A2A protocol interfaces
    • Supports Agent Card declaration (/.well-known/agent.json)
    • Simulates weather data storage and query functions

A2A Protocol Implementation

  1. Agent Card Specification
    json
    {
    "name": "WeatherAgent",
    "version": "1.0",
    "description": "Provides weather data queries for specified dates",
    "endpoints": {
    "task_submit": "/api/tasks/weather",
    "sse_subscribe": "/api/tasks/updates"
    },
    "input_schema": {
    "type": "object",
    "properties": {
    "date": {"type": "string", "format": "date"},
    "location": {"type": "string", "enum": ["Beijing"]}
    },
    "required": ["date"]
    }
    }

  2. Communication Process

    • BasketBallAgent retrieves the capability description of WeatherAgent
    • Constructs a task request that conforms to the specification
    • Sends the request and processes the response
    • Makes decisions based on the weather data

Running Instructions

  1. Start the WeatherAgent service:
    bash
    cd CASE-A2A
    python WeatherAgent.py

  2. Run the BasketBallAgent example:
    bash
    python BasketBallAgent.py

Dependency Requirements

bash
pip install fastapi uvicorn requests pydantic

Example Output

python

Sunny day example

Basketball scheduling result: {'status': 'confirmed', 'weather': {'temperature': '22℃', 'condition': 'Partly cloudy turning sunny'}}

Rainy day example

Basketball scheduling result: {'status': 'cancelled', 'reason': 'Bad weather'}

2. MCP-demo01

Basic MCP functionality example, demonstrating how to use MCP to create various tools and services.

  • assistant_mcp_amap_bot.py: Intelligent assistant integrated with Amap API

    • Supports geocoding and reverse geocoding
    • Provides route planning functionality
    • Supports nearby search and weather queries
  • assistant_mcp_txt_bot.py: Text processing intelligent assistant

    • Text statistics and analysis
    • Document parsing functionality
  • txt_counter.py: Desktop TXT file management tool

    • Counts the number of .txt files on the desktop
    • Lists all .txt files on the desktop
    • Reads the content of a specified txt file
    • Supports UTF-8 encoded text files
  • dalian_tour.html: Dalian travel itinerary planning webpage

    • Complete one-day tour itinerary
    • Printable in a friendly A4 format
    • Includes detailed information such as transportation and dining

3. MCP-demo02

Advanced MCP functionality example, demonstrating the combined application scenarios of multiple MCP servers.

  • assistant_bot.py: Multi-functional intelligent assistant
    • Integrates three MCP servers:
      1. Amap map service (amap-maps): Provides geographical location and route planning
      2. Web content fetching service (fetch): Supports web content extraction and conversion
      3. Bing search service (bing-cn-mcp-server): Provides search functionality
    • Supports three interaction modes:
      • GUI mode: Web interface with preset query suggestions
      • TUI mode: Terminal interaction supporting continuous dialogue
      • Test mode: Single query testing
    • Advanced features:
      • Web content extraction and conversion (HTML to Markdown)
      • Intelligent search and information aggregation
      • Multi-modal input support
      • Context-aware conversation management

Running example:
bash
cd MCP-demo02

Configure necessary environment variables

export DASHSCOPE_API_KEY='your-api-key'

Run (default is GUI mode)

python assistant_bot.py

Example queries:

  1. Web content extraction:

    Convert the https://example.com webpage into Markdown format2. Location Query:

    Find me a cafe near West Lake

  2. Comprehensive Search:

    Search for AI technology news from the past week

Note: Before using, make sure all necessary MCP servers are installed:
bash
npm install -g @amap/amap-maps-mcp-server
npm install -g @bing/bing-cn-mcp-server
npm install -g @fetch/fetch-mcp-server

Tool Integration

The project integrates multiple practical tools:

  • doc_parser: Document parsing tool
  • simple_doc_parser: Simple document parser

Environment Requirements

  • Python 3.7+
  • Node.js and npm (for MCP servers)
  • Related Python packages:
    • dashscope==1.22.1
    • mcp==1.7.1
    • qwen_agent==0.0.19

Configuration Instructions

1. API Keys Configuration

  1. DashScope API Key (Required):

  2. AMap API Key (Required if using map features):

2. Install Dependencies

bash

Install Python dependencies

pip install -r MCP-demo01/requirements.txt

Install Node.js dependencies (if using map features)

npm install -g @amap/amap-maps-mcp-server

Running Instructions

1. AMap Assistant (assistant_mcp_amap_bot.py)

Environment Preparation

bash

1. Install necessary dependencies

pip install dashscope qwen-agent requests

2. Set environment variables

export DASHSCOPE_API_KEY='your-api-key'
export AMAP_API_KEY='your-amap-key'

3. Install AMap MCP server

npm install -g @amap/amap-maps-mcp-server

Running Modes

  1. GUI Mode (Default) - Web Interface
    bash
    python MCP-demo01/assistant_mcp_amap_bot.py

Access http://localhost:8080 to start using

  1. TUI Mode - Terminal Interaction
    python

Modify the end of the file to:

if name == 'main':
app_tui()

  1. Test Mode - Single Query
    python

Modify the end of the file to:

if name == 'main':
test()

Example Queries

  1. Location Query:

Where is the specific address of the Forbidden City in Beijing?

  1. Route Planning:

What's the fastest way from Beijing South Railway Station to Tiananmen Square?

  1. Nearby Search:

Find me highly rated restaurants near West Lake

  1. Travel Planning:

Help me plan a two-day trip to Hangzhou, mainly visiting West Lake and Lingyin Temple

2. Text Processing Assistant (assistant_mcp_txt_bot.py)

Environment Preparation

bash

1. Install dependencies

pip install dashscope qwen-agent

2. Start local text counting service

cd MCP-demo01
python txt_counter.py

Running Modes

  1. GUI Mode (Default)
    bash
    python MCP-demo01/assistant_mcp_txt_bot.py

Access http://localhost:8080 to start using

  1. TUI Mode
    python

Modify the end of the file to:

if name == 'main':
app_tui()

  1. Test Mode
    python

Modify the end of the file to:

if name == 'main':
test()

Example Queries

  1. Basic Text Statistics:

Count the number of characters and lines in this text:
Hello World!
你好,世界!
こんにちは、世界!

  1. Code Analysis:

Count the effective lines of this Python code (excluding blank lines and comments):
def hello():
# This is a comment
print("Hello World!")

return True
  1. Text Formatting:

Format this JSON for me:
{"name":"John","age":30,"city":"New York"}

  1. Multilingual Analysis:

Analyze the character count of each language in this multilingual text:
你好世界 Hello World こんにちは

Notes

  1. An effective API key must be configured before using AMap features.
  2. Some features may require an internet connection.
  3. Ensure all dependencies are correctly installed.

Contribution Guidelines

We welcome issues and improvement suggestions! Please ensure before submitting:

  1. The code style conforms to the project standards.
  2. Appropriate test cases are added.
  3. Relevant documentation is updated.

License

This project is licensed under the MIT License. See the LICENSE file for details.

相关 MCP 服务