nothingworry commited on
Commit
78b6d7b
Β·
1 Parent(s): f09fda0

all the thing

Browse files
FILE_STRUCTURE.md CHANGED
@@ -29,18 +29,12 @@ IntegraChat/
29
  β”‚ β”‚ β”‚ └── tool_selector.py # Multi-tool selection logic
30
  β”‚ β”‚ └── utils/
31
  β”‚ β”‚ └── text_extractor.py # Text extraction utilities
32
- β”‚ β”œβ”€β”€ mcp_servers/
33
- β”‚ β”‚ β”œβ”€β”€ admin_server.py # Admin MCP server
34
- β”‚ β”‚ β”œβ”€β”€ database.py # Database connection utilities
35
- β”‚ β”‚ β”œβ”€β”€ embeddings.py # Embedding generation
36
- β”‚ β”‚ β”œβ”€β”€ main.py # RAG MCP server main
37
- β”‚ β”‚ β”œβ”€β”€ rag_server.py # RAG MCP server
38
- β”‚ β”‚ β”œβ”€β”€ web_server.py # Web search MCP server (English results)
39
- β”‚ β”‚ └── models/
40
- β”‚ β”‚ β”œβ”€β”€ __init__.py
41
- β”‚ β”‚ β”œβ”€β”€ admin.py # Admin request models
42
- β”‚ β”‚ β”œβ”€β”€ rag.py # RAG request models
43
- β”‚ β”‚ └── web.py # Web search request models
44
  β”‚ β”œβ”€β”€ tests/
45
  β”‚ β”‚ β”œβ”€β”€ conftest.py # Pytest configuration
46
  β”‚ β”‚ β”œβ”€β”€ test_agent_orchestrator.py # Orchestrator tests
@@ -64,9 +58,10 @@ IntegraChat/
64
  - **`redflag_detector.py`** - Detects policy violations
65
 
66
  ### MCP Servers
67
- - **`rag_server.py`** - RAG/knowledge retrieval server
68
- - **`web_server.py`** - Web search server (forces English results)
69
- - **`admin_server.py`** - Admin/governance server
 
70
 
71
  ### API Routes
72
  - **`agent.py`** - Main chat/agent endpoint
 
29
  β”‚ β”‚ β”‚ └── tool_selector.py # Multi-tool selection logic
30
  β”‚ β”‚ └── utils/
31
  β”‚ β”‚ └── text_extractor.py # Text extraction utilities
32
+ β”‚ β”œβ”€β”€ mcp_server/
33
+ β”‚ β”‚ β”œβ”€β”€ server.py # Unified MCP entrypoint (rag/web/admin)
34
+ β”‚ β”‚ β”œβ”€β”€ rag/ # RAG tool handlers (search/ingest/delete)
35
+ β”‚ β”‚ β”œβ”€β”€ web/ # Web search tool handler
36
+ β”‚ β”‚ β”œβ”€β”€ admin/ # Admin rules + violations tools
37
+ β”‚ β”‚ └── common/ # Shared tenant/logging/utils helpers
 
 
 
 
 
 
38
  β”‚ β”œβ”€β”€ tests/
39
  β”‚ β”‚ β”œβ”€β”€ conftest.py # Pytest configuration
40
  β”‚ β”‚ β”œβ”€β”€ test_agent_orchestrator.py # Orchestrator tests
 
58
  - **`redflag_detector.py`** - Detects policy violations
59
 
60
  ### MCP Servers
61
+ - **`backend/mcp_server/server.py`** - Unified MCP entrypoint (rag/web/admin tools)
62
+ - **`backend/mcp_server/rag/*.py`** - RAG tool handlers (search/ingest/delete)
63
+ - **`backend/mcp_server/web/search.py`** - DuckDuckGo handler
64
+ - **`backend/mcp_server/admin/*.py`** - Admin rules & violations tools
65
 
66
  ### API Routes
67
  - **`agent.py`** - Main chat/agent endpoint
TESTING_GUIDE.md CHANGED
@@ -264,17 +264,8 @@ python test_api_manual.py
264
  cd backend/api
265
  uvicorn main:app --port 8000 --reload
266
 
267
- # Terminal 2: Start RAG MCP server
268
- cd backend/mcp_servers
269
- python main.py # or uvicorn main:app --port 8001
270
-
271
- # Terminal 3: Start Web MCP server
272
- cd backend/mcp_servers
273
- python web_server.py # or uvicorn web_server:app --port 8002
274
-
275
- # Terminal 4: Start Admin MCP server
276
- cd backend/mcp_servers
277
- python admin_server.py # or uvicorn admin_server:app --port 8003
278
 
279
  # Optional: Start Ollama for LLM
280
  ollama serve
 
264
  cd backend/api
265
  uvicorn main:app --port 8000 --reload
266
 
267
+ # Terminal 2: Start unified MCP server (rag/web/admin tools)
268
+ python backend/mcp_server/server.py
 
 
 
 
 
 
 
 
 
269
 
270
  # Optional: Start Ollama for LLM
271
  ollama serve
check_rag_database.py CHANGED
@@ -18,7 +18,7 @@ def check_database():
18
  print("="*60)
19
 
20
  try:
21
- from mcp_servers.database import get_connection
22
  import psycopg2.extras
23
 
24
  conn = get_connection()
@@ -65,8 +65,8 @@ def check_database():
65
 
66
  # Test search_vectors function directly
67
  print("\n4. Testing search_vectors function directly...")
68
- from mcp_servers.embeddings import embed_text
69
- from mcp_servers.database import search_vectors
70
 
71
  # Search for tenant1's secret as tenant1
72
  query = "TENANT1_SECRET"
 
18
  print("="*60)
19
 
20
  try:
21
+ from mcp_server.common.database import get_connection
22
  import psycopg2.extras
23
 
24
  conn = get_connection()
 
65
 
66
  # Test search_vectors function directly
67
  print("\n4. Testing search_vectors function directly...")
68
+ from mcp_server.common.embeddings import embed_text
69
+ from mcp_server.common.database import search_vectors
70
 
71
  # Search for tenant1's secret as tenant1
72
  query = "TENANT1_SECRET"
env.example CHANGED
@@ -21,12 +21,16 @@ OLLAMA_MODEL=llama3.1:latest
21
  LLM_BACKEND=ollama
22
 
23
  # =============================================================
24
- # MCP SERVER URLs
25
  # =============================================================
 
26
  RAG_MCP_URL=http://localhost:8001
27
  WEB_MCP_URL=http://localhost:8002
28
  ADMIN_MCP_URL=http://localhost:8003
29
 
 
 
 
30
  # =============================================================
31
  # BACKEND CONFIG
32
  # =============================================================
 
21
  LLM_BACKEND=ollama
22
 
23
  # =============================================================
24
+ # MCP SERVER CONFIG
25
  # =============================================================
26
+ # Legacy FastAPI endpoints (remove once all callers use the unified MCP server)
27
  RAG_MCP_URL=http://localhost:8001
28
  WEB_MCP_URL=http://localhost:8002
29
  ADMIN_MCP_URL=http://localhost:8003
30
 
31
+ # Unified MCP server identifier (namespaced tools)
32
+ MCP_SERVER_ID=integrachat
33
+
34
  # =============================================================
35
  # BACKEND CONFIG
36
  # =============================================================
start.bat CHANGED
@@ -87,13 +87,31 @@ if not exist "%VENV_PYTHON%" (
87
  exit /b 1
88
  )
89
 
90
- REM Launch MCP servers in separate windows
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  echo.
92
- echo Launching MCP servers in separate windows...
93
- start "RAG MCP (8001)" "%VENV_PYTHON%" -m uvicorn backend.mcp_servers.main:app --host 0.0.0.0 --port 8001
94
- start "WEB MCP (8002)" "%VENV_PYTHON%" -m uvicorn backend.mcp_servers.web_server:web_app --host 0.0.0.0 --port 8002
95
- start "ADMIN MCP (8003)" "%VENV_PYTHON%" -m uvicorn backend.mcp_servers.admin_server:admin_app --host 0.0.0.0 --port 8003
96
- echo MCP servers started. Close their windows or press Ctrl+C inside them to stop.
97
  echo.
98
 
99
  REM Start the FastAPI server
 
87
  exit /b 1
88
  )
89
 
90
+ REM Launch unified MCP server (in its own window so you can see logs)
91
+ if not exist "backend\mcp_server\server.py" (
92
+ echo ERROR: backend\mcp_server\server.py not found!
93
+ pause
94
+ exit /b 1
95
+ )
96
+
97
+ REM Configure default MCP endpoints if not provided
98
+ if "%MCP_PORT%"=="" (
99
+ set "MCP_PORT=8900"
100
+ )
101
+ if "%RAG_MCP_URL%"=="" (
102
+ set "RAG_MCP_URL=http://localhost:%MCP_PORT%/rag"
103
+ )
104
+ if "%WEB_MCP_URL%"=="" (
105
+ set "WEB_MCP_URL=http://localhost:%MCP_PORT%/web"
106
+ )
107
+ if "%ADMIN_MCP_URL%"=="" (
108
+ set "ADMIN_MCP_URL=http://localhost:%MCP_PORT%/admin"
109
+ )
110
  echo.
111
+ echo Launching unified MCP server (rag/web/admin)...
112
+ start "Unified MCP" cmd /k ""%VENV_PYTHON%" -m backend.mcp_server.server"
113
+ timeout /t 2 >nul
114
+ echo Unified MCP server window opened (titled 'Unified MCP'). Close it manually to stop the MCP server.
 
115
  echo.
116
 
117
  REM Start the FastAPI server
verify_tenant_isolation.py CHANGED
@@ -319,7 +319,7 @@ def verify_rag_isolation():
319
  except requests.exceptions.ConnectionError:
320
  print("\n⚠️ Cannot connect to API/RAG server. Make sure they're running:")
321
  print(" uvicorn backend.api.main:app --port 8000")
322
- print(" python -m backend.mcp_servers.rag_server")
323
  return None
324
  except Exception as e:
325
  print(f"\n❌ Error: {e}")
@@ -435,7 +435,7 @@ def main():
435
  if total == 0:
436
  print("\n⚠️ No tests could run. Make sure services are running:")
437
  print(" - API: uvicorn backend.api.main:app --port 8000")
438
- print(" - RAG Server: python -m backend.mcp_servers.rag_server")
439
  elif failed == 0 and passed > 0:
440
  print("\nβœ… All tenant isolation tests PASSED!")
441
  elif failed > 0:
 
319
  except requests.exceptions.ConnectionError:
320
  print("\n⚠️ Cannot connect to API/RAG server. Make sure they're running:")
321
  print(" uvicorn backend.api.main:app --port 8000")
322
+ print(" python backend/mcp_server/server.py")
323
  return None
324
  except Exception as e:
325
  print(f"\n❌ Error: {e}")
 
435
  if total == 0:
436
  print("\n⚠️ No tests could run. Make sure services are running:")
437
  print(" - API: uvicorn backend.api.main:app --port 8000")
438
+ print(" - MCP Server: python backend/mcp_server/server.py")
439
  elif failed == 0 and passed > 0:
440
  print("\nβœ… All tenant isolation tests PASSED!")
441
  elif failed > 0: