Skip to content

Commit 19ba856

Browse files
Rewrite part1 (#7)
* move files * working refactor * Reqrite part2 (#6) * working ui * working sessio nswitching and a bunch of other stuff * fix ci
1 parent 301a31a commit 19ba856

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+12068
-8223
lines changed

.github/copilot-instructions.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
You are "Synapse", an AI Senior Tech Lead specialized in guiding the development of AI agents. Your role is to help users (developers) write robust, efficient, and maintainable code for AI agent systems.
2-
31
**Core Focus:**
42

53
* **Agent Architecture:** Advise on agent design patterns (e.g., ReAct, Plan-and-Execute), state management, and modularity.
@@ -15,5 +13,3 @@ You are "Synapse", an AI Senior Tech Lead specialized in guiding the development
1513
* Explain the reasoning behind your recommendations, focusing on AI agent best practices.
1614
* Ask clarifying questions to understand context.
1715
* Be pragmatic, balancing ideal solutions with practical constraints.
18-
19-
**Your Goal:** Mentor the developer to build high-quality, effective AI agents.

.github/workflows/build-test.yaml

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# .github/workflows/build-test.yml
22
name: Build and Test
33

4-
on:
4+
on: # yamllint disable-line rule:truthy
55
push:
66
branches: [ main ]
77
pull_request:
@@ -15,45 +15,32 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v4 # Checks out your repository code
1717

18-
- name: Set up Python
19-
uses: actions/setup-python@v5
18+
- name: Set up Node.js
19+
uses: actions/setup-node@v4
2020
with:
21-
# Use the Python version specified in pyproject.toml
22-
# Make sure this matches your requires-python range
23-
python-version: '3.12'
24-
25-
- name: Install Poetry
26-
uses: snok/install-poetry@v1
27-
with:
28-
virtualenvs-create: true # Recommended to keep envs isolated
29-
virtualenvs-in-project: true # Optional: Keep venv in project dir for caching
30-
installer-parallel: true
31-
32-
# Optional: Cache Poetry virtualenv
33-
- name: Load cached venv
34-
id: cached-poetry-dependencies
21+
# Specify the Node.js version you want to use
22+
# e.g., '18.x', '20.x', 'lts/*'
23+
node-version: '20.x'
24+
# Optional: Cache npm dependencies globally
25+
cache: 'npm'
26+
27+
# Cache node_modules based on package-lock.json
28+
- name: Load cached node_modules
29+
id: cache-node-modules
3530
uses: actions/cache@v4
3631
with:
37-
path: .venv
38-
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
32+
path: node_modules
33+
# Use package-lock.json (or yarn.lock/pnpm-lock.yaml) for the cache key
34+
key: node-modules-${{ runner.os }}-${{ steps.setup-node.outputs.node-version }}-${{ hashFiles('**/package-lock.json') }}
35+
restore-keys: |
36+
node-modules-${{ runner.os }}-${{ steps.setup-node.outputs.node-version }}-
3937
4038
- name: Install dependencies
41-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
42-
run: poetry install --no-interaction --no-root # Install dependencies only
43-
44-
# Install project and dependencies if cache missed or lock file changed
45-
- name: Install project and dependencies
46-
run: poetry install --no-interaction
47-
48-
- name: Lint with Ruff
49-
run: |
50-
poetry run ruff check .
51-
52-
- name: Check formatting with Ruff
53-
run: |
54-
poetry run ruff format --check .
55-
56-
# Add other steps like running tests using poetry run pytest (if you have tests)
57-
# - name: Run tests
58-
# run: |
59-
# poetry run pytest
39+
# Use npm ci for clean installs based on lock file, faster in CI
40+
# If cache missed, this installs everything
41+
# If cache hit, this verifies integrity and installs missing packages quickly
42+
run: npm ci
43+
44+
- name: Lint code
45+
# Assumes you have a lint script in your package.json (e.g., "lint": "eslint .")
46+
run: npm run lint

.gitignore

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,46 @@ memory.json
181181
.chat_history_cache/
182182

183183
# Flask Session files (if Flask-Session is kept)
184-
.flask_session_files/
184+
.flask_session_files/
185+
186+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
187+
188+
# dependencies
189+
/node_modules
190+
/.pnp
191+
.pnp.*
192+
.yarn/*
193+
!.yarn/patches
194+
!.yarn/plugins
195+
!.yarn/releases
196+
!.yarn/versions
197+
198+
# testing
199+
/coverage
200+
201+
# next.js
202+
/.next/
203+
/out/
204+
205+
# production
206+
/build
207+
208+
# misc
209+
.DS_Store
210+
*.pem
211+
212+
# debug
213+
npm-debug.log*
214+
yarn-debug.log*
215+
yarn-error.log*
216+
.pnpm-debug.log*
217+
218+
# env files (can opt-in for committing if needed)
219+
.env*
220+
221+
# vercel
222+
.vercel
223+
224+
# typescript
225+
*.tsbuildinfo
226+
next-env.d.ts

README.md

Lines changed: 23 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,36 @@
1-
# MCPBro - Gemini Chatbot with MCP Tools
1+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
22

3-
This project is a web-based chatbot powered by Google Gemini, utilizing the Model Context Protocol (MCP) to interact with external tools like filesystem access and memory.
3+
## Getting Started
44

5-
## Features
5+
First, run the development server:
66

7-
* **Web Interface:** Simple chat interface built with Flask and SocketIO.
8-
* **Gemini Integration:** Uses the Google Generative AI SDK for chat responses.
9-
* **MCP Tool Usage:** Connects to MCP servers (filesystem, memory) to provide tools to the Gemini model.
10-
* **Real-time Communication:** Uses Flask-SocketIO for instant message updates.
11-
* **Configuration:** Flexible configuration via `config.json` and environment variables.
12-
* **Dependency Management:** Uses Poetry for managing Python dependencies.
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
1316

14-
## Prerequisites
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
1518

16-
* Python >= 3.13
17-
* [Poetry](https://python-poetry.org/docs/#installation)
18-
* Node.js and npx (for running MCP servers like `@modelcontextprotocol/server-filesystem` and `@modelcontextprotocol/server-memory`)
19-
* A Google Gemini API Key
19+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
2020

21-
## Setup
21+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
2222

23-
1. **Clone the repository:**
24-
```bash
25-
git clone <your-repository-url>
26-
cd mcpbro
27-
```
23+
## Learn More
2824

29-
2. **Install dependencies:**
30-
```bash
31-
poetry install
32-
```
33-
This will install all necessary Python packages based on the `poetry.lock` file.
25+
To learn more about Next.js, take a look at the following resources:
3426

35-
3. **Configure the application:**
36-
* Copy the sample configuration file:
37-
```bash
38-
cp bot_config/config.json.sample bot_config/config.json
39-
```
40-
* Edit `bot_config/config.json`:
41-
* Set `gemini_api_key` to your Google Gemini API key (alternatively, set the `GEMINI_API_KEY` environment variable).
42-
* Add the absolute paths to the directories you want the filesystem tool to access under `filesystem_target_directories`.
43-
* Set `enable_memory_server` to `true` if you want to use the memory tool.
44-
* (Optional) Edit `bot_config/system_instruction.md` to customize the chatbot's behavior and personality.
27+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
4529

46-
## Running the Application
30+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
4731

48-
1. **Start the server:**
49-
You can use the Poe the Poet task defined in `pyproject.toml`:
50-
```bash
51-
poetry run poe start
52-
```
53-
Alternatively, run directly:
54-
```bash
55-
poetry run python run.py
56-
```
32+
## Deploy on Vercel
5733

58-
2. **Access the application:**
59-
Open your web browser and navigate to `http://127.0.0.1:5000` (or the host/port specified in the console output).
34+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
6035

61-
## Usage
62-
63-
* Type your messages into the input box and press Enter or click Send.
64-
* The chatbot will respond, potentially using the configured MCP tools.
65-
* Internal steps (like tool usage) will be displayed in the chat interface.
66-
* Use the `/reset` endpoint (e.g., `http://127.0.0.1:5000/reset`) to clear the chat history.
67-
* Use the `/debug` endpoint to view server-side debug logs.
68-
69-
## Key Dependencies
70-
71-
* Flask
72-
* Flask-SocketIO
73-
* Flask-Session
74-
* gevent
75-
* google-generativeai
76-
* mcp
77-
78-
See `pyproject.toml` for the full list of dependencies.
36+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

bot_config/config.json.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"enable_memory_server": false,
99
"enable_chroma_server": true,
1010
"chroma_path": "./chroma_db",
11+
"summarization_threshold_tokens": 16000,
1112
"chroma_collection_name": "chat_history",
1213
"default_gemini_model": "gemini-1.5-flash",
1314
"generation_gemini_model": "gemini-1.5-flash",
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"gemini_history_internal": "[{\"role\":\"user\",\"parts\":[{\"text\":\"hullo, how are you\"}]},{\"parts\":[{\"text\":\"Hello! I am functioning as expected and ready to assist you. How can I help you today?\"}],\"role\":\"model\"},{\"role\":\"user\",\"parts\":[{\"text\":\"hi\"}]},{\"parts\":[{\"text\":\"Hi there! How can I help you today?\"}],\"role\":\"model\"}]",
3+
"chat_history_display": [
4+
{
5+
"type": "user",
6+
"text": "hullo, how are you"
7+
},
8+
{
9+
"type": "model",
10+
"text": "Hello! I am functioning as expected and ready to assist you. How can I help you today?"
11+
},
12+
{
13+
"type": "user",
14+
"text": "hi"
15+
},
16+
{
17+
"type": "model",
18+
"text": "Hi there! How can I help you today?"
19+
}
20+
]
21+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"gemini_history_internal": "[{\"role\":\"user\",\"parts\":[{\"text\":\"test\"}]},{\"parts\":[{\"text\":\"Test acknowledged. I'm here and ready to help. How can I assist you today?\"}],\"role\":\"model\"}]",
3+
"chat_history_display": [
4+
{
5+
"type": "internal",
6+
"text": "Chat history reset."
7+
},
8+
{
9+
"type": "user",
10+
"text": "test"
11+
},
12+
{
13+
"type": "model",
14+
"text": "Test acknowledged. I'm here and ready to help. How can I assist you today?"
15+
}
16+
]
17+
}

src/chroma_db/63357852-c71d-4219-94e8-f649c98d976f/data_level0.bin renamed to chroma_db/63357852-c71d-4219-94e8-f649c98d976f/data_level0.bin

File renamed without changes.

src/chroma_db/63357852-c71d-4219-94e8-f649c98d976f/header.bin renamed to chroma_db/63357852-c71d-4219-94e8-f649c98d976f/header.bin

File renamed without changes.

src/chroma_db/63357852-c71d-4219-94e8-f649c98d976f/length.bin renamed to chroma_db/63357852-c71d-4219-94e8-f649c98d976f/length.bin

File renamed without changes.

0 commit comments

Comments
 (0)