Skip to content

Study plan template MCP

Platform admins can connect external AI tools (for example Cursor or Claude Desktop) to Garrison’s study plan template MCP server. The server exposes read-only rubric and template lookup plus optional AI-assisted draft, review, and step-instruction tools—the same capabilities as the admin UI assistant, callable from an MCP client.

Cross-links: Study plans (designer), Study plans (planning), AI guidelines, Admin study plan AI.

ItemValue
ProtocolModel Context Protocol over HTTP
Server namestudy-plan-templates
HTTP endpointPOST {APP_URL}/mcp/study-plan-templates
TransportStreamable HTTP (JSON-RPC)
AudiencePlatform admins only

Example endpoint (local dev with bin/start):

https://api.garrison.test/mcp/study-plan-templates

Replace the host with your deployment’s public API URL in production.

MCP clients cannot use the web app’s session cookies. Send an API token as a Bearer header:

Authorization: Bearer {plain-text-token}

Requirements:

  • Create the token on Profile → API tokens and select the Study plan MCP server permission (mcp:study-plan-templates).
  • The token’s user must be a platform admin (is_platform_admin).
  • The MCP route rejects tokens that do not include the study-plan MCP scope.
  • Other permissions you add to the same token in the future will apply only where those scopes are accepted—this route checks the study-plan scope only.

AI generation tools also require the admin_study_plan_ai feature flag (see below).

Unauthenticated requests receive 401 with a WWW-Authenticate: Bearer header. Non-admin users or tokens without the required scope receive 403.

  1. Sign in as a platform admin.
  2. Open Profile → API tokens.
  3. Enter a name (for example Cursor laptop).
  4. In the permissions tree, check Study plan MCP server (under Study plan templates).
  5. Create token and copy the plain-text value immediately—it is shown once.
  6. Revoke unused tokens from the same section.

Token lifetime defaults to 90 days (API_TOKEN_EXPIRATION_DAYS in api/.env).

GraphQLPurpose
apiTokenScopeTreePermission tree for the signed-in user
apiAccessTokensList your API tokens (metadata only)
createApiAccessToken(name, scopes)Issue a token; returns plainTextToken once
revokeApiAccessToken(id)Revoke by token id

Available scopes are defined in config/api_tokens.php. New integrations add entries there and wire route middleware or resolver checks to the scope key.

ScopeWho can assignUsed for
studies:readAny signed-in userGraphQL studies and study queries with a bearer token
mcp:study-plan-templatesPlatform adminStudy plan template MCP server (POST /mcp/study-plan-templates)
RequirementConfig
AI tools enabledFeature flag admin_study_plan_ai must be on (feature_flags.default_enabled)
LLM providerconfig/study_plan_ai.php / STUDY_PLAN_AI_* env vars (default Ollama in dev)

Read-only tools (get-study-plan-template, rubric resource, review when AI is on) still require platform admin auth. AI generation tools are hidden from MCP tool lists when the feature flag is off.

Usage is logged to ai_usage like GraphQL AI mutations.

Add a server entry pointing at the HTTP endpoint and your Bearer token.

Cursor (api/.mcp.json, copied from .mcp.json.example):

{
"mcpServers": {
"study-plan-templates": {
"url": "https://api.garrison.test/mcp/study-plan-templates",
"headers": {
"Authorization": "Bearer YOUR_TOKEN_FROM_PROFILE"
}
}
}
}

Use the API container’s reachable URL from your machine. For local dev with bin/start, https://api.garrison.test is typical.

Reload MCP in the client after saving. The server advertises name study-plan-templates and version 0.1.0.

Tool names use kebab-case derived from the server registration.

ToolRead-onlyFeature flagDescription
get-study-plan-templateYesLoad a template by id (UUID) or slug, including unpublished drafts
generate-study-plan-template-draftNoadmin_study_plan_aiWizard brief → unpublished template draft (JSON)
review-study-plan-templateYes*admin_study_plan_aiRubric review; criticism only, no rewrites
generate-study-plan-step-instructionsNoadmin_study_plan_aiMarkdown for one step and instruction lane

*Review calls the LLM but does not mutate stored templates.

ArgumentTypeRequiredNotes
idstring (UUID)One of id / slugTemplate primary key
slugstringOne of id / slugTemplate slug

Returns JSON: metadata, participation flags, and steps with lane markdown fields.

ArgumentTypeRequired
studyMethodstringYes — e.g. Topical, Book
spiritualPhasesstring[]Yes — e.g. ["Milk"]
focusKindstringYes
focusValuestringNo
variantstringNo
supportsMentoredParticipationbooleanYes
supportsIndividualParticipationbooleanYes
goalsstringYes — author brief
referenceTemplateIdstring (UUID)No
referenceUrlsstring[]No — up to three URLs

Returns an unpublished draft (isPublished: false). Same shape as GraphQL generateStudyPlanTemplateDraft.

Accepts a full template draft: slug, title, description, studyMethod, spiritualPhases, focusKind, focusValue, variant, isPublished, participation flags, sortOrder, and steps[] (stepKey, title, optional instruction fields, position).

Returns { findings: [{ severity, category, message, stepIndex?, suggestion? }] }. Categories use rubric slugs.

Template context plus: stepIndex, stepKey, stepTitle, instructionRole (individual | mentee | mentor), optional currentInstructions, and required intent.

Returns { instructionsMarkdown: "…" }.

URIMIMEDescription
garrison://study-plan/rubricapplication/jsonRubric dimensions (slug, title, description, aiInstructions, sortOrder)
PromptArgumentsDescription
study-plan-template-authoringgoal (optional)System context: rubric, guardrails, optional author goal
  1. Confirm admin_study_plan_ai is enabled if operators need AI tools.
  2. Configure STUDY_PLAN_AI_* / Ollama (or other provider) on the API service.
  3. Ensure the API URL is reachable from the operator’s workstation (TLS, firewall, Traefik).
  4. Platform admin creates an API token on Profile → API tokens with the study-plan MCP permission.
  5. Configure the MCP client with url + Authorization: Bearer ….
  6. Revoke tokens when a device or client is decommissioned.
SymptomCauseFix
HTTP 500 on connectMCP streamable HTTP requires Accept: application/json, text/event-stream. Clients that omit it used to crash the transport.Upgrade API (middleware normalizes Accept) or add the header in mcp.json.
HTTP 504 on AI toolsEdge gateway timeout is shorter than study-plan AI runs (draft up to ~6 minutes with queue buffer).Enable httpRoute.mcpExtendedTimeout in Helm (see values-production.example.yaml), or raise proxy timeouts on your Gateway / CDN for /mcp/*.
MCP tool error: timed out waiting for AI queueQueue worker not running, GPU saturated, or inference slower than agent timeout.Confirm queue deployment is healthy; check STUDY_PLAN_AI_* and Ollama; review ai_usage logs.
HTTP 403 from scripts / botsSome CDNs block default Python or empty User-Agent on GraphQL.Send a normal User-Agent header (Cursor and browsers are fine).

AI generation tools block the MCP HTTP request until the queued agent finishes. Read-only tools (get-study-plan-template, rubric) return quickly.

FilePurpose
api/config/api_tokens.phpPermission scopes, groups, token expiry
api/config/mcp.phpMCP route path and required scope key
api/routes/ai.phpWeb route registration and middleware
api/.mcp.json.exampleExample Cursor MCP config
api/.env.exampleAPI_TOKEN_EXPIRATION_DAYS

Implementation reference: App\Mcp\Servers\StudyPlanTemplateServer in the API package.