Add per-tool in-memory call counters to the MCP module and a GET /api/v1/status/mcp endpoint that joins them with the live tool registry and endpoint config, then render it as a new card on the System Status page with a one-click client-config copy button. - app/mcp/stats.py: lock-guarded MCPStatsTracker (the mcp SDK runs sync tool bodies via anyio.to_thread.run_sync, so this is genuinely multi-threaded, unlike the async REST routes) - app/mcp/server.py: instrument search_regulations, add get_mcp_status() - app/config/settings.py: optional MCP_PUBLIC_URL override, required because the Vite proxy and reverse proxies rewrite the Host header - StatusPage.tsx: MCP Server card, joins the existing parallel fetch Counters are process-local by design; token usage is already persisted by ModelUsageTracker since MCP calls route through ask(). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { fetchAPI, type MCPStatusResponse, type ModelUsageResponse, type SystemConfig, type SystemHealth, type SystemStats } from './index';
|
|
|
|
export async function getSystemStats(): Promise<SystemStats> {
|
|
return fetchAPI<SystemStats>('/status/stats');
|
|
}
|
|
|
|
export async function getSystemConfig(): Promise<SystemConfig> {
|
|
return fetchAPI<SystemConfig>('/status/config');
|
|
}
|
|
|
|
export async function getSystemHealth(): Promise<SystemHealth> {
|
|
return fetchAPI<SystemHealth>('/status/health');
|
|
}
|
|
|
|
/** Passive read: current connection status + cumulative token usage for all 4 AI model roles. */
|
|
export async function getModelUsage(): Promise<ModelUsageResponse> {
|
|
return fetchAPI<ModelUsageResponse>('/status/models');
|
|
}
|
|
|
|
/** Active check: sends one minimal request to each enabled model, then returns fresh statuses. */
|
|
export async function pingModelConnections(): Promise<ModelUsageResponse> {
|
|
return fetchAPI<ModelUsageResponse>('/status/models/ping', { method: 'POST' });
|
|
}
|
|
|
|
/** MCP endpoint config, advertised tools, and per-tool call counters. */
|
|
export async function getMCPStatus(): Promise<MCPStatusResponse> {
|
|
return fetchAPI<MCPStatusResponse>('/status/mcp');
|
|
}
|
|
|
|
export type { MCPStatusResponse, ModelUsageResponse, SystemConfig, SystemHealth, SystemStats };
|