Skip to content

Commit 2b124f7

Browse files
committed
feat (server-revamp): added gmaps mcp
1 parent 980e08a commit 2b124f7

File tree

17 files changed

+414
-40
lines changed

17 files changed

+414
-40
lines changed

src/client/.env.template

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# src/client/.env.template
21
# For env vars related to the Google project and Auth0 setup, comment in the discussion titled 'Request Environment Variables (.env) Here' (https://github.com/existence-master/Sentient/discussions/13) Make sure to keep the values in this file empty while committing to the repository
32

43
NEXT_PUBLIC_APP_SERVER_URL=

src/client/app/api/chat/message/route.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// src/client/app/api/chat/message/route.js
21
import { NextResponse } from "next/server"
32
import { auth0 } from "@lib/auth0"
43
import { getBackendAuthHeader } from "@lib/auth0"
@@ -13,8 +12,14 @@ export async function POST(request) {
1312
}
1413

1514
try {
16-
const { input, chatId, enable_internet, enable_weather, enable_news } =
17-
await request.json()
15+
const {
16+
input,
17+
chatId,
18+
enable_internet,
19+
enable_weather,
20+
enable_news,
21+
enable_maps
22+
} = await request.json()
1823
const authHeader = await getBackendAuthHeader()
1924

2025
// Fetch user pricing/credits to pass to the backend
@@ -41,7 +46,8 @@ export async function POST(request) {
4146
credits,
4247
enable_internet,
4348
enable_weather,
44-
enable_news
49+
enable_news,
50+
enable_maps
4551
}),
4652
// IMPORTANT: duplex must be set to 'half' to stream response body in Next.js Edge/Node runtime
4753
duplex: "half"

src/client/app/chat/[[...chatId]]/page.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// src/client/app/chat/[[...chatId]]/page.js
21
"use client"
32
import React, { useState, useEffect, useRef, useCallback, use } from "react"
43
import { useRouter } from "next/navigation"
@@ -23,7 +22,8 @@ import {
2322
IconFileText,
2423
IconPresentation,
2524
IconTable,
26-
IconMessageOff
25+
IconMessageOff,
26+
IconMap
2727
} from "@tabler/icons-react"
2828
import toast from "react-hot-toast"
2929
import GmailSearchResults from "@components/agents/GmailSearchResults"
@@ -65,6 +65,7 @@ const Chat = ({ params }) => {
6565
const [isInternetEnabled, setInternetEnabled] = useState(false)
6666
const [isWeatherEnabled, setWeatherEnabled] = useState(false)
6767
const [isNewsEnabled, setNewsEnabled] = useState(false)
68+
const [isMapsEnabled, setMapsEnabled] = useState(false)
6869

6970
// --- Refs ---
7071
const textareaRef = useRef(null)
@@ -270,7 +271,8 @@ const Chat = ({ params }) => {
270271
chatId: currentChatId,
271272
enable_internet: isInternetEnabled,
272273
enable_weather: isWeatherEnabled,
273-
enable_news: isNewsEnabled
274+
enable_news: isNewsEnabled,
275+
enable_maps: isMapsEnabled
274276
}),
275277
signal: abortControllerRef.current.signal
276278
})
@@ -698,6 +700,26 @@ const Chat = ({ params }) => {
698700
}
699701
/>
700702
</label>
703+
<label
704+
htmlFor="maps-toggle"
705+
className="flex items-center gap-1.5 cursor-pointer hover:text-white transition-colors"
706+
>
707+
<IconMap
708+
size={16}
709+
className={
710+
isMapsEnabled
711+
? "text-lightblue"
712+
: ""
713+
}
714+
/>
715+
<span>Maps</span>
716+
<Switch
717+
checked={isMapsEnabled}
718+
onCheckedChange={
719+
setMapsEnabled
720+
}
721+
/>
722+
</label>
701723
</div>
702724
{connectedIntegrations.length >
703725
0 && (

src/client/app/settings/page.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import {
2626
IconLock,
2727
IconLockOpen,
2828
IconPresentation,
29-
IconTable
29+
IconTable,
30+
IconMapPin
3031
} from "@tabler/icons-react"
3132
import { useState, useEffect, useCallback } from "react"
3233
import Sidebar from "@components/Sidebar"
@@ -41,6 +42,7 @@ const integrationIcons = {
4142
gdocs: IconFileText,
4243
gslides: IconPresentation,
4344
gsheets: IconTable,
45+
gmaps: IconMapPin,
4446
slack: IconBrandSlack,
4547
notion: IconBrandNotion,
4648
accuweather: IconCloud,
@@ -267,8 +269,8 @@ const GoogleAuthSettings = ({ mode, onModeChange, onSaveSuccess }) => {
267269
</li>
268270
<li>
269271
Enable the APIs you want to use (e.g., Gmail API, Google
270-
Drive API, Google Calendar API) in the "APIs & Services"
271-
dashboard.
272+
Drive API, Google Calendar API, Google Maps Platform APIs)
273+
in the "APIs & Services" dashboard.
272274
</li>
273275
<li>
274276
Go to "Credentials", click "Create Credentials", and select
@@ -306,6 +308,7 @@ const GoogleAuthSettings = ({ mode, onModeChange, onSaveSuccess }) => {
306308
<li>https://www.googleapis.com/auth/documents</li>
307309
<li>https://www.googleapis.com/auth/presentations</li>
308310
<li>https://www.googleapis.com/auth/spreadsheets</li>
311+
<li>https://www.googleapis.com/auth/cloud-platform</li>
309312
</ul>
310313
</li>
311314
</ol>
@@ -475,6 +478,7 @@ const Settings = () => {
475478
gslides:
476479
"https://www.googleapis.com/auth/presentations https://www.googleapis.com/auth/drive",
477480
gsheets: "https://www.googleapis.com/auth/spreadsheets",
481+
gmaps: "https://www.googleapis.com/auth/cloud-platform",
478482
github: "repo user"
479483
}
480484

src/server/.env.template

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ NEWS_MCP_SERVER_URL=http://localhost:9012/sse
4747
CHAT_TOOLS_MCP_SERVER_URL=http://localhost:9013/sse
4848
GDOCS_MCP_SERVER_URL=http://localhost:9004/sse
4949
GSLIDES_MCP_SERVER_URL=http://localhost:9014/sse
50-
GSHEETS_MCP_SERVER_URL=http://localhost:9015/sse
50+
GSHEETS_MCP_SERVER_URL=http://localhost:9015/sse
51+
GMAPS_MCP_SERVER_URL=http://localhost:9016/sse

src/server/main/chat/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# src/server/main/chat/models.py
21
from pydantic import BaseModel, Field
32
from typing import Optional, Any
43

@@ -10,6 +9,7 @@ class ChatMessageInput(BaseModel):
109
enable_internet: Optional[bool] = False
1110
enable_weather: Optional[bool] = False
1211
enable_news: Optional[bool] = False
12+
enable_maps: Optional[bool] = False
1313

1414
class ChatHistoryRequest(BaseModel):
1515
chatId: Any

src/server/main/chat/utils.py

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from ..db import MongoManager
1111
from ..llm import get_qwen_assistant
12-
from ..config import MEMORY_MCP_SERVER_URL
12+
from ..config import MEMORY_MCP_SERVER_URL, INTEGRATIONS_CONFIG
1313

1414
logger = logging.getLogger(__name__)
1515

@@ -39,13 +39,12 @@ async def generate_chat_llm_stream(
3939
assistant_message_id_override: Optional[str] = None,
4040
enable_internet: bool = False,
4141
enable_weather: bool = False,
42-
enable_news: bool = False
42+
enable_news: bool = False,
43+
enable_maps: bool = False
4344
) -> AsyncGenerator[Dict[str, Any], None]:
4445
assistant_message_id = assistant_message_id_override or str(uuid.uuid4())
4546

4647
try:
47-
from ..config import INTEGRATIONS_CONFIG
48-
4948
active_mcp_servers = {}
5049

5150
# Always connect memory and chat tools
@@ -55,25 +54,20 @@ async def generate_chat_llm_stream(
5554
mcp_config = config["mcp_server_config"]
5655
active_mcp_servers[mcp_config["name"]] = {"url": mcp_config["url"], "headers": {"X-User-ID": user_id}}
5756

58-
# Conditionally connect internet search
59-
if enable_internet:
60-
config = INTEGRATIONS_CONFIG.get("internet_search")
61-
if config and "mcp_server_config" in config:
62-
mcp_config = config["mcp_server_config"]
63-
active_mcp_servers[mcp_config["name"]] = {"url": mcp_config["url"], "headers": {"X-User-ID": user_id}}
64-
65-
# Conditionally connect weather
66-
if enable_weather:
67-
config = INTEGRATIONS_CONFIG.get("accuweather")
68-
if config and "mcp_server_config" in config:
69-
mcp_config = config["mcp_server_config"]
70-
active_mcp_servers[mcp_config["name"]] = {"url": mcp_config["url"], "headers": {"X-User-ID": user_id}}
71-
72-
if enable_news:
73-
config = INTEGRATIONS_CONFIG.get("news")
74-
if config and "mcp_server_config" in config:
75-
mcp_config = config["mcp_server_config"]
76-
active_mcp_servers[mcp_config["name"]] = {"url": mcp_config["url"], "headers": {"X-User-ID": user_id}}
57+
# Conditionally connect tools based on toggles
58+
tool_flags = {
59+
"internet_search": enable_internet,
60+
"accuweather": enable_weather,
61+
"news": enable_news,
62+
"gmaps": enable_maps
63+
}
64+
65+
for service_name, is_enabled in tool_flags.items():
66+
if is_enabled:
67+
config = INTEGRATIONS_CONFIG.get(service_name)
68+
if config and "mcp_server_config" in config:
69+
mcp_config = config["mcp_server_config"]
70+
active_mcp_servers[mcp_config["name"]] = {"url": mcp_config["url"], "headers": {"X-User-ID": user_id}}
7771

7872
tools = [{"mcpServers": active_mcp_servers}]
7973

@@ -106,11 +100,12 @@ def worker():
106100
f"You are a helpful AI assistant named Sentient. The user's name is {username}. The current date is {datetime.datetime.now().strftime('%Y-%m-%d')}.\n\n"
107101
"You have access to a few tools:\n"
108102
"- Use memory tools (`search_memories`, `save_long_term_fact`, etc.) to remember and recall information about the user.\n"
109-
"- If the user asks you to perform an action (e.g., 'send an email', 'create a presentation'), use the `create_task_from_description` tool to hand it off to the planning system. Do not try to execute it yourself.\n"
103+
"- If the user asks for an action to be performed (e.g., 'send an email', 'create a presentation'), use the `create_task_from_description` tool to hand it off to the planning system. Do not try to execute it yourself.\n"
110104
"- You can check the status of a task with `get_task_status`.\n"
111105
f"- Internet search is currently {'ENABLED' if enable_internet else 'DISABLED'}. You can use it to find real-time information if enabled.\n"
112106
f"- Weather information is currently {'ENABLED' if enable_weather else 'DISABLED'}.\n"
113-
f"- News headlines and articles are currently {'ENABLED' if enable_news else 'DISABLED'}.\n\n"
107+
f"- News headlines and articles are currently {'ENABLED' if enable_news else 'DISABLED'}.\n"
108+
f"- Google Maps for places and directions is currently {'ENABLED' if enable_maps else 'DISABLED'}.\n\n"
114109
"Be conversational and helpful."
115110
)
116111
qwen_assistant = get_qwen_assistant(system_message=system_prompt, function_list=tools)

src/server/main/config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,16 @@
140140
"url": os.getenv("GSHEETS_MCP_SERVER_URL", "http://localhost:9015/sse")
141141
}
142142
},
143+
"gmaps": {
144+
"display_name": "Google Maps",
145+
"description": "Search for places and get directions.",
146+
"auth_type": "oauth",
147+
"icon": "IconMapPin",
148+
"mcp_server_config": {
149+
"name": "gmaps_server",
150+
"url": os.getenv("GMAPS_MCP_SERVER_URL", "http://localhost:9016/sse")
151+
}
152+
},
143153
"slack": { # User-configurable Manual
144154
"display_name": "Slack",
145155
"description": "Connect to your Slack workspace to send messages and more.",

src/server/main/misc/routes.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,11 @@ async def _validate_gcp_credentials(creds_json_str: str, user_email: str) -> boo
8686
"""
8787
try:
8888
creds_info = json.loads(creds_json_str)
89-
# We need drive scope for the about.get call
90-
scopes = ['https://www.googleapis.com/auth/drive.readonly']
89+
# We need drive scope for the about.get call and cloud-platform for maps
90+
scopes = [
91+
'https://www.googleapis.com/auth/drive.readonly',
92+
'https://www.googleapis.com/auth/cloud-platform'
93+
]
9194

9295
creds = service_account.Credentials.from_service_account_info(
9396
creds_info, scopes=scopes, subject=user_email
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# HTTP Server configuration for FastMCP
2+
MCP_SERVER_HOST=127.0.0.1
3+
MCP_SERVER_PORT=9016
4+
5+
# This MCP uses the main server's Google credentials.
6+
# No separate API key is needed if using the Service Account or OAuth flow.

0 commit comments

Comments
 (0)