
Capstone: build, connect, test and secure one MCP integration
Skill packs and prompts are provided in English so they work best with the AI tools. Use them as-is.
Capstone: build, connect, test and secure one MCP integration
Where you are
This is the last lesson. You have built servers with the official SDK (L08, L10), tested them (L09), secured transports (L07, L11), studied OAuth for remote servers (L13) and the threat model (L14). Now you finish one working integration yourself. There is no video. You work from a starter project, and an automated self-check tells you which required behaviours your server shows.
What you will be able to do
- Complete a small MCP server (official Python SDK
mcp==2.3.0, spec 2026-07-28) with three designed tools, a resource and transport protections. - Connect it to a host and use it.
- Run an automated client test against it and read the result criterion by criterion.
- Pin and lock its dependencies.
- Optionally, put a server behind OAuth using the L13 lab.
How this capstone works
You complete it on your own. There is no human evaluator, and nobody grades or reviews your work. The self-check is a pytest suite that drives your server with the official MCP client and prints a status for each rubric criterion. A full green run means the listed behaviours were observed on your machine in that run. It is a self-assessment, not an accredited or verified assessment of competence. It is not a certificate, and it does not judge code quality or your security reasoning.
The brief
The domain is a synthetic greenhouse plant-care tracker. All the data is invented and already sits in starter/server.py. Do not change it. You will:
- Build. Complete TODOs 1 to 7. There are three tools:
list_plants(done for you as a worked example),get_plantandlog_watering. You also add the resourcegarden://care-guide, turn on DNS-rebinding protection, and pin and lock the project. - Connect. Run your server and add it to a host.
- Test. Run the self-check until every criterion you can reach shows Demonstrated.
- Secure. Review your server against the L14 checklist. The self-check covers only part of it.
The contract is in the lab's README.md, under "The contract". Read it before you start.
Worked example: the tool you are given
The starter's list_plants shows the pattern every tool must follow:
@mcp.tool(name="list_plants", title="List plants",
annotations=ToolAnnotations(read_only_hint=True, open_world_hint=False))
async def list_plants(
location: Annotated[Location | None, Field(description="Optional bench filter")] = None,
) -> PlantList:
"""List plants, optionally filtered by location."""
plants = [Plant(plant_id=pid, **p) for pid, p in PLANTS.items() if location is None or p["location"] == location]
return PlantList(plants=plants, count=len(plants))
Four things to copy:
- The docstring becomes the tool description.
Annotated[..., Field(...)]puts constraints in the input schema.Locationis aLiteral, so only three values are valid.- Returning a pydantic model (
PlantList) gives the tool anoutputSchemaand structured results. read_only_hint=Truetells the host this tool does not change state. Hosts treat annotations as untrusted hints unless the server is trusted, but they help a host decide when to ask the user.
Two rules from L04 matter for the TODOs. First, put a constraint such as ^PLT-\d{3}$ or "10 to 2000 ml" in the schema, not only in code. Then the SDK rejects bad input itself, and the check expects its message to contain validation error. Second, for an unknown plant or a refused action, raise ToolError(...). The client then receives a result with isError: true, which the model can read and act on, instead of a crash or a protocol error.
Practice
Download the Lab files (ZIP) for L17 and open its folder. You need uv. First, see where you start:
./run.sh check # checks starter/
The untouched starter gives 14 failed, 4 passed. Each failure says what is missing. For example: tools are ['get_plant', 'list_plants'], expected ['get_plant', 'list_plants', 'log_watering']. Work through the TODOs one at a time and rerun the check after each one.
For TODO 7, edit starter/pyproject.toml so every dependency is pinned with == (including mcp==2.3.0). Then run uv lock inside starter/. The C8 check runs uv lock --check, which may contact PyPI.
To connect your server to a host, run ./run.sh serve starter and, in another terminal:
claude mcp add --transport http greenhouse http://127.0.0.1:8765/mcp
Ask the host to list the plants and log a watering. Then try a dormant plant and watch the error come back. If you use the Inspector instead, pin @modelcontextprotocol/inspector@2.16.0 and keep its defaults.
Check your result
The check ends with a rubric table. Each criterion shows one of three statuses:
| Status | Meaning |
|---|---|
| Demonstrated | Every check mapped to the criterion ran and passed |
| Needs repair | At least one mapped check ran and failed |
| Not observed | No mapped check reached a verdict (it was skipped, or the check was not run) |
| ID | Criterion |
|---|---|
| C1 | Runs and is discoverable by a 2026-07-28 client and a legacy (2025-11-25) client |
| C2 | Exactly three tools, each with a description, a constrained inputSchema and an outputSchema |
| C3 | Correct behaviour on valid input: structured results and a visible state change |
| C4 | Errors come back as isError results: unknown id, schema-invalid input, refused action |
| C5 | Annotations separate read-only tools from the state-changing one |
| C6 | The resource garden://care-guide is listed and readable |
| C7 | Loopback binding; a foreign Origin gets 403 and a foreign Host gets 421 |
| C8 | Exact pins, including mcp==2.3.0, and a current uv.lock |
When you are finished, every row reads Demonstrated, the run ends with 18 passed, and the last line before the count is Self-assessment only: this is not an accredited assessment of competence.
C1 already passes on the starter, because the SDK provides discovery for you. C7 can show Not observed if your machine has no non-loopback IPv4 address, and C8 can show it if uv is not on your PATH. That is not a failure, but it is not evidence either. Connecting to a host is not machine-checked: record it as Not observed unless you keep your own evidence, such as a transcript.
If a criterion needs repair: how to retry
- Read the first failing assertion only, fix that, and rerun. Many failures share one cause; for example,
log_wateringmissing breaks C2, C3 and C4 together. - Do not edit
selfcheck/. A green run you produced by changing the tests shows nothing. - If C4 says input was not rejected by schema validation, the constraint is in your code instead of in
Field(...). - If C7 fails on Origin or Host, check that
enable_dns_rebinding_protection=Trueand that the allow-lists contain only127.0.0.1:PORTandlocalhost:PORT. - If port 8765 is busy, set
CAPSTONE_PORT. - Compare with the reference solution only after a real attempt: it is a separate download ("Reference solution (ZIP)"); extract it into the lab folder so it sits in
solution/../run.sh check solutionshows what a full pass looks like (18 passed). - There is no attempt limit and no deadline. Rerun as often as you like.
Security review (not machine-checked)
The self-check tests the contract on loopback. It says nothing about a remote deployment. Before you call the integration secure, go through L14 yourself:
- Least privilege per tool.
- Tool output treated as untrusted data.
- No secrets in tool arguments, in a committed
.mcp.json, or on parameters markedx-mcp-header; credentials come from the environment. - Pinned versions you can reproduce.
Optional remote track: OAuth
OAuth is outside this rubric. To practise it, run the L13 Lab files (ZIP) (./run.sh verify, which ends with ALL CHECKS PASSED (49)). Then apply the same pieces to your own server:
AuthSettings(resource_server_url=..., validate_token_resource=True); in mcp 2.3.0 the audience gate is off by default and only warns.- A
TokenVerifierthat checks signature,iss,audandexp. - RFC 9728 metadata and a 401 response with
resource_metadata. - 403
insufficient_scope. - PKCE S256 and the
resourceparameter on the client side. - No token passthrough.
Use L13's verify_client.py as a pattern for your own checks. A real deployment also needs TLS and a real authorization server, not L13's test-only one.
Reflection
Answer these for yourself. There is no one right answer, and no one will mark them.
- Which criterion took you longest to reach Demonstrated, and what was the misunderstanding behind it?
- Name one risk in your server that the self-check cannot see. What would you change before exposing it beyond your machine?
- If you added a fourth tool that deletes a plant, which annotation would it carry, and what should a host do before calling it?
Sources
- https://modelcontextprotocol.io/specification/2026-07-28/server/tools
- https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization
- https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/security_best_practices
- https://code.claude.com/docs/en/mcp
- https://github.com/modelcontextprotocol/python-sdk
