Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | 2209x 2209x 3x 3x 3x 2209x 3x 3x 3x 2209x 3x 3x 3x 2209x 3x 3x 3x 2209x 3x 3x 3x 2209x 3x 3x | import { MCPServer, MCPServerTemplate } from "@/objects/MCPServer";
import { Dictionary } from "@/types/ext";
import { AxiosRequestConfig } from "axios";
import { HistoricalAPIRouter } from "../HistoricalApiRouter";
export class MCPServerRouter extends HistoricalAPIRouter {
constructor(
host: string,
token: string | null = null,
default_config: AxiosRequestConfig | null = null,
headers: Dictionary<string> = {},
) {
super("mcp_servers", host, token, default_config, headers);
}
templates = async (): Promise<MCPServerTemplate[]> => {
const res = await this.api.get(this.endpoint("templates"));
Eif (super.validRes(res)) {
return (res.data as { templates: MCPServerTemplate[] }).templates ?? [];
}
return [];
};
list = async (): Promise<MCPServer[]> => {
const res = await this.api.get(this.prefix);
Eif (super.validRes(res)) {
return res.data as MCPServer[];
}
return [];
};
getById = async (id: string): Promise<MCPServer | null> => {
const res = await this.api.get(this.endpoint(id));
Eif (super.validRes(res)) {
return res.data as MCPServer;
}
return null;
};
create = async (
body: Omit<MCPServer, "id" | "created_at" | "tools_cache">,
): Promise<MCPServer | null> => {
const res = await this.api.post(this.prefix, body);
Eif (super.validRes(res)) {
return res.data as MCPServer;
}
return null;
};
update = async (
id: string,
body: Partial<
Pick<
MCPServer,
| "name"
| "description"
| "connection_config"
| "tools_cache"
| "is_active"
>
>,
): Promise<MCPServer | null> => {
const res = await this.api.patch(this.endpoint(id), body);
Eif (super.validRes(res)) {
return res.data as MCPServer;
}
return null;
};
delete = async (id: string): Promise<boolean> => {
const res = await this.api.delete(this.endpoint(id));
return res.status === 204;
};
}
|