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 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 | 10x 10x 10x 10x 10x 10x 10x 10x 3x 3x 1x 1x 1x 8x 8x 8x 8x 5x 8x 5x 8x 2x 2x 2x 7x 7x 7x 7x 5x 5x 5x 7x 2x 2x 2x 7x 7x 7x 7x 5x 7x 2x 2x 2x 6x 6x 3x 3x 3x 6x 6x 3x 3x 3x 3x 3x 1x 1x 2x 2x 2x 1x 1x 1x 3x 3x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 3x 3x 4x 4x 3x 1x 1x 2x 2x 1x 1x 1x 4x 2x 2x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 4x 2x 2x 2x 2x 1x 1x 1x 4x 2x 2x 2x 2x 1x 1x 1x 4x 2x 2x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 3x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 4x 2x 2x 2x 2x 1x 1x 1x 4x 2x 2x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 4x 2x 2x 2x 2x 1x 1x 1x 4x 2x 2x 2x 2x 1x 1x 1x 4x 2x 2x 2x 2x 1x 1x 1x 4x 2x 2x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 4x 2x 2x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 4x 4x 1x 1x 1x 10x 3x 2x 2x 3x 5x 2x 2x | // SPDX-FileCopyrightText: 2024-2026 Hack23 AB
// SPDX-License-Identifier: Apache-2.0
/**
* @module MCP/EPMCPClient
* @description European Parliament MCP client — domain-specific tool wrappers
* built on top of the generic {@link MCPConnection} transport.
*/
import { MCPConnection } from './mcp-connection.js';
import type {
MCPClientOptions,
MCPToolResult,
GetMEPsOptions,
GetPlenarySessionsOptions,
SearchDocumentsOptions,
GetParliamentaryQuestionsOptions,
GetCommitteeInfoOptions,
MonitorLegislativePipelineOptions,
AssessMEPInfluenceOptions,
AnalyzeCoalitionDynamicsOptions,
DetectVotingAnomaliesOptions,
ComparePoliticalGroupsOptions,
VotingRecordsOptions,
VotingPatternsOptions,
GenerateReportOptions,
AnalyzeLegislativeEffectivenessOptions,
AnalyzeCommitteeActivityOptions,
TrackMEPAttendanceOptions,
AnalyzeCountryDelegationOptions,
GeneratePoliticalLandscapeOptions,
GetCurrentMEPsOptions,
GetSpeechesOptions,
GetProceduresOptions,
GetAdoptedTextsOptions,
GetEventsOptions,
GetMeetingActivitiesOptions,
GetMeetingDecisionsOptions,
GetMEPDeclarationsOptions,
GetIncomingMEPsOptions,
GetOutgoingMEPsOptions,
GetHomonymMEPsOptions,
GetPlenaryDocumentsOptions,
GetCommitteeDocumentsOptions,
GetPlenarySessionDocumentsOptions,
GetPlenarySessionDocumentItemsOptions,
GetControlledVocabulariesOptions,
GetExternalDocumentsOptions,
GetMeetingForeseenActivitiesOptions,
GetProcedureEventsOptions,
GetMeetingPlenarySessionDocumentsOptions,
GetMeetingPlenarySessionDocumentItemsOptions,
NetworkAnalysisOptions,
SentimentTrackerOptions,
EarlyWarningSystemOptions,
ComparativeIntelligenceOptions,
CorrelateIntelligenceOptions,
GetAllGeneratedStatsOptions,
} from '../types/index.js';
/** Fallback payload for analyze_legislative_effectiveness when validation fails or tool is unavailable */
const EFFECTIVENESS_FALLBACK = '{"effectiveness": null}';
/** Fallback payload for MEP list tools */
const MEPS_FALLBACK = '{"meps": []}';
/** Fallback payload for document list tools */
const DOCUMENTS_FALLBACK = '{"documents": []}';
/** Fallback payload for event list tools */
const EVENTS_FALLBACK = '{"events": []}';
/** Fallback payload for activity list tools */
const ACTIVITIES_FALLBACK = '{"activities": []}';
/** Fallback payload for item list tools */
const ITEMS_FALLBACK = '{"items": []}';
/** Fallback payload for intelligence analysis tools */
const INTELLIGENCE_FALLBACK = '{"analysis": null}';
/** Fallback payload for precomputed statistics */
const STATS_FALLBACK = '{"stats": null}';
/**
* MCP Client for European Parliament data access.
* Extends {@link MCPConnection} with EP-specific tool wrapper methods.
*/
export class EuropeanParliamentMCPClient extends MCPConnection {
/**
* Get Members of European Parliament
*
* @param options - Filter options
* @returns List of MEPs
*/
async getMEPs(options: GetMEPsOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('get_meps', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_meps not available:', message);
return { content: [{ type: 'text', text: MEPS_FALLBACK }] };
}
}
/**
* Get plenary sessions
*
* @param options - Filter options. `dateFrom` is mapped to `startDate` and `dateTo` to `endDate`
* per the tool schema when the canonical fields are absent.
* @returns Plenary sessions data
*/
async getPlenarySessions(options: GetPlenarySessionsOptions = {}): Promise<MCPToolResult> {
try {
const { dateFrom, dateTo, ...rest } = options;
const normalizedOptions: Record<string, unknown> = { ...rest };
if (normalizedOptions['startDate'] === undefined && dateFrom !== undefined) {
normalizedOptions['startDate'] = dateFrom;
}
if (normalizedOptions['endDate'] === undefined && dateTo !== undefined) {
normalizedOptions['endDate'] = dateTo;
}
return await this.callTool('get_plenary_sessions', normalizedOptions);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_plenary_sessions not available:', message);
return { content: [{ type: 'text', text: '{"sessions": []}' }] };
}
}
/**
* Search legislative documents
*
* @param options - Search options (normalizes `keyword` to `query` if `query` is absent)
* @returns Search results
*/
async searchDocuments(options: SearchDocumentsOptions = {}): Promise<MCPToolResult> {
try {
const { keyword, ...rest } = options;
const normalizedOptions: Record<string, unknown> = { ...rest };
if (normalizedOptions['query'] === undefined && keyword !== undefined) {
const trimmed = String(keyword).trim();
Eif (trimmed.length > 0) {
normalizedOptions['query'] = trimmed;
}
}
return await this.callTool('search_documents', normalizedOptions);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('search_documents not available:', message);
return { content: [{ type: 'text', text: DOCUMENTS_FALLBACK }] };
}
}
/**
* Get parliamentary questions
*
* @param options - Filter options. `dateFrom` is mapped to `startDate` per the tool schema.
* `dateTo` is intentionally ignored because the `get_parliamentary_questions` tool schema
* only supports `startDate` as a date filter; passing `dateTo` would have no effect.
* @returns Parliamentary questions data
*/
async getParliamentaryQuestions(
options: GetParliamentaryQuestionsOptions = {}
): Promise<MCPToolResult> {
try {
const { dateFrom, dateTo: _dateTo, ...rest } = options;
const toolOptions: Record<string, unknown> = { ...rest };
if (toolOptions['startDate'] === undefined && dateFrom !== undefined) {
toolOptions['startDate'] = dateFrom;
}
return await this.callTool('get_parliamentary_questions', toolOptions);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_parliamentary_questions not available:', message);
return { content: [{ type: 'text', text: '{"questions": []}' }] };
}
}
/**
* Get committee information
*
* @param options - Filter options
* @returns Committee info data
*/
async getCommitteeInfo(options: GetCommitteeInfoOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('get_committee_info', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_committee_info not available:', message);
return { content: [{ type: 'text', text: '{"committees": []}' }] };
}
}
/**
* Monitor legislative pipeline
*
* @param options - Filter options
* @returns Legislative pipeline data
*/
async monitorLegislativePipeline(
options: MonitorLegislativePipelineOptions = {}
): Promise<MCPToolResult> {
try {
return await this.callTool('monitor_legislative_pipeline', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('monitor_legislative_pipeline not available:', message);
return { content: [{ type: 'text', text: '{"procedures": []}' }] };
}
}
/**
* Analyze legislative effectiveness of an MEP or committee
*
* @param options - Options including subjectType and subjectId
* @returns Legislative effectiveness data
*/
async analyzeLegislativeEffectiveness(
options: AnalyzeLegislativeEffectivenessOptions
): Promise<MCPToolResult> {
const { subjectType, subjectId } = options;
if (subjectId.trim().length === 0) {
console.warn(
'analyze_legislative_effectiveness called without valid subjectId (non-empty string required)'
);
return { content: [{ type: 'text', text: EFFECTIVENESS_FALLBACK }] };
}
const trimmedSubjectId = subjectId.trim();
try {
return await this.callTool('analyze_legislative_effectiveness', {
...options,
subjectType,
subjectId: trimmedSubjectId,
});
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('analyze_legislative_effectiveness not available:', message);
return { content: [{ type: 'text', text: EFFECTIVENESS_FALLBACK }] };
}
}
/**
* Assess MEP influence using 5-dimension scoring model
*
* @param options - Options including required mepId and optional date range
* @returns MEP influence score and breakdown
*/
async assessMEPInfluence(options: AssessMEPInfluenceOptions): Promise<MCPToolResult> {
const trimmedMepId = options && typeof options.mepId === 'string' ? options.mepId.trim() : '';
if (trimmedMepId.length === 0) {
console.warn('assess_mep_influence called without valid mepId (non-empty string required)');
return { content: [{ type: 'text', text: '{"influence": {}}' }] };
}
try {
return await this.callTool('assess_mep_influence', { ...options, mepId: trimmedMepId });
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('assess_mep_influence not available:', message);
return { content: [{ type: 'text', text: '{"influence": {}}' }] };
}
}
/**
* Analyze coalition dynamics and cohesion
*
* @param options - Options including optional political groups and date range
* @returns Coalition cohesion and stress analysis
*/
async analyzeCoalitionDynamics(
options: AnalyzeCoalitionDynamicsOptions = {}
): Promise<MCPToolResult> {
try {
return await this.callTool('analyze_coalition_dynamics', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('analyze_coalition_dynamics not available:', message);
return { content: [{ type: 'text', text: '{"coalitions": []}' }] };
}
}
/**
* Detect voting anomalies and party defections
*
* @param options - Options including optional MEP id, political group, and date
* @returns Anomaly detection results
*/
async detectVotingAnomalies(options: DetectVotingAnomaliesOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('detect_voting_anomalies', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('detect_voting_anomalies not available:', message);
return { content: [{ type: 'text', text: '{"anomalies": []}' }] };
}
}
/**
* Compare political groups across dimensions
*
* @param options - Options including required groups and optional metrics and date
* @returns Cross-group comparative analysis
*/
async comparePoliticalGroups(options: ComparePoliticalGroupsOptions): Promise<MCPToolResult> {
const rawGroups = options && Array.isArray(options.groups) ? options.groups : [];
const groups = rawGroups
.map((g) => (typeof g === 'string' ? g.trim() : ''))
.filter((g) => g.length > 0);
if (groups.length === 0) {
console.warn(
'compare_political_groups called without valid groups (non-empty string array required)'
);
return { content: [{ type: 'text', text: '{"comparison": {}}' }] };
}
try {
return await this.callTool('compare_political_groups', { ...options, groups });
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('compare_political_groups not available:', message);
return { content: [{ type: 'text', text: '{"comparison": {}}' }] };
}
}
/**
* Get detailed information about a specific MEP
*
* @param id - MEP identifier (must be non-empty)
* @returns Detailed MEP information including biography, contact, and activities
*/
async getMEPDetails(id: string): Promise<MCPToolResult> {
if (typeof id !== 'string' || id.trim().length === 0) {
console.warn('get_mep_details called without valid id (non-empty string required)');
return { content: [{ type: 'text', text: '{"mep": null}' }] };
}
try {
return await this.callTool('get_mep_details', { id: id.trim() });
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_mep_details not available:', message);
return { content: [{ type: 'text', text: '{"mep": null}' }] };
}
}
/**
* Retrieve voting records with optional filters
*
* @param options - Filter options (mepId, sessionId, limit)
* @returns Voting records data
*/
async getVotingRecords(options: VotingRecordsOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('get_voting_records', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_voting_records not available:', message);
return { content: [{ type: 'text', text: '{"votes": []}' }] };
}
}
/**
* Analyze voting behavior patterns for an MEP
*
* @param options - Analysis options (mepId required non-empty, dateFrom, compareWithGroup)
* @returns Voting pattern analysis
*/
async analyzeVotingPatterns(options: VotingPatternsOptions): Promise<MCPToolResult> {
if (typeof options.mepId !== 'string' || options.mepId.trim().length === 0) {
console.warn(
'analyze_voting_patterns called without valid mepId (non-empty string required)'
);
return { content: [{ type: 'text', text: '{"patterns": null}' }] };
}
try {
return await this.callTool('analyze_voting_patterns', {
...options,
mepId: options.mepId.trim(),
});
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('analyze_voting_patterns not available:', message);
return { content: [{ type: 'text', text: '{"patterns": null}' }] };
}
}
/**
* Track a legislative procedure by its identifier
*
* @param procedureId - Legislative procedure identifier (must be non-empty)
* @returns Procedure status and timeline
*/
async trackLegislation(procedureId: string): Promise<MCPToolResult> {
if (typeof procedureId !== 'string' || procedureId.trim().length === 0) {
console.warn(
'track_legislation called without valid procedureId (non-empty string required)'
);
return { content: [{ type: 'text', text: '{"procedure": null}' }] };
}
try {
return await this.callTool('track_legislation', { procedureId: procedureId.trim() });
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('track_legislation not available:', message);
return { content: [{ type: 'text', text: '{"procedure": null}' }] };
}
}
/**
* Generate an analytical report
*
* @param options - Report options (reportType required non-empty, subjectId, dateFrom)
* @returns Generated report data
*/
async generateReport(options: GenerateReportOptions): Promise<MCPToolResult> {
if (typeof options.reportType !== 'string' || options.reportType.trim().length === 0) {
console.warn('generate_report called without valid reportType (non-empty string required)');
return { content: [{ type: 'text', text: '{"report": null}' }] };
}
try {
return await this.callTool('generate_report', {
...options,
reportType: options.reportType.trim(),
});
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('generate_report not available:', message);
return { content: [{ type: 'text', text: '{"report": null}' }] };
}
}
/**
* Analyze committee activity, workload, and engagement
*
* @param options - Options including optional committeeId and date range
* @returns Committee activity analysis data
*/
async analyzeCommitteeActivity(
options: AnalyzeCommitteeActivityOptions = {}
): Promise<MCPToolResult> {
try {
return await this.callTool('analyze_committee_activity', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('analyze_committee_activity not available:', message);
return { content: [{ type: 'text', text: '{"activity": null}' }] };
}
}
/**
* Track MEP attendance patterns and trends
*
* @param options - Options including optional mepId and date range
* @returns MEP attendance data
*/
async trackMEPAttendance(options: TrackMEPAttendanceOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('track_mep_attendance', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('track_mep_attendance not available:', message);
return { content: [{ type: 'text', text: '{"attendance": null}' }] };
}
}
/**
* Analyze country delegation voting behavior and composition
*
* @param options - Options including required country code and optional date range
* @returns Country delegation analysis data
*/
async analyzeCountryDelegation(options: AnalyzeCountryDelegationOptions): Promise<MCPToolResult> {
if (typeof options.country !== 'string' || options.country.trim().length === 0) {
console.warn(
'analyze_country_delegation called without valid country (non-empty string required)'
);
return { content: [{ type: 'text', text: '{"delegation": null}' }] };
}
try {
return await this.callTool('analyze_country_delegation', {
...options,
country: options.country.trim(),
});
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('analyze_country_delegation not available:', message);
return { content: [{ type: 'text', text: '{"delegation": null}' }] };
}
}
/**
* Generate a parliament-wide political landscape overview
*
* @param options - Options including optional date range and detail level
* @returns Political landscape overview data
*/
async generatePoliticalLandscape(
options: GeneratePoliticalLandscapeOptions = {}
): Promise<MCPToolResult> {
try {
return await this.callTool('generate_political_landscape', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('generate_political_landscape not available:', message);
return { content: [{ type: 'text', text: '{"landscape": null}' }] };
}
}
/**
* Get currently active Members of European Parliament
*
* @param options - Pagination options
* @returns Active MEPs data
*/
async getCurrentMEPs(options: GetCurrentMEPsOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('get_current_meps', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_current_meps not available:', message);
return { content: [{ type: 'text', text: MEPS_FALLBACK }] };
}
}
/**
* Get plenary speeches and debate contributions
*
* @param options - Filter options including optional speechId or date range
* @returns Speeches data
*/
async getSpeeches(options: GetSpeechesOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('get_speeches', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_speeches not available:', message);
return { content: [{ type: 'text', text: '{"speeches": []}' }] };
}
}
/**
* Get legislative procedures
*
* @param options - Filter options including optional processId or year
* @returns Procedures data
*/
async getProcedures(options: GetProceduresOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('get_procedures', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_procedures not available:', message);
return { content: [{ type: 'text', text: '{"procedures": []}' }] };
}
}
/**
* Get adopted texts (legislative resolutions, positions, non-legislative resolutions)
*
* @param options - Filter options including optional docId or year
* @returns Adopted texts data
*/
async getAdoptedTexts(options: GetAdoptedTextsOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('get_adopted_texts', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_adopted_texts not available:', message);
return { content: [{ type: 'text', text: '{"texts": []}' }] };
}
}
/**
* Get European Parliament events (hearings, conferences, seminars)
*
* @param options - Filter options including optional eventId or date range
* @returns Events data
*/
async getEvents(options: GetEventsOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('get_events', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_events not available:', message);
return { content: [{ type: 'text', text: EVENTS_FALLBACK }] };
}
}
/**
* Get activities linked to a specific plenary sitting
*
* @param options - Options including required sittingId
* @returns Meeting activities data
*/
async getMeetingActivities(options: GetMeetingActivitiesOptions): Promise<MCPToolResult> {
if (typeof options.sittingId !== 'string' || options.sittingId.trim().length === 0) {
console.warn(
'get_meeting_activities called without valid sittingId (non-empty string required)'
);
return { content: [{ type: 'text', text: ACTIVITIES_FALLBACK }] };
}
try {
return await this.callTool('get_meeting_activities', {
...options,
sittingId: options.sittingId.trim(),
});
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_meeting_activities not available:', message);
return { content: [{ type: 'text', text: ACTIVITIES_FALLBACK }] };
}
}
/**
* Get decisions made in a specific plenary sitting
*
* @param options - Options including required sittingId
* @returns Meeting decisions data
*/
async getMeetingDecisions(options: GetMeetingDecisionsOptions): Promise<MCPToolResult> {
if (typeof options.sittingId !== 'string' || options.sittingId.trim().length === 0) {
console.warn(
'get_meeting_decisions called without valid sittingId (non-empty string required)'
);
return { content: [{ type: 'text', text: '{"decisions": []}' }] };
}
try {
return await this.callTool('get_meeting_decisions', {
...options,
sittingId: options.sittingId.trim(),
});
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_meeting_decisions not available:', message);
return { content: [{ type: 'text', text: '{"decisions": []}' }] };
}
}
/**
* Get MEP declarations of financial interests
*
* @param options - Filter options including optional docId or year
* @returns MEP declarations data
*/
async getMEPDeclarations(options: GetMEPDeclarationsOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('get_mep_declarations', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_mep_declarations not available:', message);
return { content: [{ type: 'text', text: '{"declarations": []}' }] };
}
}
/**
* Get incoming Members of European Parliament
*
* @param options - Pagination options
* @returns Incoming MEPs data
*/
async getIncomingMEPs(options: GetIncomingMEPsOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('get_incoming_meps', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_incoming_meps not available:', message);
return { content: [{ type: 'text', text: MEPS_FALLBACK }] };
}
}
/**
* Get outgoing Members of European Parliament
*
* @param options - Pagination options
* @returns Outgoing MEPs data
*/
async getOutgoingMEPs(options: GetOutgoingMEPsOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('get_outgoing_meps', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_outgoing_meps not available:', message);
return { content: [{ type: 'text', text: MEPS_FALLBACK }] };
}
}
/**
* Get homonym MEPs (MEPs with identical names)
*
* @param options - Pagination options
* @returns Homonym MEPs data
*/
async getHomonymMEPs(options: GetHomonymMEPsOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('get_homonym_meps', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_homonym_meps not available:', message);
return { content: [{ type: 'text', text: MEPS_FALLBACK }] };
}
}
/**
* Get plenary documents
*
* @param options - Filter options including optional docId or year
* @returns Plenary documents data
*/
async getPlenaryDocuments(options: GetPlenaryDocumentsOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('get_plenary_documents', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_plenary_documents not available:', message);
return { content: [{ type: 'text', text: DOCUMENTS_FALLBACK }] };
}
}
/**
* Get committee documents
*
* @param options - Filter options including optional docId or year
* @returns Committee documents data
*/
async getCommitteeDocuments(options: GetCommitteeDocumentsOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('get_committee_documents', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_committee_documents not available:', message);
return { content: [{ type: 'text', text: DOCUMENTS_FALLBACK }] };
}
}
/**
* Get plenary session documents (agendas, minutes, voting lists)
*
* @param options - Filter options including optional docId
* @returns Plenary session documents data
*/
async getPlenarySessionDocuments(
options: GetPlenarySessionDocumentsOptions = {}
): Promise<MCPToolResult> {
try {
return await this.callTool('get_plenary_session_documents', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_plenary_session_documents not available:', message);
return { content: [{ type: 'text', text: DOCUMENTS_FALLBACK }] };
}
}
/**
* Get plenary session document items
*
* @param options - Pagination options
* @returns Plenary session document items data
*/
async getPlenarySessionDocumentItems(
options: GetPlenarySessionDocumentItemsOptions = {}
): Promise<MCPToolResult> {
try {
return await this.callTool('get_plenary_session_document_items', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_plenary_session_document_items not available:', message);
return { content: [{ type: 'text', text: ITEMS_FALLBACK }] };
}
}
/**
* Get controlled vocabularies (standardized classification terms)
*
* @param options - Filter options including optional vocId
* @returns Controlled vocabularies data
*/
async getControlledVocabularies(
options: GetControlledVocabulariesOptions = {}
): Promise<MCPToolResult> {
try {
return await this.callTool('get_controlled_vocabularies', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_controlled_vocabularies not available:', message);
return { content: [{ type: 'text', text: '{"vocabularies": []}' }] };
}
}
/**
* Get external documents (non-EP documents such as Council positions)
*
* @param options - Filter options including optional docId or year
* @returns External documents data
*/
async getExternalDocuments(options: GetExternalDocumentsOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('get_external_documents', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_external_documents not available:', message);
return { content: [{ type: 'text', text: DOCUMENTS_FALLBACK }] };
}
}
/**
* Get foreseen (planned) activities for a specific plenary sitting
*
* @param options - Options including required sittingId
* @returns Foreseen activities data
*/
async getMeetingForeseenActivities(
options: GetMeetingForeseenActivitiesOptions
): Promise<MCPToolResult> {
if (typeof options.sittingId !== 'string' || options.sittingId.trim().length === 0) {
console.warn(
'get_meeting_foreseen_activities called without valid sittingId (non-empty string required)'
);
return { content: [{ type: 'text', text: ACTIVITIES_FALLBACK }] };
}
try {
return await this.callTool('get_meeting_foreseen_activities', {
...options,
sittingId: options.sittingId.trim(),
});
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_meeting_foreseen_activities not available:', message);
return { content: [{ type: 'text', text: ACTIVITIES_FALLBACK }] };
}
}
/**
* Get events linked to a specific legislative procedure
*
* @param options - Options including required processId
* @returns Procedure events data
*/
async getProcedureEvents(options: GetProcedureEventsOptions): Promise<MCPToolResult> {
if (typeof options.processId !== 'string' || options.processId.trim().length === 0) {
console.warn(
'get_procedure_events called without valid processId (non-empty string required)'
);
return { content: [{ type: 'text', text: EVENTS_FALLBACK }] };
}
try {
return await this.callTool('get_procedure_events', {
...options,
processId: options.processId.trim(),
});
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_procedure_events not available:', message);
return { content: [{ type: 'text', text: EVENTS_FALLBACK }] };
}
}
/**
* Get plenary session documents linked to a specific meeting
*
* @param options - Options including required sittingId
* @returns Meeting plenary session documents data
*/
async getMeetingPlenarySessionDocuments(
options: GetMeetingPlenarySessionDocumentsOptions
): Promise<MCPToolResult> {
if (typeof options.sittingId !== 'string' || options.sittingId.trim().length === 0) {
console.warn(
'get_meeting_plenary_session_documents called without valid sittingId (non-empty string required)'
);
return { content: [{ type: 'text', text: DOCUMENTS_FALLBACK }] };
}
try {
return await this.callTool('get_meeting_plenary_session_documents', {
...options,
sittingId: options.sittingId.trim(),
});
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_meeting_plenary_session_documents not available:', message);
return { content: [{ type: 'text', text: DOCUMENTS_FALLBACK }] };
}
}
/**
* Get plenary session document items linked to a specific meeting
*
* @param options - Options including required sittingId
* @returns Meeting plenary session document items data
*/
async getMeetingPlenarySessionDocumentItems(
options: GetMeetingPlenarySessionDocumentItemsOptions
): Promise<MCPToolResult> {
if (typeof options.sittingId !== 'string' || options.sittingId.trim().length === 0) {
console.warn(
'get_meeting_plenary_session_document_items called without valid sittingId (non-empty string required)'
);
return { content: [{ type: 'text', text: ITEMS_FALLBACK }] };
}
try {
return await this.callTool('get_meeting_plenary_session_document_items', {
...options,
sittingId: options.sittingId.trim(),
});
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_meeting_plenary_session_document_items not available:', message);
return { content: [{ type: 'text', text: ITEMS_FALLBACK }] };
}
}
/**
* MEP relationship network mapping using committee co-membership
*
* @param options - Options including optional mepId, analysisType, and depth
* @returns Network analysis with centrality scores and clusters
*/
async networkAnalysis(options: NetworkAnalysisOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('network_analysis', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('network_analysis not available:', message);
return { content: [{ type: 'text', text: INTELLIGENCE_FALLBACK }] };
}
}
/**
* Track political group institutional positioning and sentiment
*
* @param options - Options including optional groupId and timeframe
* @returns Sentiment tracking data
*/
async sentimentTracker(options: SentimentTrackerOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('sentiment_tracker', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('sentiment_tracker not available:', message);
return { content: [{ type: 'text', text: INTELLIGENCE_FALLBACK }] };
}
}
/**
* Detect emerging political shifts and coalition fracture signals
*
* @param options - Options including optional sensitivity and focusArea
* @returns Early warning alerts and trend indicators
*/
async earlyWarningSystem(options: EarlyWarningSystemOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('early_warning_system', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('early_warning_system not available:', message);
return { content: [{ type: 'text', text: INTELLIGENCE_FALLBACK }] };
}
}
/**
* Cross-reference MEP activities for comparative multi-dimensional profiling
*
* @param options - Options including required mepIds array and optional dimensions
* @returns Comparative intelligence profiles
*/
async comparativeIntelligence(options: ComparativeIntelligenceOptions): Promise<MCPToolResult> {
if (!Array.isArray(options.mepIds) || options.mepIds.length < 2) {
console.warn(
'comparative_intelligence called without valid mepIds (array of at least 2 required)'
);
return { content: [{ type: 'text', text: INTELLIGENCE_FALLBACK }] };
}
try {
return await this.callTool('comparative_intelligence', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('comparative_intelligence not available:', message);
return { content: [{ type: 'text', text: INTELLIGENCE_FALLBACK }] };
}
}
/**
* Cross-tool OSINT intelligence correlation engine
*
* @param options - Options including optional mepId and correlation scenarios
* @returns Correlated intelligence alerts and insights
*/
async correlateIntelligence(options: CorrelateIntelligenceOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('correlate_intelligence', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('correlate_intelligence not available:', message);
return { content: [{ type: 'text', text: INTELLIGENCE_FALLBACK }] };
}
}
/**
* Retrieve precomputed European Parliament activity statistics (EP6–EP10, 2004–2025).
* Includes yearly stats, category rankings, political landscape history, and
* average-based predictions for 2026–2030. Static data refreshed weekly — no live API calls.
*
* @param options - Filter options including optional year range, category, and flags
* @returns Precomputed EP statistics data
*/
async getAllGeneratedStats(options: GetAllGeneratedStatsOptions = {}): Promise<MCPToolResult> {
try {
return await this.callTool('get_all_generated_stats', options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn('get_all_generated_stats not available:', message);
return { content: [{ type: 'text', text: STATS_FALLBACK }] };
}
}
}
let clientInstance: EuropeanParliamentMCPClient | null = null;
/**
* Get or create singleton MCP client instance
*
* @param options - Client options
* @returns Connected MCP client
*/
export async function getEPMCPClient(
options: MCPClientOptions = {}
): Promise<EuropeanParliamentMCPClient> {
if (!clientInstance) {
clientInstance = new EuropeanParliamentMCPClient(options);
await clientInstance.connect();
}
return clientInstance;
}
/**
* Close and cleanup singleton MCP client
*/
export async function closeEPMCPClient(): Promise<void> {
if (clientInstance) {
clientInstance.disconnect();
clientInstance = null;
}
}
|