feat(mcp): accept a language for course generation - #598
Open
abdulrafey1 wants to merge 2 commits into
Open
Conversation
get_course_generation_prompt_tool takes an optional BCP 47 language tag and names the language in the prompt, covering titles, lesson text, assessment questions, answer options and feedback. The MCP server has no identity layer, so there is no user to resolve a stored preference from and the calling agent supplies the tag instead. It is validated by falling back, not by erroring: an omitted, misspelled or withdrawn tag resolves to the platform default, so a bad tag never fails a whole generation run. The published field description is the calling agent's only instruction, so it states the fallback explicitly. Replaces "in the user's language", which was undefined on a path that has no user. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The fallback tests asserted only that the platform default's name appeared in the prompt. The template's OUTPUT LANGUAGE section also carries the brief-mandated, unconditional literal "...not a literal translation of English phrasing", so that positive assertion alone could not tell the true default apart from the tool wrongly resolving to some other valid tag. Add a negative control to both the omitted- and unsupported-language tests: assert that no OTHER supported language's name appears, derived from get_settings() and SUPPORTED_LANGUAGES so it stays correct if either changes. Also pin the schema test's fallback-promise sentence, not just its "BCP 47" prefix, since that sentence is the calling agent's only instruction that a bad tag is safe rather than an error. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
hamza-56
approved these changes
Aug 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of: Sparkth UI, emails, API errors, and AI-generated content are English-only
Fourth of the phase-2 generation-language stack. Does not close the issue.
What
Lets an MCP caller name the language a generated course should be written in, and makes the
course-generation prompt state that language explicitly.
Changes
languageBCP 47 tag onCourseGenerationPromptRequest, resolved at thetool boundary
text, assessment questions, answer options and feedback
published tool schema
How to Test
uv run pytest tests/mcp/ -v— 19 tests pass.{"course_params": {"course_name": "...", "course_description": "...", "language": "es"}}and confirm the returned prompt names Spanish.
language, and separately pass a nonsense tag such as"klingon"— both return a promptnaming
DEFAULT_LANGUAGE, and neither errors.languageis optional and its descriptionstates the fallback.
Notes
No migration, no env var, no dependency. Public MCP tool signature change — additive and
backward compatible: existing callers that omit
languageget the platform default.The MCP server has an audit middleware but no identity layer, so there is no user to resolve a
stored preference from — the calling agent supplies the tag. This is why the two generation paths
are not symmetric.
The tag is validated by falling back, not by erroring: an omitted, misspelled or withdrawn tag
resolves to
DEFAULT_LANGUAGE, so a bad value never fails a whole agent-driven generation run.The published field description promises exactly that, and a test pins the promise.
The directive deliberately covers the course only, not the calling agent's own clarifying
questions.
languageis the course language and says nothing about what language the agent'shuman speaks — an English speaker may commission a Spanish course, and the agent should keep
asking its questions in the language of its own conversation.
frontend/lib/api/generated.tsis unchanged: the MCP tool schema is not part of the REST OpenAPIdocument, and
make test.frontend.apireports no drift.Manual smoke test. The tests mock nothing about the model's actual output, so before relying
on this: generate a full course through the MCP path in
esand infr, have a speaker reviewregister and terminology, and confirm assessment questions, answer options and feedback are all
translated.
This description was written with the assistance of an LLM (Claude).