Skip to content

Model Context Protocol (MCP) Server

KoAkademy provides an authenticated Model Context Protocol (MCP) HTTP server that enables AI agents (such as OpenCode, Claude Desktop, Cursor, or custom assistants) to query and modify school administration data safely.

Every tool invocation runs under the authenticated user’s account, enforces tenant school scoping, and honors fine-grained application permissions.

KoAkademy implements the MCP specification (2025-11-25) over HTTP transport using JSON-RPC 2.0.

POST /mcp/koakademy
Header Description Required
Authorization Bearer <oauth_access_token> or Bearer <sanctum_personal_access_token> Yes
Content-Type application/json Yes
Accept application/json Yes
X-KoAkademy-School ID of the school to scope operations to Optional (defaults to caller’s primary school)

The MCP endpoint is rate-limited by default to 30 requests per minute per user or IP address (throttle:mcp). This can be customized via the MCP_RATE_LIMIT environment variable in config/api.php.


MCP clients may authenticate in either of two ways:

  • OAuth: Add the MCP URL to your client and sign in through the browser. Read access is granted on approval. Staff and administrators may explicitly check Allow write access to permit mutations across available MCP tools, subject to the account’s permissions, school access, and the global write switch. Leave it unchecked for read-only access. Existing read-only connections must be reauthorized to add write access.
  • API key: Create a Sanctum personal access token from Profile / Accounts & Security with the desired MCP abilities, then send it as an Authorization: Bearer header. Developer Mode must be enabled. An mcp:write key is required for permitted modifications.

The write checkbox applies to all write-capable tools currently exposed by the MCP server; it does not add tools for other models or bypass their authorization rules. OAuth access tokens expire after one hour. Refresh tokens expire after 30 days and are rotated when used. An administrator can invalidate a user’s OAuth connections by revoking all sessions and tokens in user management. Existing API keys remain separate from OAuth connections.

After installing this version, run the migrations and generate Passport signing keys once:

Terminal window
php artisan migrate --force
php artisan passport:keys

Keep storage/oauth-private.key and storage/oauth-public.key secure and persistent across releases. Do not regenerate them on every deploy: doing so invalidates existing OAuth access tokens. Multi-server installations must share the same key pair securely, or supply PASSPORT_PRIVATE_KEY and PASSPORT_PUBLIC_KEY as environment secrets on every server. Set APP_URL to the public HTTPS URL and configure trusted proxies and session cookies for your deployment. If your login page and MCP endpoint use different hosts, ensure the session cookie is shared between those hosts.

Dynamic registration is limited to 10 requests per minute per IP. HTTPS, loopback HTTP, and the cursor, vscode, and claude native callback schemes are supported. Use a shared cache store for consistent rate limiting across replicas.

Token Ability Scope Capabilities
mcp:read Read-only Allows AI agents to execute read-only queries (get_my_context, get_student_profile, search_students, get_student_schedule, get_enrollment_status, list_student_enrollments, get_student_subject_enrollments, get_course_curriculum, get_available_subjects, etc.). Students can query their own data; staff can query school records.
mcp:write Mutating Allows AI agents to execute write operations (verify_enrollment_requirement, advance_enrollment_step, update_enrollment_remarks, enroll_student_subject, update_subject_enrollment_grade, drop_student_subject_enrollment). Restricted to staff/admin accounts and requires mcp:read.

A token with mcp:write alone without mcp:read is automatically rejected. Wildcard * tokens are strictly prohibited for MCP endpoints.

  1. User Role Gating: Staff, faculty, and administrative accounts with Developer Mode enabled can issue both mcp:read and mcp:write keys. Students in Developer Mode can issue mcp:read tokens to query their personal academic records; student accounts are prevented from issuing mcp:write keys or granting OAuth write access.
  2. Global MCP Switch: Administrators can disable the MCP server entirely via Settings -> API & Integrations -> Model Context Protocol (MCP) or via MCP_ENABLED=false in .env.
  3. Global Mutation Switch: Administrators can allow or disallow mutating tools globally (mcp_write_enabled). When disabled, write tools return an actionable error without executing changes, and get_my_context reports mcp.can_write: false.
  4. Tool-Level RBAC: Even with an mcp:write token, an agent cannot perform actions that the issuing staff account does not have permission to execute (e.g., verifying requirements or enrolling subjects requires Update:StudentEnrollment; viewing billing requires View:Cashier or view_tuition_fees).

KoAkademy registers 36 core tools across its school administration, enrollment lifecycle, curriculum, scheduling, and financial domains.

  • Access: Read-only (mcp:read)
  • Description: Returns the authenticated caller’s identity, active school, current academic period, and available curriculum capabilities. Agents should invoke this tool first.
  • Arguments: None
  • Sample Response:
    {
    "user": { "id": 14, "name": "Maria Santos", "role": "registrar" },
    "school": { "id": 1, "name": "School of Computer Studies", "code": "SCS" },
    "academic_period": { "school_year": "2026 - 2027", "semester": 1 },
    "mcp": { "token_name": "OpenCode Assistant", "can_write": true }
    }
  • Access: Read-only (mcp:read)
  • Description: Retrieves organization metadata for the active school, including contact info, dean details, curriculum frameworks, and active departments.
  • Arguments: None
  • Access: Read-only (mcp:read) · Restricted to Administrators
  • Description: Returns operational KPI statistics for the current academic period (total students, enrolled count, applicants, graduated students, active classes, and total faculty).
  • Arguments: None
  • Sample Response:
    {
    "metrics": {
    "total_students": 1420,
    "enrolled_students": 1180,
    "applicants": 185,
    "graduated_students": 55,
    "enrolled_this_period": 1120,
    "pending_enrollments": 48,
    "active_classes": 164,
    "total_faculty": 62
    }
    }

  • Access: Read-only (mcp:read) · Requires View:Student for staff; students can query their own record
  • Description: Retrieves the detailed academic profile of a student, including student number, LRN, degree program, academic year level, contact details, clearance status, and enrollment status.
  • Arguments:
    • student_id (integer, optional): The database ID or school student number. Optional for student callers (defaults to their own profile).
  • Sample Response:
    {
    "id": 42,
    "student_number": "202611",
    "name": "Eduardo Reyes",
    "email": "eduardo.reyes@student.koakademy.edu",
    "status": "enrolled",
    "clearance_status": "cleared",
    "academic_year": 2,
    "course": { "id": 3, "code": "BSCS", "title": "Computer Science" }
    }
  • Access: Read-only (mcp:read) · Requires ViewAny:Student
  • Description: Searches students in the active school by name, student number, or email. Results are bounded and omit sensitive personal data.
  • Arguments:
    • query (string, required, 2-100 chars): Search term.
    • limit (integer, optional, 1-25, default: 10): Maximum results.
  • Access: Read-only (mcp:read) · Requires View:Student for staff; students can query their own schedule
  • Description: Retrieves a student’s active class enrollments, meeting days, room assignments, instructor names, and any detected schedule time overlaps.
  • Arguments:
    • student_id (integer, required): Internal ID returned by search_students.
  • Access: Read-only (mcp:read) · Requires ViewAny:Faculty
  • Description: Searches faculty members in the active school by name, department, or faculty ID number.
  • Arguments:
    • query (string, required, 2-100 chars): Search term.
    • limit (integer, optional, 1-25, default: 10): Maximum results.

  • Access: Read-only (mcp:read) · Requires View:Course for staff; open to enrolled students
  • Description: Returns the complete curriculum of an academic program or course broken down by year level and semester with lecture/lab units, prerequisite codes, and credit types.
  • Arguments:
    • course_id (integer, required): Course / program ID.
    • year_level (integer, optional, 1-6): Filter by academic year.
    • semester (integer, optional, 1 or 2): Filter by semester.
  • Access: Read-only (mcp:read) · Requires View:Student for staff; students can query their own eligibility
  • Description: Inspects curriculum requirements for a student’s program and determines which subjects they are eligible to take, distinguishing between completed, currently enrolled, and available subjects.
  • Arguments:
    • student_id (integer, optional): Student ID. Defaults to caller if student.
    • year_level (integer, optional): Year level to evaluate. Defaults to student’s current year.
    • semester (integer, optional, 1 or 2): Defaults to current semester.
  • Access: Read-only (mcp:read) · Requires ViewAny:Course and ViewAny:Classes
  • Description: Lists active academic programs and scheduled classes with section codes, faculty assignments, rooms, and enrolled capacity for the specified academic period.
  • Arguments:
    • school_year (string, optional): e.g. "2026 - 2027". Defaults to current period.
    • semester (integer, optional, 1 or 2): Defaults to current period.
    • limit (integer, optional, 1-50, default: 25): Result cap per collection.

  • Access: Read-only (mcp:read) · Requires View:StudentEnrollment for staff; students can query their own records
  • Description: Lists all semester enrollment records for a student across their academic history with term, status, runtime, downpayment, and submission channel.
  • Arguments:
    • student_id (integer, optional): Student database ID or student number. Defaults to caller if student.
    • limit (integer, optional, 1-50, default: 20): Maximum records.
  • Access: Read-only (mcp:read) · Requires View:StudentEnrollment
  • Description: Retrieves detailed workflow state, academic period, program, and all checklist requirements (pending, verified, or waived) for an enrollment record.
  • Arguments:
    • enrollment_id (integer, required): Enrollment record ID.
  • Access: Read-only (mcp:read) · Requires View:StudentEnrollment for staff; students can query their own subjects
  • Description: Retrieves the subjects a student is enrolled in for a specific enrollment record or academic term, returning subject code, title, units, class section, instructor, grades, and remarks.
  • Arguments:
    • enrollment_id (integer, optional): Target enrollment record ID.
    • student_id (integer, optional): Target student ID.
    • school_year (string, optional): e.g. "2026 - 2027". Defaults to current term.
    • semester (integer, optional, 1 or 2): Defaults to current semester.
  • Access: Mutation (mcp:write) · Requires Update:StudentEnrollment
  • Description: Enrolls a student in an academic subject under an enrollment record, optionally assigning a scheduled class section. Automatically synchronizes class enrollments.
  • Arguments:
    • enrollment_id (integer, required): ID of the student enrollment.
    • subject_id (integer, required): ID of the curriculum subject to add.
    • class_id (integer, optional): Scheduled class ID to assign a specific schedule and section.
    • section (string, optional): Section name override if class_id is omitted.
    • is_modular (boolean, optional): Modular learning flag.
    • idempotency_key (string, required, 1-96 chars): Unique key to guarantee safe replay.
  • Access: Mutation (mcp:write) · Requires Update:StudentEnrollment
  • Description: Records or updates official grades (prelim, midterm, finals, or overall grade) and evaluation remarks on an enrolled subject.
  • Arguments:
    • subject_enrollment_id (integer, required): ID of the subject_enrollment record.
    • grade (number, optional): Final/overall grade score.
    • prelim_grade (number, optional): Prelim exam/term grade score.
    • midterm_grade (number, optional): Midterm exam/term grade score.
    • finals_grade (number, optional): Final exam/term grade score.
    • remarks (string, optional): e.g. "Passed", "Failed", "Incomplete".
    • idempotency_key (string, required, 1-96 chars): Unique key to guarantee safe replay.
  • Access: Mutation (mcp:write) · Requires Update:StudentEnrollment
  • Description: Drops or removes an enrolled subject from a student’s enrollment record and automatically releases any linked class seat.
  • Arguments:
    • subject_enrollment_id (integer, required): ID of the subject_enrollment record to drop.
    • reason (string, required, max 1000 chars): Documented reason for dropping the subject.
    • idempotency_key (string, required, 1-96 chars): Unique key to guarantee safe replay.
  • Access: Read-only (mcp:read) · Restricted to Administrators · Requires ViewAny:StudentEnrollment
  • Description: Lists enrollments currently awaiting administrative review, departmental verification, or cashier approval.
  • Arguments:
    • status (string, optional): Filter by status (e.g. "submitted", "department_verification"). Omit to list all incomplete enrollments.
    • course_id (integer, optional): Filter by program.
    • limit (integer, optional, 1-50, default: 20): Result cap.
  • Access: Read-only (mcp:read) · Requires View:StudentEnrollment
  • Description: Returns the complete historical timeline of workflow events, state transitions, requirement verifications, and waivers with actor details and audit reasons.
  • Arguments:
    • enrollment_id (integer, required): Enrollment record ID.
    • limit (integer, optional, 1-50, default: 25): Event count.
  • Access: Mutation (mcp:write) · Restricted to Administrators · Requires Update:StudentEnrollment
  • Description: Advances an enrollment to its next workflow step or executes an explicit policy transition with guaranteed idempotency.
  • Arguments:
    • enrollment_id (integer, required): Enrollment record ID.
    • transition_key (string, optional): Target transition identifier for policy-based workflows.
    • reason (string, optional, max 1000 chars): Audit reason for the transition.
    • idempotency_key (string, required, 1-96 chars): Client-supplied unique token to guarantee safe retries.
  • Access: Mutation (mcp:write) · Requires Update:StudentEnrollment
  • Description: Marks a pending document or enrollment requirement as verified. Waived requirements cannot be verified.
  • Arguments:
    • requirement_id (integer, required): Enrollment requirement ID from get_enrollment_status.
    • idempotency_key (string, required, 1-96 chars): Client-supplied unique token to guarantee safe retries.
  • Access: Mutation (mcp:write) · Requires Update:StudentEnrollment
  • Description: Updates administrative notes or registrar remarks on an enrollment record.
  • Arguments:
    • enrollment_id (integer, required): Enrollment record ID.
    • remarks (string, required, max 2000 chars): Updated remarks text.

  • Access: Read-only (mcp:read) · Requires View:Cashier or view_tuition_fees
  • Description: Calculates the verified statement of account for an enrollment, including base tuition, laboratory fees, miscellaneous fees, applied discounts, verified payments, and remaining balance due.
  • Arguments:
    • enrollment_id (integer, required): Enrollment record ID.

Add the server to your OpenCode configuration (e.g. opencode.json). OpenCode uses OAuth by default; after adding it, open /mcps and sign in:

{
"mcp": {
"servers": {
"koakademy": {
"type": "remote",
"url": "https://your-school.edu/mcp/koakademy"
}
}
}
}

To use a scoped API key instead (including a key with write access), disable OAuth and provide the token in a header. Store the key in an environment variable available to OpenCode:

{
"mcp": {
"servers": {
"koakademy": {
"type": "remote",
"url": "https://your-school.edu/mcp/koakademy",
"oauth": false,
"headers": {
"Authorization": "Bearer {env:KOAKADEMY_MCP_TOKEN}",
"X-KoAkademy-School": "1"
}
}
}
}
}

Use your client’s remote MCP configuration and complete OAuth sign-in when prompted. If your Claude Desktop version supports custom headers, the existing API-key configuration remains available in claude_desktop_config.json:

{
"mcpServers": {
"koakademy": {
"url": "https://your-school.edu/mcp/koakademy",
"headers": {
"Authorization": "Bearer YOUR_SANCTUM_TOKEN",
"X-KoAkademy-School": "1"
}
}
}
}

In .cursor/mcp.json:

{
"mcpServers": {
"koakademy": {
"url": "https://your-school.edu/mcp/koakademy",
"headers": {
"Authorization": "Bearer YOUR_SANCTUM_TOKEN"
}
}
}
}

To list available tools:

Terminal window
curl -X POST https://your-school.edu/mcp/koakademy \
-H "Authorization: Bearer YOUR_SANCTUM_TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "X-KoAkademy-School: 1" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list",
"params": {}
}'

To call a tool:

Terminal window
curl -X POST https://your-school.edu/mcp/koakademy \
-H "Authorization: Bearer YOUR_SANCTUM_TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "search_students",
"arguments": {
"query": "Maria"
}
}
}'