Skip to content

Add an MCP server as a third front-end on the shared core - #2

Merged
monikagadage merged 1 commit into
mainfrom
mcp-server
Sep 4, 2026
Merged

Add an MCP server as a third front-end on the shared core#2
monikagadage merged 1 commit into
mainfrom
mcp-server

Conversation

@monikagadage

Copy link
Copy Markdown
Owner

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 that app.py and cli.py already drive.

Layering (the point of the design)

  • mcp_server/tools.py — the 9 tools as plain, dependency-injected functions (collection, llm, db_path passed in). Imports only memory.store + topics at module level — not graph.workflow (LangChain/LangGraph), chromadb, or mcp. The tiny RAG query call is inlined and the prompt text moved to prompts.py. So all 9 tools unit-test with just pytest + a temp SQLite file + a fake collection / fake LLM.
  • mcp_server/server.py — the only file that imports mcp. Wraps each tool with @mcp.tool(), adds 3 resources (interview://topics, interview://progress, interview://question-bank/{topic}) and a mock_interview prompt. ChromaDB collection + Groq client built lazily; missing GROQ_API_KEY surfaces as a clear RuntimeError only 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_progress

Transports

python -m mcp_server (stdio) and python -m mcp_server --http (streamable-HTTP on MCP_HOST/MCP_PORT). Both smoke-tested with a real MCP client handshake — stdio lists all 9 tools + calls list_topics; HTTP returns 200 on initialize.

Shared-core extraction

topics.py and prompts.py pulled 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

  • +16 tests (test_mcp_tools.py 11, test_mcp_server.py 5). 61 total.
  • CI now pip installs the lightweight mcp SDK so the MCP tests run in the pytest-only job on 3.11 / 3.12.
  • mcp pinned >=1.6,<2 — v2.x renamed FastMCPMCPServer and changed the API; v1 FastMCP is what current client docs assume.

Verification

uv run pytest tests/ → 61 passed. stdio + HTTP handshakes confirmed. python -m mcp_server --help works.

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).
@monikagadage
monikagadage merged commit 991d184 into main Sep 4, 2026
2 checks passed
@monikagadage
monikagadage deleted the mcp-server branch September 4, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant