Class: MCPClient

Intelligence Operations/MCP Intelligence Server Client.MCPClient(config)

MCP Client Class

Constructor

new MCPClient(config)

Create a new MCP client

Parameters:
NameTypeDescription
configObject | string

Configuration object or URL string

Properties
NameTypeAttributesDescription
baseURLstring<optional>

MCP server base URL

serverUrlstring<optional>

Alias for baseURL

timeoutnumber<optional>

Request timeout in milliseconds (default: 30000)

maxRetriesnumber<optional>

Maximum retry attempts (default: 3)

authTokenstring<optional>

Optional authentication token

headersObject<optional>

Custom HTTP headers to include in all requests

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:
NameTypeDefaultDescription
documentsArray.<Object>

Array of document objects with dok_id

concurrencynumber3

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:
NameTypeDefaultDescription
fromstring

Start date (YYYY-MM-DD)

tomstring

End date (YYYY-MM-DD)

orgstringnull

Optional: Organ filter (e.g., 'kammaren', 'uu', 'fiu')

aktstringnull

Optional: Activity type

Source:
Returns:

Calendar events

Type
Promise.<Array>

(async) fetchCommitteeReports(limit, rm, organ) → {Promise.<Array>}

Fetch latest committee reports (betänkanden)

Parameters:
NameTypeDefaultDescription
limitnumber10

Number of reports to fetch

rmstringnull

Optional: Riksmöte (e.g., '2025/26')

organstringnull

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:
NameTypeDefaultDescription
dok_idstring

Document ID

include_full_textbooleantrue

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:
NameTypeDescription
searchParamsObject

Search parameters

Properties
NameTypeDescription
typestring

Document type

titlestring

Title search

dateFromstring

From date

dateTostring

To date

limitnumber

Result limit

Source:
Returns:

Government documents

Type
Promise.<Array>

(async) fetchMPs(filters) → {Promise.<Array>}

Fetch MPs (ledamöter)

Parameters:
NameTypeDescription
filtersObject

Optional filters

Properties
NameTypeDescription
partistring

Party filter

valkretsstring

Electoral district

statusstring

Status filter

limitnumber

Result limit

Source:
Returns:

MPs

Type
Promise.<Array>

(async) fetchMotions(limit, rm) → {Promise.<Array>}

Fetch latest opposition motions

Parameters:
NameTypeDefaultDescription
limitnumber10

Number of motions to fetch

rmstringnull

Optional: Riksmöte

Source:
Returns:

Motions

Type
Promise.<Array>

(async) fetchPropositions(limit, rm) → {Promise.<Array>}

Fetch latest government propositions

Parameters:
NameTypeDefaultDescription
limitnumber10

Number of propositions to fetch

rmstringnull

Optional: Riksmöte

Source:
Returns:

Propositions

Type
Promise.<Array>

(async) fetchVotingRecords(filters) → {Promise.<Array>}

Fetch voting records

Parameters:
NameTypeDescription
filtersObject

Filter parameters

Properties
NameTypeDescription
rmstring

Riksmöte

betstring

Document reference

punktstring

Voting point

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:
NameTypeDefaultDescription
toolstring

Tool name (e.g., 'get_calendar_events')

paramsObject

Tool parameters

retryCountnumber0

Current retry attempt

Source:
Returns:

Tool response

Type
Promise.<Object>

resetStats()

Reset statistics

Source:

(async) searchDocuments(searchParams) → {Promise.<Array>}

Search riksdag documents

Parameters:
NameTypeDescription
searchParamsObject

Search parameters

Properties
NameTypeDescription
sokstring

Search query

doktypstring

Document type (mot, prop, bet, etc.)

rmstring

Riksmöte

from_datestring

From date

to_datestring

To date

limitnumber

Result limit

Source:
Returns:

Documents

Type
Promise.<Array>

(async) searchSpeeches(searchParams) → {Promise.<Array>}

Search speeches/debates (anföranden)

Parameters:
NameTypeDescription
searchParamsObject

Search parameters

Properties
NameTypeDescription
sokstring

Search query

rmstring

Riksmöte

talarestring

Speaker name

partistring

Party

limitnumber

Result limit

Source:
Returns:

Speeches

Type
Promise.<Array>

(async) sleep()

Sleep utility

Source: