Constructor
new MCPClient(config)
Create a new MCP client
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
Object | string | Configuration object or URL string Properties
|
- Source:
Examples
Basic usage with default configuration
const client = new MCPClient();
With custom configuration
const client = new MCPClient({
baseURL: 'https://custom-mcp-server.com/mcp',
timeout: 60000,
maxRetries: 5,
authToken: 'Bearer xyz...',
headers: {
'X-Custom-Header': 'value',
'X-API-Key': 'abc123'
}
});
With headers from .github/copilot-mcp.json
// Configuration in .github/copilot-mcp.json:
// {
// "mcpServers": {
// "github": {
// "type": "http",
// "url": "https://api.githubcopilot.com/mcp/insiders",
// "headers": {
// "Authorization": "Bearer ${{ secrets.TOKEN }}",
// "X-MCP-Toolsets": "all"
// }
// }
// }
// }
// The client will automatically use these headers when configured via MCP
Methods
(async) enrichDocumentsWithContent(documents, concurrency) → {Promise.<Array>}
Batch fetch document details for multiple documents Fetches in parallel with rate limiting to avoid overwhelming the server
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
documents |
Array.<Object> | Array of document objects with dok_id |
|
concurrency |
number | 3 | Max parallel requests (default: 3) |
- Source:
Returns:
Documents with enriched content
- Type
- Promise.<Array>
(async) fetchCalendarEvents(from, tom, org, akt) → {Promise.<Array>}
Fetch calendar events (upcoming parliamentary activity)
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
from |
string | Start date (YYYY-MM-DD) |
|
tom |
string | End date (YYYY-MM-DD) |
|
org |
string | null | Optional: Organ filter (e.g., 'kammaren', 'uu', 'fiu') |
akt |
string | null | Optional: Activity type |
- Source:
Returns:
Calendar events
- Type
- Promise.<Array>
(async) fetchCommitteeReports(limit, rm, organ) → {Promise.<Array>}
Fetch latest committee reports (betänkanden)
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
limit |
number | 10 | Number of reports to fetch |
rm |
string | null | Optional: Riksmöte (e.g., '2025/26') |
organ |
string | null | Optional: Committee filter |
- Source:
Returns:
Committee reports
- Type
- Promise.<Array>
(async) fetchDocumentDetails(dok_id, include_full_text) → {Promise.<Object>}
Fetch detailed document with full content
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
dok_id |
string | Document ID |
|
include_full_text |
boolean | true | Include full document text (default: true) |
- Source:
Returns:
Document with content
- Type
- Promise.<Object>
(async) fetchGovernmentDocuments(searchParams) → {Promise.<Array>}
Fetch government documents (pressmeddelanden, SOU, etc.)
Parameters:
| Name | Type | Description | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
searchParams |
Object | Search parameters Properties
|
- Source:
Returns:
Government documents
- Type
- Promise.<Array>
(async) fetchMPs(filters) → {Promise.<Array>}
Fetch MPs (ledamöter)
Parameters:
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
filters |
Object | Optional filters Properties
|
- Source:
Returns:
MPs
- Type
- Promise.<Array>
(async) fetchMotions(limit, rm) → {Promise.<Array>}
Fetch latest opposition motions
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
limit |
number | 10 | Number of motions to fetch |
rm |
string | null | Optional: Riksmöte |
- Source:
Returns:
Motions
- Type
- Promise.<Array>
(async) fetchPropositions(limit, rm) → {Promise.<Array>}
Fetch latest government propositions
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
limit |
number | 10 | Number of propositions to fetch |
rm |
string | null | Optional: Riksmöte |
- Source:
Returns:
Propositions
- Type
- Promise.<Array>
(async) fetchVotingRecords(filters) → {Promise.<Array>}
Fetch voting records
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
filters |
Object | Filter parameters Properties
|
- Source:
Returns:
Voting records
- Type
- Promise.<Array>
getStats() → {Object}
Get request statistics
- Source:
Returns:
Statistics
- Type
- Object
(async) initializeSession()
Initialize MCP session for Streamable HTTP transport
- Source:
parseSSEResponse()
Parse SSE (text/event-stream) response body into JSON-RPC response
- Source:
(async) request(tool, params, retryCount) → {Promise.<Object>}
Make HTTP request to MCP server using JSON-RPC 2.0 protocol
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
tool |
string | Tool name (e.g., 'get_calendar_events') |
|
params |
Object | Tool parameters |
|
retryCount |
number | 0 | Current retry attempt |
- Source:
Returns:
Tool response
- Type
- Promise.<Object>
resetStats()
Reset statistics
- Source:
(async) searchDocuments(searchParams) → {Promise.<Array>}
Search riksdag documents
Parameters:
| Name | Type | Description | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
searchParams |
Object | Search parameters Properties
|
- Source:
Returns:
Documents
- Type
- Promise.<Array>
(async) searchSpeeches(searchParams) → {Promise.<Array>}
Search speeches/debates (anföranden)
Parameters:
| Name | Type | Description | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
searchParams |
Object | Search parameters Properties
|
- Source:
Returns:
Speeches
- Type
- Promise.<Array>
(async) sleep()
Sleep utility
- Source: