Class: MCPClient

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

MCP Client Class

Constructor

new MCPClient(config)

Create a new MCP client

Parameters:
Name Type Description
config Object | string

Configuration object or URL string

Properties
Name Type Attributes Description
baseURL string <optional>

MCP server base URL

serverUrl string <optional>

Alias for baseURL

timeout number <optional>

Request timeout in milliseconds (default: 30000)

maxRetries number <optional>

Maximum retry attempts (default: 3)

authToken string <optional>

Optional authentication token

headers Object <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:
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
Name Type Description
type string

Document type

title string

Title search

dateFrom string

From date

dateTo string

To date

limit number

Result limit

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
Name Type Description
parti string

Party filter

valkrets string

Electoral district

status string

Status filter

limit number

Result limit

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
Name Type Description
rm string

Riksmöte

bet string

Document reference

punkt string

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:
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
Name Type Description
sok string

Search query

doktyp string

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

rm string

Riksmöte

from_date string

From date

to_date string

To date

limit number

Result limit

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
Name Type Description
sok string

Search query

rm string

Riksmöte

talare string

Speaker name

parti string

Party

limit number

Result limit

Source:
Returns:

Speeches

Type
Promise.<Array>

(async) sleep()

Sleep utility

Source: