MCPcopy
hub / github.com/electerm/electerm / initSession

Function initSession

test/unit/mcp2.spec.js:37–60  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35
36// Helper to initialize MCP session
37async function initSession () {
38 const initializeRequest = {
39 jsonrpc: '2.0',
40 id: 1,
41 method: 'initialize',
42 params: {
43 protocolVersion: '2024-11-05',
44 capabilities: {},
45 clientInfo: {
46 name: 'electerm-test-client',
47 version: '1.0.0'
48 }
49 }
50 }
51
52 const response = await makeHttpRequest('post', serverUrl, initializeRequest, {
53 'Content-Type': 'application/json',
54 Accept: 'application/json, text/event-stream'
55 })
56
57 const sid = response.headers['mcp-session-id']
58 assert.ok(sid && sid !== 'null', `initSession: expected a real session ID but got: ${sid}`)
59 return sid
60}
61
62// Helper to call a tool via MCP
63async function callTool (sessionId, id, toolName, args) {

Callers 1

mcp2.spec.jsFile · 0.70

Calls 1

makeHttpRequestFunction · 0.70

Tested by

no test coverage detected