Welcome to the MCP Interviewer tutorial! If you are building a Model Context Protocol (MCP) server, you need a way to verify that it works correctly, adheres to standards, and provides high-quality tools to Large Language Models (LLMs).
In this first chapter, we will introduce the Interviewer (Orchestrator)βthe brain of this project.
Imagine your MCP Server is a job candidate applying for a position.
The Interviewer (Orchestrator) is the Hiring Manager. It doesn't necessarily do every single task itself, but it manages the entire process:
Without this orchestrator, you would have to manually connect to your server, type out JSON requests by hand, and subjectively guess if the responses were good. The Interviewer automates this entire loop.
Before diving into the code, let's look at how a user kicks off the Orchestrator. The project provides a Command Line Interface (CLI).
To interview a local server, you might run a command like this:
mcp-interviewer "python my_server.py" --test --judge
Here is what happens when you press Enter:
MCPInterviewer.Here is a high-level view of what happens inside the Orchestrator during an interview. Notice how it acts as the central hub.
Let's look at the code that powers this logic. The system is built in Python.
main.py)
The main.py file contains the logic that ties everything together. It prepares the environment and launches the interviewer.
# src/mcp_interviewer/main.py
# Create the interviewer instance
interviewer = MCPInterviewer(
client, # The AI Client (e.g., OpenAI)
model, # The AI Model name
should_run_functional_test,
should_judge_tool,
should_judge_functional_test,
)
# Start the interview process!
interview = await interviewer.interview_server(params)
Explanation:
This snippet shows the creation of the Hiring Manager. We give it the tools it needs (an AI client to help judge answers) and instructions on what to test. Then, we await the result of the interview.
_interviewer.py)
The class MCPInterviewer is where the magic happens. Its primary method is interview_server. This method orchestrates the phases of the interview.
# src/mcp_interviewer/interviewer/_interviewer.py
async def interview_server(self, params: ServerParameters) -> ServerScoreCard:
# Connect to the server using a context manager
async with mcp_client(params) as (read, write):
async with ClientSession(read, write, ...) as session:
# Phase 1: Inspect what the server can do
server = await self.inspect_server(params, session)
# Phase 2: Evaluate the quality of the tools
tool_scorecards = await self.judge_tools(server.tools)
# Phase 3: Run actual functional tests
functional_test = await self.generate_functional_test(server)
results = await self.execute_functional_test(session, functional_test)
# ... compiles results into a Scorecard ...
Explanation:
ServerScoreCard.
Once interview_server returns the data, the Orchestrator's job is nearly done. It passes the raw data back to the main script to be formatted into a report.
# src/mcp_interviewer/main.py
# Generate a readable Markdown report
path = out_dir / Path("mcp-interview.md")
with open(path, "w") as fd:
report = FullReport(interview, violations, options)
fd.write(report.build())
# Save raw JSON data for machine reading
with open(out_dir / Path("mcp-interview.json"), "w") as fd:
fd.write(interview.model_dump_json(indent=2))
Explanation: The Orchestrator ensures that the "Hiring Decision" is written down. It saves a human-readable Markdown file (the one you see in your editor) and a JSON file (for programmatic use). We will learn more about this in the Reporting System chapter.
The Interviewer (Orchestrator) is the central component that manages the lifecycle of an evaluation. It doesn't do all the heavy lifting alone; instead, it coordinates specialized subsystems to:
In the next chapter, we will look at the structured data objects the Interviewer uses to keep track of all this information.
Next Chapter: Data Models (Scorecards)
Generated by Code IQ