Developer Package

An optional package for Node and Python that signs session links and API calls for you, with a command line tool and an MCP server for coding assistants.

iOptional

The integration needs no package: a session is one signed link, and every code sample in these docs runs without it. The package saves you writing the signing, the worksheet calls and the webhook check yourself.

Install

RegistryPackageNeedsIncludes
npm@evelynlearning/tutorNode 18 or laterLibrary (ES modules, CommonJS, TypeScript types), browser helper, command line tool, MCP server
PyPIevelyn-tutorPython 3.9 or laterLibrary (typed): session links, the worksheet and usage API, webhook verification

Neither package has any dependencies. Both are MIT licensed.

npm install @evelynlearning/tutor
pip install evelyn-tutor

A session link in three lines

Set EVELYN_PARTNER_ID and EVELYN_PARTNER_SECRET on your server (both are on the API keys page of your dashboard; get a sandbox if you have none yet).

Node.js
import { EvelynTutor } from '@evelynlearning/tutor';

const tutor = new EvelynTutor(); // reads EVELYN_PARTNER_ID and EVELYN_PARTNER_SECRET
const url = tutor.sessionUrl({
  student_id: 'stu_abc123', subject: 'math', level: 'Grade 8',
  topic: 'Solving linear equations', target_kind: 'freestyle',
});
Python
from evelyn_tutor import EvelynTutor

tutor = EvelynTutor()  # reads EVELYN_PARTNER_ID and EVELYN_PARTNER_SECRET
url = tutor.session_url({
    "student_id": "stu_abc123", "subject": "math", "level": "Grade 8",
    "topic": "Solving linear equations", "target_kind": "freestyle",
})

Then show the URL in your page:

<iframe
  src="SESSION_URL"
  allow="microphone; camera; autoplay; clipboard-write"
  allowfullscreen
  style="width:100%; height:100vh; border:0">
</iframe>

Sign one URL per student per session. Creating a URL costs nothing: tutoring minutes are counted only while a session is running. The token expires after two hours unless you set another lifetime.

What the library covers

  • Session links. sessionUrl and sessionToken take the claims on the Embed Configuration page; obvious mistakes (no student_id, a duration outside 1 to 120) throw an error that says what to change.
  • Languages. tutor.languages() reads the current list. See Languages.
  • Worksheet help. worksheet.read, build, prepare, sessionUrl and outcome wrap the worksheet routes of the API.
  • Usage and session facts. tutor.usage() and tutor.sessions.summary(ids).
  • Webhooks. verifyWebhook and webhookHandler check the signature of a server webhook.
  • Any other endpoint. signRequest returns the three signing headers for a request you send yourself.
  • In the browser (Node package). @evelynlearning/tutor/embed has no secret in it: mountTutor adds the iframe and hands you the session events.
Browser: mount the tutor and listen
import { mountTutor } from '@evelynlearning/tutor/embed';

const tutor = mountTutor(document.getElementById('tutor'), {
  sessionUrl,                               // from your server
  onStarted: ({ session_id }) => {},
  onEnded: ({ session_id, duration, ended_reason }) => {},
});
Server: verify a webhook (Next.js route, or anything with the raw body)
import { verifyWebhook, EvelynWebhookError } from '@evelynlearning/tutor';

export async function POST(request) {
  const rawBody = await request.text();
  try {
    const event = verifyWebhook({ rawBody, headers: request.headers, secret: process.env.EVELYN_PARTNER_SECRET });
    if (event.type === 'session.ended') await saveSession(event.id, event.data);
  } catch (err) {
    if (err instanceof EvelynWebhookError) return Response.json({ error: err.reason }, { status: 400 });
    throw err;
  }
  return Response.json({ received: true });
}

Command line

The npm package has a command, evelyn-tutor. It reads the keys from the environment, or from .env.local / .env in the current directory.

npx @evelynlearning/tutor initSaves your keys in .env.local or .env (kept out of git) and writes a working example for Next.js, Express or plain Node.
npx @evelynlearning/tutor tokenPrints a session URL: --student test-1 --topic "Fractions" [--language hi] [--switch all] [--mode text].
npx @evelynlearning/tutor languagesLists the languages a lesson can be taught in, with their codes.
npx @evelynlearning/tutor usageShows minutes used and left.
npx @evelynlearning/tutor doctorChecks the keys, this machine's clock and one signed API call, and says when a newer version exists.
npx @evelynlearning/tutor docsPrints the integration guide.
npx @evelynlearning/tutor mcpRuns the MCP server.

MCP server for coding assistants

The npm package includes an MCP server, evelyn-tutor-mcp, so a coding assistant can read the guide, write the example files, create a test session and check the setup. Clients that take a JSON configuration use this form:

MCP client configuration
{
  "mcpServers": {
    "evelyn-tutor": {
      "command": "npx",
      "args": ["-y", "-p", "@evelynlearning/tutor", "evelyn-tutor-mcp"]
    }
  }
}

The server reads the keys from its environment, or from .env.local / .env in the directory it is started in. Only opening a session URL and starting the lesson uses tutoring minutes.

ToolWhat it does
evelyn_docsReturns the integration guide.
evelyn_get_keys_instructionsSays how to sign up and where the keys go. Sign-up needs a person.
evelyn_scaffoldReturns example files for Next.js, Express or plain Node, for the assistant to write.
evelyn_languagesLists the lesson languages and their codes.
evelyn_create_session_urlClaims in, session URL out.
evelyn_usageMinutes used and left.
evelyn_read_worksheetImage file paths in, numbered questions out.
evelyn_prepare_problemPrepares one worksheet question and returns its plan id.
evelyn_doctorChecks keys, clock and a signed call, and says what to fix.

Security and versions

  • The partner secret signs both session links and API calls. Keep it on your server: never in browser code, a mobile app or a commit.
  • Take student_id from your own sign-in, never from the request body.
  • The API is version 1 (/api/portal/v1). Within version 1 it only adds: new endpoints, optional fields, token claims, event types and languages.
  • Claims the package does not know are signed into the token as you give them, so a new option of the service can be used before you update the package.