Skip to content

Commit 4d9d414

Browse files
committed
Revert "Merge pull request 'feat: write oap mcp in local mcp config instead of using oap api' (#170) from oap_remove into main"
This reverts commit 7863a57, reversing changes made to 5d6d960.
1 parent 6091030 commit 4d9d414

12 files changed

Lines changed: 55 additions & 146 deletions

File tree

electron/main/ipc/oap.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ export function ipcOapHandler(_win: BrowserWindow) {
3434
return await oapClient.applyMCPServer(ids)
3535
})
3636

37-
ipcMain.handle("oap:getMCPServerConfig", async (_, ids: string[]) => {
38-
return await oapClient.getMCPServerConfig(ids)
39-
})
40-
4137
ipcMain.handle("oap:getMCPTags", async () => {
4238
return await oapClient.getMCPTags()
4339
})

electron/main/oap.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,6 @@ class OAPClient {
185185
})
186186
}
187187

188-
getMCPServerConfig(ids: string[]) {
189-
return this.fetch<ApiResponse<OAPMCPServer>>("/api/v1/user/mcp/batch", {
190-
method: "POST",
191-
body: JSON.stringify({ "mcp_ids": ids }),
192-
})
193-
}
194-
195188
getMe() {
196189
return this.fetch<ApiResponse<OAPUser>>("/api/v1/user/me")
197190
}

electron/preload/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ contextBridge.exposeInMainWorld("ipcRenderer", {
8282
oapSearchMCPServer: (params: MCPServerSearchParam) => ipcRenderer.invoke("oap:searchMCPServer", params),
8383
oapModelDescription: (params?: OAPModelDescriptionParam) => ipcRenderer.invoke("oap:modelDescription", params),
8484
oapApplyMCPServer: (ids: string[]) => ipcRenderer.invoke("oap:applyMCPServer", ids),
85-
oapGetMCPServerConfig: (ids: string[]) => ipcRenderer.invoke("oap:getMCPServerConfig", ids),
8685
oapGetMCPServers: () => ipcRenderer.invoke("oap:getMCPServers"),
8786
oapGetMe: () => ipcRenderer.invoke("oap:getMe"),
8887
oapGetUsage: () => ipcRenderer.invoke("oap:getUsage"),

src-tauri/src/command/oap.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ pub async fn oap_apply_mcp_server(
4545
state.apply_mcp_server(ids).await.map_err(|e| e.to_string())
4646
}
4747

48-
#[tauri::command]
49-
pub async fn oap_get_mcp_server_config(
50-
state: tauri::State<'_, Arc<OAPState>>,
51-
ids: Vec<String>,
52-
) -> Result<serde_json::Value, String> {
53-
state.get_mcp_server_config(ids).await.map_err(|e| e.to_string())
54-
}
55-
5648
#[tauri::command]
5749
pub async fn oap_get_me(
5850
state: tauri::State<'_, Arc<OAPState>>,

src-tauri/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ pub fn run() {
196196
command::oap::oap_get_mcp_servers,
197197
command::oap::oap_search_mcp_server,
198198
command::oap::oap_apply_mcp_server,
199-
command::oap::oap_get_mcp_server_config,
200199
command::oap::oap_get_me,
201200
command::oap::oap_get_usage,
202201
command::oap::open_oap_login_page,

src-tauri/src/oap.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,6 @@ impl OAPAPIClient {
201201
Ok(res)
202202
}
203203

204-
pub async fn get_mcp_server_config(&self, id: Vec<String>) -> Result<Value> {
205-
let url = self.build_url("/api/v1/user/mcp/batch");
206-
let body = serde_json::json!({ "mcp_ids": id });
207-
let res = self.fetch(self.client.post(url).json(&body)).await?;
208-
Ok(res)
209-
}
210-
211204
pub async fn get_me(&self) -> Result<Value> {
212205
self.get_me_with_token(None).await
213206
}

src/atoms/oapState.ts

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { atom } from "jotai"
2-
import { oapGetUsage, oapLimiterCheck, oapLogout } from "../ipc"
2+
import { oapGetMCPServers, oapGetUsage, oapLimiterCheck, oapLogout } from "../ipc"
33
import type { OAPMCPServer, OAPUsage, OAPUser } from "../../types/oap"
4-
import { mcpConfigAtom } from "./toolState"
54

65
export const oapUserAtom = atom<OAPUser | null>(null)
76
export const oapUsageAtom = atom<OAPUsage | null>(null)
@@ -46,25 +45,15 @@ export const isOAPProAtom = atom((get) => {
4645
return OAPLevel === "PRO"
4746
})
4847

49-
//OAP Tool is from local MCP config if extraData.oap.id exists
5048
export const loadOapToolsAtom = atom(null, async (get, set) => {
51-
const mcpConfig = get(mcpConfigAtom)
52-
const oapData = Object.entries(mcpConfig.mcpServers)
53-
.filter(([_key, mcpServer]) => (mcpServer.extraData?.oap as Record<string, unknown> | undefined)?.id)
54-
.map(([key, val]) => {
55-
const oap = val.extraData?.oap as Record<string, unknown> | undefined
56-
return {
57-
id: (oap?.id as string) ?? "",
58-
name: key,
59-
plan: (oap?.plan as string) ?? val.plan ?? "",
60-
description: val.description ?? "",
61-
tags: (oap?.tags as string[]) ?? [],
62-
transport: (oap?.transport as string) ?? "",
63-
url: (oap?.url as string) ?? "",
64-
headers: (oap?.headers as Record<string, string>) ?? null,
65-
}
66-
})
67-
set(oapToolsAtom, oapData)
49+
if(!get(isLoggedInOAPAtom)) {
50+
set(oapToolsAtom, [])
51+
return
52+
}
53+
const oapData = await oapGetMCPServers()
54+
if (oapData.status === "success") {
55+
set(oapToolsAtom, oapData.data)
56+
}
6857
return oapData
6958
})
7059

src/atoms/toolState.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export interface MCP {
1111
env?: Record<string, unknown>
1212
exclude_tools?: string[]
1313
command?: string
14-
extraData?: Record<string, unknown>
1514
}
1615

1716
export interface MCPConfig {
@@ -39,7 +38,6 @@ export interface Tool {
3938
has_credential?: boolean
4039
command?: string
4140
commandExists?: boolean
42-
extraData?: Record<string, any>
4341
}
4442

4543
export const toolsAtom = atom<Tool[]>([])

src/ipc/oap.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,6 @@ export function oapApplyMCPServer(ids: string[]): Promise<void> {
6767
return invoke("oap_apply_mcp_server", { ids })
6868
}
6969

70-
export function oapGetMCPServerConfig(ids: string[]): Promise<any> {
71-
if (isElectron) {
72-
return window.ipcRenderer.oapGetMCPServerConfig(ids)
73-
}
74-
75-
return invoke("oap_get_mcp_server_config", { ids })
76-
}
77-
7870
export function oapGetMCPServers(): Promise<ApiResponse<OAPMCPServer[]>> {
7971
if (isElectron) {
8072
return window.ipcRenderer.oapGetMCPServers()

src/views/Overlay/Tools/Popup/OAPServerList.tsx

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { useAtom, useAtomValue, useSetAtom } from "jotai"
1212
import { isOAPProAtom } from "../../../../atoms/oapState"
1313
import Tooltip from "../../../../components/Tooltip"
1414
import { OAP_ROOT_URL } from "../../../../../shared/oap"
15-
import { imgPrefix, oapGetMCPServerConfig, oapGetMCPTags, oapSearchMCPServer } from "../../../../ipc"
15+
import { imgPrefix, oapApplyMCPServer, oapGetMCPTags, oapSearchMCPServer } from "../../../../ipc"
1616
import InfoTooltip from "../../../../components/InfoTooltip"
1717
import ReactMarkdown from "react-markdown"
1818
import rehypeRaw from "rehype-raw"
@@ -24,7 +24,6 @@ import remarkGfm from "remark-gfm"
2424
import { showToastAtom } from "../../../../atoms/toastState"
2525
import Button from "../../../../components/Button"
2626
import { openUrl } from "../../../../ipc/util"
27-
import { createPortal } from "react-dom"
2827

2928
const SearchHightLight = memo(({ text, searchText }: { text: string, searchText: string }) => {
3029
if (searchText === "") {
@@ -66,7 +65,7 @@ const OAPServerList = ({
6665
onCancel,
6766
}: {
6867
oapTools: { id: string, name: string }[]
69-
onConfirm: (selectedOap: Array<any>) => void
68+
onConfirm: () => void
7069
onCancel: () => void
7170
}) => {
7271
const oriOapToolsRef = useRef(JSON.parse(JSON.stringify(oapTools)))
@@ -83,7 +82,6 @@ const OAPServerList = ({
8382
const isInitRef = useRef(false)
8483
const isFetchingRef = useRef(true)
8584
const isFetchingNextPageRef = useRef(false)
86-
const [isLoading, setIsLoading] = useState(false)
8785
const [searchText, setSearchText] = useState<string>("")
8886
const [toolList, setToolList] = useState<ToolItem[]>([])
8987
const [sort, setSort] = useState("popular")
@@ -311,17 +309,14 @@ const OAPServerList = ({
311309
if (isSubmitting) {
312310
return
313311
}
314-
setHighCostList({})
315312
setIsSubmitting(true)
316-
setIsLoading(true)
317313
const selectedServers = Array.from(
318314
new Set(oapTools.map(tool => tool.id))
319315
)
320-
const res = await oapGetMCPServerConfig(selectedServers)
321-
await onConfirm(res?.data)
322-
onCancel()
316+
await oapApplyMCPServer(selectedServers)
323317
setIsSubmitting(false)
324-
setIsLoading(false)
318+
onConfirm()
319+
onCancel()
325320
}
326321

327322
const handleBannerUrl = (url: string) => {
@@ -733,14 +728,6 @@ const OAPServerList = ({
733728
</div>
734729
</PopupConfirm>
735730
}
736-
737-
{isLoading && (
738-
createPortal(
739-
<div className="global-loading-overlay">
740-
<div className="loading-spinner"></div>
741-
</div>,
742-
document.body
743-
))}
744731
</>
745732
)
746733
}

0 commit comments

Comments
 (0)