Model Context Protocol (MCP) Server
Model Context Protocol (MCP) Server
Section titled “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.
Endpoint & Transport
Section titled “Endpoint & Transport”KoAkademy implements the MCP specification (2025-11-25) over HTTP transport using JSON-RPC 2.0.
POST /mcp/koakademyRequest Headers
Section titled “Request Headers”| 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) |
Rate Limiting
Section titled “Rate Limiting”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.
Authentication & Token Abilities
Section titled “Authentication & Token Abilities”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: Bearerheader. Developer Mode must be enabled. Anmcp:writekey 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.
OAuth deployment setup
Section titled “OAuth deployment setup”After installing this version, run the migrations and generate Passport signing keys once:
php artisan migrate --forcephp artisan passport:keysKeep 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.
Dedicated MCP Abilities
Section titled “Dedicated MCP Abilities”| 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.
Administrative & Role Gating
Section titled “Administrative & Role Gating”- User Role Gating: Staff, faculty, and administrative accounts with Developer Mode enabled can issue both
mcp:readandmcp:writekeys. Students in Developer Mode can issuemcp:readtokens to query their personal academic records; student accounts are prevented from issuingmcp:writekeys or granting OAuth write access. - Global MCP Switch: Administrators can disable the MCP server entirely via Settings -> API & Integrations -> Model Context Protocol (MCP) or via
MCP_ENABLED=falsein.env. - 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, andget_my_contextreportsmcp.can_write: false. - Tool-Level RBAC: Even with an
mcp:writetoken, an agent cannot perform actions that the issuing staff account does not have permission to execute (e.g., verifying requirements or enrolling subjects requiresUpdate:StudentEnrollment; viewing billing requiresView:Cashierorview_tuition_fees).
Tool Catalog
Section titled “Tool Catalog”KoAkademy registers 36 core tools across its school administration, enrollment lifecycle, curriculum, scheduling, and financial domains.
1. Context & School Overview
Section titled “1. Context & School Overview”get_my_context
Section titled “get_my_context”- 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 }}
get_school_details
Section titled “get_school_details”- 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
get_school_metrics
Section titled “get_school_metrics”- 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}}
2. Student & Faculty Directory
Section titled “2. Student & Faculty Directory”get_student_profile
Section titled “get_student_profile”- Access: Read-only (
mcp:read) · RequiresView:Studentfor 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" }}
search_students
Section titled “search_students”- Access: Read-only (
mcp:read) · RequiresViewAny: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.
get_student_schedule
Section titled “get_student_schedule”- Access: Read-only (
mcp:read) · RequiresView:Studentfor 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 bysearch_students.
search_faculty
Section titled “search_faculty”- Access: Read-only (
mcp:read) · RequiresViewAny: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.
3. Academic Curriculum & Subjects
Section titled “3. Academic Curriculum & Subjects”get_course_curriculum
Section titled “get_course_curriculum”- Access: Read-only (
mcp:read) · RequiresView:Coursefor 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.
get_available_subjects
Section titled “get_available_subjects”- Access: Read-only (
mcp:read) · RequiresView:Studentfor 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.
list_academic_offerings
Section titled “list_academic_offerings”- Access: Read-only (
mcp:read) · RequiresViewAny:CourseandViewAny: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,1or2): Defaults to current period.limit(integer, optional, 1-50, default: 25): Result cap per collection.
4. Enrollments & Subject Enrollments
Section titled “4. Enrollments & Subject Enrollments”list_student_enrollments
Section titled “list_student_enrollments”- Access: Read-only (
mcp:read) · RequiresView:StudentEnrollmentfor 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.
get_enrollment_status
Section titled “get_enrollment_status”- Access: Read-only (
mcp:read) · RequiresView: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.
get_student_subject_enrollments
Section titled “get_student_subject_enrollments”- Access: Read-only (
mcp:read) · RequiresView:StudentEnrollmentfor 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.
enroll_student_subject
Section titled “enroll_student_subject”- Access: Mutation (
mcp:write) · RequiresUpdate: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.
update_subject_enrollment_grade
Section titled “update_subject_enrollment_grade”- Access: Mutation (
mcp:write) · RequiresUpdate: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 thesubject_enrollmentrecord.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.
drop_student_subject_enrollment
Section titled “drop_student_subject_enrollment”- Access: Mutation (
mcp:write) · RequiresUpdate: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 thesubject_enrollmentrecord 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.
list_pending_enrollments
Section titled “list_pending_enrollments”- Access: Read-only (
mcp:read) · Restricted to Administrators · RequiresViewAny: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.
get_enrollment_audit_trail
Section titled “get_enrollment_audit_trail”- Access: Read-only (
mcp:read) · RequiresView: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.
advance_enrollment_step
Section titled “advance_enrollment_step”- Access: Mutation (
mcp:write) · Restricted to Administrators · RequiresUpdate: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.
verify_enrollment_requirement
Section titled “verify_enrollment_requirement”- Access: Mutation (
mcp:write) · RequiresUpdate:StudentEnrollment - Description: Marks a pending document or enrollment requirement as verified. Waived requirements cannot be verified.
- Arguments:
requirement_id(integer, required): Enrollment requirement ID fromget_enrollment_status.idempotency_key(string, required, 1-96 chars): Client-supplied unique token to guarantee safe retries.
update_enrollment_remarks
Section titled “update_enrollment_remarks”- Access: Mutation (
mcp:write) · RequiresUpdate: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.
5. Billing & Finance
Section titled “5. Billing & Finance”get_statement_of_account
Section titled “get_statement_of_account”- Access: Read-only (
mcp:read) · RequiresView:Cashierorview_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.
Client Configuration Guides
Section titled “Client Configuration Guides”1. OpenCode
Section titled “1. OpenCode”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" } } } }}2. Claude Desktop
Section titled “2. Claude Desktop”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" } } }}3. Cursor
Section titled “3. Cursor”In .cursor/mcp.json:
{ "mcpServers": { "koakademy": { "url": "https://your-school.edu/mcp/koakademy", "headers": { "Authorization": "Bearer YOUR_SANCTUM_TOKEN" } } }}4. Direct HTTP / cURL Example
Section titled “4. Direct HTTP / cURL Example”To list available tools:
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:
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" } } }'