cd465e0564
- Add backend/app/mcp_server.py with FastMCP server (hms-cms) - Resources: design-rules, page-structure, sync-status - Tools: trigger_sync, get_sync_log, set_rentman_token, read_file, write_file, create_page, deploy, git_commit, git_status - Bearer token auth via MCP_AUTH_TOKEN env var - Mount MCP at /mcp with streamable HTTP transport - Integrate session manager in FastAPI lifespan - Add Traefik labels for external /mcp route on hms.media-on.de - Add git, docker.io, curl to backend Dockerfile - Mount repo root + docker socket in backend container - Add mcp>=1.0.0 to requirements.txt
56 lines
1.2 KiB
TypeScript
56 lines
1.2 KiB
TypeScript
import type { $Fetch } from "nitropack";
|
|
|
|
/**
|
|
* Base API client composable.
|
|
* Uses server-side apiBase for SSR requests, public apiBase for client-side.
|
|
*/
|
|
export function useApi() {
|
|
const config = useRuntimeConfig();
|
|
// On server: config.apiBase (http://backend:8000)
|
|
// On client: config.public.apiBase (/api)
|
|
const apiBase = import.meta.server ? config.apiBase : config.public.apiBase;
|
|
|
|
const client: $Fetch = $fetch.create({
|
|
baseURL: apiBase,
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
});
|
|
|
|
async function get<T>(url: string, params?: Record<string, string | number | boolean | undefined>): Promise<T> {
|
|
return client<T>(url, {
|
|
method: "GET",
|
|
params: params as Record<string, string> | undefined,
|
|
});
|
|
}
|
|
|
|
async function post<T>(url: string, body?: unknown): Promise<T> {
|
|
return client<T>(url, {
|
|
method: "POST",
|
|
body,
|
|
});
|
|
}
|
|
|
|
async function put<T>(url: string, body?: unknown): Promise<T> {
|
|
return client<T>(url, {
|
|
method: "PUT",
|
|
body,
|
|
});
|
|
}
|
|
|
|
async function del<T>(url: string): Promise<T> {
|
|
return client<T>(url, {
|
|
method: "DELETE",
|
|
});
|
|
}
|
|
|
|
return {
|
|
apiBase,
|
|
client,
|
|
get,
|
|
post,
|
|
put,
|
|
del,
|
|
};
|
|
}
|