A2: Build a small MCP tool server
At a glance
- Task: build a local MCP server whose tools, schemas and errors help an agent select, call and recover correctly.
- Week: 2
- Weight: 2.5 points
- Due: Sunday 23:59 in the listed week
- Hand in: the server, a
report.json, and outputs from the public protocol check. - Done when: you have a real trial with evidence for each of three cases: tool selection, valid arguments and one recoverable error.
- Time: published after a timed pilot; record your prediction and actual time.
Objectives
Design a small set of tools that a model can read and use, and verify how they behave (LO2). No third-party sign-in or OAuth is required.
Prerequisites
Follow the course safety practices:
- Run the agent in a dedicated directory or container.
- Keep residency, employer and cloud credentials out of that environment.
- Keep keys out of repositories, prompts, screenshots and logs.
- Run injection demonstrations offline against the local machine only.
Use the mature coding-agent seat supplied for the course. Do not run an unknown generated command on a credential-bearing host.
Tasks
- Specify. Choose two or three read or write operations. For each, define the name, description, required arguments and errors. Also define a safe rule for when to retry.
- Generate. Ask the agent to propose handlers and schemas. Review the proposal before you put it in the server.
- Verify selection. Run a request where the right tool is clearly different from the other tools. Record which call the agent selected and the result.
- Verify arguments. Run a valid call and an invalid-argument call. Check that the server returns structured feedback without a traceback.
- Verify recovery. Make one tool return a local error that the agent can retry. Then show the agent taking the next step that your error message documents. Keep all three trials.
- Revise. Fix one unclear description or error, rerun the protocol check, and write the decision line.
Generation is the tool design the agent proposes. Verification is the protocol transcript and your own inspection of the results. The check never calls a model, and it does not turn a transcript into a mark.
Deliverables
Include the server source, schemas, report.json, and protocol output. In the report,
server_path names the submitted tool_server.py. The report has exactly three trial cases:
selection, arguments and recovery. Each trial has a request, the expected result, the
actual result, a disposition (your verdict on the result) and evidence IDs.
Copy starter/ to a submission directory of your own outside the course checkout.
Work in that copy. Run the checks from the course checkout:
python practice/a2/protocol_check.py path/to/submission/tool_server.py
python practice/a2/check.py path/to/submission
protocol_check.py is an envelope smoke test. It checks the handshake, the shape of the
tool list, one valid call and one refused invalid call. It never calls a model, so it does not
show that a model can choose and use your tool. When it passes, its output states this limit.
The check calls your first listed tool three times: valid, invalid, valid. By default it sends
the string alpha for each required argument. If your first tool needs other values, pass them
as JSON. This form works on the starter server:
python practice/a2/protocol_check.py path/to/submission/tool_server.py --arguments '{"key": "beta"}'
Register the same tool_server.py command in your mature agent's tool configuration, using
the agent's documented setting for local stdio servers. The three trials in the report are real
agent runs. They are the evidence for selection, argument handling and recovery.
Grading
The criteria are:
- tool descriptions that a model can read and act on;
- correct schema validation;
- structured, bounded errors;
- recovery evidence;
- an explanation of one revision.
The public check only detects missing or inconsistent records. It does not claim that a model selected a tool correctly on requests it has not seen.
AI use rules
Green: the agent may draft schemas and boilerplate. Yellow: it may propose descriptions or recovery paths, which you then test with your own protocol runs. Red: the expected tool, the interpretation of errors and the decision must be your own. Do not paste private data or keys into prompts or outputs. Attach one AI-use note ID.
Estimated time
Published after a timed pilot. Record your predicted and actual time. Ask for help if you do not understand a local protocol failure.
Work record outline
assignment: A2
server_path: TODO
evidence: [{id: TODO, path: TODO, observation: TODO}]
trials: [{case: selection|arguments|recovery, run_kind: real, request: TODO, expected: TODO, actual: TODO, disposition: TODO, evidence: [TODO]}]
protocol_evidence: [TODO]
explanation: TODO
ai_use_note: TODO
predicted_time: TODO
actual_time: TODO
decision: {action: accept | narrow | recheck | stop, because: [evidence ID(s)], next: TODO}
The outline lists the fields of report.json in plain text. starter/report.json holds them as JSON, except predicted_time and actual_time, which you add yourself. Evidence paths are relative to your submission directory. The check reads a field that still contains the word TODO, or text in angle brackets such as <name>, as unfilled.