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
Install
| Registry | Package | Needs | Includes |
|---|---|---|---|
| npm | @evelynlearning/tutor | Node 18 or later | Library (ES modules, CommonJS, TypeScript types), browser helper, command line tool, MCP server |
| PyPI | evelyn-tutor | Python 3.9 or later | Library (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-tutorA 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).
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',
});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.
sessionUrlandsessionTokentake the claims on the Embed Configuration page; obvious mistakes (nostudent_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,sessionUrlandoutcomewrap the worksheet routes of the API. - Usage and session facts.
tutor.usage()andtutor.sessions.summary(ids). - Webhooks.
verifyWebhookandwebhookHandlercheck the signature of a server webhook. - Any other endpoint.
signRequestreturns the three signing headers for a request you send yourself. - In the browser (Node package).
@evelynlearning/tutor/embedhas no secret in it:mountTutoradds the iframe and hands you the session events.
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 }) => {},
});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 init | Saves 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 token | Prints a session URL: --student test-1 --topic "Fractions" [--language hi] [--switch all] [--mode text]. |
npx @evelynlearning/tutor languages | Lists the languages a lesson can be taught in, with their codes. |
npx @evelynlearning/tutor usage | Shows minutes used and left. |
npx @evelynlearning/tutor doctor | Checks the keys, this machine's clock and one signed API call, and says when a newer version exists. |
npx @evelynlearning/tutor docs | Prints the integration guide. |
npx @evelynlearning/tutor mcp | Runs 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:
{
"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.
| Tool | What it does |
|---|---|
evelyn_docs | Returns the integration guide. |
evelyn_get_keys_instructions | Says how to sign up and where the keys go. Sign-up needs a person. |
evelyn_scaffold | Returns example files for Next.js, Express or plain Node, for the assistant to write. |
evelyn_languages | Lists the lesson languages and their codes. |
evelyn_create_session_url | Claims in, session URL out. |
evelyn_usage | Minutes used and left. |
evelyn_read_worksheet | Image file paths in, numbered questions out. |
evelyn_prepare_problem | Prepares one worksheet question and returns its plan id. |
evelyn_doctor | Checks 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_idfrom 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.