Add an MCP server as a third front-end on the shared core - #2
Merged
Conversation
mcp_server/ exposes the coach over the Model Context Protocol so any MCP
client (Claude Desktop, Claude Code, Cursor, VS Code) can run mock
interviews against it, reusing the same retrieval, grading, persistence,
and spaced-repetition logic that app.py and cli.py drive.
- mcp_server/tools.py: the 9 tools as dependency-injected plain functions,
kept off the LangChain/ChromaDB/mcp import chain so they unit-test with
just pytest + a temp DB + a fake collection/LLM.
- mcp_server/server.py: FastMCP wiring — tools, 3 resources
(interview://topics, interview://progress, interview://question-bank/{topic}),
a mock_interview prompt; ChromaDB collection and Groq client built
lazily; clear RuntimeError if GROQ_API_KEY is missing.
- python -m mcp_server (stdio) or --http (streamable-HTTP on MCP_HOST/PORT).
Both verified with a real MCP client handshake.
- topics.py, prompts.py: extracted so the CLI, the workflow graph, and the
MCP server share one topic list and one set of prompt strings.
- tests/: +16 (test_mcp_tools 11, test_mcp_server 5); CI now installs the
lightweight mcp SDK so they run in the pytest-only job. 61 tests total.
- mcp pinned >=1.6,<2 (v2 renamed FastMCP -> MCPServer).
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.
What
mcp_server/exposes Java Interview Coach over the Model Context Protocol — so Claude Desktop, Claude Code, Cursor, or VS Code can run mock interviews against it as a tool, reusing the exact retrieval / adaptive-selection / grading / spaced-repetition logic thatapp.pyandcli.pyalready drive.Layering (the point of the design)
mcp_server/tools.py— the 9 tools as plain, dependency-injected functions (collection,llm,db_pathpassed in). Imports onlymemory.store+topicsat module level — notgraph.workflow(LangChain/LangGraph),chromadb, ormcp. The tiny RAGquerycall is inlined and the prompt text moved toprompts.py. So all 9 tools unit-test with justpytest+ a temp SQLite file + a fake collection / fake LLM.mcp_server/server.py— the only file that importsmcp. Wraps each tool with@mcp.tool(), adds 3 resources (interview://topics,interview://progress,interview://question-bank/{topic}) and amock_interviewprompt. ChromaDB collection + Groq client built lazily; missingGROQ_API_KEYsurfaces as a clearRuntimeErroronly if a grading tool is actually called.Tools
list_topics·start_session·get_interview_question(RAG + adaptive selection) ·evaluate_answer·get_hint·record_attempt·rate_question·get_due_reviews·get_progressTransports
python -m mcp_server(stdio) andpython -m mcp_server --http(streamable-HTTP onMCP_HOST/MCP_PORT). Both smoke-tested with a real MCP client handshake — stdio lists all 9 tools + callslist_topics; HTTP returns 200 oninitialize.Shared-core extraction
topics.pyandprompts.pypulled out so the CLI, the workflow graph, and the MCP server share one topic list and one set of prompt strings instead of three drifting copies.Tests / CI
test_mcp_tools.py11,test_mcp_server.py5). 61 total.pip installs the lightweightmcpSDK so the MCP tests run in the pytest-only job on 3.11 / 3.12.mcppinned>=1.6,<2— v2.x renamedFastMCP→MCPServerand changed the API; v1FastMCPis what current client docs assume.Verification
uv run pytest tests/→ 61 passed. stdio + HTTP handshakes confirmed.python -m mcp_server --helpworks.