All files / scripts/mcp-client index.ts

81.25% Statements 13/16
100% Branches 2/2
76.92% Functions 10/13
81.25% Lines 13/16

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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108                                                    9x       18x 7x   18x           1x           1x           1x           1x           1x           1x           1x           1x                       1x                            
/**
 * @module mcp-client
 * @description Barrel re-export + singleton convenience functions.
 *
 * The monolithic mcp-client.ts has been decomposed into:
 *
 * | Module            | Responsibility                           |
 * |------------------ |------------------------------------------|
 * | transport.ts      | HTTP POST abstraction (fetch + Node.js)  |
 * | document-types.ts | doktyp → English type normalisation      |
 * | client.ts         | MCPClient class (JSON-RPC 2.0)           |
 * | index.ts          | barrel re-export + convenience functions |
 *
 * @author Hack23 AB
 * @license Apache-2.0
 */
 
export { MCPClient } from './client.js';
export { normalizeDocumentType } from './document-types.js';
 
import { MCPClient } from './client.js';
 
// ---------------------------------------------------------------------------
// Singleton & convenience functions
// ---------------------------------------------------------------------------
 
let defaultClient: MCPClient | null = null;
 
/** Get or create the default singleton MCPClient */
export function getDefaultClient(): MCPClient {
  if (!defaultClient) {
    defaultClient = new MCPClient();
  }
  return defaultClient;
}
 
export async function fetchCalendarEvents(
  ...args: Parameters<MCPClient['fetchCalendarEvents']>
): ReturnType<MCPClient['fetchCalendarEvents']> {
  return getDefaultClient().fetchCalendarEvents(...args);
}
 
export async function fetchCommitteeReports(
  ...args: Parameters<MCPClient['fetchCommitteeReports']>
): ReturnType<MCPClient['fetchCommitteeReports']> {
  return getDefaultClient().fetchCommitteeReports(...args);
}
 
export async function fetchPropositions(
  ...args: Parameters<MCPClient['fetchPropositions']>
): ReturnType<MCPClient['fetchPropositions']> {
  return getDefaultClient().fetchPropositions(...args);
}
 
export async function fetchMotions(
  ...args: Parameters<MCPClient['fetchMotions']>
): ReturnType<MCPClient['fetchMotions']> {
  return getDefaultClient().fetchMotions(...args);
}
 
export async function searchDocuments(
  ...args: Parameters<MCPClient['searchDocuments']>
): ReturnType<MCPClient['searchDocuments']> {
  return getDefaultClient().searchDocuments(...args);
}
 
export async function searchSpeeches(
  ...args: Parameters<MCPClient['searchSpeeches']>
): ReturnType<MCPClient['searchSpeeches']> {
  return getDefaultClient().searchSpeeches(...args);
}
 
export async function fetchMPs(
  ...args: Parameters<MCPClient['fetchMPs']>
): ReturnType<MCPClient['fetchMPs']> {
  return getDefaultClient().fetchMPs(...args);
}
 
export async function fetchVotingRecords(
  ...args: Parameters<MCPClient['fetchVotingRecords']>
): ReturnType<MCPClient['fetchVotingRecords']> {
  return getDefaultClient().fetchVotingRecords(...args);
}
 
export async function fetchVotingGroup(
  ...args: Parameters<MCPClient['fetchVotingGroup']>
): ReturnType<MCPClient['fetchVotingGroup']> {
  return getDefaultClient().fetchVotingGroup(...args);
}
 
export async function fetchGovernmentDocuments(
  ...args: Parameters<MCPClient['fetchGovernmentDocuments']>
): ReturnType<MCPClient['fetchGovernmentDocuments']> {
  return getDefaultClient().fetchGovernmentDocuments(...args);
}
 
export async function fetchDocumentDetails(
  ...args: Parameters<MCPClient['fetchDocumentDetails']>
): ReturnType<MCPClient['fetchDocumentDetails']> {
  return getDefaultClient().fetchDocumentDetails(...args);
}
 
export async function enrichDocumentsWithContent(
  ...args: Parameters<MCPClient['enrichDocumentsWithContent']>
): ReturnType<MCPClient['enrichDocumentsWithContent']> {
  return getDefaultClient().enrichDocumentsWithContent(...args);
}