Download desktop/src/api/mcp.ts from chenbhao/codev: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/api/mcp.ts
- Command line
-
hf download hf://chenbhao/codev@e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/api/mcp.ts
-
curl -L -o mcp.ts https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/api/mcp.ts
1.53 kB
| import { api } from './client' | |
| import type { McpServerRecord, McpUpsertPayload } from '../types/mcp' | |
| export const mcpApi = { | |
| list: (cwd?: string) => { | |
| const query = cwd ? `?cwd=${encodeURIComponent(cwd)}` : '' | |
| return api.get<{ servers: McpServerRecord[] }>(`/api/mcp${query}`) | |
| }, | |
| status: (name: string, cwd?: string) => { | |
| const query = cwd ? `?cwd=${encodeURIComponent(cwd)}` : '' | |
| return api.get<{ server: McpServerRecord }>(`/api/mcp/${encodeURIComponent(name)}/status${query}`) | |
| }, | |
| create: (name: string, payload: McpUpsertPayload, cwd?: string) => { | |
| return api.post<{ server: McpServerRecord }>('/api/mcp', { | |
| name, | |
| ...payload, | |
| ...(cwd ? { cwd } : {}), | |
| }) | |
| }, | |
| update: (name: string, payload: McpUpsertPayload, cwd?: string) => { | |
| return api.put<{ server: McpServerRecord }>(`/api/mcp/${encodeURIComponent(name)}`, { | |
| ...payload, | |
| ...(cwd ? { cwd } : {}), | |
| }) | |
| }, | |
| remove: (name: string, scope: string, cwd?: string) => { | |
| const query = new URLSearchParams({ scope }) | |
| if (cwd) query.set('cwd', cwd) | |
| return api.delete<{ ok: true }>(`/api/mcp/${encodeURIComponent(name)}?${query.toString()}`) | |
| }, | |
| toggle: (name: string, cwd?: string) => { | |
| return api.post<{ server: McpServerRecord }>(`/api/mcp/${encodeURIComponent(name)}/toggle`, cwd ? { cwd } : {}) | |
| }, | |
| reconnect: (name: string, cwd?: string) => { | |
| return api.post<{ server: McpServerRecord }>(`/api/mcp/${encodeURIComponent(name)}/reconnect`, cwd ? { cwd } : {}) | |
| }, | |
| } | |