Skip to content

About

Graduation Project "Design and Implementation of an Integrated AI Agent and MCP Server System"

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Agent System

A fully local, privacy-first AI assistant with voice, vision, and deep system control

Version Python React FastAPI Electron License


πŸ“Œ Overview

Agent System is an integrated, fully local AI agent platform that combines a Python-based MCP (Model Context Protocol) server with a modern React + Electron frontend. It gives you a powerful conversational AI that can see, hear, speak, and control your entire computer β€” all without sending a single byte to the cloud.

The system is built around Ollama for local LLM inference and is designed to be extended with custom tools, routines, and voice providers.


✨ Key Features

🧠 AI & Reasoning

  • Local LLM inference via Ollama β€” runs entirely on your machine
  • Streaming responses with Server-Sent Events (SSE) for a fluid, real-time experience
  • Deep Thinking (deep_think) β€” triggers extended chain-of-thought reasoning for complex tasks
  • Deep Search β€” web-aware research tool powered by DuckDuckGo

πŸŽ™οΈ Full Voice Pipeline

  • Real-time Speech-to-Text using OpenAI Whisper (streaming tiny.en + final small.en pass)
  • Voice Activity Detection (VAD) via Silero for precise speech boundary detection
  • Neural Text-to-Speech via Piper TTS with multiple voice models
  • Bidirectional WebSocket voice stream (/ws/voice) β€” send audio, receive speech back
  • On-demand model warmup to eliminate cold-start latency

πŸ–₯️ System Control & Automation

Tool Capability
system_commands_windows Run shell commands, scripts, and terminal operations
open_program / close_program Launch and terminate any application
computer_control GUI automation via UI Automation (click, type, navigate)
filesystem Read, write, and manage files within a safe sandbox directory

πŸ“‹ Productivity Tools

Tool Capability
manage_planner Create, update, and query a persistent daily task planner
create_new_routine / execute_routine Define and trigger named automation routines
send_email_gmail Compose and send emails with file attachments via Gmail SMTP
get_current_weather Fetch live weather data for any location
calculate Safe expression evaluator for mathematical computations

πŸ“„ Document & Vision Understanding

  • File Upload & OCR β€” supports PDF, DOCX, TXT, MD, PNG, JPG, WebP
  • Tesseract OCR for extracting text from images
  • pypdf for multi-page PDF text extraction

πŸ” Permission & Safety System

  • Per-tool permission gates β€” sensitive tools prompt the user before executing
  • "Always Allow" toggles per tool β€” grant trust once, never be asked again
  • Timed Full Access mode β€” grant blanket access for a configurable duration
  • Safe write directory sandbox β€” all file writes are contained in a safe folder

🎨 Modern Frontend (React + Vite + Electron)

  • Dark / Light mode toggle
  • Online / Offline API status indicator
  • Streaming chat UI with Markdown rendering and syntax highlighting
  • Voice chat interface with real-time transcription display
  • File attachment support in chat
  • Model selector β€” switch LLMs on the fly
  • Voice model selector β€” choose your TTS voice
  • Daily planner panel β€” view and manage tasks from the sidebar
  • Packagable as a desktop app via Electron

πŸ—οΈ Architecture

Agent-System/
β”œβ”€β”€ MCP_server/                  # Python backend
β”‚   β”œβ”€β”€ server.py                # Entry point: starts Ollama, API, and frontend
β”‚   β”œβ”€β”€ web_api.py               # FastAPI REST + WebSocket endpoints
β”‚   β”œβ”€β”€ config.py                # All configurable constants & model settings
β”‚   β”œβ”€β”€ tts_piper.py             # Piper TTS integration
β”‚   β”œβ”€β”€ ai_chat/                 # Core LLM chat engine (Ollama client)
β”‚   β”œβ”€β”€ voice/                   # Voice pipeline
β”‚   β”‚   β”œβ”€β”€ voice_manager.py     # WebSocket orchestrator
β”‚   β”‚   β”œβ”€β”€ speech_engine.py     # Whisper STT + confidence scoring
β”‚   β”‚   β”œβ”€β”€ vad.py               # Silero Voice Activity Detection
β”‚   β”‚   β”œβ”€β”€ providers/           # Local & cloud voice providers
β”‚   β”‚   └── models/              # Cached model weights
β”‚   └── tools/                   # Pluggable tool modules
β”‚       β”œβ”€β”€ calculator.py
β”‚       β”œβ”€β”€ deep_search.py
β”‚       β”œβ”€β”€ email.py
β”‚       β”œβ”€β”€ filesystem.py
β”‚       β”œβ”€β”€ planner.py
β”‚       β”œβ”€β”€ routines.py
β”‚       β”œβ”€β”€ system_commands.py
β”‚       β”œβ”€β”€ system_action_commands.py
β”‚       β”œβ”€β”€ thinker.py
β”‚       β”œβ”€β”€ ui_control.py
β”‚       └── weather.py
β”‚
β”œβ”€β”€ AI_Chatbot/                  # React + Vite + Electron frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ App.jsx
β”‚   β”‚   β”œβ”€β”€ components/          # UI components
β”‚   β”‚   β”œβ”€β”€ hooks/               # Custom React hooks (useVoiceChat, etc.)
β”‚   β”‚   β”œβ”€β”€ pages/               # Route-level pages
β”‚   β”‚   β”œβ”€β”€ api/                 # API client helpers
β”‚   β”‚   └── utils/               # Shared utilities
β”‚   β”œβ”€β”€ electron/                # Electron shell for desktop packaging
β”‚   └── package.json
β”‚
└── build.ps1                    # One-click Windows build script

Communication Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        REST / SSE / WebSocket        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   React Frontend    β”‚ ◄──────────────────────────────────► β”‚  FastAPI Server (:8000)   β”‚
β”‚  (Vite :5173 / App) β”‚                                       β”‚     web_api.py            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                                           β”‚
                                                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                                              β”‚      ai_chat Engine       β”‚
                                                              β”‚  (Ollama LLM + Tools)    β”‚
                                                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                                           β”‚
                                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                          β”‚                         Tool Registry                          β”‚
                                          β”‚  calculate Β· weather Β· email Β· filesystem Β· system_commands   β”‚
                                          β”‚  planner Β· routines Β· deep_think Β· open/close_program         β”‚
                                          β”‚  computer_control Β· deep_search                               β”‚
                                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Getting Started

Prerequisites

Requirement Notes
Python 3.10+ Required for the backend
Node.js 18+ Required for the frontend
Ollama Download here β€” must be installed and on PATH
Tesseract OCR Download here β€” install to C:\Program Files\Tesseract-OCR\
FFmpeg (optional) For audio processing; can be installed via WinGet
GPU (recommended) CUDA-capable GPU greatly accelerates Whisper and Ollama inference

1. Clone the Repository

git clone https://github.com/amrokld/Agent-System.git
cd Agent-System

2. Pull Your Ollama Model

ollama pull gpt-oss:120b-cloud
# or any other compatible model

3. Install Python Dependencies

cd MCP_server
pip install -r requirements.txt

4. Install Frontend Dependencies

cd ../AI_Chatbot
npm install

5. Run the System

# From the MCP_server directory
python server.py

This single command will:

  1. πŸš€ Start the Ollama engine
  2. 🌐 Launch the FastAPI server on http://0.0.0.0:8000
  3. βš›οΈ Start the Vite dev server for the React frontend
  4. 🌍 Open the chat UI in your browser at http://localhost:5173

πŸ“¦ Building for Production (Desktop App)

Run the included PowerShell build script from the project root:

.\build.ps1

This will:

  1. Bundle the Python backend into a standalone server.exe via PyInstaller
  2. Build the React frontend with Vite
  3. Package everything into a Windows desktop installer via Electron Builder

The final installer is placed in AI_Chatbot/release/.


βš™οΈ Configuration

All backend settings are centralized in MCP_server/config.py:

Setting Default Description
OLLAMA_MODEL gpt-oss:120b-cloud The LLM model served by Ollama
OLLAMA_KEEP_ALIVE 10m How long to keep the model loaded in memory
WHISPER_MODEL_STREAMING tiny.en Fast Whisper model for real-time STT
WHISPER_MODEL_FINAL small.en Higher-accuracy model for final transcription
VOICE_MODEL en_US-ryan-medium Default Piper TTS voice
VAD_SILENCE_TIMEOUT_MS 4000 Silence threshold to end a voice turn (ms)
STT_CONFIDENCE_THRESHOLD_FINAL 0.75 Below this, words are marked as uncertain
SAFE_WRITE_DIR ./written_files Sandboxed directory for all file output
GMAIL_USER env var Gmail address for the email tool
GMAIL_APP_PASSWORD env var Gmail app password for the email tool

You can override most settings using environment variables.


πŸ”Œ API Reference

The backend exposes a RESTful API plus WebSocket endpoints:

Method Endpoint Description
POST /api/chat Synchronous chat (returns full reply)
POST /api/chat/stream Streaming chat via SSE
POST /api/voice Upload audio β†’ get transcript (deprecated)
WS /ws/voice Real-time bidirectional voice pipeline
POST /api/voice/warmup Pre-load STT models
POST /api/tts Text β†’ WAV audio file
POST /api/file Upload file + instruction β†’ AI response
GET /api/download/{filename} Download a generated file
GET /api/model Get current active model
POST /api/model Switch active model
GET /api/voices List installed TTS voices
POST /api/voices/set Set active TTS voice
GET /api/permissions/pending Check for a pending permission request
POST /api/permission Respond to a permission request
POST /api/permissions/grant-full-access Grant timed full access
GET /api/planner/tasks Get today's planner tasks
GET /api/routines List all saved routines
GET /api/health Health check

πŸ› οΈ Tech Stack

Backend

  • FastAPI β€” High-performance async REST framework
  • Uvicorn β€” ASGI server
  • Ollama β€” Local LLM inference engine
  • OpenAI Whisper β€” Speech recognition
  • Piper TTS β€” Neural text-to-speech
  • PyTorch β€” ML inference backend (Whisper + Silero VAD)
  • FastMCP β€” Model Context Protocol integration
  • PyInstaller β€” Python bundling for distribution

Frontend


πŸ“ Project Structure Highlights

MCP_server/tools/          ← Add new tools here
MCP_server/voice/          ← Voice pipeline (VAD, STT, TTS, WebSocket)
MCP_server/ai_chat/        ← Core chat engine & Ollama client
AI_Chatbot/src/components/ ← React UI components
AI_Chatbot/src/hooks/      ← Custom hooks (useVoiceChat, etc.)
AI_Chatbot/electron/       ← Desktop app entry point

🀝 Contributing

Contributions, issues, and feature requests are welcome!

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


πŸ‘₯ Authors

This project was designed and built by:

Name Role
Abdalla Dawoud Co-Developer & Architect
Amro Khaled Co-Developer & Architect

Made with ❀️ and a lot of β˜•

"The night is darkest just before the dawn."

About

Graduation Project "Design and Implementation of an Integrated AI Agent and MCP Server System"

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages